[gitg/wip/fetch: 7/9] Implement remote state tracking
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/fetch: 7/9] Implement remote state tracking
- Date: Tue, 23 Dec 2014 17:37:54 +0000 (UTC)
commit 3050c5135965cdf0a3a8fddbe9403cfe607c076d
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Tue Dec 23 17:41:32 2014 +0100
Implement remote state tracking
gitg/history/gitg-history-refs-list.vala | 95 +++++++++++++++++++++++++-
gitg/history/gitg-history.vala | 2 +
gitg/resources/ui/gitg-history-ref-header.ui | 29 +++++++--
gitg/resources/ui/style.css | 10 +++-
4 files changed, 128 insertions(+), 8 deletions(-)
---
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index 893bee6..ee5e4d2 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -323,9 +323,39 @@ private class RefHeader : RefTyped, Gtk.ListBoxRow
private bool d_is_sub_header_remote;
private string d_name;
+ public Gitg.RemoteState remote_state
+ {
+ set
+ {
+ switch (value)
+ {
+ case Gitg.RemoteState.DISCONNECTED:
+ icon_name = null;
+ break;
+ case Gitg.RemoteState.CONNECTING:
+ icon_name = "network-wireless-acquiring-symbolic";
+ break;
+ case Gitg.RemoteState.CONNECTED:
+ icon_name = "network-idle-symbolic";
+ break;
+ case Gitg.RemoteState.TRANSFERRING:
+ icon_name = "network-transmit-receive-symbolic";
+ break;
+ }
+ }
+ }
+
+ private Gitg.Remote? d_remote;
+
+ [GtkChild]
+ private Gitg.ProgressBin d_progress_bin;
+
[GtkChild]
private Gtk.Label d_label;
+ [GtkChild]
+ private Gtk.Image d_icon;
+
public Gitg.RefType ref_type
{
get { return d_rtype; }
@@ -346,12 +376,19 @@ private class RefHeader : RefTyped, Gtk.ListBoxRow
d_rtype = rtype;
}
- public RefHeader.remote(string name)
+ public RefHeader.remote(string name, Gitg.Remote? remote)
{
this(Gitg.RefType.REMOTE, name);
+ d_remote = remote;
d_is_sub_header_remote = true;
d_label.margin_start += 12;
+
+ if (d_remote != null)
+ {
+ d_remote.bind_property("state", this, "remote_state");
+ d_remote.bind_property("transfer-progress", d_progress_bin, "fraction");
+ }
}
public bool is_sub_header_remote
@@ -369,6 +406,16 @@ private class RefHeader : RefTyped, Gtk.ListBoxRow
return d_name.casefold().collate(other.d_name.casefold());
}
+
+ public string? icon_name
+ {
+ owned get { return d_icon.icon_name; }
+ set
+ {
+ d_icon.icon_name = value;
+ d_icon.visible = (value != null);
+ }
+ }
}
public class RefsList : Gtk.ListBox
@@ -376,6 +423,7 @@ public class RefsList : Gtk.ListBox
private Gitg.Repository? d_repository;
private Gee.HashMap<Gitg.Ref, RefRow> d_ref_map;
private Gtk.ListBoxRow? d_selected_row;
+ private Gitg.Remote[] d_remotes;
private class RemoteHeader
{
@@ -391,6 +439,8 @@ public class RefsList : Gtk.ListBox
private Gee.HashMap<string, RemoteHeader> d_header_map;
+ public GitgExt.RemoteLookup? remote_lookup { get; set; }
+
public Gitg.Repository? repository
{
get { return d_repository; }
@@ -404,11 +454,24 @@ public class RefsList : Gtk.ListBox
}
}
+ protected override void dispose()
+ {
+ foreach (var remote in d_remotes)
+ {
+ remote.tip_updated.disconnect(on_tip_updated);
+ }
+
+ d_remotes = new Gitg.Remote[0];
+
+ base.dispose();
+ }
+
construct
{
d_header_map = new Gee.HashMap<string, RemoteHeader>();
d_ref_map = new Gee.HashMap<Gitg.Ref, RefRow>();
selection_mode = Gtk.SelectionMode.BROWSE;
+ d_remotes = new Gitg.Remote[0];
set_sort_func(sort_rows);
}
@@ -470,6 +533,13 @@ public class RefsList : Gtk.ListBox
{
child.destroy();
}
+
+ foreach (var remote in d_remotes)
+ {
+ remote.tip_updated.disconnect(on_tip_updated);
+ }
+
+ d_remotes = new Gitg.Remote[0];
}
private void reselect_row(Gtk.ListBoxRow a)
@@ -534,9 +604,30 @@ public class RefsList : Gtk.ListBox
add(header);
}
+ private void on_tip_updated(Ggit.Remote remote,
+ string refname,
+ Ggit.OId a,
+ Ggit.OId b)
+ {
+ stdout.printf("remote tip updated: %s, %s, %s\n", refname, a.to_string()[0:6],
b.to_string()[0:6]);
+ }
+
private RefHeader add_remote_header(string name)
{
- var header = new RefHeader.remote(name);
+ Gitg.Remote? remote = null;
+
+ if (remote_lookup != null)
+ {
+ remote = remote_lookup.lookup(name);
+ }
+
+ if (remote != null)
+ {
+ d_remotes += remote;
+ remote.tip_updated.connect(on_tip_updated);
+ }
+
+ var header = new RefHeader.remote(name, remote);
header.show();
d_header_map[name] = new RemoteHeader(header);
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 1a7f36f..86c1394 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -447,6 +447,8 @@ namespace GitgHistory
{
d_main = new Paned();
+ d_main.refs_list.remote_lookup = application.remote_lookup;
+
d_main.commit_list_view.model = d_commit_list_model;
d_main.commit_list_view.get_selection().changed.connect((sel) => {
diff --git a/gitg/resources/ui/gitg-history-ref-header.ui b/gitg/resources/ui/gitg-history-ref-header.ui
index ddd3cdf..6915dbe 100644
--- a/gitg/resources/ui/gitg-history-ref-header.ui
+++ b/gitg/resources/ui/gitg-history-ref-header.ui
@@ -9,12 +9,31 @@
<class name="sidebar"/>
</style>
<child>
- <object class="GtkLabel" id="d_label">
+ <object class="GitgProgressBin" id="d_progress_bin">
<property name="visible">True</property>
- <property name="margin_top">3</property>
- <property name="margin_bottom">3</property>
- <property name="margin_start">16</property>
- <property name="halign">start</property>
+ <child>
+ <object class="GtkBox" id="d_box">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="d_label">
+ <property name="visible">True</property>
+ <property name="margin_top">3</property>
+ <property name="margin_bottom">3</property>
+ <property name="margin_start">16</property>
+ <property name="halign">start</property>
+ <property name="hexpand">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage" id="d_icon">
+ <property name="visible">False</property>
+ <property name="halign">end</property>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/gitg/resources/ui/style.css b/gitg/resources/ui/style.css
index 101caac..dea9390 100644
--- a/gitg/resources/ui/style.css
+++ b/gitg/resources/ui/style.css
@@ -89,6 +89,14 @@ GitgHistoryPaned GtkEntry.ref_editing_entry:selected {
background-color: shade (@theme_bg_color, 0.9);
}
+.list-row .progress-bin {
+ background-color: shade (@theme_base_color, 0.9);
+}
+
+.list-row:selected .progress-bin {
+ background-color: shade (@theme_selected_bg_color, 1.2);
+}
+
.branch, .remote, .tag, .stash {
border-radius: 6px;
border: 1px solid @theme_bg_color;
@@ -133,4 +141,4 @@ GitgHistoryRefRow {
font-size: 0.8em;
color: @insensitive_fg_color;
font-family: monospace;
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]