[gtk+/filechooserentry: 19/53] filechooserentry: Simplify code



commit 03b6995ee9bee18fe2a69bb4e10e9cd5a5412db0
Author: Benjamin Otte <otte redhat com>
Date:   Fri Nov 4 16:33:58 2011 +0100

    filechooserentry: Simplify code
    
    Now that we've imported the function in the last commit, rename it and
    omit useless arguments by instead passing in the entry directly.

 gtk/gtkfilechooserentry.c |   33 +++++++++++++++------------------
 1 files changed, 15 insertions(+), 18 deletions(-)
---
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index c491e65..69f5af8 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -442,12 +442,11 @@ has_uri_scheme (const char *str)
 }
 
 static gboolean
-_gtk_file_system_parse (GtkFileSystem     *file_system,
-		        GFile             *base_file,
-		        const gchar       *str,
-		        GFile            **folder,
-		        gchar            **file_part,
-		        GError           **error)
+gtk_file_chooser_entry_parse (GtkFileChooserEntry  *chooser_entry,
+                              const gchar          *str,
+                              GFile               **folder,
+                              gchar               **file_part,
+                              GError              **error)
 {
   GFile *file;
   gboolean result = FALSE;
@@ -494,8 +493,8 @@ _gtk_file_system_parse (GtkFileSystem     *file_system,
     file = g_file_parse_name (str);
   else
     {
-      if (base_file)
-	file = g_file_resolve_relative_path (base_file, str);
+      if (chooser_entry->base_folder)
+	file = g_file_resolve_relative_path (chooser_entry->base_folder, str);
       else
 	{
 	  *folder = NULL;
@@ -508,7 +507,7 @@ _gtk_file_system_parse (GtkFileSystem     *file_system,
 	}
     }
 
-  if (base_file && g_file_equal (base_file, file))
+  if (chooser_entry->base_folder && g_file_equal (chooser_entry->base_folder, file))
     {
       /* this is when user types '.', could be the
        * beginning of a hidden file, ./ or ../
@@ -585,12 +584,11 @@ find_common_prefix (GtkFileChooserEntry *chooser_entry,
 
   text_up_to_cursor = gtk_editable_get_chars (editable, 0, gtk_editable_get_position (editable));
 
-  parsed = _gtk_file_system_parse (chooser_entry->file_system,
-				   chooser_entry->base_folder,
-				   text_up_to_cursor,
-				   &parsed_folder_file,
-				   &parsed_file_part,
-				   error);
+  parsed = gtk_file_chooser_entry_parse (chooser_entry,
+                                         text_up_to_cursor,
+                                         &parsed_folder_file,
+                                         &parsed_file_part,
+                                         error);
 
   g_free (text_up_to_cursor);
 
@@ -1507,9 +1505,8 @@ refresh_current_folder_and_file_part (GtkFileChooserEntry *chooser_entry,
   text = gtk_editable_get_chars (editable, 0, end_pos);
 
   error = NULL;
-  if (!_gtk_file_system_parse (chooser_entry->file_system,
-			       chooser_entry->base_folder, text,
-			       &folder_file, &file_part, &error))
+  if (!gtk_file_chooser_entry_parse (chooser_entry,
+			             text, &folder_file, &file_part, &error))
     {
       if (g_error_matches (error, GTK_FILE_CHOOSER_ERROR, GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME))
 	{



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