Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 341757 | Differences between
and this patch

Collapse All | Expand All

(-)gtk+2.0-2.21.6.orig/gtk/Makefile.am (+4 lines)
Lines 249-254 Link Here
249
	gtkmenu.h		\
249
	gtkmenu.h		\
250
	gtkmenubar.h		\
250
	gtkmenubar.h		\
251
	gtkmenuitem.h		\
251
	gtkmenuitem.h		\
252
	ubuntumenuproxy.h	\
253
	ubuntumenuproxymodule.h	\
252
	gtkmenushell.h		\
254
	gtkmenushell.h		\
253
	gtkmenutoolbutton.h	\
255
	gtkmenutoolbutton.h	\
254
	gtkmessagedialog.h	\
256
	gtkmessagedialog.h	\
Lines 517-522 Link Here
517
	gtkmenu.c		\
519
	gtkmenu.c		\
518
	gtkmenubar.c		\
520
	gtkmenubar.c		\
519
	gtkmenuitem.c		\
521
	gtkmenuitem.c		\
522
	ubuntumenuproxy.c	\
523
	ubuntumenuproxymodule.c	\
520
	gtkmenushell.c		\
524
	gtkmenushell.c		\
521
	gtkmenutoolbutton.c	\
525
	gtkmenutoolbutton.c	\
522
	gtkmessagedialog.c	\
526
	gtkmessagedialog.c	\
(-)gtk+-2.22.1/gtk/Makefile.in.orig (-7 / +9 lines)
Lines 148-154 Link Here
148
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
148
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
149
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
149
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
150
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
150
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
151
	gtkmenu.c gtkmenubar.c gtkmenuitem.c gtkmenushell.c \
151
	gtkmenu.c gtkmenubar.c gtkmenuitem.c ubuntumenuproxy.c ubuntumenuproxymodule.c gtkmenushell.c \
152
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
152
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
153
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
153
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
154
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
154
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
Lines 234-240 Link Here
234
	gtkinfobar.lo gtkinputdialog.lo gtkinvisible.lo gtkitem.lo \
234
	gtkinfobar.lo gtkinputdialog.lo gtkinvisible.lo gtkitem.lo \
235
	gtkkeyhash.lo gtklabel.lo gtklayout.lo gtklinkbutton.lo \
235
	gtkkeyhash.lo gtklabel.lo gtklayout.lo gtklinkbutton.lo \
236
	gtkliststore.lo gtkmain.lo gtkmarshal.lo gtkmarshalers.lo \
236
	gtkliststore.lo gtkmain.lo gtkmarshal.lo gtkmarshalers.lo \
237
	gtkmenu.lo gtkmenubar.lo gtkmenuitem.lo gtkmenushell.lo \
237
	gtkmenu.lo gtkmenubar.lo gtkmenuitem.lo ubuntumenuproxy.lo ubuntumenuproxymodule.lo gtkmenushell.lo \
238
	gtkmenutoolbutton.lo gtkmessagedialog.lo gtkmisc.lo \
238
	gtkmenutoolbutton.lo gtkmessagedialog.lo gtkmisc.lo \
239
	gtkmnemonichash.lo gtkmodules.lo gtkmountoperation.lo \
239
	gtkmnemonichash.lo gtkmodules.lo gtkmountoperation.lo \
240
	gtknotebook.lo gtkobject.lo gtkoffscreenwindow.lo \
240
	gtknotebook.lo gtkobject.lo gtkoffscreenwindow.lo \
Lines 339-345 Link Here
339
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
339
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
340
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
340
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
341
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
341
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
342
	gtkmenu.c gtkmenubar.c gtkmenuitem.c gtkmenushell.c \
342
	gtkmenu.c gtkmenubar.c gtkmenuitem.c ubuntumenuproxy.c ubuntumenuproxymodule.c gtkmenushell.c \
343
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
343
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
344
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
344
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
345
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
345
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
Lines 426-432 Link Here
426
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
426
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
427
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
427
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
428
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
428
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
429
	gtkmenu.c gtkmenubar.c gtkmenuitem.c gtkmenushell.c \
429
	gtkmenu.c gtkmenubar.c gtkmenuitem.c ubuntumenuproxy.c ubuntumenuproxymodule.c gtkmenushell.c \
430
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
430
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
431
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
431
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
432
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
432
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
Lines 513-519 Link Here
513
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
513
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
514
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
514
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
515
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
515
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
516
	gtkmenu.c gtkmenubar.c gtkmenuitem.c gtkmenushell.c \
516
	gtkmenu.c gtkmenubar.c gtkmenuitem.c ubuntumenuproxy.c ubuntumenuproxymodule.c gtkmenushell.c \
517
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
517
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
518
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
518
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
519
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
519
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
Lines 1030-1036 Link Here
1030
	gtkimmodule.h gtkimmulticontext.h gtkinfobar.h gtkinvisible.h \
1030
	gtkimmodule.h gtkimmulticontext.h gtkinfobar.h gtkinvisible.h \
1031
	gtkitem.h gtklabel.h gtklayout.h gtklinkbutton.h \
1031
	gtkitem.h gtklabel.h gtklayout.h gtklinkbutton.h \
1032
	gtkliststore.h gtkmain.h gtkmenu.h gtkmenubar.h gtkmenuitem.h \
1032
	gtkliststore.h gtkmain.h gtkmenu.h gtkmenubar.h gtkmenuitem.h \
1033
	gtkmenushell.h gtkmenutoolbutton.h gtkmessagedialog.h \
1033
	ubuntumenuproxy.h ubuntumenuproxymodule.h gtkmenushell.h gtkmenutoolbutton.h gtkmessagedialog.h \
1034
	gtkmisc.h gtkmodules.h gtkmountoperation.h gtknotebook.h \
1034
	gtkmisc.h gtkmodules.h gtkmountoperation.h gtknotebook.h \
1035
	gtkobject.h gtkoffscreenwindow.h gtkorientable.h \
1035
	gtkobject.h gtkoffscreenwindow.h gtkorientable.h \
1036
	gtkpagesetup.h gtkpaned.h gtkpapersize.h gtkplug.h \
1036
	gtkpagesetup.h gtkpaned.h gtkpapersize.h gtkplug.h \
Lines 1131-1137 Link Here
1131
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
1131
	gtkinfobar.c gtkinputdialog.c gtkinvisible.c gtkitem.c \
1132
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
1132
	gtkkeyhash.c gtklabel.c gtklayout.c gtklinkbutton.c \
1133
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
1133
	gtkliststore.c gtkmain.c gtkmarshal.c gtkmarshalers.c \
1134
	gtkmenu.c gtkmenubar.c gtkmenuitem.c gtkmenushell.c \
1134
	gtkmenu.c gtkmenubar.c gtkmenuitem.c ubuntumenuproxy.c ubuntumenuproxymodule.c gtkmenushell.c \
1135
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
1135
	gtkmenutoolbutton.c gtkmessagedialog.c gtkmisc.c \
1136
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
1136
	gtkmnemonichash.c gtkmodules.c gtkmountoperation.c \
1137
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
1137
	gtknotebook.c gtkobject.c gtkoffscreenwindow.c gtkorientable.c \
Lines 1888-1893 Link Here
1888
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenu.Plo@am__quote@
1888
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenu.Plo@am__quote@
1889
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenubar.Plo@am__quote@
1889
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenubar.Plo@am__quote@
1890
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenuitem.Plo@am__quote@
1890
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenuitem.Plo@am__quote@
1891
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubuntumenuproxy.Plo@am__quote@
1892
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ubuntumenuproxymodule.Plo@am__quote@
1891
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenushell.Plo@am__quote@
1893
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenushell.Plo@am__quote@
1892
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenutoolbutton.Plo@am__quote@
1894
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmenutoolbutton.Plo@am__quote@
1893
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmessagedialog.Plo@am__quote@
1895
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gtkmessagedialog.Plo@am__quote@
(-)gtk+2.0-2.21.6.orig/gtk/gtk.h (+2 lines)
Lines 65-70 Link Here
65
#include <gtk/gtkcellview.h>
65
#include <gtk/gtkcellview.h>
66
#include <gtk/gtkcheckbutton.h>
66
#include <gtk/gtkcheckbutton.h>
67
#include <gtk/gtkcheckmenuitem.h>
67
#include <gtk/gtkcheckmenuitem.h>
68
#include <gtk/ubuntumenuproxy.h>
69
#include <gtk/ubuntumenuproxymodule.h>
68
#include <gtk/gtkclipboard.h>
70
#include <gtk/gtkclipboard.h>
69
#include <gtk/gtkcolorbutton.h>
71
#include <gtk/gtkcolorbutton.h>
70
#include <gtk/gtkcolorsel.h>
72
#include <gtk/gtkcolorsel.h>
(-)gtk+2.0-2.21.6.orig/gtk/gtk.symbols (+16 lines)
Lines 2572-2577 Link Here
2572
#endif
2572
#endif
2573
#endif
2573
#endif
2574
2574
2575
#if IN_HEADER(__UBUNTU_MENU_PROXY_H__)
2576
#if IN_FILE(__UBUNTU_MENU_PROXY_C__)
2577
ubuntu_menu_proxy_get_type G_GNUC_CONST
2578
ubuntu_menu_proxy_get
2579
ubuntu_menu_proxy_insert
2580
#endif
2581
#endif
2582
2583
#if IN_HEADER(__UBUNTU_MENU_PROXY_MODULE_H__)
2584
#if IN_FILE(__UBUNTU_MENU_PROXY_MODULE_C__)
2585
ubuntu_menu_proxy_module_get_type
2586
ubuntu_menu_proxy_module_get
2587
#endif
2588
#endif
2589
2575
#if IN_HEADER(__GTK_MENU_SHELL_H__)
2590
#if IN_HEADER(__GTK_MENU_SHELL_H__)
2576
#if IN_FILE(__GTK_MENU_SHELL_C__)
2591
#if IN_FILE(__GTK_MENU_SHELL_C__)
2577
gtk_menu_shell_activate_item
2592
gtk_menu_shell_activate_item
Lines 2586-2591 Link Here
2586
gtk_menu_shell_select_item
2601
gtk_menu_shell_select_item
2587
gtk_menu_shell_set_take_focus
2602
gtk_menu_shell_set_take_focus
2588
gtk_menu_shell_get_take_focus
2603
gtk_menu_shell_get_take_focus
2604
ubuntu_gtk_menu_shell_activate_mnemonic
2589
#endif
2605
#endif
2590
#endif
2606
#endif
2591
2607
(-)gtk+2.0-2.21.6.orig/gtk/gtkmenubar.c (-2 / +45 lines)
Lines 107-113 Link Here
107
  widget_class->size_allocate = gtk_menu_bar_size_allocate;
107
  widget_class->size_allocate = gtk_menu_bar_size_allocate;
108
  widget_class->expose_event = gtk_menu_bar_expose;
108
  widget_class->expose_event = gtk_menu_bar_expose;
109
  widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
109
  widget_class->hierarchy_changed = gtk_menu_bar_hierarchy_changed;
110
  
110
111
  menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
111
  menu_shell_class->submenu_placement = GTK_TOP_BOTTOM;
112
  menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
112
  menu_shell_class->get_popup_delay = gtk_menu_bar_get_popup_delay;
113
  menu_shell_class->move_current = gtk_menu_bar_move_current;
113
  menu_shell_class->move_current = gtk_menu_bar_move_current;
Lines 218-225 Link Here
218
}
218
}
219
219
220
static void
220
static void
221
local_notify (GtkWidget  *widget,
222
              GParamSpec *pspec,
223
              gpointer    user_data)
224
{
225
  gboolean local;
226
227
  g_object_get (widget,
228
                "ubuntu-local", &local,
229
                NULL);
230
231
  gtk_widget_queue_resize (widget);
232
233
  /*
234
  if (local)
235
    {
236
      gtk_widget_show (widget);
237
    }
238
  else
239
    {
240
      gtk_widget_hide (widget);
241
    }
242
  */
243
}
244
245
static void
221
gtk_menu_bar_init (GtkMenuBar *object)
246
gtk_menu_bar_init (GtkMenuBar *object)
222
{
247
{
248
  g_signal_connect (object,
249
                    "notify::ubuntu-local",
250
                    G_CALLBACK (local_notify),
251
                    NULL);
223
}
252
}
224
253
225
GtkWidget*
254
GtkWidget*
Lines 284-296 Link Here
284
  gint nchildren;
313
  gint nchildren;
285
  GtkRequisition child_requisition;
314
  GtkRequisition child_requisition;
286
  gint ipadding;
315
  gint ipadding;
316
  gboolean local = FALSE;
287
317
288
  g_return_if_fail (GTK_IS_MENU_BAR (widget));
318
  g_return_if_fail (GTK_IS_MENU_BAR (widget));
289
  g_return_if_fail (requisition != NULL);
319
  g_return_if_fail (requisition != NULL);
290
320
291
  requisition->width = 0;
321
  requisition->width = 0;
292
  requisition->height = 0;
322
  requisition->height = 0;
293
  
323
324
  g_object_get (widget,
325
                "ubuntu-local",
326
                &local,
327
                NULL);
328
329
  if (!local)
330
    {
331
      requisition->width = 0;
332
      requisition->height = 0;
333
334
      return;
335
    }
336
294
  if (gtk_widget_get_visible (widget))
337
  if (gtk_widget_get_visible (widget))
295
    {
338
    {
296
      menu_bar = GTK_MENU_BAR (widget);
339
      menu_bar = GTK_MENU_BAR (widget);
(-)gtk+2.0-2.21.6/gtk/gtkmenushell.h (+1 lines)
Lines 135-140 Link Here
135
void     _gtk_menu_shell_set_keyboard_mode (GtkMenuShell *menu_shell,
135
void     _gtk_menu_shell_set_keyboard_mode (GtkMenuShell *menu_shell,
136
                                            gboolean      keyboard_mode);
136
                                            gboolean      keyboard_mode);
137
gboolean _gtk_menu_shell_get_keyboard_mode (GtkMenuShell *menu_shell);
137
gboolean _gtk_menu_shell_get_keyboard_mode (GtkMenuShell *menu_shell);
138
gboolean ubuntu_gtk_menu_shell_activate_mnemonic (GtkMenuShell *shell, GtkWidget *item);
138
139
139
G_END_DECLS
140
G_END_DECLS
(-)gtk+2.0-2.21.6.orig/gtk/gtkmenushell.c (-1 / +89 lines)
Lines 37-42 Link Here
37
#include "gtkmenubar.h"
37
#include "gtkmenubar.h"
38
#include "gtkmenuitem.h"
38
#include "gtkmenuitem.h"
39
#include "gtkmenushell.h"
39
#include "gtkmenushell.h"
40
#include "ubuntumenuproxy.h"
40
#include "gtkmnemonichash.h"
41
#include "gtkmnemonichash.h"
41
#include "gtktearoffmenuitem.h"
42
#include "gtktearoffmenuitem.h"
42
#include "gtkwindow.h"
43
#include "gtkwindow.h"
Lines 64-70 Link Here
64
65
65
enum {
66
enum {
66
  PROP_0,
67
  PROP_0,
67
  PROP_TAKE_FOCUS
68
  PROP_TAKE_FOCUS,
69
  PROP_LOCAL
68
};
70
};
69
71
70
/* Terminology:
72
/* Terminology:
Lines 135-140 Link Here
135
  GtkMnemonicHash *mnemonic_hash;
137
  GtkMnemonicHash *mnemonic_hash;
136
  GtkKeyHash *key_hash;
138
  GtkKeyHash *key_hash;
137
139
140
  UbuntuMenuProxy *proxy;
141
  gboolean         local;
142
138
  guint take_focus : 1;
143
  guint take_focus : 1;
139
  guint activated_submenu : 1;
144
  guint activated_submenu : 1;
140
  /* This flag is a crutch to keep mnemonics in the same menu
145
  /* This flag is a crutch to keep mnemonics in the same menu
Lines 381-386 Link Here
381
							 TRUE,
386
							 TRUE,
382
							 GTK_PARAM_READWRITE));
387
							 GTK_PARAM_READWRITE));
383
388
389
  g_object_class_install_property (object_class,
390
                                   PROP_LOCAL,
391
                                   g_param_spec_boolean ("ubuntu-local",
392
                                                         P_("Local menu"),
393
                                                         P_("Determines whether the menu is local"),
394
                                                         FALSE,
395
                                                         GTK_PARAM_READWRITE));
396
384
  g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
397
  g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
385
}
398
}
386
399
Lines 391-396 Link Here
391
}
404
}
392
405
393
static void
406
static void
407
show_local_notify (UbuntuMenuProxy *proxy,
408
                   GParamSpec      *pspec,
409
                   GtkMenuShell    *shell)
410
{
411
  gboolean local;
412
413
  g_object_get (proxy,
414
                "show-local", &local,
415
                NULL);
416
417
  g_object_set (shell,
418
                "ubuntu-local", local,
419
                NULL);
420
}
421
422
static void
394
gtk_menu_shell_init (GtkMenuShell *menu_shell)
423
gtk_menu_shell_init (GtkMenuShell *menu_shell)
395
{
424
{
396
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
425
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
Lines 408-413 Link Here
408
  priv->key_hash = NULL;
437
  priv->key_hash = NULL;
409
  priv->take_focus = TRUE;
438
  priv->take_focus = TRUE;
410
  priv->activated_submenu = FALSE;
439
  priv->activated_submenu = FALSE;
440
  priv->proxy = ubuntu_menu_proxy_get ();
441
  priv->local = FALSE;
442
443
  if (priv->proxy != NULL)
444
    g_signal_connect (priv->proxy, "notify::show-local",
445
                      G_CALLBACK (show_local_notify),
446
                      menu_shell);
411
}
447
}
412
448
413
static void
449
static void
Lines 417-428 Link Here
417
                             GParamSpec   *pspec)
453
                             GParamSpec   *pspec)
418
{
454
{
419
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
455
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
456
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (object);
420
457
421
  switch (prop_id)
458
  switch (prop_id)
422
    {
459
    {
423
    case PROP_TAKE_FOCUS:
460
    case PROP_TAKE_FOCUS:
424
      gtk_menu_shell_set_take_focus (menu_shell, g_value_get_boolean (value));
461
      gtk_menu_shell_set_take_focus (menu_shell, g_value_get_boolean (value));
425
      break;
462
      break;
463
    case PROP_LOCAL:
464
      priv->local = g_value_get_boolean (value);
465
      break;
426
    default:
466
    default:
427
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
467
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
428
      break;
468
      break;
Lines 436-447 Link Here
436
                             GParamSpec  *pspec)
476
                             GParamSpec  *pspec)
437
{
477
{
438
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
478
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
479
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
480
  gboolean local;
439
481
440
  switch (prop_id)
482
  switch (prop_id)
441
    {
483
    {
442
    case PROP_TAKE_FOCUS:
484
    case PROP_TAKE_FOCUS:
443
      g_value_set_boolean (value, gtk_menu_shell_get_take_focus (menu_shell));
485
      g_value_set_boolean (value, gtk_menu_shell_get_take_focus (menu_shell));
444
      break;
486
      break;
487
    case PROP_LOCAL:
488
      if (priv->proxy == NULL) {
489
        local = TRUE;
490
      } else {
491
        local = priv->local;
492
      }
493
494
      g_value_set_boolean (value, local);
495
      break;
445
    default:
496
    default:
446
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
497
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
447
      break;
498
      break;
Lines 454-459 Link Here
454
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
505
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
455
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
506
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
456
507
508
  if (priv->proxy != NULL)
509
    {
510
      g_signal_handlers_disconnect_by_func (priv->proxy,
511
                                            show_local_notify,
512
                                            menu_shell);
513
    }
514
457
  if (priv->mnemonic_hash)
515
  if (priv->mnemonic_hash)
458
    _gtk_mnemonic_hash_free (priv->mnemonic_hash);
516
    _gtk_mnemonic_hash_free (priv->mnemonic_hash);
459
  if (priv->key_hash)
517
  if (priv->key_hash)
Lines 483-496 Link Here
483
		       gint          position)
541
		       gint          position)
484
{
542
{
485
  GtkMenuShellClass *class;
543
  GtkMenuShellClass *class;
544
  GtkMenuShellPrivate *priv;
486
545
487
  g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
546
  g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
488
  g_return_if_fail (GTK_IS_MENU_ITEM (child));
547
  g_return_if_fail (GTK_IS_MENU_ITEM (child));
489
548
490
  class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
549
  class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
491
550
551
  priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
552
492
  if (class->insert)
553
  if (class->insert)
493
    class->insert (menu_shell, child, position);
554
    class->insert (menu_shell, child, position);
555
556
  /* insert to proxy */
557
  if (priv->proxy != NULL)
558
    ubuntu_menu_proxy_insert (priv->proxy,
559
                              GTK_WIDGET (menu_shell),
560
                              child,
561
                              position);
494
}
562
}
495
563
496
static void
564
static void
Lines 1815-1819 Link Here
1815
    }
1883
    }
1816
}
1884
}
1817
1885
1886
gboolean
1887
ubuntu_gtk_menu_shell_activate_mnemonic (GtkMenuShell *shell, GtkWidget *item)
1888
{
1889
  GtkMenuShellPrivate *priv;
1890
1891
  g_return_val_if_fail (GTK_IS_MENU_SHELL (shell), FALSE);
1892
1893
  priv = GTK_MENU_SHELL_GET_PRIVATE (shell);
1894
1895
  if (priv->proxy && !ubuntu_menu_proxy_show_local (priv->proxy))
1896
    {
1897
      ubuntu_menu_proxy_activate_menu (priv->proxy,
1898
                                       item);
1899
1900
      return TRUE;
1901
    }
1902
1903
  return FALSE;
1904
}
1905
1818
#define __GTK_MENU_SHELL_C__
1906
#define __GTK_MENU_SHELL_C__
1819
#include "gtkaliasdef.c"
1907
#include "gtkaliasdef.c"
(-)gtk+2.0-2.21.6.orig/gtk/tests/Makefile.am (+4 lines)
Lines 45-50 Link Here
45
recentmanager_SOURCES 		 = recentmanager.c
45
recentmanager_SOURCES 		 = recentmanager.c
46
recentmanager_LDADD   		 = $(progs_ldadd)
46
recentmanager_LDADD   		 = $(progs_ldadd)
47
47
48
TEST_PROGS                      += menuproxy
49
menuproxy_SOURCES                = menuproxy.c
50
menuproxy_LDADD                  = $(progs_ldadd)
51
48
TEST_PROGS			+= floating
52
TEST_PROGS			+= floating
49
floating_SOURCES		 = floating.c
53
floating_SOURCES		 = floating.c
50
floating_LDADD			 = $(progs_ldadd)
54
floating_LDADD			 = $(progs_ldadd)
(-)gtk+2.0-2.21.6/gtk/tests/menuproxy.c (+278 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2009 Canonical, Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 *
19
 * Authors: Cody Russell <bratsche@gnome.org>
20
 */
21
22
#undef GTK_DISABLE_DEPRECATED
23
#include "../gtk/gtk.h"
24
25
typedef struct _TestProxy      TestProxy;
26
typedef struct _TestProxyClass TestProxyClass;
27
28
//static GType           test_proxy_type_id      = 0;
29
//static TestProxyClass *test_proxy_parent_class = NULL;
30
31
#define TEST_TYPE_PROXY     (test_proxy_type_id)
32
#define TEST_PROXY(o)       (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_PROXY, TestProxy))
33
#define TEST_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_PROXY, TestProxyClass))
34
#define TEST_IS_PROXY(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_PROXY))
35
36
struct _TestProxy
37
{
38
  UbuntuMenuProxy parent_object;
39
};
40
41
struct _TestProxyClass
42
{
43
  UbuntuMenuProxyClass parent_class;
44
};
45
46
static void test_proxy_insert         (UbuntuMenuProxy *proxy,
47
                                       GtkWidget    *child,
48
                                       guint         position);
49
50
G_DEFINE_DYNAMIC_TYPE(TestProxy, test_proxy, UBUNTU_TYPE_MENU_PROXY)
51
52
static void
53
test_proxy_init (TestProxy *proxy)
54
{
55
}
56
57
static void
58
test_proxy_class_init (TestProxyClass *class)
59
{
60
  UbuntuMenuProxyClass *proxy_class = UBUNTU_MENU_PROXY_CLASS (class);
61
62
  test_proxy_parent_class = g_type_class_peek_parent (class);
63
64
  proxy_class->insert = test_proxy_insert;
65
}
66
67
static void
68
test_proxy_class_finalize (TestProxyClass *class)
69
{
70
}
71
72
static void
73
test_proxy_insert (UbuntuMenuProxy *proxy,
74
                   GtkWidget    *child,
75
                   guint         position)
76
{
77
}
78
79
/* ---------------------------------------------------- */
80
81
#define TEST_TYPE_MODULE         (test_module_get_type ())
82
#define TEST_MODULE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), TEST_TYPE_MODULE, TestModule))
83
#define TEST_MODULE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), TEST_TYPE_MODULE, TestModuleClass))
84
#define TEST_IS_MODULE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), TEST_TYPE_MODULE))
85
#define TEST_IS_MODULE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), TEST_TYPE_MODULE))
86
#define TEST_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), TEST_TYPE_MODULE, TestModuleClass))
87
88
89
typedef struct _TestModule      TestModule;
90
typedef struct _TestModuleClass TestModuleClass;
91
92
struct _TestModule
93
{
94
  GTypeModule  parent_instance;
95
};
96
97
struct _TestModuleClass
98
{
99
  GTypeModuleClass  parent_class;
100
};
101
102
static gboolean
103
test_module_load (GTypeModule *module)
104
{
105
  g_print ("registering type...\n");
106
  g_print ("     type_id = %d\n", test_proxy_type_id);
107
108
  test_proxy_register_type (G_TYPE_MODULE (module));
109
110
  //test_proxy_get_type (G_TYPE_MODULE (module));
111
112
  g_print ("     type_id = %d\n", test_proxy_type_id);
113
114
  return TRUE;
115
}
116
117
static void
118
test_module_unload (GTypeModule *module)
119
{
120
}
121
122
static void
123
test_module_class_init (TestModuleClass *class)
124
{
125
  GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
126
127
  type_module_class->load = test_module_load;
128
  type_module_class->unload = test_module_unload;
129
}
130
131
static void
132
test_module_init (TestModule *module)
133
{
134
}
135
136
G_DEFINE_TYPE (TestModule, test_module, G_TYPE_TYPE_MODULE);
137
138
TestModule *
139
test_module_new (void)
140
{
141
  TestModule *module = g_object_new (TEST_TYPE_MODULE,
142
                                     NULL);
143
144
  g_print ("test_module_new(): %p\n", module);
145
146
  return module;
147
}
148
149
150
/* ---------------------------------------------------- */
151
152
static void
153
non_null_proxy_test (void)
154
{
155
  UbuntuMenuProxyModule *module;
156
157
  /* prevent the module loader from finding a proxy module */
158
  g_unsetenv ("UBUNTU_MENUPROXY");
159
160
  module = ubuntu_menu_proxy_module_get ();
161
  test_proxy_register_type (G_TYPE_MODULE (module));
162
  //test_proxy_get_type (G_TYPE_MODULE (module));
163
164
  GtkWidget *widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
165
  g_object_ref_sink (widget);
166
167
  g_assert (GTK_IS_MENU_BAR (widget));
168
  //g_assert (GTK_MENU_SHELL (widget)->proxy != NULL);
169
170
  g_object_unref (widget);
171
}
172
173
static void
174
null_proxy_test (void)
175
{
176
  GtkWidget *widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
177
  g_object_ref_sink (widget);
178
179
  g_assert (GTK_IS_MENU_BAR (widget));
180
181
  //g_assert (GTK_MENU_SHELL (widget)->proxy == NULL);
182
183
  g_object_unref (widget);
184
}
185
186
static gboolean inserted_called = FALSE;
187
188
static void
189
inserted_cb (UbuntuMenuProxy *proxy,
190
             GtkWidget    *child,
191
             guint         position,
192
             gpointer      data)
193
{
194
  g_return_if_fail (UBUNTU_IS_MENU_PROXY (proxy));
195
  g_return_if_fail (GTK_IS_WIDGET (child));
196
  inserted_called = TRUE;
197
}
198
199
static void
200
menubar_signals_proxy_test (void)
201
{
202
  GtkWidget *widget   = NULL;
203
  GtkWidget *menuitem = NULL;
204
  UbuntuMenuProxy *proxy;
205
206
  //ubuntu_menu_proxy_register_type (test_proxy_get_type ());
207
208
  widget = g_object_new (GTK_TYPE_MENU_BAR, NULL);
209
  g_object_ref_sink (widget);
210
211
  g_assert (GTK_IS_MENU_BAR (widget));
212
  //g_assert (GTK_MENU_SHELL (widget)->proxy != NULL);
213
214
  /*
215
  proxy = GTK_MENU_SHELL (widget)->proxy;
216
217
  g_signal_connect (proxy,
218
                    "inserted", G_CALLBACK (inserted_cb),
219
                    NULL);
220
  */
221
222
  // insert menuitem
223
  menuitem = gtk_menu_item_new_with_label ("Test Item");
224
  gtk_menu_shell_append (GTK_MENU_SHELL (widget),
225
                         menuitem);
226
227
  g_assert (inserted_called == TRUE);
228
229
  g_object_unref (widget);
230
}
231
232
static void
233
proxy_type_exists_test (void)
234
{
235
#if 0
236
  UbuntuMenuProxyModule *module;
237
238
  g_unsetenv ("GTK_MENUPROXY");
239
240
  module = ubuntu_menu_proxy_module_get ();
241
  test_proxy_get_type (G_TYPE_MODULE (module));
242
#endif
243
244
  g_assert (ubuntu_menu_proxy_get_type () != 0);
245
}
246
247
static void
248
can_instantiate_test (void)
249
{
250
  TestModule *module = test_module_new ();
251
252
  g_type_module_use (G_TYPE_MODULE (module));
253
254
  UbuntuMenuProxy *proxy = ubuntu_menu_proxy_get ();
255
256
  g_assert (proxy != NULL);
257
258
  g_object_ref_sink (proxy);
259
260
  g_assert (TEST_IS_PROXY (proxy));
261
  g_assert (UBUNTU_IS_MENU_PROXY (proxy));
262
263
  g_object_unref (proxy);
264
}
265
266
int
267
main (int argc, char *argv[])
268
{
269
  gtk_test_init (&argc, &argv);
270
271
  g_test_add_func ("/proxy/null-proxy", null_proxy_test);
272
  g_test_add_func ("/proxy/type-exists", proxy_type_exists_test);
273
  g_test_add_func ("/proxy/can-instantiate", can_instantiate_test);
274
  g_test_add_func ("/proxy/non-null-proxy", non_null_proxy_test);
275
  g_test_add_func ("/proxy/menubar-signals-proxy", menubar_signals_proxy_test);
276
277
  return g_test_run();
278
}
(-)gtk+2.0-2.21.6/gtk/ubuntumenuproxy.c (+249 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2010 Canonical, Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 *
19
 * Authors: Cody Russell <bratsche@gnome.org>
20
 */
21
22
#include "config.h"
23
#include "gtkintl.h"
24
#include "gtkmarshalers.h"
25
#include "ubuntumenuproxy.h"
26
#include "ubuntumenuproxymodule.h"
27
#include "gtkmodules.h"
28
#include "gtkprivate.h"
29
#include "gtkalias.h"
30
31
enum {
32
  PROP_0,
33
  PROP_SHOW_LOCAL
34
};
35
36
enum {
37
  INSERTED,
38
  LOCAL_NOTIFY,
39
  ACTIVATE_MENU,
40
  LAST_SIGNAL
41
};
42
43
#define UBUNTU_MENU_PROXY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyPrivate))
44
45
typedef struct _UbuntuMenuProxyPrivate UbuntuMenuProxyPrivate;
46
47
struct _UbuntuMenuProxyPrivate
48
{
49
  gboolean show_local;
50
};
51
52
static guint               menu_proxy_signals[LAST_SIGNAL] = { 0 };
53
static GObjectClass       *parent_class = NULL;
54
static UbuntuMenuProxy    *proxy_singleton = NULL;
55
56
static void     ubuntu_menu_proxy_real_insert     (UbuntuMenuProxy *proxy,
57
                                                   GtkWidget    *parent,
58
                                                   GtkWidget    *child,
59
                                                   guint         position);
60
static gboolean ubuntu_menu_proxy_real_show_local (UbuntuMenuProxy *proxy);
61
62
63
64
/* --------------------------------------------------------- */
65
66
G_DEFINE_TYPE (UbuntuMenuProxy, ubuntu_menu_proxy, G_TYPE_OBJECT)
67
68
static GObject *
69
ubuntu_menu_proxy_constructor (GType                  type,
70
                               guint                  n_params,
71
                               GObjectConstructParam *params)
72
{
73
  GObject *object;
74
75
  if (proxy_singleton != NULL)
76
    {
77
      object = g_object_ref (proxy_singleton);
78
    }
79
  else
80
    {
81
      object = G_OBJECT_CLASS (ubuntu_menu_proxy_parent_class)->constructor (type,
82
                                                                             n_params,
83
                                                                             params);
84
85
      proxy_singleton = UBUNTU_MENU_PROXY (object);
86
      g_object_add_weak_pointer (object, (gpointer) &proxy_singleton);
87
    }
88
89
  return object;
90
}
91
92
static void
93
ubuntu_menu_proxy_init (UbuntuMenuProxy *proxy)
94
{
95
}
96
97
static void
98
ubuntu_menu_proxy_get_property (GObject    *object,
99
                                guint       prop_id,
100
                                GValue     *value,
101
                                GParamSpec *pspec)
102
{
103
  UbuntuMenuProxyPrivate *priv = UBUNTU_MENU_PROXY_GET_PRIVATE (object);
104
105
  switch (prop_id)
106
    {
107
    case PROP_SHOW_LOCAL:
108
      g_value_set_boolean (value, priv->show_local);
109
      break;
110
111
    default:
112
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
113
      break;
114
    }
115
}
116
117
static void
118
ubuntu_menu_proxy_set_property (GObject      *object,
119
                                guint         prop_id,
120
                                const GValue *value,
121
                                GParamSpec   *pspec)
122
{
123
  UbuntuMenuProxyPrivate *priv = UBUNTU_MENU_PROXY_GET_PRIVATE (object);
124
125
  switch (prop_id)
126
    {
127
    case PROP_SHOW_LOCAL:
128
      priv->show_local = g_value_get_boolean (value);
129
      g_signal_emit (object, menu_proxy_signals[LOCAL_NOTIFY], 0, priv->show_local);
130
      break;
131
132
    default:
133
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
134
      break;
135
    }
136
}
137
138
static void
139
ubuntu_menu_proxy_class_init (UbuntuMenuProxyClass *class)
140
{
141
  GObjectClass *object_class = G_OBJECT_CLASS (class);
142
143
  parent_class = g_type_class_peek_parent (class);
144
145
  object_class->get_property = ubuntu_menu_proxy_get_property;
146
  object_class->set_property = ubuntu_menu_proxy_set_property;
147
148
  g_object_class_install_property (object_class,
149
                                   PROP_SHOW_LOCAL,
150
                                   g_param_spec_boolean ("show-local",
151
                                                         P_("Show the local menu"),
152
                                                         P_("Whether the menu is displayed locally"),
153
                                                         FALSE,
154
                                                         GTK_PARAM_READWRITE));
155
156
  menu_proxy_signals[INSERTED] =
157
    g_signal_new (I_("inserted"),
158
                  G_TYPE_FROM_CLASS (class),
159
                  G_SIGNAL_RUN_LAST,
160
                  G_STRUCT_OFFSET (UbuntuMenuProxyClass, inserted),
161
                  NULL, NULL,
162
                  _gtk_marshal_VOID__OBJECT_UINT,
163
                  G_TYPE_NONE, 2,
164
                  GTK_TYPE_WIDGET, G_TYPE_UINT);
165
166
  menu_proxy_signals[LOCAL_NOTIFY] =
167
    g_signal_new (I_("local-notify"),
168
                  G_TYPE_FROM_CLASS (class),
169
                  G_SIGNAL_RUN_LAST,
170
                  NULL,
171
                  NULL, NULL,
172
                  _gtk_marshal_VOID__BOOLEAN,
173
                  G_TYPE_NONE, 1,
174
                  G_TYPE_BOOLEAN);
175
176
  menu_proxy_signals[ACTIVATE_MENU] =
177
    g_signal_new (I_("activate-menu"),
178
                  G_TYPE_FROM_CLASS (class),
179
                  G_SIGNAL_RUN_LAST,
180
                  NULL,
181
                  NULL, NULL,
182
                  _gtk_marshal_VOID__OBJECT,
183
                  G_TYPE_NONE, 1,
184
                  G_TYPE_OBJECT);
185
186
  class->insert = ubuntu_menu_proxy_real_insert;
187
  class->show_local = ubuntu_menu_proxy_real_show_local;
188
189
  object_class->constructor = ubuntu_menu_proxy_constructor;
190
191
  g_type_class_add_private (object_class, sizeof (UbuntuMenuProxyPrivate));
192
}
193
194
UbuntuMenuProxy *
195
ubuntu_menu_proxy_get (void)
196
{
197
  if (!proxy_singleton)
198
    {
199
      ubuntu_menu_proxy_module_get ();
200
    }
201
202
  return proxy_singleton;
203
}
204
205
static void
206
ubuntu_menu_proxy_real_insert (UbuntuMenuProxy *proxy,
207
                               GtkWidget    *parent,
208
                               GtkWidget    *child,
209
                               guint         position)
210
{
211
}
212
213
static gboolean
214
ubuntu_menu_proxy_real_show_local (UbuntuMenuProxy *proxy)
215
{
216
  return TRUE;
217
}
218
219
void
220
ubuntu_menu_proxy_insert (UbuntuMenuProxy *proxy,
221
                          GtkWidget    *parent,
222
                          GtkWidget    *child,
223
                          guint         position)
224
{
225
  g_return_if_fail (UBUNTU_IS_MENU_PROXY (proxy));
226
227
  UBUNTU_MENU_PROXY_GET_CLASS (proxy)->insert (proxy,
228
                                               parent,
229
                                               child,
230
                                               position);
231
}
232
233
gboolean
234
ubuntu_menu_proxy_show_local (UbuntuMenuProxy *proxy)
235
{
236
  g_return_val_if_fail (UBUNTU_IS_MENU_PROXY (proxy), TRUE);
237
238
  return UBUNTU_MENU_PROXY_GET_CLASS (proxy)->show_local (proxy);
239
}
240
241
void
242
ubuntu_menu_proxy_activate_menu (UbuntuMenuProxy *proxy,
243
                                 GtkWidget       *widget)
244
{
245
  g_signal_emit (proxy, menu_proxy_signals[ACTIVATE_MENU], 0, widget);
246
}
247
248
#define __UBUNTU_MENU_PROXY_C__
249
#include "gtkaliasdef.c"
(-)gtk+2.0-2.21.6/gtk/ubuntumenuproxy.h (+74 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2010 Canonical, Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 *
19
 * Authors: Cody Russell <bratsche@gnome.org>
20
 */
21
22
#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23
#error "Only <gtk/gtk.h> can be included directly."
24
#endif
25
26
#ifndef __UBUNTU_MENU_PROXY_H__
27
#define __UBUNTU_MENU_PROXY_H__
28
29
#include <gtk/gtkwidget.h>
30
#include <gtk/gtktypeutils.h>
31
32
G_BEGIN_DECLS
33
34
#define UBUNTU_TYPE_MENU_PROXY           (ubuntu_menu_proxy_get_type ())
35
#define UBUNTU_MENU_PROXY(o)             (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxy))
36
#define UBUNTU_MENU_PROXY_CLASS(k)       (G_TYPE_CHECK_CLASS_CAST ((k), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyClass))
37
#define UBUNTU_IS_MENU_PROXY(o)          (G_TYPE_CHECK_INSTANCE_TYPE ((o), UBUNTU_TYPE_MENU_PROXY))
38
#define UBUNTU_IS_MENU_PROXY_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), UBUNTU_TYPE_MENU_PROXY))
39
#define UBUNTU_MENU_PROXY_GET_CLASS(o)   (G_TYPE_INSTANCE_GET_CLASS ((o), UBUNTU_TYPE_MENU_PROXY, UbuntuMenuProxyClass))
40
41
42
typedef struct _UbuntuMenuProxy      UbuntuMenuProxy;
43
typedef struct _UbuntuMenuProxyClass UbuntuMenuProxyClass;
44
45
struct _UbuntuMenuProxy
46
{
47
  GObject parent_object;
48
};
49
50
struct _UbuntuMenuProxyClass
51
{
52
  GObjectClass parent_class;
53
54
  /* vtable */
55
  void     (* insert)     (UbuntuMenuProxy *proxy, GtkWidget *parent, GtkWidget *child, guint position);
56
  gboolean (* show_local) (UbuntuMenuProxy *proxy);
57
58
  /* signals */
59
  void (* inserted)  (UbuntuMenuProxy *proxy, GtkWidget *child);
60
};
61
62
GType              ubuntu_menu_proxy_get_type      (void) G_GNUC_CONST;
63
UbuntuMenuProxy*   ubuntu_menu_proxy_get           (void);
64
void               ubuntu_menu_proxy_insert        (UbuntuMenuProxy *proxy,
65
                                                    GtkWidget       *parent,
66
                                                    GtkWidget       *child,
67
                                                    guint            position);
68
gboolean           ubuntu_menu_proxy_show_local    (UbuntuMenuProxy *proxy);
69
void               ubuntu_menu_proxy_activate_menu (UbuntuMenuProxy *proxy,
70
                                                    GtkWidget       *widget);
71
72
G_END_DECLS
73
74
#endif /* __UBUNTU_MENU_PROXY_H__ */
(-)gtk+2.0-2.21.6/gtk/ubuntumenuproxymodule.c (+212 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2010 Canonical, Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 *
19
 * Authors: Cody Russell <bratsche@gnome.org>
20
 */
21
22
#include "config.h"
23
#include "gtkintl.h"
24
#include "ubuntumenuproxy.h"
25
#include "ubuntumenuproxymodule.h"
26
#include "gtkmodules.h"
27
#include "gtkalias.h"
28
29
enum {
30
  PROP_0,
31
  PROP_MODULENAME
32
};
33
34
static GObject  *ubuntu_menu_proxy_module_constructor   (GType                  type,
35
                                                         guint                  n_params,
36
                                                         GObjectConstructParam *params);
37
static void      ubuntu_menu_proxy_module_finalize      (GObject               *object);
38
static gboolean  ubuntu_menu_proxy_module_real_load     (GTypeModule           *gmodule);
39
static void      ubuntu_menu_proxy_module_real_unload   (GTypeModule           *gmodule);
40
41
42
G_DEFINE_TYPE (UbuntuMenuProxyModule, ubuntu_menu_proxy_module, G_TYPE_TYPE_MODULE);
43
44
static UbuntuMenuProxyModule *proxy_module_singleton = NULL;
45
46
static void
47
ubuntu_menu_proxy_module_class_init (UbuntuMenuProxyModuleClass *class)
48
{
49
  GObjectClass     *object_class      = G_OBJECT_CLASS (class);
50
  GTypeModuleClass *type_module_class = G_TYPE_MODULE_CLASS (class);
51
52
  object_class->finalize     = ubuntu_menu_proxy_module_finalize;
53
54
  type_module_class->load    = ubuntu_menu_proxy_module_real_load;
55
  type_module_class->unload  = ubuntu_menu_proxy_module_real_unload;
56
}
57
58
static void
59
ubuntu_menu_proxy_module_init (UbuntuMenuProxyModule *module)
60
{
61
  module->name     = g_strdup (g_getenv ("UBUNTU_MENUPROXY"));
62
  module->library  = NULL;
63
  module->load     = NULL;
64
  module->unload   = NULL;
65
}
66
67
static void
68
ubuntu_menu_proxy_module_finalize (GObject *object)
69
{
70
  UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (object);
71
72
  if (module->name != NULL)
73
    {
74
      g_free (module->name);
75
    }
76
77
  G_OBJECT_CLASS (ubuntu_menu_proxy_module_parent_class)->finalize (object);
78
}
79
80
static gboolean
81
ubuntu_menu_proxy_module_real_load (GTypeModule *gmodule)
82
{
83
  UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (gmodule);
84
  gchar *path;
85
86
  if (proxy_module_singleton != NULL)
87
    return TRUE;
88
89
  if (!module->name)
90
    {
91
      g_warning ("Module path not set");
92
      return FALSE;
93
    }
94
95
  path = _gtk_find_module (module->name, "menuproxies");
96
97
  module->library = g_module_open (path, 0);
98
99
  if (!module->library)
100
    {
101
      g_printerr ("%s\n", g_module_error ());
102
      return FALSE;
103
    }
104
105
  /* Make sure that the loaded library contains the required methods */
106
  if (!g_module_symbol (module->library,
107
                        "menu_proxy_module_load",
108
                        (gpointer *) &module->load) ||
109
      !g_module_symbol (module->library,
110
                        "menu_proxy_module_unload",
111
                        (gpointer *) &module->unload))
112
    {
113
      g_printerr ("%s\n", g_module_error ());
114
      g_module_close (module->library);
115
116
      return FALSE;
117
    }
118
119
  /* Initialize the loaded module */
120
  module->load (module);
121
122
  return TRUE;
123
}
124
125
static void
126
ubuntu_menu_proxy_module_real_unload (GTypeModule *gmodule)
127
{
128
  UbuntuMenuProxyModule *module = UBUNTU_MENU_PROXY_MODULE (gmodule);
129
130
  module->unload (module);
131
132
  g_module_close (module->library);
133
  module->library = NULL;
134
135
  module->load   = NULL;
136
  module->unload = NULL;
137
}
138
139
static gboolean
140
is_valid_module_name (const gchar *name)
141
{
142
#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN)
143
  return g_str_has_prefix (name, "lib") && g_str_has_suffix (name, ".so");
144
#else
145
  return g_str_has_suffix (name, ".dll");
146
#endif
147
}
148
149
static void
150
setup_instance (UbuntuMenuProxyModule *module)
151
{
152
  GType *proxy_types;
153
  guint  n_proxies;
154
155
  proxy_types = g_type_children (UBUNTU_TYPE_MENU_PROXY,
156
                                 &n_proxies);
157
158
  if (n_proxies > 1)
159
    {
160
      g_warning ("There are %d child types of UbuntuMenuProxy, should be 0 or 1.\n",
161
                 n_proxies);
162
    }
163
  else if (n_proxies == 1)
164
    {
165
      g_object_new (proxy_types[0], NULL);
166
    }
167
}
168
169
UbuntuMenuProxyModule *
170
ubuntu_menu_proxy_module_get (void)
171
{
172
  if (!proxy_module_singleton)
173
    {
174
      UbuntuMenuProxyModule *module = NULL;
175
      const gchar *module_name;
176
177
      module_name = g_getenv ("UBUNTU_MENUPROXY");
178
179
      if (module_name != NULL)
180
        {
181
          if (is_valid_module_name (module_name))
182
            {
183
              gchar *path = _gtk_find_module (module_name, "menuproxies");
184
185
              module = g_object_new (UBUNTU_TYPE_MENU_PROXY_MODULE,
186
                                     NULL);
187
188
              if (!g_type_module_use (G_TYPE_MODULE (module)))
189
                {
190
                  g_warning ("Failed to load type module: %s\n", path);
191
192
                  g_object_unref (module);
193
                  g_free (path);
194
195
                  return NULL;
196
                }
197
198
              setup_instance (module);
199
200
              g_free (path);
201
              g_type_module_unuse (G_TYPE_MODULE (module));
202
            }
203
204
          proxy_module_singleton = module;
205
        }
206
    }
207
208
  return proxy_module_singleton;
209
}
210
211
#define __UBUNTU_MENU_PROXY_MODULE_C__
212
#include "gtkaliasdef.c"
(-)gtk+2.0-2.21.6/gtk/ubuntumenuproxymodule.h (+69 lines)
Added Link Here
1
/*
2
 * Copyright (C) 2010 Canonical, Ltd.
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 *
19
 * Authors: Cody Russell <bratsche@gnome.org>
20
 */
21
22
#if defined(GTK_DISABLE_SINGLE_INCLUDES) && !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
23
#error "Only <gtk/gtk.h> can be included directly."
24
#endif
25
26
#ifndef __UBUNTU_MENU_PROXY_MODULE_H__
27
#define __UBUNTU_MENU_PROXY_MODULE_H__
28
29
#include <glib-object.h>
30
#include <gmodule.h>
31
32
G_BEGIN_DECLS
33
34
#define UBUNTU_TYPE_MENU_PROXY_MODULE         (ubuntu_menu_proxy_module_get_type ())
35
#define UBUNTU_MENU_PROXY_MODULE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModule))
36
#define UBUNTU_MENU_PROXY_MODULE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST ((k), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModuleClass))
37
#define UBUNTU_IS_MENU_MODULE_PROXY(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), UBUNTU_TYPE_MENU_PROXY_MODULE))
38
#define UBUNTU_IS_MENU_PROXY_MODULE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), UBUNTU_TYPE_MENU_PROXY_MODULE))
39
#define UBUNTU_MENU_PROXY_MODULE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), UBUNTU_TYPE_MENU_PROXY_MODULE, UbuntuMenuProxyModuleClass))
40
41
typedef struct _UbuntuMenuProxyModule        UbuntuMenuProxyModule;
42
typedef struct _UbuntuMenuProxyModuleClass   UbuntuMenuProxyModuleClass;
43
typedef struct _UbuntuMenuProxyModulePrivate UbuntuMenuProxyModulePrivate;
44
45
struct _UbuntuMenuProxyModule
46
{
47
  GTypeModule parent_instance;
48
49
  UbuntuMenuProxyModulePrivate *priv;
50
51
  GModule *library;
52
  gchar   *name;
53
54
  void        (* load)     (UbuntuMenuProxyModule *module);
55
  void        (* unload)   (UbuntuMenuProxyModule *module);
56
};
57
58
struct _UbuntuMenuProxyModuleClass
59
{
60
  GTypeModuleClass parent_class;
61
};
62
63
GType                  ubuntu_menu_proxy_module_get_type (void) G_GNUC_CONST;
64
65
UbuntuMenuProxyModule *ubuntu_menu_proxy_module_get      (void);
66
67
G_END_DECLS
68
69
#endif /* __UBUNTU_MENU_PROXY_MODULE_H__ */
(-)gtk+2.0-2.21.6.orig/gtk/gtkwindow.c (-1 / +18 lines)
Lines 94-100 Link Here
94
  PROP_GRAVITY,
94
  PROP_GRAVITY,
95
  PROP_TRANSIENT_FOR,
95
  PROP_TRANSIENT_FOR,
96
  PROP_OPACITY,
96
  PROP_OPACITY,
97
  
97
  PROP_NO_PROXY,
98
98
  /* Readonly properties */
99
  /* Readonly properties */
99
  PROP_IS_ACTIVE,
100
  PROP_IS_ACTIVE,
100
  PROP_HAS_TOPLEVEL_FOCUS,
101
  PROP_HAS_TOPLEVEL_FOCUS,
Lines 195-200 Link Here
195
196
196
  gdouble opacity;
197
  gdouble opacity;
197
198
199
  gboolean no_proxy;
200
198
  gchar *startup_id;
201
  gchar *startup_id;
199
};
202
};
200
203
Lines 502-507 Link Here
502
							NULL,
505
							NULL,
503
							GTK_PARAM_READWRITE));
506
							GTK_PARAM_READWRITE));
504
507
508
  g_object_class_install_property (object_class,
509
                                   PROP_NO_PROXY,
510
                                   g_param_spec_boolean ("ubuntu-no-proxy",
511
                                                         P_("Disable menu proxies for this window"),
512
                                                         P_("Disable menu proxies for this window"),
513
                                                         FALSE,
514
                                                         GTK_PARAM_READWRITE));
515
505
  /**
516
  /**
506
   * GtkWindow:startup-id:
517
   * GtkWindow:startup-id:
507
   *
518
   *
Lines 1084-1089 Link Here
1084
    case PROP_MNEMONICS_VISIBLE:
1095
    case PROP_MNEMONICS_VISIBLE:
1085
      gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
1096
      gtk_window_set_mnemonics_visible (window, g_value_get_boolean (value));
1086
      break;
1097
      break;
1098
    case PROP_NO_PROXY:
1099
      priv->no_proxy = g_value_get_boolean (value);
1100
      break;
1087
    default:
1101
    default:
1088
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1102
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1089
      break;
1103
      break;
Lines 1202-1207 Link Here
1202
    case PROP_MNEMONICS_VISIBLE:
1216
    case PROP_MNEMONICS_VISIBLE:
1203
      g_value_set_boolean (value, priv->mnemonics_visible);
1217
      g_value_set_boolean (value, priv->mnemonics_visible);
1204
      break;
1218
      break;
1219
    case PROP_NO_PROXY:
1220
      g_value_set_boolean (value, priv->no_proxy);
1221
      break;
1205
    default:
1222
    default:
1206
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1223
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1207
      break;
1224
      break;
(-)gtk+2.0-2.21.6.orig/gtk/gtkmenuitem.c (-1 / +11 lines)
Lines 1395-1401 Link Here
1395
				  widget);
1395
				  widget);
1396
    }
1396
    }
1397
  else
1397
  else
1398
    g_signal_emit (widget, menu_item_signals[ACTIVATE_ITEM], 0);
1398
    {
1399
      if (GTK_IS_MENU_BAR (widget->parent) &&
1400
          ubuntu_gtk_menu_shell_activate_mnemonic (GTK_MENU_SHELL (widget->parent), widget))
1401
        {
1402
          //g_print ("send activate to remote!\n");
1403
        }
1404
      else
1405
        {
1406
          g_signal_emit (widget, menu_item_signals[ACTIVATE_ITEM], 0);
1407
        }
1408
    }
1399
  
1409
  
1400
  return TRUE;
1410
  return TRUE;
1401
}
1411
}

Return to bug 341757