summaryrefslogtreecommitdiff
path: root/gtk/gtkwidget.h
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-06-14 12:12:10 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-06-18 14:47:33 -0400
commitef031e1a9d024d62f5ec24bd70c25f1668ebe943 (patch)
tree09b74701186aa212dd745a3c64da2433d9fde754 /gtk/gtkwidget.h
parent9b62da10e6c81889510c07f4a6ef23546e9aad92 (diff)
downloadgtk+-ef031e1a9d024d62f5ec24bd70c25f1668ebe943.tar.gz
Allow registering actions per-class
Add a facility to register and install actions at class init time. The intended use for these actions is for a) context and other model-based menus b) key bindings Most of these actions are going to be stateless, so add separate apis for the simple and stateful cases. We avoid creating an action group for these by teaching the action muxer about these actions. The action muxer also maintains the enabled state for these actions.
Diffstat (limited to 'gtk/gtkwidget.h')
-rw-r--r--gtk/gtkwidget.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index ca9d768ea6..73e92ac1cb 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -1023,6 +1023,76 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_widget_should_layout (GtkWidget *widget);
+/**
+ * GtkWidgetActionActivateFunc:
+ * @widget: the widget to which the action belongs
+ * @action_name: the action name
+ * @parameter: parameter for activation
+ *
+ * The type of the callback functions used for activating
+ * actions installed with gtk_widget_class_install_action().
+ *
+ * The @parameter must match the @parameter_type of the action.
+ */
+typedef void (* GtkWidgetActionActivateFunc) (GtkWidget *widget,
+ const char *action_name,
+ GVariant *parameter);
+
+/**
+ * GtkWidgetActionGetStateFunc:
+ * @widget: the widget to which the action belongs
+ * @action_name: the action name
+ *
+ * The type of the callback functions used to query the state
+ * of stateful actions installed with gtk_widget_class_install_action().
+ *
+ * See the #GAction documentation for more details about the
+ * meaning of these properties.
+ */
+typedef GVariant * (* GtkWidgetActionGetStateFunc) (GtkWidget *widget,
+ const char *action_name);
+
+/**
+ * GtkWidgetActionSetStateFunc:
+ * @widget: the widget to which the action belongs
+ * @action_name: the action name
+ * @state: the new state
+ *
+ * The type of the callback functions used to change the
+ * state of actions installed with gtk_widget_class_install_action().
+ *
+ * The @state must match the @state_type of the action.
+ *
+ * This callback is used when the action state is
+ * changed via the #GActionGroup API.
+ */
+typedef void (*GtkWidgetActionSetStateFunc) (GtkWidget *widget,
+ const char *action_name,
+ GVariant *state);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_class_install_action (GtkWidgetClass *widget_class,
+ const char *action_name,
+ GtkWidgetActionActivateFunc activate);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_class_install_stateful_action (GtkWidgetClass *widget_class,
+ const char *action_name,
+ GtkWidgetActionActivateFunc activate,
+ const char *parameter_type,
+ GtkWidgetActionSetStateFunc set_state,
+ GtkWidgetActionGetStateFunc get_state);
+
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_action_enabled_changed (GtkWidget *widget,
+ const char *action_name,
+ gboolean enabled);
+GDK_AVAILABLE_IN_ALL
+void gtk_widget_action_state_changed (GtkWidget *widget,
+ const char *action_name,
+ GVariant *state);
+
+
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidget, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRequisition, gtk_requisition_free)