[Xfce4-commits] [xfce/xfce4-panel] 01/02: Add xfce_panel_plugin_menu_destroy to plugin API
noreply at xfce.org
noreply at xfce.org
Sat Apr 4 21:14:35 CEST 2020
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 xfce/xfce4-panel.
commit fb37ad2c35b7903c22f8c4e1de9238783937be36
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sat Apr 4 20:47:36 2020 +0200
Add xfce_panel_plugin_menu_destroy to plugin API
This call allows plugins to destroy and recreate the plugin's
context menu. This is not necessary for most plugins, as the
xfce_panel_plugin_menu_insert_item refreshes the menu.
In the case of the launcher's action menu we need to more frequently
refresh the menu and also be able to remove all custom icons at once.
---
docs/references/libxfce4panel-sections.txt | 1 +
libxfce4panel/xfce-panel-plugin.c | 57 +++++++++++++++++++-----------
libxfce4panel/xfce-panel-plugin.h | 2 ++
3 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/docs/references/libxfce4panel-sections.txt b/docs/references/libxfce4panel-sections.txt
index c2d59b3..58e832e 100644
--- a/docs/references/libxfce4panel-sections.txt
+++ b/docs/references/libxfce4panel-sections.txt
@@ -103,6 +103,7 @@ xfce_panel_plugin_add_action_widget
xfce_panel_plugin_menu_insert_item
xfce_panel_plugin_menu_show_configure
xfce_panel_plugin_menu_show_about
+xfce_panel_plugin_menu_destroy
xfce_panel_plugin_remove
xfce_panel_plugin_block_menu
xfce_panel_plugin_unblock_menu
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 1e11b6e..52159ee 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -1197,26 +1197,6 @@ xfce_panel_plugin_menu_panel_help (XfcePanelPlugin *plugin)
-static void
-xfce_panel_plugin_menu_destroy (XfcePanelPlugin *plugin)
-{
- GSList *li;
-
- panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
-
- if (plugin->priv->menu != NULL)
- {
- /* remove custom items before they get destroyed */
- for (li = plugin->priv->menu_items; li != NULL; li = li->next)
- gtk_container_remove (GTK_CONTAINER (plugin->priv->menu), GTK_WIDGET (li->data));
-
- gtk_menu_detach (GTK_MENU (plugin->priv->menu));
- plugin->priv->menu = NULL;
- }
-}
-
-
-
static GtkMenu *
xfce_panel_plugin_menu_get (XfcePanelPlugin *plugin)
{
@@ -2408,6 +2388,43 @@ xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin)
/**
+ * xfce_panel_plugin_menu_destroy:
+ * @plugin : an #XfcePanelPlugin.
+ *
+ * Remove all custom menu items added through #xfce_panel_plugin_menu_insert_item
+ * from the menu.
+ **/
+ void
+ xfce_panel_plugin_menu_destroy (XfcePanelPlugin *plugin)
+ {
+ GSList *li;
+
+ panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ panel_return_if_fail (XFCE_PANEL_PLUGIN_CONSTRUCTED (plugin));
+
+ if (plugin->priv->menu != NULL)
+ {
+ /* remove custom items before they get destroyed */
+ for (li = plugin->priv->menu_items; li != NULL; li = li->next)
+ {
+ if (GTK_IS_WIDGET (li->data))
+ {
+ gtk_container_remove (GTK_CONTAINER (plugin->priv->menu), GTK_WIDGET (li->data));
+ g_object_unref (li->data);
+ }
+ xfce_panel_plugin_menu_item_destroy (GTK_WIDGET (li->data), plugin);
+ }
+ g_slist_free (li);
+
+ gtk_menu_detach (GTK_MENU (plugin->priv->menu));
+ plugin->priv->menu = NULL;
+ }
+ }
+
+
+
+
+/**
* xfce_panel_plugin_get_locked:
* @plugin : an #XfcePanelPlugin.
*
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index 6cfe47c..dee7539 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -209,6 +209,8 @@ void xfce_panel_plugin_menu_show_configure (XfcePanelPlugin *
void xfce_panel_plugin_menu_show_about (XfcePanelPlugin *plugin);
+void xfce_panel_plugin_menu_destroy (XfcePanelPlugin *plugin);
+
gboolean xfce_panel_plugin_get_locked (XfcePanelPlugin *plugin);
void xfce_panel_plugin_remove (XfcePanelPlugin *plugin);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list