[gitg] Show repository directory in dash



commit f8362fa2a89d501f86cd0ef71a3b5e994662d273
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Aug 9 18:09:40 2015 +0200

    Show repository directory in dash

 gitg/gitg-dash-view.vala                           |    2 +-
 libgitg/gitg-repository-list-box.vala              |   51 ++++++++++++++++---
 .../resources/ui/gitg-repository-list-box-row.ui   |    7 +++
 3 files changed, 51 insertions(+), 9 deletions(-)
---
diff --git a/gitg/gitg-dash-view.vala b/gitg/gitg-dash-view.vala
index 87bedc1..18089fb 100644
--- a/gitg/gitg-dash-view.vala
+++ b/gitg/gitg-dash-view.vala
@@ -381,7 +381,7 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
                var subfolder = location.resolve_relative_path(subfolder_name);
 
                // Clone
-               var row = d_repository_list_box.begin_cloning(subfolder_name);
+               var row = d_repository_list_box.begin_cloning(subfolder);
 
                clone.begin(row, url, subfolder, is_bare, (obj, res) => {
                        Gitg.Repository? repository = null;
diff --git a/libgitg/gitg-repository-list-box.vala b/libgitg/gitg-repository-list-box.vala
index 4b985f1..51644d3 100644
--- a/libgitg/gitg-repository-list-box.vala
+++ b/libgitg/gitg-repository-list-box.vala
@@ -61,6 +61,8 @@ namespace Gitg
                        public signal void request_remove();
 
                        private SelectionMode d_mode;
+                       private string? d_dirname;
+                       private string? d_branch_name;
 
                        private static Gtk.IconSize s_icon_size;
 
@@ -142,13 +144,45 @@ namespace Gitg
                        public string? repository_name
                        {
                                get { return d_repository_label.get_text(); }
-                               set { d_repository_label.set_markup("<b>%s</b>".printf(value)); }
+                               set { d_repository_label.label = value; }
+                       }
+
+                       public string? dirname
+                       {
+                               get { return d_dirname; }
+                               set
+                               {
+                                       d_dirname = value;
+                                       update_branch_label();
+                               }
                        }
 
                        public string? branch_name
                        {
-                               get { return d_branch_label.get_text(); }
-                               set { d_branch_label.set_markup("<small>%s</small>".printf(value)); }
+                               get { return d_branch_name; }
+                               set
+                               {
+                                       d_branch_name = value;
+                                       update_branch_label();
+                               }
+                       }
+
+                       private void update_branch_label()
+                       {
+                               if (d_branch_name == null || d_branch_name == "")
+                               {
+                                       // Translators: this is used to construct: "at <directory>", to 
indicate where the repository is at.
+                                       d_branch_label.label = _("at %s").printf(d_dirname);
+                               }
+                               else if (d_dirname == null || d_dirname == "")
+                               {
+                                       d_branch_label.label = d_branch_name;
+                               }
+                               else
+                               {
+                                       // Translators: this is used to construct: "<branch-name> at 
<directory>"
+                                       d_branch_label.label = _("%s at %s").printf(d_branch_name, d_dirname);
+                               }
                        }
 
                        public bool loading
@@ -186,9 +220,9 @@ namespace Gitg
                                }
                        }
 
-                       public Row(string name, string branch_name, bool has_remote)
+                       public Row(string name, string dirname, string branch_name, bool has_remote)
                        {
-                               Object(repository_name: name, branch_name: branch_name, has_remote: 
has_remote);
+                               Object(repository_name: name, dirname: dirname, branch_name: branch_name, 
has_remote: has_remote);
                        }
 
                        public void add_submodule(Ggit.Submodule module)
@@ -400,9 +434,9 @@ namespace Gitg
                        }
                }
 
-               public Row? begin_cloning(string name)
+               public Row? begin_cloning(File location)
                {
-                       var row = new Row(name, _("Cloning..."), true);
+                       var row = new Row(location.get_basename(), 
Utils.replace_home_dir_with_tilde(location.get_parent()), _("Cloning..."), true);
 
                        row.loading = true;
                        row.show();
@@ -434,7 +468,8 @@ namespace Gitg
                                }
                                catch {}
 
-                               row = new Row(repository.name, head_name, has_remote);
+                               var dirname = Utils.replace_home_dir_with_tilde((repository.workdir != null ? 
repository.workdir : repository.location).get_parent());
+                               row = new Row(repository.name, dirname, head_name, has_remote);
                                row.repository = repository;
                                row.show();
 
diff --git a/libgitg/resources/ui/gitg-repository-list-box-row.ui 
b/libgitg/resources/ui/gitg-repository-list-box-row.ui
index 4f06a5e..635194f 100644
--- a/libgitg/resources/ui/gitg-repository-list-box-row.ui
+++ b/libgitg/resources/ui/gitg-repository-list-box-row.ui
@@ -17,6 +17,7 @@
             <property name="margin_top">12</property>
             <property name="margin_bottom">12</property>
             <property name="column_spacing">10</property>
+            <property name="hexpand">True</property>
             <child>
               <object class="GtkRevealer" id="d_remove_revealer">
                 <property name="visible">True</property>
@@ -68,6 +69,9 @@
                 <property name="valign">end</property>
                 <property name="hexpand">True</property>
                 <property name="ellipsize">end</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                </attributes>
               </object>
               <packing>
                 <property name="left_attach">2</property>
@@ -85,6 +89,9 @@
                 <property name="halign">start</property>
                 <property name="valign">start</property>
                 <property name="ellipsize">end</property>
+                <attributes>
+                  <attribute name="scale" value="0.833"/>
+                </attributes>
                 <style>
                   <class name="dim-label"/>
                 </style>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]