[gitg] Show ahead/behind in refs list
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Show ahead/behind in refs list
- Date: Sat, 22 Aug 2015 12:23:19 +0000 (UTC)
commit 316d46c3cec7822168d08b7902cbf8c73027b5d6
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sat Aug 22 14:06:11 2015 +0200
Show ahead/behind in refs list
gitg/history/gitg-history-refs-list.vala | 37 +++++++++++++++++++++++++++++
gitg/resources/ui/gitg-history-ref-row.ui | 16 +++++++++++-
2 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index a0249d9..25073c4 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -66,6 +66,9 @@ private class RefRow : RefTyped, Gtk.ListBoxRow
private Gtk.Label d_label;
[GtkChild]
+ private Gtk.Label d_ahead_behind;
+
+ [GtkChild]
private Gtk.Box d_box;
[GtkChild]
@@ -138,6 +141,40 @@ private class RefRow : RefTyped, Gtk.ListBoxRow
}
d_revealer.notify["child-revealed"].connect(on_child_revealed);
+
+ if (reference != null && reference.is_branch())
+ {
+ var branch = reference as Gitg.Branch;
+
+ try
+ {
+ var upstream = branch.get_upstream();
+
+ size_t ahead = 0;
+ size_t behind = 0;
+
+ reference.get_owner().get_ahead_behind(reference.resolve().get_target(),
+ upstream.resolve().get_target(),
+ out ahead,
+ out behind);
+
+ if (ahead != 0 || behind != 0)
+ {
+ if (ahead != 0 && behind != 0)
+ {
+ d_ahead_behind.label = _("%d ahead, %d behind").printf(ahead,
behind);
+ }
+ else if (ahead != 0)
+ {
+ d_ahead_behind.label = _("%d ahead").printf(ahead);
+ }
+ else
+ {
+ d_ahead_behind.label = _("%d behind").printf(behind);
+ }
+ }
+ } catch {}
+ }
}
public Ggit.Signature? updated
diff --git a/gitg/resources/ui/gitg-history-ref-row.ui b/gitg/resources/ui/gitg-history-ref-row.ui
index da434d2..14c4ef2 100644
--- a/gitg/resources/ui/gitg-history-ref-row.ui
+++ b/gitg/resources/ui/gitg-history-ref-row.ui
@@ -21,7 +21,7 @@
<property name="margin_start">18</property>
<property name="margin_top">3</property>
<property name="margin_bottom">3</property>
- <property name="margin_end">3</property>
+ <property name="margin_end">6</property>
<child>
<object class="GtkImage" id="d_icon">
<property name="icon_size">1</property>
@@ -32,6 +32,20 @@
<property name="visible">True</property>
<property name="ellipsize">middle</property>
<property name="halign">start</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="d_ahead_behind">
+ <property name="visible">True</property>
+ <property name="halign">end</property>
+ <property name="ellipsize">middle</property>
+ <attributes>
+ <attribute name="scale" value="0.8333333333333"/>
+ </attributes>
+ <style>
+ <class name="dim-label"/>
+ </style>
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]