Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Günther Wagner
gnome-builder
Commits
a4dc776f
Commit
a4dc776f
authored
Jan 16, 2019
by
Christian Hergert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tree: add support for rendering with error squiggles
parent
03e7f03a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
0 deletions
+81
-0
src/libide/tree/ide-tree-node.c
src/libide/tree/ide-tree-node.c
+51
-0
src/libide/tree/ide-tree-node.h
src/libide/tree/ide-tree-node.h
+5
-0
src/libide/tree/ide-tree.c
src/libide/tree/ide-tree.c
+25
-0
No files found.
src/libide/tree/ide-tree-node.c
View file @
a4dc776f
...
...
@@ -96,6 +96,9 @@ struct _IdeTreeNode
/* If this is a synthesized empty node */
guint
is_empty
:
1
;
/* If there are errors associated with the node's item */
guint
has_error
:
1
;
/* If the node maybe has children */
guint
children_possible
:
1
;
...
...
@@ -122,6 +125,7 @@ enum {
PROP_DISPLAY_NAME
,
PROP_EXPANDED_ICON
,
PROP_EXPANDED_ICON_NAME
,
PROP_HAS_ERROR
,
PROP_ICON
,
PROP_ICON_NAME
,
PROP_IS_HEADER
,
...
...
@@ -250,6 +254,10 @@ ide_tree_node_get_property (GObject *object,
g_value_set_string
(
value
,
ide_tree_node_get_display_name
(
self
));
break
;
case
PROP_HAS_ERROR
:
g_value_set_boolean
(
value
,
ide_tree_node_get_has_error
(
self
));
break
;
case
PROP_ICON
:
g_value_set_object
(
value
,
ide_tree_node_get_icon
(
self
));
break
;
...
...
@@ -305,6 +313,10 @@ ide_tree_node_set_property (GObject *object,
ide_tree_node_set_expanded_icon_name
(
self
,
g_value_get_string
(
value
));
break
;
case
PROP_HAS_ERROR
:
ide_tree_node_set_has_error
(
self
,
g_value_get_boolean
(
value
));
break
;
case
PROP_ICON
:
ide_tree_node_set_icon
(
self
,
g_value_get_object
(
value
));
break
;
...
...
@@ -420,6 +432,22 @@ ide_tree_node_class_init (IdeTreeNodeClass *klass)
NULL
,
(
G_PARAM_WRITABLE
|
G_PARAM_STATIC_STRINGS
));
/**
* IdeTreeNode:has-error:
*
* The "has-error" property is true if the node should be rendered with
* an error styling. This is useful when errors are known by the diagnostics
* manager for a given file or folder.
*
* Since: 3.32
*/
properties
[
PROP_HAS_ERROR
]
=
g_param_spec_boolean
(
"has-error"
,
"Has Error"
,
"If the node has an error associated with it's item"
,
FALSE
,
(
G_PARAM_READWRITE
|
G_PARAM_EXPLICIT_NOTIFY
|
G_PARAM_STATIC_STRINGS
));
/**
* IdeTreeNode:icon:
*
...
...
@@ -1892,3 +1920,26 @@ ide_tree_node_is_selected (IdeTreeNode *self)
return
FALSE
;
}
gboolean
ide_tree_node_get_has_error
(
IdeTreeNode
*
self
)
{
g_return_val_if_fail
(
IDE_IS_TREE_NODE
(
self
),
FALSE
);
return
self
->
has_error
;
}
void
ide_tree_node_set_has_error
(
IdeTreeNode
*
self
,
gboolean
has_error
)
{
g_return_if_fail
(
IDE_IS_TREE_NODE
(
self
));
has_error
=
!!
has_error
;
if
(
has_error
!=
self
->
has_error
)
{
self
->
has_error
=
has_error
;
g_object_notify_by_pspec
(
G_OBJECT
(
self
),
properties
[
PROP_HAS_ERROR
]);
}
}
src/libide/tree/ide-tree-node.h
View file @
a4dc776f
...
...
@@ -69,6 +69,11 @@ typedef int (*IdeTreeNodeCompare) (IdeTreeNode *node,
IDE_AVAILABLE_IN_3_32
IdeTreeNode
*
ide_tree_node_new
(
void
);
IDE_AVAILABLE_IN_3_32
gboolean
ide_tree_node_get_has_error
(
IdeTreeNode
*
self
);
IDE_AVAILABLE_IN_3_32
void
ide_tree_node_set_has_error
(
IdeTreeNode
*
self
,
gboolean
has_error
);
IDE_AVAILABLE_IN_3_32
const
gchar
*
ide_tree_node_get_tag
(
IdeTreeNode
*
self
);
IDE_AVAILABLE_IN_3_32
void
ide_tree_node_set_tag
(
IdeTreeNode
*
self
,
...
...
src/libide/tree/ide-tree.c
View file @
a4dc776f
...
...
@@ -161,6 +161,31 @@ text_cell_func (GtkCellLayout *layout,
}
}
if
(
ide_tree_node_get_has_error
(
node
))
{
PangoAttrList
*
attrs
=
NULL
;
PangoAttrList
*
copy
=
NULL
;
g_object_get
(
cell
,
"attributes"
,
&
attrs
,
NULL
);
if
(
attrs
!=
NULL
)
copy
=
pango_attr_list_copy
(
attrs
);
else
copy
=
pango_attr_list_new
();
pango_attr_list_insert
(
copy
,
pango_attr_underline_new
(
PANGO_UNDERLINE_ERROR
));
pango_attr_list_insert
(
copy
,
pango_attr_underline_color_new
(
65535
,
0
,
0
));
g_object_set
(
cell
,
"attributes"
,
copy
,
NULL
);
g_clear_pointer
(
&
attrs
,
pango_attr_list_unref
);
g_clear_pointer
(
&
copy
,
pango_attr_list_unref
);
}
/* Only apply styling if the node isn't selected */
if
(
!
ide_tree_node_is_selected
(
node
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment