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.
This commit is contained in:
Benjamin Otte 2011-11-04 16:33:58 +01:00
parent 9d09028970
commit c3da748cb2

View File

@ -442,12 +442,11 @@ has_uri_scheme (const char *str)
} }
static gboolean static gboolean
_gtk_file_system_parse (GtkFileSystem *file_system, gtk_file_chooser_entry_parse (GtkFileChooserEntry *chooser_entry,
GFile *base_file, const gchar *str,
const gchar *str, GFile **folder,
GFile **folder, gchar **file_part,
gchar **file_part, GError **error)
GError **error)
{ {
GFile *file; GFile *file;
gboolean result = FALSE; gboolean result = FALSE;
@ -494,8 +493,8 @@ _gtk_file_system_parse (GtkFileSystem *file_system,
file = g_file_parse_name (str); file = g_file_parse_name (str);
else else
{ {
if (base_file) if (chooser_entry->base_folder)
file = g_file_resolve_relative_path (base_file, str); file = g_file_resolve_relative_path (chooser_entry->base_folder, str);
else else
{ {
*folder = NULL; *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 /* this is when user types '.', could be the
* beginning of a hidden file, ./ or ../ * 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)); text_up_to_cursor = gtk_editable_get_chars (editable, 0, gtk_editable_get_position (editable));
parsed = _gtk_file_system_parse (chooser_entry->file_system, parsed = gtk_file_chooser_entry_parse (chooser_entry,
chooser_entry->base_folder, text_up_to_cursor,
text_up_to_cursor, &parsed_folder_file,
&parsed_folder_file, &parsed_file_part,
&parsed_file_part, error);
error);
g_free (text_up_to_cursor); 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); text = gtk_editable_get_chars (editable, 0, end_pos);
error = NULL; error = NULL;
if (!_gtk_file_system_parse (chooser_entry->file_system, if (!gtk_file_chooser_entry_parse (chooser_entry,
chooser_entry->base_folder, text, text, &folder_file, &file_part, &error))
&folder_file, &file_part, &error))
{ {
if (g_error_matches (error, GTK_FILE_CHOOSER_ERROR, GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME)) if (g_error_matches (error, GTK_FILE_CHOOSER_ERROR, GTK_FILE_CHOOSER_ERROR_INCOMPLETE_HOSTNAME))
{ {