]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkmenushell.c
Don't use *DISABLE_DEPRECATED guards
[~andy/gtk] / gtk / gtkmenushell.c
index 172b5766c01d5500f5401153040f8e47cb557fdc..0e613b20102995ddd271cf516e04b949d93d252a 100644 (file)
 #include "gtkbindings.h"
 #include "gtkkeyhash.h"
 #include "gtklabel.h"
-#include "gtkmainprivate.h"
 #include "gtkmarshalers.h"
 #include "gtkmenubar.h"
 #include "gtkmenuitemprivate.h"
 #include "gtkmenushellprivate.h"
 #include "gtkmenuprivate.h"
 #include "gtkmnemonichash.h"
-#include "gtktearoffmenuitem.h"
 #include "gtkwindow.h"
 #include "gtkprivate.h"
 #include "gtkintl.h"
 #include "gtktypebuiltins.h"
 
+#include "gtktearoffmenuitem.h"
+
+#include "a11y/gtkmenushellaccessible.h"
+
+
 #define MENU_SHELL_TIMEOUT   500
 
 #define PACK_DIRECTION(m)                                 \
@@ -70,6 +73,7 @@ enum {
   CANCEL,
   CYCLE_FOCUS,
   MOVE_SELECTED,
+  INSERT,
   LAST_SIGNAL
 };
 
@@ -367,6 +371,31 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
                   G_TYPE_BOOLEAN, 1,
                   G_TYPE_INT);
 
+  /**
+   * GtkMenuShell::insert:
+   * @menu_shell: the object on which the signal is emitted
+   * @child: the #GtkMenuItem that is being inserted
+   * @position: the position at which the insert occurs
+   *
+   * The ::insert signal is emitted when a new #GtkMenuItem is added to
+   * a #GtkMenuShell.  A separate signal is used instead of
+   * GtkContainer::add because of the need for an additional position
+   * parameter.
+   *
+   * The inverse of this signal is the GtkContainer::removed signal.
+   *
+   * Since: 3.2
+   **/
+  menu_shell_signals[INSERT] =
+    g_signal_new (I_("insert"),
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GtkMenuShellClass, insert),
+                  NULL, NULL,
+                  _gtk_marshal_VOID__OBJECT_INT,
+                  G_TYPE_NONE, 2, GTK_TYPE_WIDGET, G_TYPE_INT);
+
+
   binding_set = gtk_binding_set_by_class (klass);
   gtk_binding_entry_add_signal (binding_set,
                                 GDK_KEY_Escape, 0,
@@ -422,6 +451,8 @@ gtk_menu_shell_class_init (GtkMenuShellClass *klass)
                                                          TRUE,
                                                          GTK_PARAM_READWRITE));
 
+  gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_MENU_SHELL_ACCESSIBLE);
+
   g_type_class_add_private (object_class, sizeof (GtkMenuShellPrivate));
 }
 
@@ -549,15 +580,10 @@ gtk_menu_shell_insert (GtkMenuShell *menu_shell,
                        GtkWidget    *child,
                        gint          position)
 {
-  GtkMenuShellClass *class;
-
   g_return_if_fail (GTK_IS_MENU_SHELL (menu_shell));
   g_return_if_fail (GTK_IS_MENU_ITEM (child));
 
-  class = GTK_MENU_SHELL_GET_CLASS (menu_shell);
-
-  if (class->insert)
-    class->insert (menu_shell, child, position);
+  g_signal_emit (menu_shell, menu_shell_signals[INSERT], 0, child, position);
 }
 
 static void
@@ -628,8 +654,8 @@ gtk_menu_shell_realize (GtkWidget *widget)
   gtk_style_context_set_background (context, window);
 }
 
-void
-_gtk_menu_shell_activate (GtkMenuShell *menu_shell)
+static void
+gtk_menu_shell_activate (GtkMenuShell *menu_shell)
 {
   GtkMenuShellPrivate *priv = menu_shell->priv;
 
@@ -697,7 +723,7 @@ gtk_menu_shell_button_press (GtkWidget      *widget,
               gtk_widget_get_parent (menu_item) == widget &&
               menu_item != priv->active_menu_item)
             {
-              _gtk_menu_shell_activate (menu_shell);
+              gtk_menu_shell_activate (menu_shell);
               priv->button = event->button;
 
               if (GTK_MENU_SHELL_GET_CLASS (menu_shell)->submenu_placement == GTK_TOP_BOTTOM)
@@ -1190,7 +1216,6 @@ gtk_real_menu_shell_deactivate (GtkMenuShell *menu_shell)
 
   if (priv->active)
     {
-
       priv->button = 0;
       priv->active = FALSE;
       priv->activate_time = 0;
@@ -1313,6 +1338,8 @@ gtk_menu_shell_real_select_item (GtkMenuShell *menu_shell,
       return;
     }
 
+  gtk_menu_shell_activate (menu_shell);
+
   priv->active_menu_item = menu_item;
   if (pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT)
     _gtk_menu_item_set_placement (GTK_MENU_ITEM (priv->active_menu_item),
@@ -1859,8 +1886,11 @@ gtk_menu_shell_activate_mnemonic (GtkMenuShell *menu_shell,
                                   event->group);
 
   if (entries)
-    result = _gtk_mnemonic_hash_activate (mnemonic_hash,
-                                          GPOINTER_TO_UINT (entries->data));
+    {
+      result = _gtk_mnemonic_hash_activate (mnemonic_hash,
+                                            GPOINTER_TO_UINT (entries->data));
+      g_slist_free (entries);
+    }
 
   return result;
 }
@@ -1990,7 +2020,7 @@ gtk_menu_shell_set_take_focus (GtkMenuShell *menu_shell,
  *
  * Gets the currently selected item.
  *
- * Returns: the currently selected item
+ * Returns: (transfer none): the currently selected item
  *
  * Since: 3.0
  */
@@ -2011,7 +2041,7 @@ gtk_menu_shell_get_selected_item (GtkMenuShell *menu_shell)
  * The parent menu shell of a submenu is the #GtkMenu or #GtkMenuBar
  * from which it was opened up.
  *
- * Returns: the parent #GtkMenuShell
+ * Returns: (transfer none): the parent #GtkMenuShell
  *
  * Since: 3.0
  */