diff options
author | monsta <[email protected]> | 2016-01-04 17:50:08 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-01-04 17:50:08 +0300 |
commit | 4a9c10288ab7dcd26c667c5d8fefbbc44e8c4cf3 (patch) | |
tree | b592eb6f48349da2080d8a5ef351c72f714e1663 | |
parent | 4dbb7347a4b344658d28cfd49f6a925f000422ee (diff) | |
download | mate-applets-4a9c10288ab7dcd26c667c5d8fefbbc44e8c4cf3.tar.bz2 mate-applets-4a9c10288ab7dcd26c667c5d8fefbbc44e8c4cf3.tar.xz |
stickynotes: new icon names and paths + fix deprecations
adapted from
https://git.gnome.org/browse/gnome-applets/commit/?id=76982eb73ce1bd912cc19a55d3b6682b9da93687
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | stickynotes/Makefile.am | 3 | ||||
-rw-r--r-- | stickynotes/pixmaps/Makefile.am | 22 | ||||
-rw-r--r-- | stickynotes/pixmaps/stickynotes-stock-close.png (renamed from stickynotes/pixmaps/close.png) | bin | 363 -> 363 bytes | |||
-rw-r--r-- | stickynotes/pixmaps/stickynotes-stock-locked.png (renamed from stickynotes/pixmaps/locked.png) | bin | 403 -> 403 bytes | |||
-rw-r--r-- | stickynotes/pixmaps/stickynotes-stock-resize-se.png (renamed from stickynotes/pixmaps/resize_se.png) | bin | 312 -> 312 bytes | |||
-rw-r--r-- | stickynotes/pixmaps/stickynotes-stock-resize-sw.png (renamed from stickynotes/pixmaps/resize_sw.png) | bin | 295 -> 295 bytes | |||
-rw-r--r-- | stickynotes/pixmaps/stickynotes-stock-unlocked.png (renamed from stickynotes/pixmaps/unlocked.png) | bin | 398 -> 398 bytes | |||
-rw-r--r-- | stickynotes/stickynotes.c | 38 | ||||
-rw-r--r-- | stickynotes/stickynotes_applet.c | 70 | ||||
-rw-r--r-- | stickynotes/stickynotes_applet.h | 10 |
11 files changed, 51 insertions, 93 deletions
diff --git a/configure.ac b/configure.ac index 6b8c7d75..b6df0752 100644 --- a/configure.ac +++ b/configure.ac @@ -551,6 +551,7 @@ AC_DEFINE_DIR(MATE_PIXMAPSDIR, "${pixmapsdir}", [Mate Pixmaps Directory]) AC_DEFINE_DIR(PKGDATADIR, "${pkgdatadir}", [Mate Applets 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 05512c41..8ab9f7d0 100644 --- a/stickynotes/Makefile.am +++ b/stickynotes/Makefile.am @@ -17,8 +17,7 @@ AM_CPPFLAGS = \ $(MATEDESKTOP_CFLAGS) \ $(LIBWNCK_CFLAGS) \ $(XML2_CFLAGS) \ - -DSTICKYNOTES_MENU_UI_DIR=\""$(uidir)"\"\ - -DSTICKYNOTES_ICONDIR=\"$(datadir)/pixmaps/mate-stickynotes/\" + -DSTICKYNOTES_MENU_UI_DIR=\""$(uidir)"\" libexec_PROGRAMS = stickynotes-applet diff --git a/stickynotes/pixmaps/Makefile.am b/stickynotes/pixmaps/Makefile.am index 837ecbb8..c5c39781 100644 --- a/stickynotes/pixmaps/Makefile.am +++ b/stickynotes/pixmaps/Makefile.am @@ -1,12 +1,11 @@ ## Process this file with automake to produce Makefile.in -stickynotes_applet_pixmapsdir = $(datadir)/pixmaps/mate-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 = \ mate-sticky-notes-applet.16.png \ @@ -16,7 +15,7 @@ icons = \ mate-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 +32,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 +56,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/pixmaps/close.png b/stickynotes/pixmaps/stickynotes-stock-close.png Binary files differindex ad0e1eaa..ad0e1eaa 100644 --- a/stickynotes/pixmaps/close.png +++ b/stickynotes/pixmaps/stickynotes-stock-close.png diff --git a/stickynotes/pixmaps/locked.png b/stickynotes/pixmaps/stickynotes-stock-locked.png Binary files differindex 878eedb4..878eedb4 100644 --- a/stickynotes/pixmaps/locked.png +++ b/stickynotes/pixmaps/stickynotes-stock-locked.png diff --git a/stickynotes/pixmaps/resize_se.png b/stickynotes/pixmaps/stickynotes-stock-resize-se.png Binary files differindex 374314ba..374314ba 100644 --- a/stickynotes/pixmaps/resize_se.png +++ b/stickynotes/pixmaps/stickynotes-stock-resize-se.png diff --git a/stickynotes/pixmaps/resize_sw.png b/stickynotes/pixmaps/stickynotes-stock-resize-sw.png Binary files differindex fa216283..fa216283 100644 --- a/stickynotes/pixmaps/resize_sw.png +++ b/stickynotes/pixmaps/stickynotes-stock-resize-sw.png diff --git a/stickynotes/pixmaps/unlocked.png b/stickynotes/pixmaps/stickynotes-stock-unlocked.png Binary files differindex 72bbc9ee..72bbc9ee 100644 --- a/stickynotes/pixmaps/unlocked.png +++ b/stickynotes/pixmaps/stickynotes-stock-unlocked.png diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c index acfa2b30..3ffc88dd 100644 --- a/stickynotes/stickynotes.c +++ b/stickynotes/stickynotes.c @@ -40,9 +40,7 @@ /* Stop gcc complaining about xmlChar's signedness */ #define XML_CHAR(str) ((xmlChar *) (str)) -#if GTK_CHECK_VERSION (3, 0, 0) #define STICKYNOTES_ICON_SIZE 8 -#endif static gboolean save_scheduled = FALSE; @@ -107,9 +105,6 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h) { StickyNote *note; GtkBuilder *builder; -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkIconSize size; -#endif note = g_new (StickyNote, 1); @@ -202,24 +197,15 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h) note->y); /* Set the button images */ -#if GTK_CHECK_VERSION (3, 0, 0) 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); -#else - size = gtk_icon_size_from_name ("stickynotes_icon_size"); - gtk_image_set_from_stock (note->img_close, - STICKYNOTES_STOCK_CLOSE, size); - gtk_image_set_from_stock (note->img_resize_se, - STICKYNOTES_STOCK_RESIZE_SE, size); - gtk_image_set_from_stock (note->img_resize_sw, - STICKYNOTES_STOCK_RESIZE_SW, size); -#endif + gtk_widget_show(note->w_lock); gtk_widget_show(note->w_close); gtk_widget_show(GTK_WIDGET (gtk_builder_get_object (builder, "resize_bar"))); @@ -692,40 +678,24 @@ stickynote_set_font (StickyNote *note, const gchar *font_str, gboolean save) /* Lock/Unlock a sticky note from editing */ void stickynote_set_locked(StickyNote *note, gboolean locked) { -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkIconSize size; -#endif note->locked = locked; /* Set cursor visibility and editability */ gtk_text_view_set_editable(GTK_TEXT_VIEW(note->w_body), !locked); gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(note->w_body), !locked); -#if !GTK_CHECK_VERSION (3, 0, 0) - size = gtk_icon_size_from_name ("stickynotes_icon_size"); -#endif - /* Show appropriate icon and tooltip */ if (locked) { -#if GTK_CHECK_VERSION (3, 0, 0) gtk_image_set_from_icon_name (note->img_lock, STICKYNOTES_STOCK_LOCKED, GTK_ICON_SIZE_MENU); gtk_widget_set_tooltip_text(note->w_lock, _("This note is locked.")); } else { gtk_image_set_from_icon_name (note->img_lock, STICKYNOTES_STOCK_UNLOCKED, GTK_ICON_SIZE_MENU); -#else - gtk_image_set_from_stock(note->img_lock, STICKYNOTES_STOCK_LOCKED, size); - gtk_widget_set_tooltip_text(note->w_lock, _("This note is locked.")); - } - else { - gtk_image_set_from_stock(note->img_lock, STICKYNOTES_STOCK_UNLOCKED, size); -#endif gtk_widget_set_tooltip_text(note->w_lock, _("This note is unlocked.")); } -#if GTK_CHECK_VERSION (3, 0, 0) gtk_image_set_pixel_size (note->img_lock, STICKYNOTES_ICON_SIZE); -#endif + gtk_toggle_action_set_active(note->ta_lock_toggle_item, locked); stickynotes_applet_update_menus(); diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c index ad4cf3ea..6448b896 100644 --- a/stickynotes/stickynotes_applet.c +++ b/stickynotes/stickynotes_applet.c @@ -57,15 +57,6 @@ static const GtkToggleActionEntry stickynotes_applet_menu_toggle_actions[] = G_CALLBACK (menu_toggle_lock_cb), FALSE } }; -/* 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(MatePanelApplet *mate_panel_applet, const gchar *iid, gpointer data) { @@ -131,6 +122,33 @@ 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 @@ -144,11 +162,6 @@ stickynotes_applet_init (MatePanelApplet *mate_panel_applet) g_set_application_name (_("Sticky Notes")); -#if !GTK_CHECK_VERSION (3, 0, 0) - /* Register size for icons */ - gtk_icon_size_register ("stickynotes_icon_size", 8,8); -#endif - gtk_window_set_default_icon_name ("mate-sticky-notes-applet"); stickynotes->icon_normal = gtk_icon_theme_load_icon ( @@ -184,30 +197,6 @@ stickynotes_applet_init (MatePanelApplet *mate_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) { @@ -339,7 +328,8 @@ void stickynotes_applet_init_prefs(void) } /* Create a Sticky Notes applet */ -StickyNotesApplet * stickynotes_applet_new(MatePanelApplet *mate_panel_applet) +StickyNotesApplet * +stickynotes_applet_new(MatePanelApplet *mate_panel_applet) { AtkObject *atk_obj; gchar *ui_path; @@ -406,6 +396,8 @@ StickyNotesApplet * stickynotes_applet_new(MatePanelApplet *mate_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); mate_panel_applet_set_background_widget (mate_panel_applet, applet->w_applet); diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h index a4eb0cfa..6a1663d0 100644 --- a/stickynotes/stickynotes_applet.h +++ b/stickynotes/stickynotes_applet.h @@ -30,7 +30,6 @@ #define STICKYNOTES_SCHEMA "org.mate.stickynotes" #define BUILDER_PATH GTK_BUILDERDIR "/stickynotes.ui" -#define ICON_PATH STICKYNOTES_ICONDIR #define STICKYNOTES_STOCK_LOCKED "stickynotes-stock-locked" #define STICKYNOTES_STOCK_UNLOCKED "stickynotes-stock-unlocked" @@ -69,14 +68,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 { @@ -106,7 +97,6 @@ typedef enum extern StickyNotes *stickynotes; void stickynotes_applet_init(MatePanelApplet *mate_panel_applet); -void stickynotes_applet_init_icons(void); void stickynotes_applet_init_prefs(void); StickyNotesApplet * stickynotes_applet_new(MatePanelApplet *mate_panel_applet); |