[Xfce4-commits] [apps/xfce4-notifyd] 01/02: panel-plugin: Make DND option a switch for better visibility

noreply at xfce.org noreply at xfce.org
Fri Dec 1 00:41:28 CET 2017


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-notifyd.

commit 93569f353ea269bbe4e44996bcb049c2b077e3fe
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Dec 1 00:18:06 2017 +0100

    panel-plugin: Make DND option a switch for better visibility
---
 panel-plugin/notification-plugin-log.c | 44 +++++++++++++++++++++++++++-------
 panel-plugin/notification-plugin.c     | 16 -------------
 panel-plugin/notification-plugin.h     |  6 ++---
 3 files changed, 39 insertions(+), 27 deletions(-)

diff --git a/panel-plugin/notification-plugin-log.c b/panel-plugin/notification-plugin-log.c
index 488622a..c4e74c6 100644
--- a/panel-plugin/notification-plugin-log.c
+++ b/panel-plugin/notification-plugin-log.c
@@ -42,6 +42,25 @@
 
 
 static void
+notification_plugin_menu_item_activate (GtkWidget      *menuitem,
+                                        gpointer        user_data)
+{
+  NotificationPlugin *notification_plugin = user_data;
+  gboolean            muted;
+
+  muted = !gtk_switch_get_active (GTK_SWITCH (notification_plugin->do_not_disturb_switch));
+  gtk_switch_set_active (GTK_SWITCH (notification_plugin->do_not_disturb_switch), muted);
+  if (muted)
+    gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+                                  "notification-disabled-symbolic", GTK_ICON_SIZE_MENU);
+  else
+    gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
+                                  "notification-symbolic", GTK_ICON_SIZE_MENU);
+}
+
+
+
+static void
 notification_plugin_settings_activate_cb (GtkMenuItem *menuitem,
                                           gpointer     user_data)
 {
@@ -73,7 +92,7 @@ void
 notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
 {
   GtkMenu *menu = GTK_MENU (notification_plugin->menu);
-  GtkWidget *mi, *image, *label;
+  GtkWidget *mi, *image, *label, *box;
   GKeyFile *notify_log;
   gint i;
   GDateTime *today;
@@ -99,12 +118,20 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
   if (log_icon_size == -1)
     log_icon_size = DEFAULT_LOG_ICON_SIZE;
 
-  /* checkmenuitem for the do not disturb mode of xfce4-notifyd */
-  mi = gtk_check_menu_item_new_with_mnemonic (_("_Do not disturb"));
+  /* switch for the do not disturb mode of xfce4-notifyd */
+  mi = gtk_menu_item_new ();
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
+  label = gtk_label_new (NULL);
+  gtk_label_set_markup_with_mnemonic (GTK_LABEL (label), _("<b>_Do not disturb</b>"));
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  notification_plugin->do_not_disturb_switch = gtk_switch_new ();
+  gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX (box), notification_plugin->do_not_disturb_switch, FALSE, FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (mi), box);
   xfconf_g_property_bind (notification_plugin->channel, "/do-not-disturb", G_TYPE_BOOLEAN,
-                          G_OBJECT (mi), "active");
+                          G_OBJECT (notification_plugin->do_not_disturb_switch), "active");
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
-  gtk_widget_show (mi);
+  gtk_widget_show_all (mi);
   /* Reset the notification status icon since all items are now read */
   if (xfconf_channel_get_bool (notification_plugin->channel, "/do-not-disturb", FALSE))
     gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
@@ -112,9 +139,10 @@ notification_plugin_menu_populate (NotificationPlugin *notification_plugin)
   else
     gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
                                   "notification-symbolic", GTK_ICON_SIZE_MENU);
-  g_signal_connect (mi, "toggled",
-                    G_CALLBACK (dnd_toggled_cb), notification_plugin);
-  /* footer items */
+  g_signal_connect (mi, "activate",
+                    G_CALLBACK (notification_plugin_menu_item_activate), notification_plugin);
+
+  /* separator before the log */
   mi = gtk_separator_menu_item_new ();
   gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
   gtk_widget_show (mi);
diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index ae22be6..5b7b1d4 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -42,22 +42,6 @@ XFCE_PANEL_PLUGIN_REGISTER (notification_plugin_construct);
 
 
 
-void
-dnd_toggled_cb (GtkCheckMenuItem *checkmenuitem,
-                gpointer          user_data)
-{
-  NotificationPlugin *notification_plugin = user_data;
-
-  if (gtk_check_menu_item_get_active (checkmenuitem))
-    gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
-                                  "notification-disabled-symbolic", GTK_ICON_SIZE_MENU);
-  else
-    gtk_image_set_from_icon_name (GTK_IMAGE (notification_plugin->image),
-                                  "notification-symbolic", GTK_ICON_SIZE_MENU);
-}
-
-
-
 GtkWidget *
 notification_plugin_menu_new (NotificationPlugin *notification_plugin)
 {
diff --git a/panel-plugin/notification-plugin.h b/panel-plugin/notification-plugin.h
index 9cb01e4..6152f4b 100644
--- a/panel-plugin/notification-plugin.h
+++ b/panel-plugin/notification-plugin.h
@@ -44,14 +44,14 @@ typedef struct
     GtkWidget       *image;
     GtkWidget       *menu;
 
+    /* menu widgets */
+    GtkWidget       *do_not_disturb_switch;
+
     /* handlers */
     guint            menu_size_allocate_next_handler;
 }
 NotificationPlugin;
 
-void dnd_toggled_cb           (GtkCheckMenuItem   *checkmenuitem,
-                               gpointer            user_data);
-
 G_END_DECLS
 
 #endif /* !__NOTIFICATION_PLUGIN_H__ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list