[gnome-builder/gnome-builder-3-24] symbol: add symbol helpers to ide-symbol utils
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/gnome-builder-3-24] symbol: add symbol helpers to ide-symbol utils
- Date: Tue, 4 Apr 2017 22:13:40 +0000 (UTC)
commit 8af752cd6c2de3ed8eafdf9a8d0d30f7199d4110
Author: Christian Hergert <chergert redhat com>
Date: Tue Apr 4 14:55:37 2017 -0700
symbol: add symbol helpers to ide-symbol utils
libide/symbols/ide-symbol.c | 140 +++++++++++++++++++++++++++++
libide/symbols/ide-symbol.h | 2 +
plugins/symbol-tree/symbol-tree-builder.c | 134 +---------------------------
3 files changed, 144 insertions(+), 132 deletions(-)
---
diff --git a/libide/symbols/ide-symbol.c b/libide/symbols/ide-symbol.c
index 321eb2f..90bdaf1 100644
--- a/libide/symbols/ide-symbol.c
+++ b/libide/symbols/ide-symbol.c
@@ -183,3 +183,143 @@ ide_symbol_unref (IdeSymbol *self)
EGG_COUNTER_DEC (instances);
}
}
+
+const gchar *
+ide_symbol_kind_get_icon_name (IdeSymbolKind kind)
+{
+ const gchar *icon_name = NULL;
+
+ switch (kind)
+ {
+ case IDE_SYMBOL_FUNCTION:
+ icon_name = "lang-function-symbolic";
+ break;
+
+ case IDE_SYMBOL_ENUM:
+ icon_name = "lang-enum-symbolic";
+ break;
+
+ case IDE_SYMBOL_ENUM_VALUE:
+ icon_name = "lang-enum-value-symbolic";
+ break;
+
+ case IDE_SYMBOL_STRUCT:
+ icon_name = "lang-struct-symbolic";
+ break;
+
+ case IDE_SYMBOL_CLASS:
+ icon_name = "lang-class-symbolic";
+ break;
+
+ case IDE_SYMBOL_METHOD:
+ icon_name = "lang-method-symbolic";
+ break;
+
+ case IDE_SYMBOL_UNION:
+ icon_name = "lang-union-symbolic";
+ break;
+
+ case IDE_SYMBOL_SCALAR:
+ case IDE_SYMBOL_FIELD:
+ case IDE_SYMBOL_VARIABLE:
+ icon_name = "lang-variable-symbolic";
+ break;
+
+ case IDE_SYMBOL_ARRAY:
+ case IDE_SYMBOL_BOOLEAN:
+ case IDE_SYMBOL_CONSTANT:
+ case IDE_SYMBOL_CONSTRUCTOR:
+ case IDE_SYMBOL_FILE:
+ case IDE_SYMBOL_HEADER:
+ case IDE_SYMBOL_INTERFACE:
+ case IDE_SYMBOL_MODULE:
+ case IDE_SYMBOL_NAMESPACE:
+ case IDE_SYMBOL_NUMBER:
+ case IDE_SYMBOL_NONE:
+ case IDE_SYMBOL_PACKAGE:
+ case IDE_SYMBOL_PROPERTY:
+ case IDE_SYMBOL_STRING:
+ case IDE_SYMBOL_KEYWORD:
+ icon_name = NULL;
+ break;
+
+ case IDE_SYMBOL_UI_ATTRIBUTES:
+ icon_name = "ui-attributes-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_CHILD:
+ icon_name = "ui-child-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_ITEM:
+ icon_name = "ui-item-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_MENU:
+ icon_name = "ui-menu-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_OBJECT:
+ icon_name = "ui-object-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_PACKING:
+ icon_name = "ui-packing-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_PROPERTY:
+ icon_name = "ui-property-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_SECTION:
+ icon_name = "ui-section-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_SIGNAL:
+ icon_name = "ui-signal-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_STYLE:
+ icon_name = "ui-style-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_SUBMENU:
+ icon_name = "ui-submenu-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_TEMPLATE:
+ icon_name = "ui-template-symbolic";
+ break;
+
+ case IDE_SYMBOL_XML_ATTRIBUTE:
+ icon_name = "xml-attribute-symbolic";
+ break;
+
+ case IDE_SYMBOL_XML_CDATA:
+ icon_name = "xml-cdata-symbolic";
+ break;
+
+ case IDE_SYMBOL_XML_COMMENT:
+ icon_name = "xml-comment-symbolic";
+ break;
+
+ case IDE_SYMBOL_XML_DECLARATION:
+ icon_name = "xml-declaration-symbolic";
+ break;
+
+ case IDE_SYMBOL_XML_ELEMENT:
+ icon_name = "xml-element-symbolic";
+ break;
+
+ case IDE_SYMBOL_UI_MENU_ATTRIBUTE:
+ case IDE_SYMBOL_UI_STYLE_CLASS:
+ icon_name = NULL;
+ break;
+
+ default:
+ icon_name = NULL;
+ break;
+ }
+
+ return icon_name;
+}
diff --git a/libide/symbols/ide-symbol.h b/libide/symbols/ide-symbol.h
index 7e31d92..2cffa80 100644
--- a/libide/symbols/ide-symbol.h
+++ b/libide/symbols/ide-symbol.h
@@ -51,6 +51,7 @@ typedef enum
IDE_SYMBOL_STRUCT,
IDE_SYMBOL_UNION,
IDE_SYMBOL_VARIABLE,
+ IDE_SYMBOL_KEYWORD,
IDE_SYMBOL_UI_ATTRIBUTES,
IDE_SYMBOL_UI_CHILD,
IDE_SYMBOL_UI_ITEM,
@@ -95,6 +96,7 @@ IdeSymbol *ide_symbol_new (const gchar *n
IdeSourceLocation *declaration_location,
IdeSourceLocation *definition_location,
IdeSourceLocation *canonical_location);
+const gchar *ide_symbol_kind_get_icon_name (IdeSymbolKind kind);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeSymbol, ide_symbol_unref)
diff --git a/plugins/symbol-tree/symbol-tree-builder.c b/plugins/symbol-tree/symbol-tree-builder.c
index b33e56d..80bea21 100644
--- a/plugins/symbol-tree/symbol-tree-builder.c
+++ b/plugins/symbol-tree/symbol-tree-builder.c
@@ -61,7 +61,7 @@ symbol_tree_builder_build_node (IdeTreeBuilder *builder,
{
g_autoptr(IdeSymbolNode) symbol = NULL;
const gchar *name;
- const gchar *icon_name = NULL;
+ const gchar *icon_name;
IdeTreeNode *child;
IdeSymbolKind kind;
gboolean has_children;
@@ -71,137 +71,7 @@ symbol_tree_builder_build_node (IdeTreeBuilder *builder,
name = ide_symbol_node_get_name (symbol);
kind = ide_symbol_node_get_kind (symbol);
use_markup = ide_symbol_node_get_use_markup (symbol);
-
- switch (kind)
- {
- case IDE_SYMBOL_FUNCTION:
- icon_name = "lang-function-symbolic";
- break;
-
- case IDE_SYMBOL_ENUM:
- icon_name = "lang-enum-symbolic";
- break;
-
- case IDE_SYMBOL_ENUM_VALUE:
- icon_name = "lang-enum-value-symbolic";
- break;
-
- case IDE_SYMBOL_STRUCT:
- icon_name = "lang-struct-symbolic";
- break;
-
- case IDE_SYMBOL_CLASS:
- icon_name = "lang-class-symbolic";
- break;
-
- case IDE_SYMBOL_METHOD:
- icon_name = "lang-method-symbolic";
- break;
-
- case IDE_SYMBOL_UNION:
- icon_name = "lang-union-symbolic";
- break;
-
- case IDE_SYMBOL_SCALAR:
- case IDE_SYMBOL_FIELD:
- case IDE_SYMBOL_VARIABLE:
- icon_name = "lang-variable-symbolic";
- break;
-
- case IDE_SYMBOL_ARRAY:
- case IDE_SYMBOL_BOOLEAN:
- case IDE_SYMBOL_CONSTANT:
- case IDE_SYMBOL_CONSTRUCTOR:
- case IDE_SYMBOL_FILE:
- case IDE_SYMBOL_HEADER:
- case IDE_SYMBOL_INTERFACE:
- case IDE_SYMBOL_MODULE:
- case IDE_SYMBOL_NAMESPACE:
- case IDE_SYMBOL_NUMBER:
- case IDE_SYMBOL_NONE:
- case IDE_SYMBOL_PACKAGE:
- case IDE_SYMBOL_PROPERTY:
- case IDE_SYMBOL_STRING:
- icon_name = NULL;
- break;
-
- case IDE_SYMBOL_UI_ATTRIBUTES:
- icon_name = "ui-attributes-symbolic";
- break;
-
- case IDE_SYMBOL_UI_CHILD:
- icon_name = "ui-child-symbolic";
- break;
-
- case IDE_SYMBOL_UI_ITEM:
- icon_name = "ui-item-symbolic";
- break;
-
- case IDE_SYMBOL_UI_MENU:
- icon_name = "ui-menu-symbolic";
- break;
-
- case IDE_SYMBOL_UI_OBJECT:
- icon_name = "ui-object-symbolic";
- break;
-
- case IDE_SYMBOL_UI_PACKING:
- icon_name = "ui-packing-symbolic";
- break;
-
- case IDE_SYMBOL_UI_PROPERTY:
- icon_name = "ui-property-symbolic";
- break;
-
- case IDE_SYMBOL_UI_SECTION:
- icon_name = "ui-section-symbolic";
- break;
-
- case IDE_SYMBOL_UI_SIGNAL:
- icon_name = "ui-signal-symbolic";
- break;
-
- case IDE_SYMBOL_UI_STYLE:
- icon_name = "ui-style-symbolic";
- break;
-
- case IDE_SYMBOL_UI_SUBMENU:
- icon_name = "ui-submenu-symbolic";
- break;
-
- case IDE_SYMBOL_UI_TEMPLATE:
- icon_name = "ui-template-symbolic";
- break;
-
- case IDE_SYMBOL_XML_ATTRIBUTE:
- icon_name = "xml-attribute-symbolic";
- break;
-
- case IDE_SYMBOL_XML_CDATA:
- icon_name = "xml-cdata-symbolic";
- break;
-
- case IDE_SYMBOL_XML_COMMENT:
- icon_name = "xml-comment-symbolic";
- break;
-
- case IDE_SYMBOL_XML_DECLARATION:
- icon_name = "xml-declaration-symbolic";
- break;
-
- case IDE_SYMBOL_XML_ELEMENT:
- icon_name = "xml-element-symbolic";
- break;
-
- case IDE_SYMBOL_UI_MENU_ATTRIBUTE:
- case IDE_SYMBOL_UI_STYLE_CLASS:
- icon_name = NULL;
- break;
-
- default:
- icon_name = NULL;
- break;
- }
+ icon_name = ide_symbol_kind_get_icon_name (kind);
has_children = !!ide_symbol_tree_get_n_children (symbol_tree, symbol);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]