mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-08-27 20:09:23 +00:00
Add most basic history view support
This commit is contained in:
parent
eb586c855c
commit
7ed1ba943d
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue