[gitg] Add infobar



commit a5972bd72c9f7ce495bdbc0c61f0e9262c519afe
Author: Sindhu S <sindhus live in>
Date:   Fri Jun 21 00:26:18 2013 +0530

    Add infobar
    
    Add infobar and route silent failure from opening non-git repository
    directories to infobar.

 gitg/gitg-window.vala            |   28 ++++++++++++++++-
 gitg/resources/ui/gitg-window.ui |   60 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 85 insertions(+), 3 deletions(-)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 649ed78..1191805 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -64,6 +64,15 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
        [GtkChild]
        private Gtk.Stack d_stack_view;
 
+       [GtkChild]
+       private Gtk.InfoBar infobar;
+       [GtkChild]
+       private Gtk.Label infobar_primary_label;
+       [GtkChild]
+       private Gtk.Label infobar_secondary_label;
+       [GtkChild]
+       private Gtk.Button infobar_close_button;
+
        private static const ActionEntry[] win_entries = {
                {"search", on_search_activated, null, "false", null},
                {"gear-menu", on_gear_menu_activated, null, "false", null},
@@ -208,6 +217,7 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                                        parent_path = parent_path.replace(Environment.get_home_dir(), "~");
                                }
                                title = @"$(d_repository.name) ($parent_path) - gitg";
+                               infobar.hide();
                        }
 
                        d_header_bar.set_title(d_repository.name);
@@ -667,9 +677,11 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
                {
                        repo = Ggit.Repository.discover(path);
                }
-               catch
+               catch (Error e)
                {
-                       // TODO: make error thingie
+                       string repo_name = path.get_basename();
+                       var primary_msg = ("\"%s\" is not a Git repository!").printf(repo_name);
+                       show_infobar(primary_msg, e.message, Gtk.MessageType.WARNING);
                        return;
                }
 
@@ -681,6 +693,18 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
 
                this.repository = repository;
        }
+
+       private void show_infobar(string primary_msg, string secondary_msg, Gtk.MessageType type)
+       {
+               infobar.message_type = type;
+               infobar_primary_label.set_label ("<b>%s</b>".printf (Markup.escape_text(primary_msg)));
+               infobar_secondary_label.set_label ("<small>%s</small>".printf 
(Markup.escape_text(secondary_msg)));
+               infobar.show ();
+
+               infobar_close_button.clicked.connect (() => {
+                       infobar.hide ();
+               });
+       }
 }
 
 }
diff --git a/gitg/resources/ui/gitg-window.ui b/gitg/resources/ui/gitg-window.ui
index b6b2c3a..da2e105 100644
--- a/gitg/resources/ui/gitg-window.ui
+++ b/gitg/resources/ui/gitg-window.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+`<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.3 -->
   <!-- interface-requires gitg 0.0 -->
@@ -122,6 +122,64 @@
       <object class="GtkGrid" id="grid1">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
+         <child>
+          <object class="GtkInfoBar" id="infobar">
+             <property name="visible">False</property>
+             <child internal-child="content_area">
+               <object class="GtkBox" id="infobar_content_area">
+                 <property name="visible">True</property>
+                 <property name="can_focus">False</property>
+                 <property name="border_width">8</property>
+                 <property name="orientation">vertical</property>
+                 <property name="spacing">16</property>
+                 <child>
+                   <object class="GtkLabel" id="infobar_primary_label">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="selectable">True</property>
+                     <property name="use-markup">True</property>
+                     <property name="halign">GTK_ALIGN_START</property>
+                   </object>
+                   <packing>
+                     <property name="expand">False</property>
+                     <property name="fill">True</property>
+                     <property name="position">0</property>
+                   </packing>
+                 </child>
+                 <child>
+                   <object class="GtkLabel" id="infobar_secondary_label">
+                     <property name="visible">True</property>
+                     <property name="can_focus">True</property>
+                     <property name="selectable">True</property>
+                     <property name="use-markup">True</property>
+                     <property name="halign">GTK_ALIGN_START</property>
+                   </object>
+                   <packing>
+                     <property name="expand">False</property>
+                     <property name="fill">True</property>
+                     <property name="position">1</property>
+                   </packing>
+                 </child>
+                 <child internal-child="action_area">
+                   <object class="GtkButtonBox" id="infobar_action_area">
+                     <property name="visible">True</property>
+                     <property name="can_focus">False</property>
+                     <property name="border_width">5</property>
+                     <property name="orientation">vertical</property>
+                     <property name="spacing">6</property>
+                     <property name="layout_style">end</property>
+                 <child>
+                   <object class="GtkButton" id="infobar_close_button">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Close</property>
+                    </object>
+                 </child>
+                   </object>
+                 </child>
+               </object>
+            </child>
+          </object>
+         </child>
         <child>
           <object class="GtkSearchBar" id="d_search_bar">
             <property name="visible">True</property>


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