diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-11-09 19:27:53 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-11-09 19:27:53 -0500 |
commit | 2b177587e65a5cded88d0c20d293597fda6a06a8 (patch) | |
tree | 6b31f66e800c7390cd2d8a30fdb535cb4dd65757 | |
parent | 8b7940c0b1b3c3c9aa643e7e924b9c948114f9e2 (diff) | |
download | gtk+-2b177587e65a5cded88d0c20d293597fda6a06a8.tar.gz |
Move a function around
_Gtk_file_chooser_label_for_file is not actually
used in gtkfilechooserdefault.c anymore, so move
it to a better place.
-rw-r--r-- | gtk/gtkfilechooserdefault.c | 56 | ||||
-rw-r--r-- | gtk/gtkfilechooserdefault.h | 2 | ||||
-rw-r--r-- | gtk/gtkfilechooserutils.c | 50 | ||||
-rw-r--r-- | gtk/gtkfilechooserutils.h | 2 |
4 files changed, 52 insertions, 58 deletions
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 6458d9a61a..e573534f08 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -896,62 +896,6 @@ set_preview_widget (GtkFileChooserDefault *impl, update_preview_widget_visibility (impl); } -/* FIXME: GtkFileSystem needs a function to split a remote path - * into hostname and path components, or maybe just have a - * gtk_file_system_path_get_display_name(). - * - * This function is also used in gtkfilechooserbutton.c - */ -gchar * -_gtk_file_chooser_label_for_file (GFile *file) -{ - const gchar *path, *start, *end, *p; - gchar *uri, *host, *label; - - uri = g_file_get_uri (file); - - start = strstr (uri, "://"); - if (start) - { - start += 3; - path = strchr (start, '/'); - if (path) - end = path; - else - { - end = uri + strlen (uri); - path = "/"; - } - - /* strip username */ - p = strchr (start, '@'); - if (p && p < end) - start = p + 1; - - p = strchr (start, ':'); - if (p && p < end) - end = p; - - host = g_strndup (start, end - start); - - /* Translators: the first string is a path and the second string - * is a hostname. Nautilus and the panel contain the same string - * to translate. - */ - label = g_strdup_printf (_("%1$s on %2$s"), path, host); - - g_free (host); - } - else - { - label = g_strdup (uri); - } - - g_free (uri); - - return label; -} - /* Callback used when the "New Folder" button is clicked */ static void new_folder_button_clicked (GtkButton *button, diff --git a/gtk/gtkfilechooserdefault.h b/gtk/gtkfilechooserdefault.h index 3c90de2100..8b2f3f3ae1 100644 --- a/gtk/gtkfilechooserdefault.h +++ b/gtk/gtkfilechooserdefault.h @@ -33,8 +33,6 @@ typedef struct _GtkFileChooserDefault GtkFileChooserDefault; GType _gtk_file_chooser_default_get_type (void) G_GNUC_CONST; GtkWidget *_gtk_file_chooser_default_new (void); -gchar * _gtk_file_chooser_label_for_file (GFile *file); - G_END_DECLS #endif /* __GTK_FILE_CHOOSER_DEFAULT_H__ */ diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c index 2b2542cd7b..bc7bb49622 100644 --- a/gtk/gtkfilechooserutils.c +++ b/gtk/gtkfilechooserutils.c @@ -449,3 +449,53 @@ _gtk_file_chooser_get_settings_for_widget (GtkWidget *widget) return settings; } + +gchar * +_gtk_file_chooser_label_for_file (GFile *file) +{ + const gchar *path, *start, *end, *p; + gchar *uri, *host, *label; + + uri = g_file_get_uri (file); + + start = strstr (uri, "://"); + if (start) + { + start += 3; + path = strchr (start, '/'); + if (path) + end = path; + else + { + end = uri + strlen (uri); + path = "/"; + } + + /* strip username */ + p = strchr (start, '@'); + if (p && p < end) + start = p + 1; + + p = strchr (start, ':'); + if (p && p < end) + end = p; + + host = g_strndup (start, end - start); + /* Translators: the first string is a path and the second string + * is a hostname. Nautilus and the panel contain the same string + * to translate. + */ + label = g_strdup_printf (_("%1$s on %2$s"), path, host); + + g_free (host); + } + else + { + label = g_strdup (uri); + } + + g_free (uri); + + return label; +} + diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h index ad9ef364b5..21b98b0297 100644 --- a/gtk/gtkfilechooserutils.h +++ b/gtk/gtkfilechooserutils.h @@ -54,6 +54,8 @@ GList *_gtk_file_chooser_extract_recent_folders (GList *infos); GSettings *_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget); +gchar * _gtk_file_chooser_label_for_file (GFile *file); + G_END_DECLS #endif /* __GTK_FILE_CHOOSER_UTILS_H__ */ |