[gitg] files: add icon to the list elements
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] files: add icon to the list elements
- Date: Thu, 18 Oct 2012 13:42:30 +0000 (UTC)
commit 2c08e9af560575e21fac846e184d24ea6412dfd0
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Thu Oct 18 15:41:33 2012 +0200
files: add icon to the list elements
plugins/files/gitg-files-tree-store.vala | 38 ++++++++++++++++++++++-------
plugins/files/resources/view-files.ui | 8 +++++-
2 files changed, 36 insertions(+), 10 deletions(-)
---
diff --git a/plugins/files/gitg-files-tree-store.vala b/plugins/files/gitg-files-tree-store.vala
index e853cde..fd9d896 100644
--- a/plugins/files/gitg-files-tree-store.vala
+++ b/plugins/files/gitg-files-tree-store.vala
@@ -36,7 +36,7 @@ public class TreeStore : Gtk.TreeStore
construct
{
- set_column_types(new Type[] {typeof(string), typeof(bool), typeof(Ggit.OId)});
+ set_column_types(new Type[] {typeof(Icon), typeof(string), typeof(bool), typeof(Ggit.OId)});
set_sort_func(0, (model, a, b) => {
string aname;
@@ -44,8 +44,8 @@ public class TreeStore : Gtk.TreeStore
bool aisdir;
bool bisdir;
- model.get(a, 0, out aname, 1, out aisdir);
- model.get(b, 0, out bname, 1, out bisdir);
+ model.get(a, 1, out aname, 2, out aisdir);
+ model.get(b, 1, out bname, 2, out bisdir);
if (aisdir == bisdir)
{
@@ -69,7 +69,7 @@ public class TreeStore : Gtk.TreeStore
{
Ggit.OId ret;
- get(iter, 2, out ret);
+ get(iter, 3, out ret);
return ret;
}
@@ -92,7 +92,7 @@ public class TreeStore : Gtk.TreeStore
{
string ret;
- get(iter, 0, out ret);
+ get(iter, 1, out ret);
return ret;
}
@@ -101,7 +101,7 @@ public class TreeStore : Gtk.TreeStore
{
bool ret;
- get(iter, 1, out ret);
+ get(iter, 2, out ret);
return ret;
}
@@ -130,12 +130,32 @@ public class TreeStore : Gtk.TreeStore
get_iter(out parent, paths.lookup(root));
}
+ Icon ?icon = null;
+ if (isdir)
+ {
+ icon = new ThemedIcon("folder");
+ }
+ else
+ {
+ var ct = ContentType.guess(entry.get_name(), null, null);
+
+ if (ContentType.is_unknown(ct))
+ {
+ icon = new ThemedIcon("text-x-generic");
+ }
+ else
+ {
+ icon = ContentType.get_icon(ct);
+ }
+ }
+
Gtk.TreeIter iter;
append(out iter, parent);
set(iter,
- 0, entry.get_name(),
- 1, isdir,
- 2, entry.get_id(),
+ 0, icon,
+ 1, entry.get_name(),
+ 2, isdir,
+ 3, entry.get_id(),
-1);
if (isdir)
diff --git a/plugins/files/resources/view-files.ui b/plugins/files/resources/view-files.ui
index 9d27f2f..c0e05f0 100644
--- a/plugins/files/resources/view-files.ui
+++ b/plugins/files/resources/view-files.ui
@@ -26,9 +26,15 @@
<property name="sizing">autosize</property>
<property name="title" translatable="yes">column</property>
<child>
+ <object class="GtkCellRendererPixbuf" id="cell_renderer_icon"/>
+ <attributes>
+ <attribute name="gicon">0</attribute>
+ </attributes>
+ </child>
+ <child>
<object class="GtkCellRendererText" id="cell_renderer_name"/>
<attributes>
- <attribute name="text">0</attribute>
+ <attribute name="text">1</attribute>
</attributes>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]