SF.net SVN: geany:[4615] branches/geany-0.18.1
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Jan 31 16:28:25 UTC 2010
Revision: 4615
http://geany.svn.sourceforge.net/geany/?rev=4615&view=rev
Author: eht16
Date: 2010-01-31 16:28:21 +0000 (Sun, 31 Jan 2010)
Log Message:
-----------
Backport from trunk:
Only set the menu of the button if a non-empty GtkMenu is passed to geany_menu_button_action_set_menu() so the menu arrow keeps insensitive.
Modified Paths:
--------------
branches/geany-0.18.1/ChangeLog
branches/geany-0.18.1/src/geanymenubuttonaction.c
Modified: branches/geany-0.18.1/ChangeLog
===================================================================
--- branches/geany-0.18.1/ChangeLog 2010-01-31 16:28:04 UTC (rev 4614)
+++ branches/geany-0.18.1/ChangeLog 2010-01-31 16:28:21 UTC (rev 4615)
@@ -43,6 +43,10 @@
could be loaded which is only displayed *if* libvte.so is loaded.
* src/editor.c:
Allow autocompletion for HTML entities even within a word.
+ * src/geanymenubuttonaction.c:
+ Only set the menu of the button if a non-empty GtkMenu is passed to
+ geany_menu_button_action_set_menu() so the menu arrow keeps
+ insensitive.
2009-10-26 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
Modified: branches/geany-0.18.1/src/geanymenubuttonaction.c
===================================================================
--- branches/geany-0.18.1/src/geanymenubuttonaction.c 2010-01-31 16:28:04 UTC (rev 4614)
+++ branches/geany-0.18.1/src/geanymenubuttonaction.c 2010-01-31 16:28:21 UTC (rev 4615)
@@ -44,7 +44,6 @@
enum
{
BUTTON_CLICKED,
-
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
@@ -126,20 +125,55 @@
}
-void geany_menu_button_action_set_menu(GeanyMenubuttonAction *action, GtkWidget *menu)
+static void menu_items_changed_cb(GtkContainer *container, GtkWidget *widget, GeanyMenubuttonAction *action)
{
GeanyMenubuttonActionPrivate *priv;
+ gboolean enable;
GSList *l;
g_return_if_fail(action != NULL);
- g_return_if_fail(menu != NULL);
priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
+ if (priv->menu != NULL)
+ enable = (g_list_length(gtk_container_get_children(GTK_CONTAINER(priv->menu))) > 0);
+ else
+ enable = FALSE;
- priv->menu = menu;
+ if (enable)
+ {
+ foreach_slist(l, gtk_action_get_proxies(GTK_ACTION(action)))
+ {
+ if (gtk_menu_tool_button_get_menu(GTK_MENU_TOOL_BUTTON(l->data)) == NULL)
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(l->data), priv->menu);
+ }
+ }
+ else
+ {
+ foreach_slist(l, gtk_action_get_proxies(GTK_ACTION(action)))
+ {
+ gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(l->data), NULL);
+ }
+ }
+}
- foreach_slist(l, gtk_action_get_proxies(GTK_ACTION(action)))
+
+void geany_menu_button_action_set_menu(GeanyMenubuttonAction *action, GtkWidget *menu)
+{
+ GeanyMenubuttonActionPrivate *priv;
+
+ g_return_if_fail(action != NULL);
+
+ priv = GEANY_MENU_BUTTON_ACTION_GET_PRIVATE(action);
+
+ if (priv->menu != NULL)
+ g_signal_handlers_disconnect_by_func(priv->menu, menu_items_changed_cb, action);
+ if (menu != NULL)
{
- gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(l->data), priv->menu);
+ g_signal_connect(menu, "add", G_CALLBACK(menu_items_changed_cb), action);
+ g_signal_connect(menu, "remove", G_CALLBACK(menu_items_changed_cb), action);
}
+
+ priv->menu = menu;
+
+ menu_items_changed_cb(GTK_CONTAINER(menu), NULL, action);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list