[gtk+] Move a function around
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Move a function around
- Date: Sun, 10 Nov 2013 00:28:39 +0000 (UTC)
commit 2b177587e65a5cded88d0c20d293597fda6a06a8
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Nov 9 19:27:53 2013 -0500
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.
gtk/gtkfilechooserdefault.c | 56 -------------------------------------------
gtk/gtkfilechooserdefault.h | 2 -
gtk/gtkfilechooserutils.c | 50 ++++++++++++++++++++++++++++++++++++++
gtk/gtkfilechooserutils.h | 2 +
4 files changed, 52 insertions(+), 58 deletions(-)
---
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 6458d9a..e573534 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 3c90de2..8b2f3f3 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 2b2542c..bc7bb49 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 ad9ef36..21b98b0 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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]