[gthumb] moved some utilities to gio-utils.c
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] moved some utilities to gio-utils.c
- Date: Wed, 11 Dec 2019 16:49:58 +0000 (UTC)
commit 77a9f81e18bec0498262792580fc3889598493c2
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Dec 7 14:48:57 2019 +0100
moved some utilities to gio-utils.c
gthumb/gio-utils.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++
gthumb/gio-utils.h | 5 ++++
gthumb/gth-browser.c | 62 ----------------------------------------------
gthumb/gth-browser.h | 4 ---
4 files changed, 75 insertions(+), 66 deletions(-)
---
diff --git a/gthumb/gio-utils.c b/gthumb/gio-utils.c
index 794860fd..d094451a 100644
--- a/gthumb/gio-utils.c
+++ b/gthumb/gio-utils.c
@@ -24,7 +24,10 @@
#include <glib/gi18n.h>
#include <gio/gio.h>
#include "gth-file-data.h"
+#include "gth-file-source.h"
+#include "gth-file-source-vfs.h"
#include "gth-hook.h"
+#include "gth-main.h"
#include "gth-metadata-provider.h"
#include "gth-overwrite-dialog.h"
#include "glib-utils.h"
@@ -2232,3 +2235,70 @@ _g_file_set_modification_time (GFile *file,
return result;
}
+
+
+GFileInfo *
+_g_file_get_info_for_display (GFile *file)
+{
+ GFileInfo *file_info;
+ GthFileSource *file_source;
+
+ file_info = NULL;
+ file_source = gth_main_get_file_source (file);
+ if ((file_source != NULL) && ! GTH_IS_FILE_SOURCE_VFS (file_source))
+ file_info = gth_file_source_get_file_info (file_source, file, GFILE_DISPLAY_ATTRIBUTES);
+
+ if (file_info == NULL) {
+ char *name;
+ char *uri;
+ GIcon *icon;
+
+ file_info = g_file_info_new ();
+
+ name = _g_file_get_display_name (file);
+ g_file_info_set_display_name (file_info, name);
+
+ uri = g_file_get_uri (file);
+ icon = g_themed_icon_new (g_str_has_prefix (uri, "file://") ? "folder-symbolic" :
"folder-remote-symbolic");
+ g_file_info_set_symbolic_icon (file_info, icon);
+
+ g_object_unref (icon);
+ g_free (uri);
+ g_free (name);
+ }
+
+ return file_info;
+}
+
+
+GMenuItem *
+_g_menu_item_new_for_file (GFile *file,
+ const char *custom_label)
+{
+ GMenuItem *item;
+ GFileInfo *info;
+
+ item = g_menu_item_new (NULL, NULL);
+ info = _g_file_get_info_for_display (file);
+ if (info != NULL) {
+ g_menu_item_set_label (item, (custom_label != NULL) ? custom_label :
g_file_info_get_display_name (info));
+ g_menu_item_set_icon (item, g_file_info_get_symbolic_icon (info));
+
+ g_object_unref (info);
+ }
+
+ return item;
+}
+
+
+GMenuItem *
+_g_menu_item_new_for_file_data (GthFileData *file_data)
+{
+ GMenuItem *item;
+
+ item = g_menu_item_new (NULL, NULL);
+ g_menu_item_set_label (item, g_file_info_get_display_name (file_data->info));
+ g_menu_item_set_icon (item, g_file_info_get_symbolic_icon (file_data->info));
+
+ return item;
+}
diff --git a/gthumb/gio-utils.h b/gthumb/gio-utils.h
index 3031b3f7..3215381f 100644
--- a/gthumb/gio-utils.h
+++ b/gthumb/gio-utils.h
@@ -118,6 +118,7 @@ gboolean _g_file_set_modification_time (GFile *file,
GTimeVal *timeval,
GCancellable *cancellable,
GError **error);
+GFileInfo * _g_file_get_info_for_display (GFile *file);
/* Directory utils */
@@ -166,6 +167,7 @@ void _g_file_list_trash_async (GList *file_list,
/* GFile list */
GCancellable *cancellable,
ReadyFunc callback,
gpointer user_data);
+GFileInfo * _g_file_get_info_for_display (GFile *file);
/* Misc utils */
@@ -187,6 +189,9 @@ gboolean _g_input_stream_read_all (GInputStream *istream,
gsize *size,
GCancellable *cancellable,
GError **error);
+GMenuItem * _g_menu_item_new_for_file (GFile *file,
+ const char *custom_label);
+GMenuItem * _g_menu_item_new_for_file_data (GthFileData *file_data);
G_END_DECLS
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 542601ad..1275eec2 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -6981,65 +6981,3 @@ gth_browser_keep_mouse_visible (GthBrowser *browser,
{
browser->priv->keep_mouse_visible = value;
}
-
-
-GMenuItem *
-_g_menu_item_new_for_file (GFile *file,
- const char *custom_label)
-{
- GMenuItem *item;
- gboolean updated;
- GthFileSource *file_source;
-
- item = g_menu_item_new (NULL, NULL);
-
- updated = FALSE;
- file_source = gth_main_get_file_source (file);
- if (file_source == NULL)
- return item;
-
- if (! GTH_IS_FILE_SOURCE_VFS (file_source)) {
- GFileInfo *info;
-
- info = gth_file_source_get_file_info (file_source, file, GFILE_DISPLAY_ATTRIBUTES);
- if (info != NULL) {
- g_menu_item_set_label (item, (custom_label != NULL) ? custom_label :
g_file_info_get_display_name (info));
- g_menu_item_set_icon (item, g_file_info_get_symbolic_icon (info));
- updated = TRUE;
- }
-
- _g_object_unref (info);
- }
-
- if (! updated) {
- char *name;
- char *uri;
- GIcon *icon;
-
- name = _g_file_get_display_name (file);
- uri = g_file_get_uri (file);
- icon = g_themed_icon_new (g_str_has_prefix (uri, "file://") ? "folder-symbolic" :
"folder-remote-symbolic");
- g_menu_item_set_label (item, (custom_label != NULL) ? custom_label : name);
- g_menu_item_set_icon (item, icon);
-
- g_free (uri);
- g_free (name);
- }
-
- _g_object_unref (file_source);
-
- return item;
-}
-
-
-GMenuItem *
-_g_menu_item_new_for_file_data (GthFileData *file_data)
-{
- GMenuItem *item;
-
- item = g_menu_item_new (NULL, NULL);
- g_menu_item_set_label (item, g_file_info_get_display_name (file_data->info));
- g_menu_item_set_icon (item, g_file_info_get_symbolic_icon (file_data->info));
-
- return item;
-}
diff --git a/gthumb/gth-browser.h b/gthumb/gth-browser.h
index 34462125..d3dab8ad 100644
--- a/gthumb/gth-browser.h
+++ b/gthumb/gth-browser.h
@@ -289,10 +289,6 @@ void gth_browser_keep_mouse_visible (GthBrowser *browser,
/* utilities */
-GMenuItem * _g_menu_item_new_for_file (GFile *file,
- const char *custom_label);
-GMenuItem * _g_menu_item_new_for_file_data (GthFileData *file_data);
-
G_END_DECLS
#endif /* GTH_BROWSER_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]