nautilus r14877 - in trunk: . eel src
- From: pborelli svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r14877 - in trunk: . eel src
- Date: Thu, 22 Jan 2009 13:12:22 +0000 (UTC)
Author: pborelli
Date: Thu Jan 22 13:12:22 2009
New Revision: 14877
URL: http://svn.gnome.org/viewvc/nautilus?rev=14877&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/eel/eel-gtk-extensions.c
trunk/eel/eel-gtk-extensions.h
trunk/src/nautilus-navigation-action.c
trunk/src/nautilus-window-menus.c
Modified: trunk/eel/eel-gtk-extensions.c
==============================================================================
--- trunk/eel/eel-gtk-extensions.c (original)
+++ trunk/eel/eel-gtk-extensions.c Thu Jan 22 13:12:22 2009
@@ -436,6 +436,26 @@
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
eel_point_in_allocation (const GtkAllocation *allocation,
int x, int y)
Modified: trunk/eel/eel-gtk-extensions.h
==============================================================================
--- trunk/eel/eel-gtk-extensions.h (original)
+++ trunk/eel/eel-gtk-extensions.h Thu Jan 22 13:12:22 2009
@@ -111,6 +111,9 @@
int index,
gboolean visible);
+/* GtkMenuToolButton */
+GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button);
+
/* GtkLabel */
void eel_gtk_label_make_bold (GtkLabel *label);
void eel_gtk_label_set_scale (GtkLabel *label,
Modified: trunk/src/nautilus-navigation-action.c
==============================================================================
--- trunk/src/nautilus-navigation-action.c (original)
+++ trunk/src/nautilus-navigation-action.c Thu Jan 22 13:12:22 2009
@@ -33,8 +33,8 @@
#include "nautilus-navigation-window.h"
#include "nautilus-window-private.h"
#include "nautilus-navigation-window-slot.h"
-
#include <gtk/gtk.h>
+#include <eel/eel-gtk-extensions.h>
static void nautilus_navigation_action_init (NautilusNavigationAction *action);
static void nautilus_navigation_action_class_init (NautilusNavigationActionClass *class);
@@ -159,7 +159,6 @@
}
}
-
static void
show_menu_callback (GtkMenuToolButton *button,
NautilusNavigationAction *action)
@@ -225,7 +224,6 @@
NautilusNavigationAction *naction = NAUTILUS_NAVIGATION_ACTION (action);
GtkMenuToolButton *button = GTK_MENU_TOOL_BUTTON (proxy);
GtkWidget *menu;
- GtkContainer *container;
GtkWidget *child;
/* set an empty menu, so the arrow button becomes sensitive */
@@ -240,8 +238,7 @@
/* Make sure that middle click works. Note that there is some code duplication
* between here and nautilus-window-menus.c */
- container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (proxy)));
- child = GTK_WIDGET (gtk_container_get_children (container)->data);
+ child = eel_gtk_menu_tool_button_get_button (button);
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);
}
@@ -253,13 +250,11 @@
disconnect_proxy (GtkAction *action, GtkWidget *proxy)
{
if (GTK_IS_MENU_TOOL_BUTTON (proxy)) {
- GtkContainer *container;
GtkWidget *child;
g_signal_handlers_disconnect_by_func (proxy, G_CALLBACK (show_menu_callback), action);
- container = GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (proxy)));
- child = GTK_WIDGET (gtk_container_get_children (container)->data);
+ child = eel_gtk_menu_tool_button_get_button (GTK_MENU_TOOL_BUTTON (proxy));
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);
}
Modified: trunk/src/nautilus-window-menus.c
==============================================================================
--- trunk/src/nautilus-window-menus.c (original)
+++ trunk/src/nautilus-window-menus.c Thu Jan 22 13:12:22 2009
@@ -42,6 +42,7 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
+#include <eel/eel-gtk-extensions.h>
#include <eel/eel-preferences.h>
#include <libnautilus-extension/nautilus-menu-provider.h>
#include <libnautilus-private/nautilus-file-utilities.h>
@@ -622,13 +623,7 @@
/* Menu items already forward middle clicks */
widget = NULL;
} else if (GTK_IS_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);
+ widget = eel_gtk_menu_tool_button_get_button (GTK_MENU_TOOL_BUTTON (proxy));
} else if (GTK_IS_TOOL_BUTTON (proxy)) {
/* The tool button's button is the direct child */
widget = gtk_bin_get_child (GTK_BIN (proxy));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]