~ubuntu-branches/ubuntu/utopic/gtk+2.0/utopic

« back to all changes in this revision

Viewing changes to .pc/062_dnd_menubar.patch/gtk/gtkmenushell.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-06-07 17:15:49 UTC
  • Revision ID: package-import@ubuntu.com-20130607171549-mxb2rt9jscf01sfb
Tags: 2.24.18-0ubuntu2
* debian/patches/043_ubuntu_menu_proxy.patch,
  debian/patches/072_indicator_menu_update.patch,
  debian/libgtk2.0-0.symbols:
  - drop old menu patches, we deprecate appmenu-gtk in favor of the new
    unity-gtk-module code
* debian/patches/gtk-shell-shows-menubar.patch:
  -list gtk-shell-shows-menubar setting, that's required to have 
   the local menubars hidding under unity in favor of the unity ones, 
   thanks William Hua for the work on those changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include "gtkmenubar.h"
38
38
#include "gtkmenuitem.h"
39
39
#include "gtkmenushell.h"
40
 
#include "ubuntumenuproxy.h"
41
40
#include "gtkmnemonichash.h"
42
41
#include "gtktearoffmenuitem.h"
43
42
#include "gtkwindow.h"
66
65
 
67
66
enum {
68
67
  PROP_0,
69
 
  PROP_TAKE_FOCUS,
70
 
  PROP_LOCAL
 
68
  PROP_TAKE_FOCUS
71
69
};
72
70
 
73
71
/* Terminology:
138
136
  GtkMnemonicHash *mnemonic_hash;
139
137
  GtkKeyHash *key_hash;
140
138
 
141
 
  UbuntuMenuProxy *proxy;
142
 
  gboolean         local;
143
 
 
144
139
  guint take_focus : 1;
145
140
  guint activated_submenu : 1;
146
141
  /* This flag is a crutch to keep mnemonics in the same menu
411
406
                                                         TRUE,
412
407
                                                         GTK_PARAM_READWRITE));
413
408
 
414
 
  g_object_class_install_property (object_class,
415
 
                                   PROP_LOCAL,
416
 
                                   g_param_spec_boolean ("ubuntu-local",
417
 
                                                         P_("Local menu"),
418
 
                                                         P_("Determines whether the menu is local"),
419
 
                                                         FALSE,
420
 
                                                         GTK_PARAM_READWRITE));
421
 
 
422
409
  g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
423
410
}
424
411
 
429
416
}
430
417
 
431
418
static void
432
 
show_local_notify (UbuntuMenuProxy *proxy,
433
 
                   GParamSpec      *pspec,
434
 
                   GtkMenuShell    *shell)
435
 
{
436
 
  g_object_notify (shell, "ubuntu-local");
437
 
}
438
 
 
439
 
static void
440
419
gtk_menu_shell_init (GtkMenuShell *menu_shell)
441
420
{
442
421
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
454
433
  priv->key_hash = NULL;
455
434
  priv->take_focus = TRUE;
456
435
  priv->activated_submenu = FALSE;
457
 
  priv->proxy = ubuntu_menu_proxy_get ();
458
 
  priv->local = FALSE;
459
 
 
460
 
  if (priv->proxy != NULL)
461
 
    g_signal_connect (priv->proxy, "notify::show-local",
462
 
                      G_CALLBACK (show_local_notify),
463
 
                      menu_shell);
464
436
}
465
437
 
466
438
static void
470
442
                             GParamSpec   *pspec)
471
443
{
472
444
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
473
 
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (object);
474
445
 
475
446
  switch (prop_id)
476
447
    {
477
448
    case PROP_TAKE_FOCUS:
478
449
      gtk_menu_shell_set_take_focus (menu_shell, g_value_get_boolean (value));
479
450
      break;
480
 
    case PROP_LOCAL:
481
 
      priv->local = g_value_get_boolean (value);
482
 
      break;
483
451
    default:
484
452
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
485
453
      break;
493
461
                             GParamSpec  *pspec)
494
462
{
495
463
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
496
 
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
497
 
  gboolean local;
498
464
 
499
465
  switch (prop_id)
500
466
    {
501
467
    case PROP_TAKE_FOCUS:
502
468
      g_value_set_boolean (value, gtk_menu_shell_get_take_focus (menu_shell));
503
469
      break;
504
 
    case PROP_LOCAL:
505
 
      if (priv->proxy == NULL || ubuntu_menu_proxy_show_local (priv->proxy)) {
506
 
        local = TRUE;
507
 
      } else {
508
 
        local = priv->local;
509
 
      }
510
 
 
511
 
      g_value_set_boolean (value, local);
512
 
      break;
513
470
    default:
514
471
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
515
472
      break;
522
479
  GtkMenuShell *menu_shell = GTK_MENU_SHELL (object);
523
480
  GtkMenuShellPrivate *priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
524
481
 
525
 
  if (priv->proxy != NULL)
526
 
    {
527
 
      g_signal_handlers_disconnect_by_func (priv->proxy,
528
 
                                            show_local_notify,
529
 
                                            menu_shell);
530
 
    }
531
 
 
532
482
  if (priv->mnemonic_hash)
533
483
    _gtk_mnemonic_hash_free (priv->mnemonic_hash);
534
484
  if (priv->key_hash)
557
507
                       GtkWidget    *child,
558
508
                       gint          position)
559
509
{
560
 
  GtkMenuShellPrivate *priv;
561
 
 
562
510
  g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
563
511
  g_return_if_fail (GTK_IS_MENU_ITEM (child));
564
512
 
565
 
  priv = GTK_MENU_SHELL_GET_PRIVATE (menu_shell);
566
 
 
567
513
  g_signal_emit (menu_shell, menu_shell_signals[INSERT], 0, child, position);
568
 
 
569
 
  /* insert to proxy */
570
 
  if (priv->proxy != NULL)
571
 
    ubuntu_menu_proxy_insert (priv->proxy,
572
 
                              GTK_WIDGET (menu_shell),
573
 
                              child,
574
 
                              position);
575
514
}
576
515
 
577
516
static void
1896
1835
    }
1897
1836
}
1898
1837
 
1899
 
gboolean
1900
 
ubuntu_gtk_menu_shell_activate_mnemonic (GtkMenuShell *shell, GtkWidget *item)
1901
 
{
1902
 
  GtkMenuShellPrivate *priv;
1903
 
 
1904
 
  g_return_val_if_fail (GTK_IS_MENU_SHELL (shell), FALSE);
1905
 
 
1906
 
  priv = GTK_MENU_SHELL_GET_PRIVATE (shell);
1907
 
 
1908
 
  if (priv->proxy && !ubuntu_menu_proxy_show_local (priv->proxy))
1909
 
    {
1910
 
      ubuntu_menu_proxy_activate_menu (priv->proxy,
1911
 
                                       item);
1912
 
 
1913
 
      return TRUE;
1914
 
    }
1915
 
 
1916
 
  return FALSE;
1917
 
}
1918
 
 
1919
 
gboolean
1920
 
ubuntu_gtk_menu_shell_activate_first (GtkMenuShell *menu_shell,
1921
 
                                      gboolean      search_sensitive)
1922
 
{
1923
 
  GtkWidget *to_select = NULL;
1924
 
  GList *tmp_list;
1925
 
 
1926
 
  tmp_list = menu_shell->children;
1927
 
  while (tmp_list)
1928
 
    {
1929
 
      GtkWidget *child = tmp_list->data;
1930
 
      
1931
 
      if ((!search_sensitive && gtk_widget_get_visible (child)) ||
1932
 
          _gtk_menu_item_is_selectable (child))
1933
 
        {
1934
 
          to_select = child;
1935
 
          if (!GTK_IS_TEAROFF_MENU_ITEM (child))
1936
 
            break;
1937
 
        }
1938
 
      
1939
 
      tmp_list = tmp_list->next;
1940
 
    }
1941
 
 
1942
 
  return to_select &&
1943
 
         ubuntu_gtk_menu_shell_activate_mnemonic(menu_shell, to_select);
1944
 
}
1945
 
 
1946
1838
#define __GTK_MENU_SHELL_C__
1947
1839
#include "gtkaliasdef.c"