From 6fa736fdb7929a6351becffe93460f00b9722e51 Mon Sep 17 00:00:00 2001 From: Olivier Duchateau Date: Sat, 18 Feb 2017 20:01:06 +0100 Subject: [PATCH] Use GIcon struct instead of gchar --- src/process-window.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/process-window.c b/src/process-window.c index de80028..7356476 100644 --- a/src/process-window.c +++ b/src/process-window.c @@ -23,6 +23,9 @@ #include #include +#include +#include +#include #include #include #include @@ -90,6 +93,45 @@ filter_entry_icon_pressed_cb (GtkEntry *entry, } } +gchar * +system_icons_lookup (void) +{ + const gchar * const *dirs; + gchar *path; + gint i; + + dirs = g_get_system_data_dirs (); + for (i = 0; path == NULL && dirs[i] != NULL; ++i) { + path = g_build_path (G_DIR_SEPARATOR_S, dirs[i], "icons", NULL); + if (g_path_is_absolute (path) && g_file_test (path, G_FILE_TEST_IS_DIR)) + return path; + + g_free (path); + path = NULL; + } + + return path; +} + +GFile * +get_xccrosshair_filename (void) +{ + gchar *root_dir; + gchar *filename; + GFile *file = NULL; + + root_dir = system_icons_lookup (); + if (root_dir != NULL) { + filename = g_build_filename (root_dir, "hicolor", "24x24", "actions", "xc_crosshair.png", NULL); + if (filename == NULL) + g_free (filename); + + file = g_file_new_for_path (filename); + } + + return file; +} + Window Select_Window (Display *dpy, int screen) { @@ -223,6 +265,8 @@ xtm_process_window_init (XtmProcessWindow *window) GtkToolItem *xwininfo; gint width, height; gchar *markup; + GFile *file; + GIcon *file_icon; window->settings = xtm_settings_get_default (); @@ -247,7 +291,13 @@ xtm_process_window_init (XtmProcessWindow *window) window->settings_button = xtm_settings_tool_button_new (); gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (window->settings_button), 1); - icon = gtk_image_new_from_icon_name ("xc_crosshair", GTK_ICON_SIZE_LARGE_TOOLBAR); + file = get_xccrosshair_filename (); + if (file == NULL) + g_object_unref (file); + + file_icon = g_file_icon_new (file); + icon = gtk_image_new_from_gicon (file_icon, GTK_ICON_SIZE_LARGE_TOOLBAR); + g_object_unref (file); xwininfo = gtk_tool_button_new (icon, _("Identify Window")); gtk_widget_set_tooltip_text (GTK_WIDGET (xwininfo), _("Identify an open window by clicking on it.")); gtk_toolbar_insert (GTK_TOOLBAR (window->toolbar), GTK_TOOL_ITEM (xwininfo), 2); -- 2.11.1