[gtk/shortcuts-rebased-again: 116/124] inspector: Show shortcut actions and triggers



commit 6e4cdf2ee6e84e3f900db1af6293be30d8bb2d02
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jun 19 04:27:56 2019 +0000

    inspector: Show shortcut actions and triggers
    
    Show these in the property details for
    GtkShortcut objects.

 gtk/inspector/prop-editor.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
---
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index b44a2c177b..24158be0a1 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -46,6 +46,8 @@
 #include "gtklistbox.h"
 #include "gtkcomboboxtext.h"
 #include "gtkmenubutton.h"
+#include "gtkshortcutaction.h"
+#include "gtkshortcuttrigger.h"
 
 struct _GtkInspectorPropEditorPrivate
 {
@@ -1095,6 +1097,47 @@ property_editor (GObject                *object,
       gtk_widget_set_halign (prop_edit, GTK_ALIGN_START);
       gtk_widget_set_valign (prop_edit, GTK_ALIGN_CENTER);
     }
+  else if (type == G_TYPE_PARAM_BOXED &&
+           G_PARAM_SPEC_VALUE_TYPE (spec) == GTK_TYPE_SHORTCUT_ACTION)
+    {
+      GtkShortcutAction *action;
+      g_object_get (object, spec->name, &action, NULL);
+      if (action)
+        {
+          msg = gtk_shortcut_action_to_string (action);
+          gtk_shortcut_action_unref (action);
+        }
+      else
+        msg = NULL;
+      prop_edit = gtk_label_new (msg);
+    }
+  else if (type == G_TYPE_PARAM_BOXED &&
+           G_PARAM_SPEC_VALUE_TYPE (spec) == GTK_TYPE_SHORTCUT_TRIGGER)
+    {
+      GtkShortcutTrigger *trigger;
+      g_object_get (object, spec->name, &trigger, NULL);
+      if (trigger)
+        {
+          msg = gtk_shortcut_trigger_to_string (trigger);
+          gtk_shortcut_trigger_unref (trigger);
+        }
+      else
+        msg = NULL;
+      prop_edit = gtk_label_new (msg);
+    }
+  else if (type == G_TYPE_PARAM_VARIANT)
+    {
+      GVariant *variant;
+      g_object_get (object, spec->name, &variant, NULL);
+      if (variant)
+        {
+          msg = g_variant_print (variant, FALSE);
+          g_variant_unref (variant);
+        }
+      else
+        msg = NULL;
+      prop_edit = gtk_label_new (msg);
+    }
   else
     {
       msg = g_strdup_printf (_("Uneditable property type: %s"),


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