[Xfce4-commits] [apps/xfce4-notifyd] 21/24: panel-plugin: Update menu position when size was changed

noreply at xfce.org noreply at xfce.org
Fri Sep 8 23:27:52 CEST 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 cb66f989f9275db3ecac3d283dc3decc0bfd5f0d
Author: Viktor Odintsev <ninetls at xfce.org>
Date:   Sat Aug 26 22:43:01 2017 +0300

    panel-plugin: Update menu position when size was changed
---
 panel-plugin/notification-plugin.c | 32 ++++++++++++++++++++++++++++++++
 panel-plugin/notification-plugin.h |  3 +++
 2 files changed, 35 insertions(+)

diff --git a/panel-plugin/notification-plugin.c b/panel-plugin/notification-plugin.c
index fba715e..82df27b 100644
--- a/panel-plugin/notification-plugin.c
+++ b/panel-plugin/notification-plugin.c
@@ -113,6 +113,32 @@ cb_menu_deactivate (GtkMenuShell *menu,
 
 
 
+static gboolean
+cb_menu_size_allocate_next (NotificationPlugin *notification_plugin)
+{
+  gtk_menu_reposition (GTK_MENU (notification_plugin->menu));
+  notification_plugin->menu_size_allocate_next_handler = 0;
+
+  return G_SOURCE_REMOVE;
+}
+
+
+
+static void
+cb_menu_size_allocate (GtkWidget          *menu,
+                       GdkRectangle       *allocation,
+                       NotificationPlugin *notification_plugin)
+{
+  if (notification_plugin->menu_size_allocate_next_handler != 0)
+    g_source_remove (notification_plugin->menu_size_allocate_next_handler);
+
+  /* defer gtk_menu_reposition call since it may not work in size event handler */
+  notification_plugin->menu_size_allocate_next_handler =
+    g_idle_add ((GSourceFunc)cb_menu_size_allocate_next, notification_plugin);
+}
+
+
+
 static void
 notification_plugin_log_file_changed (GFileMonitor     *monitor,
                                        GFile            *file,
@@ -174,6 +200,8 @@ notification_plugin_new (XfcePanelPlugin *panel_plugin)
                     G_CALLBACK (cb_button_pressed), notification_plugin);
   g_signal_connect (notification_plugin->menu, "deactivate",
                     G_CALLBACK (cb_menu_deactivate), notification_plugin);
+  g_signal_connect (notification_plugin->menu, "size-allocate",
+                    G_CALLBACK (cb_menu_size_allocate), notification_plugin);
 
   /* start monitoring the log file for changes */
   notify_log_path = xfce_resource_lookup (XFCE_RESOURCE_CACHE, XFCE_NOTIFY_LOG_FILE);
@@ -201,6 +229,10 @@ notification_plugin_free (XfcePanelPlugin *plugin,
   /* destroy the panel widgets */
   gtk_widget_destroy (notification_plugin->button);
 
+  /* remove deferred size allocation handler */
+  if (notification_plugin->menu_size_allocate_next_handler != 0)
+    g_source_remove (notification_plugin->menu_size_allocate_next_handler);
+
   /* free the plugin structure */
   panel_slice_free (NotificationPlugin, notification_plugin);
 }
diff --git a/panel-plugin/notification-plugin.h b/panel-plugin/notification-plugin.h
index a317b7b..438f8a1 100644
--- a/panel-plugin/notification-plugin.h
+++ b/panel-plugin/notification-plugin.h
@@ -41,6 +41,9 @@ typedef struct
     GtkWidget       *button;
     GtkWidget       *image;
     GtkWidget       *menu;
+
+    /* handlers */
+    guint            menu_size_allocate_next_handler;
 }
 NotificationPlugin;
 

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


More information about the Xfce4-commits mailing list