[gitg] Set style of navigation tree view more like in nautilus
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Set style of navigation tree view more like in nautilus
- Date: Fri, 1 Mar 2013 21:32:40 +0000 (UTC)
commit e46ec3f74da7e2209d70a8b12fc93b54df3d4570
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Fri Mar 1 22:31:42 2013 +0100
Set style of navigation tree view more like in nautilus
gitg/gitg-window.vala | 19 ++++++--
libgitg-ext/gitg-ext-navigation-tree-view.vala | 61 ++++++++++++++---------
libgitg-ext/gitg-ext-navigation.vala | 1 +
plugins/history/gitg-history-navigation.vala | 5 ++
4 files changed, 58 insertions(+), 28 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 8b86b67..e17789b 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -205,14 +205,25 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable, Gtk.
// 1) Clear the navigation tree
d_navigation.model.clear();
- if (view != null)
+ if (view != null && view.navigation != null)
{
+ d_navigation.set_show_expanders(view.navigation.show_expanders);
+
+ if (view.navigation.show_expanders)
+ {
+ d_navigation.set_level_indentation(0);
+ }
+ else
+ {
+ d_navigation.set_level_indentation(12);
+ }
+
// 2) Populate the navigation tree for this view
d_navigation.model.populate(view.navigation);
- d_navigation.expand_all();
-
- d_navigation.select_first();
}
+
+ d_navigation.expand_all();
+ d_navigation.select_first();
// Update panels
d_panels.update();
diff --git a/libgitg-ext/gitg-ext-navigation-tree-view.vala b/libgitg-ext/gitg-ext-navigation-tree-view.vala
index 96e99cb..7cc3cf3 100644
--- a/libgitg-ext/gitg-ext-navigation-tree-view.vala
+++ b/libgitg-ext/gitg-ext-navigation-tree-view.vala
@@ -24,6 +24,7 @@ private enum Column
{
ICON_NAME,
TEXT,
+ HEADER,
HINT,
SECTION,
OID
@@ -66,7 +67,7 @@ public class NavigationTreeModel : Gtk.TreeStore
construct
{
- set_column_types({typeof(string), typeof(string), typeof(uint), typeof(uint), typeof(uint)});
+ set_column_types({typeof(string), typeof(string), typeof(string), typeof(uint), typeof(uint),
typeof(uint)});
d_callbacks = new Activated[100];
d_callbacks.length = 0;
@@ -100,7 +101,7 @@ public class NavigationTreeModel : Gtk.TreeStore
@set(iter,
Column.ICON_NAME, icon_name,
- Column.TEXT, text,
+ hint == Hint.HEADER ? Column.HEADER : Column.TEXT, text,
Column.HINT, hint,
Column.SECTION, d_sections,
Column.OID, d_oid);
@@ -247,7 +248,8 @@ public class NavigationRendererText : Gtk.CellRendererText
}
}
- public uint hint { get; set; }
+ public uint hint
+ { get; set; }
construct
{
@@ -348,8 +350,6 @@ public class NavigationRendererText : Gtk.CellRendererText
var stx = widget.get_style_context();
ensure_pixbuf(stx);
- int xpad = 3;
-
if (d_pixbuf == null)
{
base.render(ctx, widget, background_area, cell_area, state);
@@ -358,14 +358,14 @@ public class NavigationRendererText : Gtk.CellRendererText
{
// render the text with an additional padding
Gdk.Rectangle area = cell_area;
- area.x += d_pixbuf.width + xpad;
+ area.x += d_pixbuf.width + 3;
base.render(ctx, widget, background_area, area, state);
// render the pixbuf
- int ypad = (cell_area.height - d_pixbuf.height) / 2;
+ int yp = (cell_area.height - d_pixbuf.height) / 2;
- stx.render_icon(ctx, d_pixbuf, cell_area.x, cell_area.y + ypad);
+ stx.render_icon(ctx, d_pixbuf, cell_area.x, cell_area.y + yp);
}
}
}
@@ -377,28 +377,41 @@ public class NavigationTreeView : Gtk.TreeView
var model = new NavigationTreeModel();
set_model(model);
+ var col = new Gtk.TreeViewColumn();
+
+ var padcell = new Gtk.CellRendererText();
+ var headercell = new NavigationRendererText();
var cell = new NavigationRendererText();
- var col = new Gtk.TreeViewColumn.with_attributes("text",
- cell,
- "icon_name", Column.ICON_NAME,
- "text", Column.TEXT,
- "hint", Column.HINT);
- col.set_cell_data_func(cell, (col, cell, model, iter) => {
- uint hint;
+ padcell.xpad = 6;
+ headercell.ypad = 6;
+
+ headercell.weight = Pango.Weight.BOLD;
+ col.pack_start(padcell, false);
+ col.pack_start(headercell, true);
+ col.pack_start(cell, true);
+
+ col.set_attributes(headercell,
+ "icon_name", Column.ICON_NAME,
+ "text", Column.HEADER);
+
+ col.set_attributes(cell,
+ "icon_name", Column.ICON_NAME,
+ "text", Column.TEXT);
+
+ col.set_cell_data_func(headercell, (layout, cell, model, iter) => {
+ Hint hint;
model.get(iter, Column.HINT, out hint);
- Gtk.CellRendererText t = cell as Gtk.CellRendererText;
+ cell.visible = (hint == Hint.HEADER);
+ });
- if (hint == Hint.HEADER)
- {
- t.weight = Pango.Weight.BOLD;
- }
- else
- {
- t.weight = Pango.Weight.NORMAL;
- }
+ col.set_cell_data_func(cell, (layout, cell, model, iter) => {
+ Hint hint;
+ model.get(iter, Column.HINT, out hint);
+
+ cell.visible = (hint != Hint.HEADER);
});
set_row_separator_func((model, iter) => {
diff --git a/libgitg-ext/gitg-ext-navigation.vala b/libgitg-ext/gitg-ext-navigation.vala
index 4b6f8f0..b3b92b2 100644
--- a/libgitg-ext/gitg-ext-navigation.vala
+++ b/libgitg-ext/gitg-ext-navigation.vala
@@ -32,6 +32,7 @@ public interface Navigation : Object
public abstract void populate(GitgExt.NavigationTreeModel model);
public abstract bool available { get; }
+ public abstract bool show_expanders { get; }
public abstract NavigationSide navigation_side { get; }
}
diff --git a/plugins/history/gitg-history-navigation.vala b/plugins/history/gitg-history-navigation.vala
index ad0f16c..1d14cbf 100644
--- a/plugins/history/gitg-history-navigation.vala
+++ b/plugins/history/gitg-history-navigation.vala
@@ -213,6 +213,11 @@ namespace GitgHistory
{
get { return true; }
}
+
+ public bool show_expanders
+ {
+ get { return false; }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]