Commit b9643ca8 authored by Christian Hergert's avatar Christian Hergert

tree: add support for markup text for nodes

parent d5abc98f
......@@ -108,6 +108,9 @@ struct _IdeTreeNode
/* If true, we remove all children on collapse */
guint reset_on_collapse : 1;
/* If pango markup should be used */
guint use_markup : 1;
/* If true, we use ide_clear_and_destroy_object() */
guint destroy_item : 1;
......@@ -132,6 +135,7 @@ enum {
PROP_ITEM,
PROP_RESET_ON_COLLAPSE,
PROP_TAG,
PROP_USE_MARKUP,
N_PROPS
};
......@@ -278,6 +282,10 @@ ide_tree_node_get_property (GObject *object,
g_value_set_string (value, ide_tree_node_get_tag (self));
break;
case PROP_USE_MARKUP:
g_value_set_boolean (value, ide_tree_node_get_use_markup (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -341,6 +349,10 @@ ide_tree_node_set_property (GObject *object,
ide_tree_node_set_tag (self, g_value_get_string (value));
break;
case PROP_USE_MARKUP:
ide_tree_node_set_use_markup (self, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -541,6 +553,21 @@ ide_tree_node_class_init (IdeTreeNodeClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
/**
* IdeTreeNode:use-markup:
*
* If #TRUE, the "use-markup" property denotes that #IdeTreeNode:display-name
* contains pango markup.
*
* Since: 3.32
*/
properties [PROP_USE_MARKUP] =
g_param_spec_boolean ("use-markup",
"Use Markup",
"If pango markup should be used",
FALSE,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
......@@ -1940,6 +1967,31 @@ ide_tree_node_set_has_error (IdeTreeNode *self,
if (has_error != self->has_error)
{
self->has_error = has_error;
ide_tree_node_emit_changed (self);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_HAS_ERROR]);
}
}
gboolean
ide_tree_node_get_use_markup (IdeTreeNode *self)
{
g_return_val_if_fail (IDE_IS_TREE_NODE (self), FALSE);
return self->use_markup;
}
void
ide_tree_node_set_use_markup (IdeTreeNode *self,
gboolean use_markup)
{
g_return_if_fail (IDE_IS_TREE_NODE (self));
use_markup = !!use_markup;
if (use_markup != self->use_markup)
{
self->use_markup = use_markup;
ide_tree_node_emit_changed (self);
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_USE_MARKUP]);
}
}
......@@ -193,5 +193,10 @@ void ide_tree_node_set_foreground_rgba (IdeTreeNode *self,
const GdkRGBA *foreground_rgba);
IDE_AVAILABLE_IN_3_32
gboolean ide_tree_node_is_selected (IdeTreeNode *self);
IDE_AVAILABLE_IN_3_32
gboolean ide_tree_node_get_use_markup (IdeTreeNode *self);
IDE_AVAILABLE_IN_3_32
void ide_tree_node_set_use_markup (IdeTreeNode *self,
gboolean use_markup);
G_END_DECLS
......@@ -198,9 +198,10 @@ text_cell_func (GtkCellLayout *layout,
display_name = ide_tree_node_get_display_name (node);
set_props:
g_object_set (cell,
"text", display_name,
NULL);
if (ide_tree_node_get_use_markup (node))
g_object_set (cell, "markup", display_name, NULL);
else
g_object_set (cell, "text", display_name, NULL);
}
static void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment