[gnome-builder/wip/gtk4-port: 721/736] plugins/symbol-tree: handle NULL names better




commit d30ac113daf3e5023629b1d2911c29ef6f38370f
Author: Christian Hergert <chergert redhat com>
Date:   Thu Apr 21 19:23:54 2022 -0700

    plugins/symbol-tree: handle NULL names better

 src/plugins/symbol-tree/gbp-symbol-workspace-addin.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c 
b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
index 6ef483538..d3f6a1538 100644
--- a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
+++ b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
@@ -56,15 +56,24 @@ static void
 gbp_symbol_workspace_addin_set_symbol (GbpSymbolWorkspaceAddin *self,
                                        IdeSymbol               *symbol)
 {
-  const char *label;
-  const char *icon_name;
+  const char *label = NULL;
+  const char *icon_name = NULL;
 
   IDE_ENTRY;
 
   g_assert (GBP_IS_SYMBOL_WORKSPACE_ADDIN (self));
   g_assert (!symbol || IDE_IS_SYMBOL (symbol));
 
-  if (symbol == NULL)
+  if (symbol != NULL)
+    {
+      icon_name = ide_symbol_kind_get_icon_name (ide_symbol_get_kind (symbol));
+      label = ide_symbol_get_name (symbol);
+
+      if (ide_str_empty0 (label))
+        label = NULL;
+    }
+
+  if (label == NULL)
     {
       gtk_label_set_label (self->menu_label, _("Select Symbol…"));
       gtk_image_set_from_icon_name (self->menu_image, NULL);
@@ -72,9 +81,6 @@ gbp_symbol_workspace_addin_set_symbol (GbpSymbolWorkspaceAddin *self,
       IDE_EXIT;
     }
 
-  label = ide_symbol_get_name (symbol);
-  icon_name = ide_symbol_kind_get_icon_name (ide_symbol_get_kind (symbol));
-
   gtk_label_set_label (self->menu_label, label);
   gtk_image_set_from_icon_name (self->menu_image, icon_name);
   gtk_widget_set_visible (GTK_WIDGET (self->menu_image), icon_name != NULL);


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