[gitg] Create link to setup user profile from introduction



commit 094bbaa75c4d51e26af32bd7126db289602db8d0
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Fri Aug 7 13:28:58 2015 +0200

    Create link to setup user profile from introduction
    
    The link is only made available if the user has not yet setup any
    global user information, i.e. no name or e-mail configured.

 gitg/gitg-dash-view.vala            |   32 ++++++++++++++++++++++++++++++++
 gitg/resources/ui/gitg-dash-view.ui |   26 ++++++++++++++++++++++++--
 2 files changed, 56 insertions(+), 2 deletions(-)
---
diff --git a/gitg/gitg-dash-view.vala b/gitg/gitg-dash-view.vala
index df76d24..ae30075 100644
--- a/gitg/gitg-dash-view.vala
+++ b/gitg/gitg-dash-view.vala
@@ -33,6 +33,9 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
        [GtkChild( name = "introduction" )]
        private Gtk.Grid d_introduction;
 
+       [GtkChild( name = "label_profile") ]
+       private Gtk.Label d_label_profile;
+
        [GtkChild( name = "scrolled_window" )]
        private Gtk.ScrolledWindow d_scrolled_window;
 
@@ -236,6 +239,35 @@ class DashView : Gtk.Grid, GitgExt.UIElement, GitgExt.Activity, GitgExt.Selectab
 
                d_repository_list_box.add.connect(update_availability);
                d_repository_list_box.remove.connect(update_availability);
+
+               // Translators: the two %s will be used to create a link to the author dialog.
+               d_label_profile.label = _("In the mean time, you may want to %sset up your git 
profile%s.").printf("<a href=\"setup-profile\">", "</a>");
+               update_setup_profile_visibility();
+       }
+
+       private void update_setup_profile_visibility()
+       {
+               try
+               {
+                       var config = new Ggit.Config.default().snapshot();
+                       var author_name = config.get_string("user.name");
+                       var author_email = config.get_string("user.email");
+
+                       if (author_name != "" && author_email != "")
+                       {
+                               d_label_profile.visible = false;
+                               return;
+                       }
+               } catch {}
+
+               d_label_profile.visible = true;
+       }
+
+       [GtkCallback]
+       private bool setup_profile_activated()
+       {
+               AuthorDetailsDialog.show_global(application as Window);
+               return true;
        }
 
        private void update_availability()
diff --git a/gitg/resources/ui/gitg-dash-view.ui b/gitg/resources/ui/gitg-dash-view.ui
index 2fe5f45..b47e76e 100644
--- a/gitg/resources/ui/gitg-dash-view.ui
+++ b/gitg/resources/ui/gitg-dash-view.ui
@@ -6,6 +6,7 @@
       <object class="GtkGrid" id="introduction">
         <property name="visible">False</property>
         <property name="column-spacing">12</property>
+        <property name="row-spacing">12</property>
         <property name="valign">center</property>
         <property name="halign">center</property>
         <property name="hexpand">True</property>
@@ -24,7 +25,7 @@
             <property name="left_attach">0</property>
             <property name="top_attach">0</property>
             <property name="width">1</property>
-            <property name="height">1</property>
+            <property name="height">2</property>
           </packing>
         </child>
         <child>
@@ -38,7 +39,7 @@
             <property name="vexpand">True</property>
             <property name="wrap">True</property>
             <property name="xalign">0</property>
-            <property name="max-width-chars">30</property>
+            <property name="max-width-chars">40</property>
           </object>
           <packing>
             <property name="left_attach">1</property>
@@ -47,6 +48,27 @@
             <property name="height">1</property>
           </packing>
         </child>
+        <child>
+          <object class="GtkLabel" id="label_profile">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="valign">start</property>
+            <property name="hexpand">False</property>
+            <property name="vexpand">True</property>
+            <property name="wrap">True</property>
+            <property name="xalign">0</property>
+            <property name="max_width_chars">40</property>
+            <property name="use_markup">True</property>
+            <signal name="activate-link" handler="setup_profile_activated" swapped="no"/>
+          </object>
+          <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">1</property>
+            <property name="width">1</property>
+            <property name="height">1</property>
+          </packing>
+        </child>
       </object>
       <packing>
         <property name="left_attach">0</property>


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