From 10b9c30fc79de5f8d9516ba153df233c4968da65 Mon Sep 17 00:00:00 2001 From: Fabien Broquard Date: Tue, 2 Oct 2018 20:29:38 +0200 Subject: na-tray: wide panels, add GSettings to the applet The new GSettings allow to change and remember the minimum icon size for the grid. The default icon size is set at 24px. --- applets/notification_area/Makefile.am | 10 +++++++- applets/notification_area/main.c | 29 +++++++++++++++++++++- applets/notification_area/main.h | 3 +++ ...e.panel.applet.notification-area.gschema.xml.in | 9 +++++++ 4 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 applets/notification_area/org.mate.panel.applet.notification-area.gschema.xml.in (limited to 'applets') diff --git a/applets/notification_area/Makefile.am b/applets/notification_area/Makefile.am index b584f084..67d4f8c6 100644 --- a/applets/notification_area/Makefile.am +++ b/applets/notification_area/Makefile.am @@ -93,6 +93,9 @@ org.mate.panel.applet.NotificationAreaAppletFactory.service: $(service_in_files) $< > $@ endif +notification_area_gschemas_in = org.mate.panel.applet.notification-area.gschema.xml.in +gsettings_SCHEMAS = $(notification_area_gschemas_in:.xml.in=.xml) + ui_FILES = \ notification-area-menu.xml @@ -106,8 +109,12 @@ BUILT_SOURCES = \ na-resources.c \ na-resources.h +@INTLTOOL_XML_NOMERGE_RULE@ +@GSETTINGS_RULES@ + EXTRA_DIST = \ org.mate.panel.NotificationAreaApplet.mate-panel-applet.in.in \ + $(notification_area_gschemas_in) \ $(ui_FILES) \ na.gresource.xml \ $(service_in_files) @@ -115,6 +122,7 @@ EXTRA_DIST = \ CLEANFILES = \ $(applet_DATA) \ $(applet_DATA).in \ - $(service_DATA) + $(service_DATA) \ + $(gsettings_SCHEMAS) -include $(top_srcdir)/git.mk diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c index df07a3e2..9fc63e04 100644 --- a/applets/notification_area/main.c +++ b/applets/notification_area/main.c @@ -25,9 +25,11 @@ #include #include +#include #include #include +#include #include "main.h" #include "na-grid.h" @@ -40,7 +42,10 @@ struct _NaTrayAppletPrivate { - GtkWidget *grid; + GtkWidget *grid; + + GSettings *settings; + gint min_icon_size; #ifdef PROVIDE_WATCHER_SERVICE GfStatusNotifierWatcher *sn_watcher; @@ -104,6 +109,23 @@ get_gtk_orientation_from_applet_orient (MatePanelAppletOrient orient) return GTK_ORIENTATION_HORIZONTAL; } +static void +gsettings_changed_min_icon_size (GSettings *settings, + gchar *key, + NaTrayApplet *applet) +{ + applet->priv->min_icon_size = g_settings_get_int (settings, key); + + na_grid_set_min_icon_size (NA_GRID (applet->priv->grid), applet->priv->min_icon_size); +} + +static void +setup_gsettings (NaTrayApplet *applet) +{ + applet->priv->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (applet), NA_TRAY_SCHEMA); + g_signal_connect (applet->priv->settings, "changed::" KEY_MIN_ICON_SIZE, G_CALLBACK (gsettings_changed_min_icon_size), applet); +} + static void help_cb(GtkAction* action, NaTrayApplet* applet) { GError* error = NULL; @@ -203,6 +225,11 @@ na_tray_applet_realize (GtkWidget *widget) NA_RESOURCE_PATH "notification-area-menu.xml", action_group); g_object_unref(action_group); + + setup_gsettings (applet); + + // load min icon size + gsettings_changed_min_icon_size (applet->priv->settings, KEY_MIN_ICON_SIZE, applet); } static void diff --git a/applets/notification_area/main.h b/applets/notification_area/main.h index 3b8f11f1..afeb6608 100644 --- a/applets/notification_area/main.h +++ b/applets/notification_area/main.h @@ -26,6 +26,9 @@ #define NA_RESOURCE_PATH "/org/mate/panel/applet/na/" +#define NA_TRAY_SCHEMA "org.mate.panel.applet.notification-area" +#define KEY_MIN_ICON_SIZE "min-icon-size" + G_BEGIN_DECLS #define NA_TYPE_TRAY_APPLET (na_tray_applet_get_type ()) diff --git a/applets/notification_area/org.mate.panel.applet.notification-area.gschema.xml.in b/applets/notification_area/org.mate.panel.applet.notification-area.gschema.xml.in new file mode 100644 index 00000000..0a6bf46e --- /dev/null +++ b/applets/notification_area/org.mate.panel.applet.notification-area.gschema.xml.in @@ -0,0 +1,9 @@ + + + + 24 + Minimum icon size + The minimum size an icon can have. + + + -- cgit v1.2.1