[gitg/vala] Add most basic history view support
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Add most basic history view support
- Date: Sun, 15 Apr 2012 12:59:16 +0000 (UTC)
commit 7ed1ba943d133d02cda9c4561c9ba8424a2f9a84
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Sun Apr 15 14:58:01 2012 +0200
Add most basic history view support
plugins/history/Makefile.am | 9 ++--
plugins/history/gitg-history.vala | 35 ++++++++++++++-
plugins/history/resources/view-history.ui | 71 +++++++++++++++++++++++++++++
3 files changed, 109 insertions(+), 6 deletions(-)
---
diff --git a/plugins/history/Makefile.am b/plugins/history/Makefile.am
index 099c165..e6fc558 100644
--- a/plugins/history/Makefile.am
+++ b/plugins/history/Makefile.am
@@ -12,20 +12,19 @@ plugin_DATA = history.plugin
VALAFLAGS = $(GITG_PLUGIN_VALAFLAGS)
VALA_SOURCES = \
- gitg-history.vala \
+ gitg-history.vala \
gitg-history-navigation.vala
libhistory_la_LDFLAGS = $(GITG_PLUGIN_LIBTOOL_FLAGS)
-
libhistory_la_LIBADD = $(GITG_PLUGIN_LIBS)
libhistory_la_CFLAGS = -w
-libhistory_la_SOURCES = \
+libhistory_la_SOURCES = \
$(VALA_SOURCES) \
gitg-history-resources.c
-BUILT_SOURCES = \
- gitg-history-resources.c \
+BUILT_SOURCES = \
+ gitg-history-resources.c \
gitg-history-resources.h
gitg-history-resources.c: resources/resources.xml $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies --sourcedir $(srcdir)/resources resources/resources.xml)
diff --git a/plugins/history/gitg-history.vala b/plugins/history/gitg-history.vala
index 8a03455..b927b8c 100644
--- a/plugins/history/gitg-history.vala
+++ b/plugins/history/gitg-history.vala
@@ -7,6 +7,9 @@ namespace GitgHistory
{
public GitgExt.Application? application { owned get; construct; }
+ private Gtk.TreeView d_view;
+ private GitgGtk.CommitModel? d_model;
+
private Gtk.Widget d_main;
public string id
@@ -14,6 +17,12 @@ namespace GitgHistory
owned get { return "/org/gnome/gitg/Views/History"; }
}
+ construct
+ {
+ d_model = new GitgGtk.CommitModel(application.repository);
+ application.bind_property("repository", d_model, "repository", BindingFlags.DEFAULT);
+ }
+
public bool is_available()
{
// The history view is available only when there is a repository
@@ -60,11 +69,35 @@ namespace GitgHistory
private void build_ui()
{
- var ret = from_builder("view-history.ui", {"view"});
+ var ret = from_builder("view-history.ui", {"view", "commit_list_view"});
+ d_view = ret["commit_list_view"] as Gtk.TreeView;
+ d_view.model = d_model;
+
+ update_walker(null);
d_main = ret["view"] as Gtk.Widget;
}
+ private void update_walker(Ggit.Ref? head)
+ {
+ Ggit.Ref? th = head;
+
+ if (th == null && application.repository != null)
+ {
+ try
+ {
+ th = application.repository.get_head();
+ } catch {}
+ }
+
+ if (th != null)
+ {
+ d_model.set_include(new Ggit.OId[] { th.get_id() });
+ }
+
+ d_model.reload();
+ }
+
private Gee.HashMap<string, Object>? from_builder(string path, string[] ids)
{
var builder = new Gtk.Builder();
diff --git a/plugins/history/resources/view-history.ui b/plugins/history/resources/view-history.ui
index c725a0d..a8ac5d3 100644
--- a/plugins/history/resources/view-history.ui
+++ b/plugins/history/resources/view-history.ui
@@ -7,6 +7,77 @@
<property name="vexpand">True</property>
<property name="hexpand">True</property>
<property name="orientation">vertical</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled_window_commit_list">
+ <property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow-type">etched-in</property>
+ <child>
+ <object class="GtkTreeView" id="commit_list_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="rules_hint">True</property>
+ <property name="fixed-height-mode">True</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="column_commit_list_subject">
+ <property name="title" translatable="yes">Subject</property>
+ <property name="sizing">fixed</property>
+ <property name="resizable">True</property>
+ <property name="fixed-width">400</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer_commit_list_subject">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="column_commit_list_author">
+ <property name="title" translatable="yes">Author</property>
+ <property name="sizing">fixed</property>
+ <property name="resizable">True</property>
+ <property name="fixed-width">200</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer_commit_list_author">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="text">4</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="column_commit_list_date">
+ <property name="title" translatable="yes">Date</property>
+ <property name="sizing">fixed</property>
+ <property name="resizable">True</property>
+ <property name="fixed-width">150</property>
+ <child>
+ <object class="GtkCellRendererText" id="renderer_commit_list_date">
+ <property name="ellipsize">end</property>
+ </object>
+ <attributes>
+ <attribute name="text">6</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]