[gnome-applets] stickynotes: don't use custom stock icons



commit 76982eb73ce1bd912cc19a55d3b6682b9da93687
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Mar 26 15:11:08 2015 +0200

    stickynotes: don't use custom stock icons

 configure.ac                                       |    1 +
 stickynotes/Makefile.am                            |    3 +-
 stickynotes/pixmaps/Makefile.am                    |   24 ++++---
 .../{close.png => stickynotes-stock-close.png}     |  Bin 363 -> 363 bytes
 .../{locked.png => stickynotes-stock-locked.png}   |  Bin 403 -> 403 bytes
 ...size_se.png => stickynotes-stock-resize-se.png} |  Bin 312 -> 312 bytes
 ...size_sw.png => stickynotes-stock-resize-sw.png} |  Bin 295 -> 295 bytes
 ...unlocked.png => stickynotes-stock-unlocked.png} |  Bin 398 -> 398 bytes
 stickynotes/stickynotes.c                          |    5 +-
 stickynotes/stickynotes_applet.c                   |   70 ++++++++++----------
 stickynotes/stickynotes_applet.h                   |   12 ----
 11 files changed, 53 insertions(+), 62 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9007172..5b3ae97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -604,6 +604,7 @@ AC_DEFINE_DIR(GNOME_ICONDIR, "${iconsdir}", [Gnome Icon Directory])
 AC_DEFINE_DIR(GNOME_PIXMAPSDIR, "${pixmapsdir}", [Gnome Pixmaps Directory])
 AC_DEFINE_DIR(GTK_BUILDERDIR, "${builderdir}", [GtkBuilder Resources Directory])
 AC_DEFINE_DIR(DATADIR, "${datadir}", [datadir])
+AC_DEFINE_DIR(PKG_DATA_DIR, "${pkgdatadir}", [pkgdatadir])
 AC_DEFINE_DIR(SYSCONFDIR, "${sysconfdir}", [sysconfdir])
 AC_DEFINE_DIR(LIBDIR, "${libdir}", [libdir])
 AC_DEFINE_DIR(PREFIX, "$prefix", [install prefix])
diff --git a/stickynotes/Makefile.am b/stickynotes/Makefile.am
index 6d3c2ec..259956f 100644
--- a/stickynotes/Makefile.am
+++ b/stickynotes/Makefile.am
@@ -21,8 +21,7 @@ AM_CPPFLAGS =                                 \
        $(LIBWNCK_CFLAGS)                       \
        $(XML2_CFLAGS)                          \
        $(WARN_CFLAGS)                          \
-       -DSTICKYNOTES_MENU_UI_DIR=\""$(uidir)"\"\
-       -DSTICKYNOTES_ICONDIR=\"$(datadir)/pixmaps/stickynotes/\"
+       -DSTICKYNOTES_MENU_UI_DIR=\""$(uidir)"\"
 
 libexec_PROGRAMS = stickynotes_applet
 
diff --git a/stickynotes/pixmaps/Makefile.am b/stickynotes/pixmaps/Makefile.am
index 2a1014a..2c4df30 100644
--- a/stickynotes/pixmaps/Makefile.am
+++ b/stickynotes/pixmaps/Makefile.am
@@ -1,12 +1,9 @@
-## Process this file with automake to produce Makefile.in
-
-stickynotes_applet_pixmapsdir = $(datadir)/pixmaps/stickynotes
-stickynotes_applet_pixmaps_DATA = \
-       locked.png \
-       unlocked.png \
-       close.png \
-       resize_se.png \
-       resize_sw.png
+app_icons = \
+       stickynotes-stock-locked.png \
+       stickynotes-stock-unlocked.png \
+       stickynotes-stock-close.png \
+       stickynotes-stock-resize-se.png \
+       stickynotes-stock-resize-sw.png
 
 icons = \
        gnome-sticky-notes-applet.16.png \
@@ -16,7 +13,7 @@ icons = \
        gnome-sticky-notes-applet.svg
 
 EXTRA_DIST = \
-       $(stickynotes_applet_pixmaps_DATA) \
+       $(app_icons) \
        $(icons)
 
 gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor
@@ -33,6 +30,9 @@ uninstall-local:
                fi; \
                rm -f $(DESTDIR)$(iconsdir)/hicolor/$$SIZE/apps/$$FILE; \
        done
+       for icon in $(app_icons); do \
+               rm -f $(DESTDIR)$(pkgdatadir)/icons/hicolor/48x48/apps/$$icon; \
+       done
        @-if test -z "$(DESTDIR)"; then \
                echo "Updating Gtk icon cache."; \
                $(gtk_update_icon_cache); \
@@ -54,6 +54,10 @@ install-data-local:
                mkdir -p $(DESTDIR)$(iconsdir)/hicolor/$$SIZE/apps/; \
                $(INSTALL_DATA) $(srcdir)/$$icon $(DESTDIR)$(iconsdir)/hicolor/$$SIZE/apps/$$FILE; \
        done
+       for icon in $(app_icons); do \
+               mkdir -p $(DESTDIR)$(pkgdatadir)/icons/hicolor/48x48/apps/; \
+               $(INSTALL_DATA) $(srcdir)/$$icon $(DESTDIR)$(pkgdatadir)/icons/hicolor/48x48/apps/$$icon; \
+       done
        @-if test -z "$(DESTDIR)"; then \
                echo "Updating Gtk icon cache."; \
                $(gtk_update_icon_cache); \
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index 24ec89d..5b33d9a 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -31,6 +31,7 @@
 
 /* Stop gcc complaining about xmlChar's signedness */
 #define XML_CHAR(str) ((xmlChar *) (str))
+#define XML_PATH       "/.config/gnome-applets/stickynotes"
 #define STICKYNOTES_ICON_SIZE 8
 
 static gboolean save_scheduled = FALSE;
@@ -227,10 +228,10 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
        gtk_image_set_from_icon_name (note->img_close, STICKYNOTES_STOCK_CLOSE, GTK_ICON_SIZE_MENU);
        gtk_image_set_pixel_size (note->img_close, STICKYNOTES_ICON_SIZE);
 
-       gtk_image_set_from_stock (note->img_resize_se, STICKYNOTES_STOCK_RESIZE_SE, GTK_ICON_SIZE_MENU);
+       gtk_image_set_from_icon_name (note->img_resize_se, STICKYNOTES_STOCK_RESIZE_SE, GTK_ICON_SIZE_MENU);
        gtk_image_set_pixel_size (note->img_resize_se, STICKYNOTES_ICON_SIZE);
 
-       gtk_image_set_from_stock (note->img_resize_sw, STICKYNOTES_STOCK_RESIZE_SW, GTK_ICON_SIZE_MENU);
+       gtk_image_set_from_icon_name (note->img_resize_sw, STICKYNOTES_STOCK_RESIZE_SW, GTK_ICON_SIZE_MENU);
        gtk_image_set_pixel_size (note->img_resize_sw, STICKYNOTES_ICON_SIZE);
 
        gtk_widget_show(note->w_lock);
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index bd931af..93bb1a5 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -37,16 +37,6 @@ static const GActionEntry stickynotes_applet_menu_actions [] = {
        { "about",       menu_about_cb,       NULL, NULL,    NULL }
 };
 
-/* Sticky Notes Icons */
-static const StickyNotesStockIcon stickynotes_icons[] =
-{
-       { STICKYNOTES_STOCK_LOCKED, STICKYNOTES_ICONDIR "/locked.png" },
-       { STICKYNOTES_STOCK_UNLOCKED, STICKYNOTES_ICONDIR "/unlocked.png" },
-       { STICKYNOTES_STOCK_CLOSE, STICKYNOTES_ICONDIR "/close.png" },
-       { STICKYNOTES_STOCK_RESIZE_SE, STICKYNOTES_ICONDIR "/resize_se.png" },
-       { STICKYNOTES_STOCK_RESIZE_SW, STICKYNOTES_ICONDIR "/resize_sw.png" }
-};
-
 /* Sticky Notes applet factory */
 static gboolean stickynotes_applet_factory(PanelApplet *panel_applet, const gchar *iid, gpointer data)
 {
@@ -112,6 +102,35 @@ stickynotes_make_prelight_icon (GdkPixbuf *dest, GdkPixbuf *src, int shift)
        }
 }
 
+static void
+icon_theme_changed (GtkIconTheme *icon_theme,
+                    gpointer      user_data)
+{
+       gtk_icon_theme_append_search_path (icon_theme,
+                                          PKG_DATA_DIR G_DIR_SEPARATOR_S "icons");
+}
+
+static void
+stickynotes_applet_init_icons (void)
+{
+       GtkIconTheme *icon_theme;
+
+       icon_theme = gtk_icon_theme_get_default ();
+       icon_theme_changed (icon_theme, NULL);
+
+       g_signal_connect (gtk_icon_theme_get_default (), "changed",
+                         G_CALLBACK (icon_theme_changed), NULL);
+}
+
+static void
+stickynotes_destroy (GtkWidget *widget,
+                     gpointer   user_dta)
+{
+       g_signal_handlers_disconnect_by_func (gtk_icon_theme_get_default (),
+                                             icon_theme_changed, NULL);
+}
+
+
 
 /* Create and initalize global sticky notes instance */
 void
@@ -159,30 +178,6 @@ stickynotes_applet_init (PanelApplet *panel_applet)
        install_check_click_on_desktop ();
 }
 
-/* Initialize Sticky Notes Icons */
-void stickynotes_applet_init_icons(void)
-{
-       GtkIconFactory *icon_factory = gtk_icon_factory_new();
-
-       gint i;
-       for (i = 0; i < G_N_ELEMENTS(stickynotes_icons); i++) {
-               StickyNotesStockIcon icon = stickynotes_icons[i];
-               GtkIconSource *icon_source = gtk_icon_source_new();
-               GtkIconSet *icon_set = gtk_icon_set_new();
-
-               gtk_icon_source_set_filename(icon_source, icon.filename);
-               gtk_icon_set_add_source(icon_set, icon_source);
-               gtk_icon_factory_add(icon_factory, icon.stock_id, icon_set);
-
-               gtk_icon_source_free(icon_source);
-               gtk_icon_set_unref(icon_set);
-       }
-
-       gtk_icon_factory_add_default(icon_factory);
-
-       g_object_unref(G_OBJECT(icon_factory));
-}
-
 void stickynotes_applet_init_prefs(void)
 {
 
@@ -314,7 +309,8 @@ void stickynotes_applet_init_prefs(void)
 }
 
 /* Create a Sticky Notes applet */
-StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
+StickyNotesApplet *
+stickynotes_applet_new (PanelApplet *panel_applet)
 {
        AtkObject *atk_obj;
        gchar *ui_path;
@@ -377,8 +373,10 @@ StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
                        G_CALLBACK(applet_change_orient_cb), applet);
        g_signal_connect(G_OBJECT(applet->w_applet), "destroy",
                        G_CALLBACK(applet_destroy_cb), applet);
+       g_signal_connect(G_OBJECT(applet->w_applet), "destroy",
+                       G_CALLBACK(stickynotes_destroy), NULL);
 
-        panel_applet_set_background_widget (panel_applet, applet->w_applet);
+       panel_applet_set_background_widget (panel_applet, applet->w_applet);
 
        atk_obj = gtk_widget_get_accessible (applet->w_applet);
        atk_object_set_name (atk_obj, _("Sticky Notes"));
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index fd9e519..d3acb32 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -26,9 +26,6 @@
 
 #define IS_STRING_EMPTY(x) ((x) == NULL || (x)[0] == '\0')
 
-#define XML_PATH       "/.config/gnome-applets/stickynotes"
-#define ICON_PATH      STICKYNOTES_ICONDIR
-
 #define STICKYNOTES_STOCK_LOCKED       "stickynotes-stock-locked"
 #define STICKYNOTES_STOCK_UNLOCKED     "stickynotes-stock-unlocked"
 #define STICKYNOTES_STOCK_CLOSE        "stickynotes-stock-close"
@@ -66,14 +63,6 @@ typedef struct
     gboolean visible;       /* Toggle show/hide notes */
 } StickyNotes;
 
-/* Sticky Notes Icons */
-typedef struct
-{
-       gchar *stock_id;
-       gchar *filename;
-
-} StickyNotesStockIcon;
-
 /* Sticky Notes Applet */
 typedef struct
 {
@@ -103,7 +92,6 @@ typedef enum
 extern StickyNotes *stickynotes;
 
 void stickynotes_applet_init(PanelApplet *panel_applet);
-void stickynotes_applet_init_icons(void);
 void stickynotes_applet_init_prefs(void);
 
 StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]