Commit 1b6f5b79 authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

add utility function to get a GtkMenuToolButton's button

2009-01-22  Paolo Borelli  <pborelli@katamail.com>

	* eel/eel-gtk-extensions.[ch]: add utility function
	to get a GtkMenuToolButton's button

	* src/nautilus-window-menus.c:
	* src/nautilus-navigation-action.c:
	Use the above util function that doesn't leak the children
	list.


svn path=/trunk/; revision=14877
parent 657283d2
2009-01-22 Paolo Borelli <pborelli@katamail.com>
* eel/eel-gtk-extensions.[ch]: add utility function
to get a GtkMenuToolButton's button
* src/nautilus-window-menus.c:
* src/nautilus-navigation-action.c:
Use the above util function that doesn't leak the children
list.
2009-01-20 A. Walton <awalton@gnome.org> 2009-01-20 A. Walton <awalton@gnome.org>
* src/nautilus-main.c (main): * src/nautilus-main.c (main):
......
...@@ -436,6 +436,26 @@ eel_gtk_menu_set_item_visibility (GtkMenu *menu, int index, gboolean visible) ...@@ -436,6 +436,26 @@ eel_gtk_menu_set_item_visibility (GtkMenu *menu, int index, gboolean visible)
g_list_free (children); g_list_free (children);
} }
GtkWidget *
eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button)
{
GtkContainer *container;
GList *children;
GtkWidget *button;
g_return_val_if_fail (GTK_IS_MENU_TOOL_BUTTON (tool_button), NULL);
/* The menu tool button's button is the first child
* of the child hbox. */
container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (tool_button)));
children = gtk_container_get_children (container);
button = GTK_WIDGET (children->data);
g_list_free (children);
return button;
}
gboolean gboolean
eel_point_in_allocation (const GtkAllocation *allocation, eel_point_in_allocation (const GtkAllocation *allocation,
int x, int y) int x, int y)
......
...@@ -111,6 +111,9 @@ void eel_gtk_menu_set_item_visibility (GtkMenu ...@@ -111,6 +111,9 @@ void eel_gtk_menu_set_item_visibility (GtkMenu
int index, int index,
gboolean visible); gboolean visible);
/* GtkMenuToolButton */
GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button);
/* GtkLabel */ /* GtkLabel */
void eel_gtk_label_make_bold (GtkLabel *label); void eel_gtk_label_make_bold (GtkLabel *label);
void eel_gtk_label_set_scale (GtkLabel *label, void eel_gtk_label_set_scale (GtkLabel *label,
......
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
#include "nautilus-navigation-window.h" #include "nautilus-navigation-window.h"
#include "nautilus-window-private.h" #include "nautilus-window-private.h"
#include "nautilus-navigation-window-slot.h" #include "nautilus-navigation-window-slot.h"
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <eel/eel-gtk-extensions.h>
static void nautilus_navigation_action_init (NautilusNavigationAction *action); static void nautilus_navigation_action_init (NautilusNavigationAction *action);
static void nautilus_navigation_action_class_init (NautilusNavigationActionClass *class); static void nautilus_navigation_action_class_init (NautilusNavigationActionClass *class);
...@@ -159,7 +159,6 @@ fill_menu (NautilusNavigationWindow *window, ...@@ -159,7 +159,6 @@ fill_menu (NautilusNavigationWindow *window,
} }
} }
static void static void
show_menu_callback (GtkMenuToolButton *button, show_menu_callback (GtkMenuToolButton *button,
NautilusNavigationAction *action) NautilusNavigationAction *action)
...@@ -225,7 +224,6 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) ...@@ -225,7 +224,6 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
NautilusNavigationAction *naction = NAUTILUS_NAVIGATION_ACTION (action); NautilusNavigationAction *naction = NAUTILUS_NAVIGATION_ACTION (action);
GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (proxy); GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (proxy);
GtkWidget *menu; GtkWidget *menu;
GtkContainer *container;
GtkWidget *child; GtkWidget *child;
/* set an empty menu, so the arrow button becomes sensitive */ /* set an empty menu, so the arrow button becomes sensitive */
...@@ -240,8 +238,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy) ...@@ -240,8 +238,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
/* Make sure that middle click works. Note that there is some code duplication /* Make sure that middle click works. Note that there is some code duplication
* between here and nautilus-window-menus.c */ * between here and nautilus-window-menus.c */
container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (proxy))); child = eel_gtk_menu_tool_button_get_button (button);
child = GTK_WIDGET (gtk_container_get_children (container)->data);
g_signal_connect (child, "button-press-event", G_CALLBACK (proxy_button_press_event_cb), NULL); g_signal_connect (child, "button-press-event", G_CALLBACK (proxy_button_press_event_cb), NULL);
g_signal_connect (child, "button-release-event", G_CALLBACK (proxy_button_release_event_cb), NULL); g_signal_connect (child, "button-release-event", G_CALLBACK (proxy_button_release_event_cb), NULL);
} }
...@@ -253,13 +250,11 @@ static void ...@@ -253,13 +250,11 @@ static void
disconnect_proxy (GtkAction *action, GtkWidget *proxy) disconnect_proxy (GtkAction *action, GtkWidget *proxy)
{ {
if (GTK_IS_MENU_TOOL_BUTTON (proxy)) { if (GTK_IS_MENU_TOOL_BUTTON (proxy)) {
GtkContainer *container;
GtkWidget *child; GtkWidget *child;
g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (show_menu_callback), action); g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (show_menu_callback), action);
container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (proxy))); child = eel_gtk_menu_tool_button_get_button (GTK_MENU_TOOL_BUTTON (proxy));
child = GTK_WIDGET (gtk_container_get_children (container)->data);
g_signal_handlers_disconnect_by_func (child, G_CALLBACK (proxy_button_press_event_cb), NULL); g_signal_handlers_disconnect_by_func (child, G_CALLBACK (proxy_button_press_event_cb), NULL);
g_signal_handlers_disconnect_by_func (child, G_CALLBACK (proxy_button_release_event_cb), NULL); g_signal_handlers_disconnect_by_func (child, G_CALLBACK (proxy_button_release_event_cb), NULL);
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-preferences.h> #include <eel/eel-preferences.h>
#include <libnautilus-extension/nautilus-menu-provider.h> #include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-file-utilities.h>
...@@ -622,13 +623,7 @@ get_event_widget (GtkWidget *proxy) ...@@ -622,13 +623,7 @@ get_event_widget (GtkWidget *proxy)
/* Menu items already forward middle clicks */ /* Menu items already forward middle clicks */
widget = NULL; widget = NULL;
} else if (GTK_IS_MENU_TOOL_BUTTON (proxy)) { } else if (GTK_IS_MENU_TOOL_BUTTON (proxy)) {
/** widget = eel_gtk_menu_tool_button_get_button (GTK_MENU_TOOL_BUTTON (proxy));
* The menu tool button's button is the first child
* of the child hbox.
*/
GtkContainer *container =
GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (proxy)));
widget = GTK_WIDGET (gtk_container_get_children (container)->data);
} else if (GTK_IS_TOOL_BUTTON (proxy)) { } else if (GTK_IS_TOOL_BUTTON (proxy)) {
/* The tool button's button is the direct child */ /* The tool button's button is the direct child */
widget = gtk_bin_get_child (GTK_BIN (proxy)); widget = gtk_bin_get_child (GTK_BIN (proxy));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment