[gnome-builder/wip/gtk4-port] libide/code: add IdeSymbolNode:icon-name property



commit 0b4be5f19c9fff5012ceaa05bd83a6b61020bf95
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 21 16:33:14 2022 -0700

    libide/code: add IdeSymbolNode:icon-name property
    
    This is a helper to get access to the icon name based on the symbol kind.
    This allows binding from GtkBuilder without having to manually copy
    property values around.

 src/libide/code/ide-symbol-node.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/libide/code/ide-symbol-node.c b/src/libide/code/ide-symbol-node.c
index 05ad3f150..d465bc9fd 100644
--- a/src/libide/code/ide-symbol-node.c
+++ b/src/libide/code/ide-symbol-node.c
@@ -45,6 +45,7 @@ enum {
   PROP_KIND,
   PROP_NAME,
   PROP_USE_MARKUP,
+  PROP_ICON_NAME,
   N_PROPS
 };
 
@@ -74,6 +75,13 @@ ide_symbol_node_real_get_location_finish (IdeSymbolNode  *self,
   return ide_task_propagate_pointer (IDE_TASK (result), error);
 }
 
+static const char *
+ide_symbol_node_get_icon_name (IdeSymbolNode *self)
+{
+  IdeSymbolKind kind = ide_symbol_node_get_kind (self);
+  return ide_symbol_kind_get_icon_name (kind);
+}
+
 static void
 ide_symbol_node_finalize (GObject *object)
 {
@@ -99,6 +107,10 @@ ide_symbol_node_get_property (GObject    *object,
       g_value_set_string (value, ide_symbol_node_get_name (self));
       break;
 
+    case PROP_ICON_NAME:
+      g_value_set_static_string (value, ide_symbol_node_get_icon_name (self));
+      break;
+
     case PROP_KIND:
       g_value_set_enum (value, ide_symbol_node_get_kind (self));
       break;
@@ -134,6 +146,7 @@ ide_symbol_node_set_property (GObject      *object,
 
     case PROP_KIND:
       priv->kind = g_value_get_enum (value);
+      g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]);
       break;
 
     case PROP_FLAGS:
@@ -168,6 +181,13 @@ ide_symbol_node_class_init (IdeSymbolNodeClass *klass)
                          NULL,
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
+  properties [PROP_ICON_NAME] =
+    g_param_spec_string ("icon-name",
+                         "Icon Name",
+                         "Icon Name",
+                         NULL,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
   properties [PROP_KIND] =
     g_param_spec_enum ("kind",
                        "Kind",


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