1 ## Description: add some description
2 ## Origin/Author: add some origin or author
4 Index: gtk+2.0-2.24.5/gtk/Makefile.am
5 ===================================================================
6 --- gtk+2.0-2.24.5.orig/gtk/Makefile.am 2011-07-19 09:10:44.000000000 -0400
7 +++ gtk+2.0-2.24.5/gtk/Makefile.am 2011-07-19 09:14:08.706398687 -0400
13 + ubuntumenuproxymodule.h \
22 + ubuntumenuproxymodule.c \
26 Index: gtk+2.0-2.24.5/gtk/gtk.h
27 ===================================================================
28 --- gtk+2.0-2.24.5.orig/gtk/gtk.h 2011-02-19 09:31:37.000000000 -0500
29 +++ gtk+2.0-2.24.5/gtk/gtk.h 2011-07-19 09:10:44.000000000 -0400
31 #include <gtk/gtkcellview.h>
32 #include <gtk/gtkcheckbutton.h>
33 #include <gtk/gtkcheckmenuitem.h>
34 +#include <gtk/ubuntumenuproxy.h>
35 +#include <gtk/ubuntumenuproxymodule.h>
36 #include <gtk/gtkclipboard.h>
37 #include <gtk/gtkcolorbutton.h>
38 #include <gtk/gtkcolorsel.h>
39 Index: gtk+2.0-2.24.5/gtk/gtk.symbols
40 ===================================================================
41 --- gtk+2.0-2.24.5.orig/gtk/gtk.symbols 2011-07-19 09:10:44.000000000 -0400
42 +++ gtk+2.0-2.24.5/gtk/gtk.symbols 2011-07-19 09:14:09.810398653 -0400
43 @@ -2606,6 +2606,21 @@
47 +#if IN_HEADER(__UBUNTU_MENU_PROXY_H__)
48 +#if IN_FILE(__UBUNTU_MENU_PROXY_C__)
49 +ubuntu_menu_proxy_get_type G_GNUC_CONST
50 +ubuntu_menu_proxy_get
51 +ubuntu_menu_proxy_insert
55 +#if IN_HEADER(__UBUNTU_MENU_PROXY_MODULE_H__)
56 +#if IN_FILE(__UBUNTU_MENU_PROXY_MODULE_C__)
57 +ubuntu_menu_proxy_module_get_type
58 +ubuntu_menu_proxy_module_get
62 #if IN_HEADER(__GTK_MENU_SHELL_H__)
63 #if IN_FILE(__GTK_MENU_SHELL_C__)
64 gtk_menu_shell_activate_item
66 gtk_menu_shell_select_item
67 gtk_menu_shell_set_take_focus
68 gtk_menu_shell_get_take_focus
69 +ubuntu_gtk_menu_shell_activate_mnemonic
73 Index: gtk+2.0-2.24.5/gtk/gtkmenubar.c
74 ===================================================================
75 --- gtk+2.0-2.24.5.orig/gtk/gtkmenubar.c 2011-02-19 09:31:37.000000000 -0500
76 +++ gtk+2.0-2.24.5/gtk/gtkmenubar.c 2011-07-19 10:09:40.706295821 -0400
78 widget_class->size_allocate = gtk_menu_bar_size_allocate;
79 widget_class->expose_event = gtk_menu_bar_expose;
80 widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
83 menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
84 menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
85 menu_shell_class->move_current = gtk_menu_bar_move_current;
90 +local_notify (GtkWidget *widget,
96 + g_object_get (widget,
97 + "ubuntu-local", &local,
100 + gtk_widget_queue_resize (widget);
105 + gtk_widget_show (widget);
109 + gtk_widget_hide (widget);
115 gtk_menu_bar_init (GtkMenuBar *object)
117 + g_signal_connect (object,
118 + "notify::ubuntu-local",
119 + G_CALLBACK (local_notify),
124 @@ -284,13 +313,27 @@
126 GtkRequisition child_requisition;
128 + gboolean local = FALSE;
130 g_return_if_fail (GTK_IS_MENU_BAR (widget));
131 g_return_if_fail (requisition != NULL);
133 requisition->width = 0;
134 requisition->height = 0;
137 + g_object_get (widget,
144 + requisition->width = 0;
145 + requisition->height = 0;
150 if (gtk_widget_get_visible (widget))
152 menu_bar = GTK_MENU_BAR (widget);
154 GtkMenuShell *menu_shell = GTK_MENU_SHELL (menubars->data);
156 _gtk_menu_shell_set_keyboard_mode (menu_shell, TRUE);
157 - _gtk_menu_shell_activate (menu_shell);
158 - gtk_menu_shell_select_first (menu_shell, FALSE);
159 + if (ubuntu_gtk_menu_shell_activate_first (GTK_MENU_SHELL (menu_shell), FALSE))
161 + //g_print ("send activate to remote!\n");
165 + _gtk_menu_shell_activate (menu_shell);
166 + gtk_menu_shell_select_first (menu_shell, FALSE);
169 g_list_free (menubars);
171 Index: gtk+2.0-2.24.5/gtk/gtkmenushell.c
172 ===================================================================
173 --- gtk+2.0-2.24.5.orig/gtk/gtkmenushell.c 2011-02-19 09:31:37.000000000 -0500
174 +++ gtk+2.0-2.24.5/gtk/gtkmenushell.c 2011-07-19 10:09:14.650296626 -0400
176 #include "gtkmenubar.h"
177 #include "gtkmenuitem.h"
178 #include "gtkmenushell.h"
179 +#include "ubuntumenuproxy.h"
180 #include "gtkmnemonichash.h"
181 #include "gtktearoffmenuitem.h"
182 #include "gtkwindow.h"
194 GtkMnemonicHash *mnemonic_hash;
195 GtkKeyHash *key_hash;
197 + UbuntuMenuProxy *proxy;
200 guint take_focus : 1;
201 guint activated_submenu : 1;
202 /* This flag is a crutch to keep mnemonics in the same menu
205 GTK_PARAM_READWRITE));
207 + g_object_class_install_property (object_class,
209 + g_param_spec_boolean ("ubuntu-local",
211 + P_("Determines whether the menu is local"),
213 + GTK_PARAM_READWRITE));
215 g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
222 +show_local_notify (UbuntuMenuProxy *proxy,
224 + GtkMenuShell *shell)
226 + g_object_notify (shell, "ubuntu-local");
230 gtk_menu_shell_init (GtkMenuShell *menu_shell)
232 GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
234 priv->key_hash = NULL;
235 priv->take_focus = TRUE;
236 priv->activated_submenu = FALSE;
237 + priv->proxy = ubuntu_menu_proxy_get ();
238 + priv->local = FALSE;
240 + if (priv->proxy != NULL)
241 + g_signal_connect (priv->proxy, "notify::show-local",
242 + G_CALLBACK (show_local_notify),
247 @@ -417,12 +445,16 @@
250 GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
251 + GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (object);
255 case PROP_TAKE_FOCUS:
256 gtk_menu_shell_set_take_focus (menu_shell, g_value_get_boolean (value));
259 + priv->local = g_value_get_boolean (value);
262 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
264 @@ -436,12 +468,23 @@
267 GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
268 + GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
273 case PROP_TAKE_FOCUS:
274 g_value_set_boolean (value, gtk_menu_shell_get_take_focus (menu_shell));
277 + if (priv->proxy == NULL || ubuntu_menu_proxy_show_local (priv->proxy)) {
280 + local = priv->local;
283 + g_value_set_boolean (value, local);
286 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
289 GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
290 GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
292 + if (priv->proxy != NULL)
294 + g_signal_handlers_disconnect_by_func (priv->proxy,
299 if (priv->mnemonic_hash)
300 _gtk_mnemonic_hash_free (priv->mnemonic_hash);
302 @@ -483,14 +533,24 @@
305 GtkMenuShellClass *class;
306 + GtkMenuShellPrivate *priv;
308 g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
309 g_return_if_fail (GTK_IS_MENU_ITEM (child));
311 class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
313 + priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
316 class->insert (menu_shell, child, position);
318 + /* insert to proxy */
319 + if (priv->proxy != NULL)
320 + ubuntu_menu_proxy_insert (priv->proxy,
321 + GTK_WIDGET (menu_shell),
327 @@ -1815,5 +1875,52 @@
332 +ubuntu_gtk_menu_shell_activate_mnemonic (GtkMenuShell *shell, GtkWidget *item)
334 + GtkMenuShellPrivate *priv;
336 + g_return_val_if_fail (GTK_IS_MENU_SHELL (shell), FALSE);
338 + priv = GTK_MENU_SHELL_GET_PRIVATE (shell);
340 + if (priv->proxy && !ubuntu_menu_proxy_show_local (priv->proxy))
342 + ubuntu_menu_proxy_activate_menu (priv->proxy,
352 +ubuntu_gtk_menu_shell_activate_first (GtkMenuShell *menu_shell,
353 + gboolean search_sensitive)
355 + GtkWidget *to_select = NULL;
358 + tmp_list = menu_shell->children;
361 + GtkWidget *child = tmp_list->data;
363 + if ((!search_sensitive && gtk_widget_get_visible (child)) ||
364 + _gtk_menu_item_is_selectable (child))
367 + if (!GTK_IS_TEAROFF_MENU_ITEM (child))
371 + tmp_list = tmp_list->next;
374 + return to_select &&
375 + ubuntu_gtk_menu_shell_activate_mnemonic(menu_shell, to_select);
378 #define __GTK_MENU_SHELL_C__
379 #include "gtkaliasdef.c"
380 Index: gtk+2.0-2.24.5/gtk/tests/Makefile.am
381 ===================================================================
382 --- gtk+2.0-2.24.5.orig/gtk/tests/Makefile.am 2011-02-19 09:31:37.000000000 -0500
383 +++ gtk+2.0-2.24.5/gtk/tests/Makefile.am 2011-07-19 09:10:44.000000000 -0400
385 recentmanager_SOURCES = recentmanager.c
386 recentmanager_LDADD = $(progs_ldadd)
388 +TEST_PROGS += menuproxy
389 +menuproxy_SOURCES = menuproxy.c
390 +menuproxy_LDADD = $(progs_ldadd)
392 TEST_PROGS += floating
393 floating_SOURCES = floating.c
394 floating_LDADD = $(progs_ldadd)
395 Index: gtk+2.0-2.24.5/gtk/tests/menuproxy.c
396 ===================================================================
397 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
398 +++ gtk+2.0-2.24.5/gtk/tests/menuproxy.c 2011-07-19 09:10:44.000000000 -0400
401 + * Copyright (C) 2009 Canonical, Ltd.
403 + * This library is free software; you can redistribute it and/or
404 + * modify it under the terms of the GNU Lesser General Public
405 + * License as published by the Free Software Foundation; either
406 + * version 2 of the License, or (at your option) any later version.
408 + * This library is distributed in the hope that it will be useful,
409 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
410 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
411 + * Lesser General Public License for more details.
413 + * You should have received a copy of the GNU Lesser General Public
414 + * License along with this library; if not, write to the
415 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
416 + * Boston, MA 02111-1307, USA.
418 + * Authors: Cody Russell <bratsche@gnome.org>
421 +#undef GTK_DISABLE_DEPRECATED
422 +#include "../gtk/gtk.h"
424 +typedef struct _TestProxy TestProxy;
425 +typedef struct _TestProxyClass TestProxyClass;
427 +//static GType test_proxy_type_id = 0;
428 +//static TestProxyClass *test_proxy_parent_class = NULL;
430 +#define TEST_TYPE_PROXY (test_proxy_type_id)
431 +#define TEST_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_PROXY, TestProxy))
432 +#define TEST_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_PROXY, TestProxyClass))
433 +#define TEST_IS_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_PROXY))
437 + UbuntuMenuProxy parent_object;
440 +struct _TestProxyClass
442 + UbuntuMenuProxyClass parent_class;
445 +static void test_proxy_insert (UbuntuMenuProxy *proxy,
449 +G_DEFINE_DYNAMIC_TYPE(TestProxy, test_proxy, UBUNTU_TYPE_MENU_PROXY)
452 +test_proxy_init (TestProxy *proxy)
457 +test_proxy_class_init (TestProxyClass *class)
459 + UbuntuMenuProxyClass *proxy_class = UBUNTU_MENU_PROXY_CLASS (class);
461 + test_proxy_parent_class = g_type_class_peek_parent (class);
463 + proxy_class->insert = test_proxy_insert;
467 +test_proxy_class_finalize (TestProxyClass *class)
472 +test_proxy_insert (UbuntuMenuProxy *proxy,
478 +/* ---------------------------------------------------- */
480 +#define TEST_TYPE_MODULE (test_module_get_type ())
481 +#define TEST_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_MODULE, TestModule))
482 +#define TEST_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_MODULE, TestModuleClass))
483 +#define TEST_IS_MODULE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_MODULE))
484 +#define TEST_IS_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_MODULE))
485 +#define TEST_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_MODULE, TestModuleClass))
488 +typedef struct _TestModule TestModule;
489 +typedef struct _TestModuleClass TestModuleClass;
493 + GTypeModule parent_instance;
496 +struct _TestModuleClass
498 + GTypeModuleClass parent_class;
502 +test_module_load (GTypeModule *module)
504 + g_print ("registering type...\n");
505 + g_print (" type_id = %d\n", test_proxy_type_id);
507 + test_proxy_register_type (G_TYPE_MODULE (module));
509 + //test_proxy_get_type (G_TYPE_MODULE (module));
511 + g_print (" type_id = %d\n", test_proxy_type_id);
517 +test_module_unload (GTypeModule *module)
522 +test_module_class_init (TestModuleClass *class)
524 + GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
526 + type_module_class->load = test_module_load;
527 + type_module_class->unload = test_module_unload;
531 +test_module_init (TestModule *module)
535 +G_DEFINE_TYPE (TestModule, test_module, G_TYPE_TYPE_MODULE);
538 +test_module_new (void)
540 + TestModule *module = g_object_new (TEST_TYPE_MODULE,
543 + g_print ("test_module_new(): %p\n", module);
549 +/* ---------------------------------------------------- */
552 +non_null_proxy_test (void)
554 + UbuntuMenuProxyModule *module;
556 + /* prevent the module loader from finding a proxy module */
557 + g_unsetenv ("UBUNTU_MENUPROXY");
559 + module = ubuntu_menu_proxy_module_get ();
560 + test_proxy_register_type (G_TYPE_MODULE (module));
561 + //test_proxy_get_type (G_TYPE_MODULE (module));
563 + GtkWidget *widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
564 + g_object_ref_sink (widget);
566 + g_assert (GTK_IS_MENU_BAR (widget));
567 + //g_assert (GTK_MENU_SHELL (widget)->proxy != NULL);
569 + g_object_unref (widget);
573 +null_proxy_test (void)
575 + GtkWidget *widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
576 + g_object_ref_sink (widget);
578 + g_assert (GTK_IS_MENU_BAR (widget));
580 + //g_assert (GTK_MENU_SHELL (widget)->proxy == NULL);
582 + g_object_unref (widget);
585 +static gboolean inserted_called = FALSE;
588 +inserted_cb (UbuntuMenuProxy *proxy,
593 + g_return_if_fail (UBUNTU_IS_MENU_PROXY (proxy));
594 + g_return_if_fail (GTK_IS_WIDGET (child));
595 + inserted_called = TRUE;
599 +menubar_signals_proxy_test (void)
601 + GtkWidget *widget = NULL;
602 + GtkWidget *menuitem = NULL;
603 + UbuntuMenuProxy *proxy;
605 + //ubuntu_menu_proxy_register_type (test_proxy_get_type ());
607 + widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
608 + g_object_ref_sink (widget);
610 + g_assert (GTK_IS_MENU_BAR (widget));
611 + //g_assert (GTK_MENU_SHELL (widget)->proxy != NULL);
614 + proxy = GTK_MENU_SHELL (widget)->proxy;
616 + g_signal_connect (proxy,
617 + "inserted", G_CALLBACK (inserted_cb),
622 + menuitem = gtk_menu_item_new_with_label ("Test Item");
623 + gtk_menu_shell_append (GTK_MENU_SHELL (widget),
626 + g_assert (inserted_called == TRUE);
628 + g_object_unref (widget);
632 +proxy_type_exists_test (void)
635 + UbuntuMenuProxyModule *module;
637 + g_unsetenv ("GTK_MENUPROXY");
639 + module = ubuntu_menu_proxy_module_get ();
640 + test_proxy_get_type (G_TYPE_MODULE (module));
643 + g_assert (ubuntu_menu_proxy_get_type () != 0);
647 +can_instantiate_test (void)
649 + TestModule *module = test_module_new ();
651 + g_type_module_use (G_TYPE_MODULE (module));
653 + UbuntuMenuProxy *proxy = ubuntu_menu_proxy_get ();
655 + g_assert (proxy != NULL);
657 + g_object_ref_sink (proxy);
659 + g_assert (TEST_IS_PROXY (proxy));
660 + g_assert (UBUNTU_IS_MENU_PROXY (proxy));
662 + g_object_unref (proxy);
666 +main (int argc, char *argv[])
668 + gtk_test_init (&argc, &argv);
670 + g_test_add_func ("/proxy/null-proxy", null_proxy_test);
671 + g_test_add_func ("/proxy/type-exists", proxy_type_exists_test);
672 + g_test_add_func ("/proxy/can-instantiate", can_instantiate_test);
673 + g_test_add_func ("/proxy/non-null-proxy", non_null_proxy_test);
674 + g_test_add_func ("/proxy/menubar-signals-proxy", menubar_signals_proxy_test);
676 + return g_test_run();
678 Index: gtk+2.0-2.24.5/gtk/ubuntumenuproxy.c
679 ===================================================================
680 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
681 +++ gtk+2.0-2.24.5/gtk/ubuntumenuproxy.c 2011-07-19 09:10:44.000000000 -0400
684 + * Copyright (C) 2010 Canonical, Ltd.
686 + * This library is free software; you can redistribute it and/or
687 + * modify it under the terms of the GNU Lesser General Public
688 + * License as published by the Free Software Foundation; either
689 + * version 2 of the License, or (at your option) any later version.
691 + * This library is distributed in the hope that it will be useful,
692 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
693 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
694 + * Lesser General Public License for more details.
696 + * You should have received a copy of the GNU Lesser General Public
697 + * License along with this library; if not, write to the
698 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
699 + * Boston, MA 02111-1307, USA.
701 + * Authors: Cody Russell <bratsche@gnome.org>
705 +#include "gtkintl.h"
706 +#include "gtkmarshalers.h"
707 +#include "ubuntumenuproxy.h"
708 +#include "ubuntumenuproxymodule.h"
709 +#include "gtkmodules.h"
710 +#include "gtkprivate.h"
711 +#include "gtkalias.h"
725 +#define UBUNTU_MENU_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyPrivate))
727 +typedef struct _UbuntuMenuProxyPrivate UbuntuMenuProxyPrivate;
729 +struct _UbuntuMenuProxyPrivate
731 + gboolean show_local;
734 +static guint menu_proxy_signals[LAST_SIGNAL] = { 0 };
735 +static GObjectClass *parent_class = NULL;
736 +static UbuntuMenuProxy *proxy_singleton = NULL;
738 +static void ubuntu_menu_proxy_real_insert (UbuntuMenuProxy *proxy,
742 +static gboolean ubuntu_menu_proxy_real_show_local (UbuntuMenuProxy *proxy);
746 +/* --------------------------------------------------------- */
748 +G_DEFINE_TYPE (UbuntuMenuProxy, ubuntu_menu_proxy, G_TYPE_OBJECT)
751 +ubuntu_menu_proxy_constructor (GType type,
753 + GObjectConstructParam *params)
757 + if (proxy_singleton != NULL)
759 + object = g_object_ref (proxy_singleton);
763 + object = G_OBJECT_CLASS (ubuntu_menu_proxy_parent_class)->constructor (type,
767 + proxy_singleton = UBUNTU_MENU_PROXY (object);
768 + g_object_add_weak_pointer (object, (gpointer) &proxy_singleton);
775 +ubuntu_menu_proxy_init (UbuntuMenuProxy *proxy)
780 +ubuntu_menu_proxy_get_property (GObject *object,
785 + UbuntuMenuProxyPrivate *priv = UBUNTU_MENU_PROXY_GET_PRIVATE (object);
789 + case PROP_SHOW_LOCAL:
790 + g_value_set_boolean (value, priv->show_local);
794 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
800 +ubuntu_menu_proxy_set_property (GObject *object,
802 + const GValue *value,
805 + UbuntuMenuProxyPrivate *priv = UBUNTU_MENU_PROXY_GET_PRIVATE (object);
809 + case PROP_SHOW_LOCAL:
810 + priv->show_local = g_value_get_boolean (value);
811 + g_signal_emit (object, menu_proxy_signals[LOCAL_NOTIFY], 0, priv->show_local);
815 + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
821 +ubuntu_menu_proxy_class_init (UbuntuMenuProxyClass *class)
823 + GObjectClass *object_class = G_OBJECT_CLASS (class);
825 + parent_class = g_type_class_peek_parent (class);
827 + object_class->get_property = ubuntu_menu_proxy_get_property;
828 + object_class->set_property = ubuntu_menu_proxy_set_property;
830 + g_object_class_install_property (object_class,
832 + g_param_spec_boolean ("show-local",
833 + P_("Show the local menu"),
834 + P_("Whether the menu is displayed locally"),
836 + GTK_PARAM_READWRITE));
838 + menu_proxy_signals[INSERTED] =
839 + g_signal_new (I_("inserted"),
840 + G_TYPE_FROM_CLASS (class),
842 + G_STRUCT_OFFSET (UbuntuMenuProxyClass, inserted),
844 + _gtk_marshal_VOID__OBJECT_UINT,
846 + GTK_TYPE_WIDGET, G_TYPE_UINT);
848 + menu_proxy_signals[LOCAL_NOTIFY] =
849 + g_signal_new (I_("local-notify"),
850 + G_TYPE_FROM_CLASS (class),
854 + _gtk_marshal_VOID__BOOLEAN,
858 + menu_proxy_signals[ACTIVATE_MENU] =
859 + g_signal_new (I_("activate-menu"),
860 + G_TYPE_FROM_CLASS (class),
864 + _gtk_marshal_VOID__OBJECT,
868 + class->insert = ubuntu_menu_proxy_real_insert;
869 + class->show_local = ubuntu_menu_proxy_real_show_local;
871 + object_class->constructor = ubuntu_menu_proxy_constructor;
873 + g_type_class_add_private (object_class, sizeof (UbuntuMenuProxyPrivate));
877 +ubuntu_menu_proxy_get (void)
879 + if (!proxy_singleton)
881 + ubuntu_menu_proxy_module_get ();
884 + return proxy_singleton;
888 +ubuntu_menu_proxy_real_insert (UbuntuMenuProxy *proxy,
896 +ubuntu_menu_proxy_real_show_local (UbuntuMenuProxy *proxy)
902 +ubuntu_menu_proxy_insert (UbuntuMenuProxy *proxy,
907 + g_return_if_fail (UBUNTU_IS_MENU_PROXY (proxy));
909 + UBUNTU_MENU_PROXY_GET_CLASS (proxy)->insert (proxy,
916 +ubuntu_menu_proxy_show_local (UbuntuMenuProxy *proxy)
918 + g_return_val_if_fail (UBUNTU_IS_MENU_PROXY (proxy), TRUE);
920 + return UBUNTU_MENU_PROXY_GET_CLASS (proxy)->show_local (proxy);
924 +ubuntu_menu_proxy_activate_menu (UbuntuMenuProxy *proxy,
927 + g_signal_emit (proxy, menu_proxy_signals[ACTIVATE_MENU], 0, widget);
930 +#define __UBUNTU_MENU_PROXY_C__
931 +#include "gtkaliasdef.c"
932 Index: gtk+2.0-2.24.5/gtk/ubuntumenuproxy.h
933 ===================================================================
934 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
935 +++ gtk+2.0-2.24.5/gtk/ubuntumenuproxy.h 2011-07-19 09:10:44.000000000 -0400
938 + * Copyright (C) 2010 Canonical, Ltd.
940 + * This library is free software; you can redistribute it and/or
941 + * modify it under the terms of the GNU Lesser General Public
942 + * License as published by the Free Software Foundation; either
943 + * version 2 of the License, or (at your option) any later version.
945 + * This library is distributed in the hope that it will be useful,
946 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
947 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
948 + * Lesser General Public License for more details.
950 + * You should have received a copy of the GNU Lesser General Public
951 + * License along with this library; if not, write to the
952 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
953 + * Boston, MA 02111-1307, USA.
955 + * Authors: Cody Russell <bratsche@gnome.org>
958 +#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
959 +#error "Only <gtk/gtk.h> can be included directly."
962 +#ifndef __UBUNTU_MENU_PROXY_H__
963 +#define __UBUNTU_MENU_PROXY_H__
965 +#include <gtk/gtkwidget.h>
966 +#include <gtk/gtktypeutils.h>
970 +#define UBUNTU_TYPE_MENU_PROXY (ubuntu_menu_proxy_get_type ())
971 +#define UBUNTU_MENU_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxy))
972 +#define UBUNTU_MENU_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyClass))
973 +#define UBUNTU_IS_MENU_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UBUNTU_TYPE_MENU_PROXY))
974 +#define UBUNTU_IS_MENU_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UBUNTU_TYPE_MENU_PROXY))
975 +#define UBUNTU_MENU_PROXY_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyClass))
978 +typedef struct _UbuntuMenuProxy UbuntuMenuProxy;
979 +typedef struct _UbuntuMenuProxyClass UbuntuMenuProxyClass;
981 +struct _UbuntuMenuProxy
983 + GObject parent_object;
986 +struct _UbuntuMenuProxyClass
988 + GObjectClass parent_class;
991 + void (* insert) (UbuntuMenuProxy *proxy, GtkWidget *parent, GtkWidget *child, guint position);
992 + gboolean (* show_local) (UbuntuMenuProxy *proxy);
995 + void (* inserted) (UbuntuMenuProxy *proxy, GtkWidget *child);
998 +GType ubuntu_menu_proxy_get_type (void) G_GNUC_CONST;
999 +UbuntuMenuProxy* ubuntu_menu_proxy_get (void);
1000 +void ubuntu_menu_proxy_insert (UbuntuMenuProxy *proxy,
1001 + GtkWidget *parent,
1004 +gboolean ubuntu_menu_proxy_show_local (UbuntuMenuProxy *proxy);
1005 +void ubuntu_menu_proxy_activate_menu (UbuntuMenuProxy *proxy,
1006 + GtkWidget *widget);
1010 +#endif /* __UBUNTU_MENU_PROXY_H__ */
1011 Index: gtk+2.0-2.24.5/gtk/ubuntumenuproxymodule.c
1012 ===================================================================
1013 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1014 +++ gtk+2.0-2.24.5/gtk/ubuntumenuproxymodule.c 2011-07-19 09:10:44.000000000 -0400
1017 + * Copyright (C) 2010 Canonical, Ltd.
1019 + * This library is free software; you can redistribute it and/or
1020 + * modify it under the terms of the GNU Lesser General Public
1021 + * License as published by the Free Software Foundation; either
1022 + * version 2 of the License, or (at your option) any later version.
1024 + * This library is distributed in the hope that it will be useful,
1025 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1026 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1027 + * Lesser General Public License for more details.
1029 + * You should have received a copy of the GNU Lesser General Public
1030 + * License along with this library; if not, write to the
1031 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1032 + * Boston, MA 02111-1307, USA.
1034 + * Authors: Cody Russell <bratsche@gnome.org>
1037 +#include "config.h"
1038 +#include "gtkintl.h"
1039 +#include "ubuntumenuproxy.h"
1040 +#include "ubuntumenuproxymodule.h"
1041 +#include "gtkmodules.h"
1042 +#include "gtkalias.h"
1049 +static GObject *ubuntu_menu_proxy_module_constructor (GType type,
1051 + GObjectConstructParam *params);
1052 +static void ubuntu_menu_proxy_module_finalize (GObject *object);
1053 +static gboolean ubuntu_menu_proxy_module_real_load (GTypeModule *gmodule);
1054 +static void ubuntu_menu_proxy_module_real_unload (GTypeModule *gmodule);
1057 +G_DEFINE_TYPE (UbuntuMenuProxyModule, ubuntu_menu_proxy_module, G_TYPE_TYPE_MODULE);
1059 +static UbuntuMenuProxyModule *proxy_module_singleton = NULL;
1062 +ubuntu_menu_proxy_module_class_init (UbuntuMenuProxyModuleClass *class)
1064 + GObjectClass *object_class = G_OBJECT_CLASS (class);
1065 + GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
1067 + object_class->finalize = ubuntu_menu_proxy_module_finalize;
1069 + type_module_class->load = ubuntu_menu_proxy_module_real_load;
1070 + type_module_class->unload = ubuntu_menu_proxy_module_real_unload;
1074 +ubuntu_menu_proxy_module_init (UbuntuMenuProxyModule *module)
1076 + module->name = g_strdup (g_getenv ("UBUNTU_MENUPROXY"));
1077 + module->library = NULL;
1078 + module->load = NULL;
1079 + module->unload = NULL;
1083 +ubuntu_menu_proxy_module_finalize (GObject *object)
1085 + UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (object);
1087 + if (module->name != NULL)
1089 + g_free (module->name);
1092 + G_OBJECT_CLASS (ubuntu_menu_proxy_module_parent_class)->finalize (object);
1096 +ubuntu_menu_proxy_module_real_load (GTypeModule *gmodule)
1098 + UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (gmodule);
1101 + if (proxy_module_singleton != NULL)
1104 + if (!module->name)
1106 + g_warning ("Module path not set");
1110 + path = _gtk_find_module (module->name, "menuproxies");
1112 + module->library = g_module_open (path, 0);
1114 + if (!module->library)
1116 + g_printerr ("%s\n", g_module_error ());
1120 + /* Make sure that the loaded library contains the required methods */
1121 + if (!g_module_symbol (module->library,
1122 + "menu_proxy_module_load",
1123 + (gpointer *) &module->load) ||
1124 + !g_module_symbol (module->library,
1125 + "menu_proxy_module_unload",
1126 + (gpointer *) &module->unload))
1128 + g_printerr ("%s\n", g_module_error ());
1129 + g_module_close (module->library);
1134 + /* Initialize the loaded module */
1135 + module->load (module);
1141 +ubuntu_menu_proxy_module_real_unload (GTypeModule *gmodule)
1143 + UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (gmodule);
1145 + module->unload (module);
1147 + g_module_close (module->library);
1148 + module->library = NULL;
1150 + module->load = NULL;
1151 + module->unload = NULL;
1155 +is_valid_module_name (const gchar *name)
1157 +#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
1158 + return g_str_has_prefix (name, "lib") && g_str_has_suffix (name, ".so");
1160 + return g_str_has_suffix (name, ".dll");
1165 +setup_instance (UbuntuMenuProxyModule *module)
1167 + GType *proxy_types;
1170 + proxy_types = g_type_children (UBUNTU_TYPE_MENU_PROXY,
1173 + if (n_proxies > 1)
1175 + g_warning ("There are %d child types of UbuntuMenuProxy, should be 0 or 1.\n",
1178 + else if (n_proxies == 1)
1180 + g_object_new (proxy_types[0], NULL);
1184 +UbuntuMenuProxyModule *
1185 +ubuntu_menu_proxy_module_get (void)
1187 + if (!proxy_module_singleton)
1189 + UbuntuMenuProxyModule *module = NULL;
1190 + const gchar *module_name;
1192 + module_name = g_getenv ("UBUNTU_MENUPROXY");
1194 + if (module_name != NULL)
1196 + if (is_valid_module_name (module_name))
1198 + gchar *path = _gtk_find_module (module_name, "menuproxies");
1200 + module = g_object_new (UBUNTU_TYPE_MENU_PROXY_MODULE,
1203 + if (!g_type_module_use (G_TYPE_MODULE (module)))
1205 + g_warning ("Failed to load type module: %s\n", path);
1207 + g_object_unref (module);
1213 + setup_instance (module);
1216 + g_type_module_unuse (G_TYPE_MODULE (module));
1219 + proxy_module_singleton = module;
1223 + return proxy_module_singleton;
1226 +#define __UBUNTU_MENU_PROXY_MODULE_C__
1227 +#include "gtkaliasdef.c"
1228 Index: gtk+2.0-2.24.5/gtk/ubuntumenuproxymodule.h
1229 ===================================================================
1230 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
1231 +++ gtk+2.0-2.24.5/gtk/ubuntumenuproxymodule.h 2011-07-19 09:10:44.000000000 -0400
1234 + * Copyright (C) 2010 Canonical, Ltd.
1236 + * This library is free software; you can redistribute it and/or
1237 + * modify it under the terms of the GNU Lesser General Public
1238 + * License as published by the Free Software Foundation; either
1239 + * version 2 of the License, or (at your option) any later version.
1241 + * This library is distributed in the hope that it will be useful,
1242 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1243 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1244 + * Lesser General Public License for more details.
1246 + * You should have received a copy of the GNU Lesser General Public
1247 + * License along with this library; if not, write to the
1248 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1249 + * Boston, MA 02111-1307, USA.
1251 + * Authors: Cody Russell <bratsche@gnome.org>
1254 +#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
1255 +#error "Only <gtk/gtk.h> can be included directly."
1258 +#ifndef __UBUNTU_MENU_PROXY_MODULE_H__
1259 +#define __UBUNTU_MENU_PROXY_MODULE_H__
1261 +#include <glib-object.h>
1262 +#include <gmodule.h>
1266 +#define UBUNTU_TYPE_MENU_PROXY_MODULE (ubuntu_menu_proxy_module_get_type ())
1267 +#define UBUNTU_MENU_PROXY_MODULE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModule))
1268 +#define UBUNTU_MENU_PROXY_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModuleClass))
1269 +#define UBUNTU_IS_MENU_MODULE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), UBUNTU_TYPE_MENU_PROXY_MODULE))
1270 +#define UBUNTU_IS_MENU_PROXY_MODULE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), UBUNTU_TYPE_MENU_PROXY_MODULE))
1271 +#define UBUNTU_MENU_PROXY_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModuleClass))
1273 +typedef struct _UbuntuMenuProxyModule UbuntuMenuProxyModule;
1274 +typedef struct _UbuntuMenuProxyModuleClass UbuntuMenuProxyModuleClass;
1275 +typedef struct _UbuntuMenuProxyModulePrivate UbuntuMenuProxyModulePrivate;
1277 +struct _UbuntuMenuProxyModule
1279 + GTypeModule parent_instance;
1281 + UbuntuMenuProxyModulePrivate *priv;
1286 + void (* load) (UbuntuMenuProxyModule *module);
1287 + void (* unload) (UbuntuMenuProxyModule *module);
1290 +struct _UbuntuMenuProxyModuleClass
1292 + GTypeModuleClass parent_class;
1295 +GType ubuntu_menu_proxy_module_get_type (void) G_GNUC_CONST;
1297 +UbuntuMenuProxyModule *ubuntu_menu_proxy_module_get (void);
1301 +#endif /* __UBUNTU_MENU_PROXY_MODULE_H__ */
1302 Index: gtk+2.0-2.24.5/gtk/gtkwindow.c
1303 ===================================================================
1304 --- gtk+2.0-2.24.5.orig/gtk/gtkwindow.c 2011-06-15 18:37:19.000000000 -0400
1305 +++ gtk+2.0-2.24.5/gtk/gtkwindow.c 2011-07-19 09:14:09.882398651 -0400
1313 /* Readonly properties */
1315 PROP_HAS_TOPLEVEL_FOCUS,
1320 + gboolean no_proxy;
1325 @@ -502,6 +505,14 @@
1327 GTK_PARAM_READWRITE));
1329 + g_object_class_install_property (object_class,
1331 + g_param_spec_boolean ("ubuntu-no-proxy",
1332 + P_("Disable menu proxies for this window"),
1333 + P_("Disable menu proxies for this window"),
1335 + GTK_PARAM_READWRITE));
1338 * GtkWindow:startup-id:
1340 @@ -1084,6 +1095,9 @@
1341 case PROP_MNEMONICS_VISIBLE:
1342 gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
1344 + case PROP_NO_PROXY:
1345 + priv->no_proxy = g_value_get_boolean (value);
1348 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1350 @@ -1202,6 +1216,9 @@
1351 case PROP_MNEMONICS_VISIBLE:
1352 g_value_set_boolean (value, priv->mnemonics_visible);
1354 + case PROP_NO_PROXY:
1355 + g_value_set_boolean (value, priv->no_proxy);
1358 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1360 Index: gtk+2.0-2.24.5/gtk/gtkmenuitem.c
1361 ===================================================================
1362 --- gtk+2.0-2.24.5.orig/gtk/gtkmenuitem.c 2011-06-15 18:37:19.000000000 -0400
1363 +++ gtk+2.0-2.24.5/gtk/gtkmenuitem.c 2011-07-19 09:14:08.346398698 -0400
1364 @@ -1395,7 +1395,17 @@
1368 - g_signal_emit (widget, menu_item_signals[ACTIVATE_ITEM], 0);
1370 + if (GTK_IS_MENU_BAR (widget->parent) &&
1371 + ubuntu_gtk_menu_shell_activate_mnemonic (GTK_MENU_SHELL (widget->parent), widget))
1373 + //g_print ("send activate to remote!\n");
1377 + g_signal_emit (widget, menu_item_signals[ACTIVATE_ITEM], 0);