[gtk] Add owner types for widget actions



commit 412006ad234dabeda560e70687c2a6020830fe02
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 22 09:35:57 2019 -0400

    Add owner types for widget actions
    
    This lets us filter out actions from parent classes
    when introspecting.

 gtk/gtkactionmuxerprivate.h | 1 +
 gtk/gtkwidget.c             | 8 ++++++++
 gtk/gtkwidget.h             | 1 +
 3 files changed, 10 insertions(+)
---
diff --git a/gtk/gtkactionmuxerprivate.h b/gtk/gtkactionmuxerprivate.h
index 5a1218d84a..b1b8cef9cc 100644
--- a/gtk/gtkactionmuxerprivate.h
+++ b/gtk/gtkactionmuxerprivate.h
@@ -34,6 +34,7 @@ G_BEGIN_DECLS
 typedef struct {
   char *name;
 
+  GType owner;
   GVariantType *parameter_type;
   GVariantType *state_type;
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index c96909a5e0..de0ed764dc 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -13503,6 +13503,7 @@ gtk_widget_class_install_stateful_action (GtkWidgetClass              *widget_cl
     }
 
   action = g_new0 (GtkWidgetAction, 1);
+  action->owner = G_TYPE_FROM_CLASS (widget_class);
   action->name = g_strdup (action_name);
   action->activate = activate;
   action->parameter_type = parameter_type ? g_variant_type_new (parameter_type) : NULL;
@@ -13568,6 +13569,7 @@ gtk_widget_action_state_changed (GtkWidget  *widget,
  * gtk_widget_class_query_action:
  * @widget_class: a #GtkWidgetClass
  * @index_: position of the action to query
+ * @owner: the type where the action was defined
  * @action_name: return location for the action name
  * @parameter_type: return location for the parameter type
  * @state_type: return location for the state type
@@ -13576,12 +13578,17 @@ gtk_widget_action_state_changed (GtkWidget  *widget,
  * a widget class using gtk_widget_class_install_action()
  * during class initialization.
  *
+ * Note that this function will also return actions defined
+ * by parent classes. You can identify those by looking
+ * at @owner.
+ *
  * Returns: %TRUE if the action was found,
  *     %FALSE if @index_ is out of range
  */
 gboolean
 gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
                                guint                index_,
+                               GType               *owner,
                                const char         **action_name,
                                const GVariantType **parameter_type,
                                const GVariantType **state_type)
@@ -13592,6 +13599,7 @@ gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
     {
       GtkWidgetAction *action = g_ptr_array_index (priv->actions, index_);
 
+      *owner = action->owner;
       *action_name = action->name;
       *parameter_type = action->parameter_type;
       *state_type = action->state_type;
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 31161141ed..4893910fb9 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1087,6 +1087,7 @@ void                    gtk_widget_class_install_stateful_action (GtkWidgetClass
 GDK_AVAILABLE_IN_ALL
 gboolean               gtk_widget_class_query_action  (GtkWidgetClass      *widget_class,
                                                        guint                index_,
+                                                       GType               *owner,
                                                        const char         **action_name,
                                                        const GVariantType **parameter_type,
                                                        const GVariantType **state_type);


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