[gnome-shell] St: add a popup-menu signal to StWidget



commit fe16f2b058855b8e097db14c57dccab6b789902a
Author: Dan Winship <danw gnome org>
Date:   Wed Jan 26 14:45:38 2011 -0500

    St: add a popup-menu signal to StWidget
    
    Add a popup-menu signal to StWidget, and emit it if the user types the
    Menu key or Shift+F10 while the widget is focused.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=618887

 src/st/st-button.c |    2 +-
 src/st/st-entry.c  |    2 +-
 src/st/st-widget.c |   34 ++++++++++++++++++++++++++++++++++
 src/st/st-widget.h |   14 ++++++++------
 4 files changed, 44 insertions(+), 8 deletions(-)
---
diff --git a/src/st/st-button.c b/src/st/st-button.c
index c3eca61..5684267 100644
--- a/src/st/st-button.c
+++ b/src/st/st-button.c
@@ -218,7 +218,7 @@ st_button_key_press (ClutterActor    *actor,
         }
     }
 
-  return FALSE;
+  return CLUTTER_ACTOR_CLASS (st_button_parent_class)->key_press_event (actor, event);
 }
 
 static gboolean
diff --git a/src/st/st-entry.c b/src/st/st-entry.c
index c963c98..ef25ab3 100644
--- a/src/st/st-entry.c
+++ b/src/st/st-entry.c
@@ -586,7 +586,7 @@ st_entry_key_press_event (ClutterActor    *actor,
       return TRUE;
     }
 
-  return FALSE;
+  return CLUTTER_ACTOR_CLASS (st_entry_parent_class)->key_press_event (actor, event);
 }
 
 static void
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index 02148ba..45b3f8d 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -103,6 +103,7 @@ enum
 enum
 {
   STYLE_CHANGED,
+  POPUP_MENU,
 
   LAST_SIGNAL
 };
@@ -689,6 +690,21 @@ st_widget_key_focus_out (ClutterActor *actor)
   st_widget_remove_style_pseudo_class (widget, "focus");
 }
 
+static gboolean
+st_widget_key_press_event (ClutterActor    *actor,
+                           ClutterKeyEvent *event)
+{
+  if (event->keyval == CLUTTER_KEY_Menu ||
+      (event->keyval == CLUTTER_KEY_F10 &&
+       (event->modifier_state & CLUTTER_SHIFT_MASK)))
+    {
+      g_signal_emit (actor, signals[POPUP_MENU], 0);
+      return TRUE;
+    }
+
+  return FALSE;
+}
+
 static void
 st_widget_hide (ClutterActor *actor)
 {
@@ -763,6 +779,7 @@ st_widget_class_init (StWidgetClass *klass)
   actor_class->leave_event = st_widget_leave;
   actor_class->key_focus_in = st_widget_key_focus_in;
   actor_class->key_focus_out = st_widget_key_focus_out;
+  actor_class->key_press_event = st_widget_key_press_event;
   actor_class->hide = st_widget_hide;
 
   actor_class->get_accessible = st_widget_get_accessible;
@@ -918,6 +935,7 @@ st_widget_class_init (StWidgetClass *klass)
 
   /**
    * StWidget::style-changed:
+   * @widget: the #StWidget
    *
    * Emitted when the style information that the widget derives from the
    * theme changes
@@ -930,6 +948,22 @@ st_widget_class_init (StWidgetClass *klass)
                   NULL, NULL,
                   _st_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
+
+  /**
+   * StWidget::popup-menu:
+   * @widget: the #StWidget
+   *
+   * Emitted when the user has requested a context menu (eg, via a
+   * keybinding)
+   */
+  signals[POPUP_MENU] =
+    g_signal_new ("popup-menu",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (StWidgetClass, popup_menu),
+                  NULL, NULL,
+                  _st_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
 }
 
 /**
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index 8945436..81c9928 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -77,13 +77,15 @@ struct _StWidgetClass
   /*< private >*/
   ClutterActorClass parent_class;
 
-  /* vfuncs */
-  void     (* style_changed)   (StWidget         *self);
-  gboolean (* navigate_focus)  (StWidget         *self,
-                                ClutterActor     *from,
-                                GtkDirectionType  direction);
+  /* signals */
+  void     (* style_changed)       (StWidget         *self);
+  void     (* popup_menu)          (StWidget         *self);
 
-  GType    (*get_accessible_type)   (void);
+  /* vfuncs */
+  gboolean (* navigate_focus)      (StWidget         *self,
+                                    ClutterActor     *from,
+                                    GtkDirectionType  direction);
+  GType    (* get_accessible_type) (void);
 };
 
 GType st_widget_get_type (void) G_GNUC_CONST;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]