[gimp] app: port file-actions and file-commands from URI to GFile



commit c2f7ec7b160f177f6426c79b6325727be7c06b52
Author: Michael Natterer <mitch gimp org>
Date:   Tue Jul 8 01:19:39 2014 +0200

    app: port file-actions and file-commands from URI to GFile

 app/actions/file-actions.c  |   17 ++++++-------
 app/actions/file-commands.c |   51 ++++++++++++++++++++++---------------------
 2 files changed, 34 insertions(+), 34 deletions(-)
---
diff --git a/app/actions/file-actions.c b/app/actions/file-actions.c
index 756ccb3..c66ce6a 100644
--- a/app/actions/file-actions.c
+++ b/app/actions/file-actions.c
@@ -30,9 +30,9 @@
 #include "core/gimp.h"
 #include "core/gimpcontainer.h"
 #include "core/gimpimage.h"
+#include "core/gimpimagefile.h"
 #include "core/gimpviewable.h"
 
-#include "file/file-utils.h"
 #include "file/gimp-file.h"
 
 #include "plug-in/gimppluginmanager-file.h"
@@ -344,15 +344,15 @@ file_actions_last_opened_update (GimpContainer   *container,
 
           if (GIMP_ACTION (action)->viewable != (GimpViewable *) imagefile)
             {
-              const gchar *uri;
-              gchar       *filename;
+              GFile       *file;
+              const gchar *name;
               gchar       *basename;
               gchar       *escaped;
 
-              uri = gimp_object_get_name (imagefile);
+              file = gimp_imagefile_get_file (imagefile);
 
-              filename = file_utils_uri_display_name (uri);
-              basename = file_utils_uri_display_basename (uri);
+              name     = gimp_file_get_utf8_name (file);
+              basename = g_path_get_basename (name);
 
               escaped = gimp_escape_uline (basename);
 
@@ -360,13 +360,12 @@ file_actions_last_opened_update (GimpContainer   *container,
 
               g_object_set (action,
                             "label",    escaped,
-                            "tooltip",  filename,
+                            "tooltip",  name,
                             "visible",  TRUE,
                             "viewable", imagefile,
                             NULL);
 
-              g_free (filename);
-              g_free (escaped);
+               g_free (escaped);
             }
         }
       else
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index ca3467e..daba322 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -41,7 +41,6 @@
 #include "file/file-open.h"
 #include "file/file-procedure.h"
 #include "file/file-save.h"
-#include "file/file-utils.h"
 #include "file/gimp-file.h"
 
 #include "widgets/gimpactiongroup.h"
@@ -600,25 +599,26 @@ file_save_dialog_response (GtkWidget *dialog,
       GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
       GtkWindow      *parent;
       GtkWidget      *other;
-      gchar          *folder;
-      gchar          *uri;
-      gchar          *name;
+      GFile          *folder;
+      GFile          *file;
+      gchar          *basename;
 
-      parent = gtk_window_get_transient_for (GTK_WINDOW (dialog));
-      folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog));
-      uri    = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
-      name   = file_utils_uri_display_basename (uri);
-      g_free (uri);
+      parent   = gtk_window_get_transient_for (GTK_WINDOW (dialog));
+      folder   = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (dialog));
+      file     = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+      basename = g_path_get_basename (gimp_file_get_utf8_name (file));
+      g_object_unref (file);
 
       other = file_export_dialog_show (file_dialog->image->gimp,
                                        file_dialog->image,
                                        GTK_WIDGET (parent));
 
-      gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (other), folder);
-      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), name);
+      gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (other),
+                                                folder, NULL);
+      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), basename);
 
-      g_free (folder);
-      g_free (name);
+      g_object_unref (folder);
+      g_free (basename);
     }
 }
 
@@ -687,15 +687,15 @@ file_export_dialog_response (GtkWidget *dialog,
       GimpFileDialog *file_dialog = GIMP_FILE_DIALOG (dialog);
       GtkWindow      *parent;
       GtkWidget      *other;
-      gchar          *folder;
-      gchar          *uri;
-      gchar          *name;
+      GFile          *folder;
+      GFile          *file;
+      gchar          *basename;
 
-      parent = gtk_window_get_transient_for (GTK_WINDOW (dialog));
-      folder = gtk_file_chooser_get_current_folder_uri (GTK_FILE_CHOOSER (dialog));
-      uri    = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
-      name   = file_utils_uri_display_basename (uri);
-      g_free (uri);
+      parent   = gtk_window_get_transient_for (GTK_WINDOW (dialog));
+      folder   = gtk_file_chooser_get_current_folder_file (GTK_FILE_CHOOSER (dialog));
+      file     = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+      basename = g_path_get_basename (gimp_file_get_utf8_name (file));
+      g_object_unref (file);
 
       other = file_save_dialog_show (file_dialog->image->gimp,
                                      file_dialog->image,
@@ -703,11 +703,12 @@ file_export_dialog_response (GtkWidget *dialog,
                                      _("Save Image"),
                                      FALSE, FALSE, NULL);
 
-      gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (other), folder);
-      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), name);
+      gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (other),
+                                                folder, NULL);
+      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (other), basename);
 
-      g_free (folder);
-      g_free (name);
+      g_object_unref (folder);
+      g_free (basename);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]