diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-05-08 03:34:14 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-05-08 03:34:14 +0000 |
commit | 97b450dfd71559d8975a74778c839c8c397d8f7b (patch) | |
tree | 702fbc0e40af795df83c1a1fa361eca390a429a4 | |
parent | 46c1e154f187ffc421ea5b17436369c5b477ee4a (diff) | |
download | gtk+-97b450dfd71559d8975a74778c839c8c397d8f7b.tar.gz |
Improve the action editor more
-rw-r--r-- | gtk/inspector/action-editor.c | 29 | ||||
-rw-r--r-- | gtk/inspector/action-editor.h | 4 | ||||
-rw-r--r-- | gtk/inspector/actions.c | 4 | ||||
-rw-r--r-- | gtk/inspector/actions.ui | 9 |
4 files changed, 37 insertions, 9 deletions
diff --git a/gtk/inspector/action-editor.c b/gtk/inspector/action-editor.c index 3c6d8721a7..7919296cfc 100644 --- a/gtk/inspector/action-editor.c +++ b/gtk/inspector/action-editor.c @@ -45,7 +45,8 @@ enum PROP_0, PROP_GROUP, PROP_PREFIX, - PROP_NAME + PROP_NAME, + PROP_SIZEGROUP }; G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorActionEditor, gtk_inspector_action_editor, GTK_TYPE_BOX) @@ -267,28 +268,29 @@ constructed (GObject *object) GtkInspectorActionEditor *r = GTK_INSPECTOR_ACTION_EDITOR (object); GVariant *state; GtkWidget *row; + GtkWidget *activate; GtkWidget *label; r->priv->enabled = g_action_group_get_action_enabled (r->priv->group, r->priv->name); state = g_action_group_get_action_state (r->priv->group, r->priv->name); - r->priv->sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); + activate = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10); + gtk_container_add (GTK_CONTAINER (row), activate); + gtk_size_group_add_widget (r->priv->sg, activate); r->priv->activate_button = gtk_button_new_with_label (_("Activate")); g_signal_connect (r->priv->activate_button, "clicked", G_CALLBACK (activate_action), r); - gtk_size_group_add_widget (r->priv->sg, r->priv->activate_button); gtk_widget_set_sensitive (r->priv->activate_button, r->priv->enabled); - gtk_container_add (GTK_CONTAINER (row), r->priv->activate_button); + gtk_container_add (GTK_CONTAINER (activate), r->priv->activate_button); r->priv->parameter_type = g_action_group_get_action_parameter_type (r->priv->group, r->priv->name); if (r->priv->parameter_type) { r->priv->parameter_entry = variant_editor_new (r->priv->parameter_type, parameter_changed, r); gtk_widget_set_sensitive (r->priv->parameter_entry, r->priv->enabled); - gtk_container_add (GTK_CONTAINER (row), r->priv->parameter_entry); + gtk_container_add (GTK_CONTAINER (activate), r->priv->parameter_entry); } gtk_container_add (GTK_CONTAINER (r), row); @@ -350,6 +352,10 @@ get_property (GObject *object, g_value_set_string (value, r->priv->name); break; + case PROP_SIZEGROUP: + g_value_set_object (value, r->priv->sg); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -380,6 +386,10 @@ set_property (GObject *object, r->priv->name = g_value_dup_string (value); break; + case PROP_SIZEGROUP: + r->priv->sg = g_value_get_object (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); break; @@ -407,16 +417,21 @@ gtk_inspector_action_editor_class_init (GtkInspectorActionEditorClass *klass) g_object_class_install_property (object_class, PROP_NAME, g_param_spec_string ("name", "Name", "The action name", NULL, G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_SIZEGROUP, + g_param_spec_object ("sizegroup", "Size Group", "The Size Group for activate", + GTK_TYPE_SIZE_GROUP, G_PARAM_READWRITE|G_PARAM_CONSTRUCT)); } GtkWidget * gtk_inspector_action_editor_new (GActionGroup *group, const gchar *prefix, - const gchar *name) + const gchar *name, + GtkSizeGroup *activate) { return g_object_new (GTK_TYPE_INSPECTOR_ACTION_EDITOR, "group", group, "prefix", prefix, "name", name, + "sizegroup", activate, NULL); } diff --git a/gtk/inspector/action-editor.h b/gtk/inspector/action-editor.h index 5edb2b247d..097ae12707 100644 --- a/gtk/inspector/action-editor.h +++ b/gtk/inspector/action-editor.h @@ -20,6 +20,7 @@ #include <gtk/gtkbox.h> +#include <gtk/gtksizegroup.h> #define GTK_TYPE_INSPECTOR_ACTION_EDITOR (gtk_inspector_action_editor_get_type()) @@ -49,7 +50,8 @@ G_BEGIN_DECLS GType gtk_inspector_action_editor_get_type (void); GtkWidget *gtk_inspector_action_editor_new (GActionGroup *group, const gchar *prefix, - const gchar *name); + const gchar *name, + GtkSizeGroup *activate); G_END_DECLS diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c index 2562617d27..c6a9c92000 100644 --- a/gtk/inspector/actions.c +++ b/gtk/inspector/actions.c @@ -51,6 +51,7 @@ struct _GtkInspectorActionsPrivate GtkSizeGroup *enabled; GtkSizeGroup *parameter; GtkSizeGroup *state; + GtkSizeGroup *activate; GHashTable *groups; }; @@ -131,7 +132,7 @@ add_action (GtkInspectorActions *sl, gtk_container_add (GTK_CONTAINER (box), label); g_object_set_data (G_OBJECT (row), "state", label); - editor = gtk_inspector_action_editor_new (group, prefix, name); + editor = gtk_inspector_action_editor_new (group, prefix, name, sl->priv->activate); gtk_style_context_add_class (gtk_widget_get_style_context (editor), "cell"); gtk_container_add (GTK_CONTAINER (box), editor); @@ -312,6 +313,7 @@ gtk_inspector_actions_class_init (GtkInspectorActionsClass *klass) gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, enabled); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, parameter); gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, state); + gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorActions, activate); } // vim: set et sw=2 ts=2: diff --git a/gtk/inspector/actions.ui b/gtk/inspector/actions.ui index 86f068b60c..33ba5d58ad 100644 --- a/gtk/inspector/actions.ui +++ b/gtk/inspector/actions.ui @@ -50,6 +50,12 @@ <property name="xalign">0</property> </object> </child> + <child> + <object class="GtkLabel" id="changes_heading"> + <property name="label" translatable="yes"></property> + <property name="xalign">0</property> + </object> + </child> </object> </child> <child> @@ -97,4 +103,7 @@ <widget name="state_heading"/> </widgets> </object> + <object class="GtkSizeGroup" id="activate"> + <property name="mode">horizontal</property> + </object> </interface> |