[gitg/wip/actions: 10/26] Generalize info bar to user query



commit ad93f2cf771f1ab73559de9247b8eb8dda333791
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sun Jan 19 19:13:23 2014 +0100

    Generalize info bar to user query

 gitg/Makefile.am                   |    1 +
 gitg/gitg-info-bar.vala            |   64 ++++++++++++++++++++++++++++++++++++
 gitg/gitg-window.vala              |    8 ++--
 gitg/resources/gitg-resources.xml  |    1 +
 gitg/resources/ui/gitg-info-bar.ui |   44 ++++++++++++++++++++++++
 5 files changed, 114 insertions(+), 4 deletions(-)
---
diff --git a/gitg/Makefile.am b/gitg/Makefile.am
index c2e4540..d5c6a31 100644
--- a/gitg/Makefile.am
+++ b/gitg/Makefile.am
@@ -53,6 +53,7 @@ gitg_gitg_VALASOURCES =                                               \
        gitg/gitg-window.vala                                   \
        gitg/gitg-clone-dialog.vala                             \
        gitg/gitg-author-details-dialog.vala                    \
+       gitg/gitg-info-bar.vala                                 \
        gitg/gitg-resource.vala                                 \
        gitg/gitg-application.vala                              \
        gitg/gitg-plugins-engine.vala                           \
diff --git a/gitg/gitg-info-bar.vala b/gitg/gitg-info-bar.vala
new file mode 100644
index 0000000..e09d714
--- /dev/null
+++ b/gitg/gitg-info-bar.vala
@@ -0,0 +1,64 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2014 - Jesse van den Kieboom
+ *
+ * gitg is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * gitg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Gitg
+{
+
+[GtkTemplate (ui = "/org/gnome/gitg/ui/gitg-info-bar.ui")]
+class InfoBar : Gtk.InfoBar
+{
+       [GtkChild]
+       private Gtk.Label d_title_label;
+
+       [GtkChild]
+       private Gtk.Label d_message_label;
+
+       private string d_title;
+       private string d_message;
+
+       public string title
+       {
+               get { return d_title; }
+               set
+               {
+                       d_title = value;
+
+                       var escaped = Markup.escape_text(d_title);
+                       d_title_label.set_markup(@"<b>$escaped</b>");
+               }
+       }
+
+       public string message
+       {
+               get { return d_message; }
+               set
+               {
+                       d_message = value;
+
+                       var escaped = Markup.escape_text(d_message);
+
+                       d_message_label.set_markup(@"<small>$escaped</small>");
+               }
+       }
+
+}
+
+}
+
+// ex:ts=4 noet
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 7f71a02..9116132 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -123,9 +123,9 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, GitgExt.Action
        }
 
        [GtkCallback]
-       private void dash_view_show_error(string primary_msg, string secondary_message)
+       private void dash_view_show_error(string title, string message)
        {
-               show_infobar(primary_msg, secondary_message, Gtk.MessageType.ERROR);
+               show_infobar(title, message, Gtk.MessageType.ERROR);
        }
 
        construct
@@ -542,8 +542,8 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, GitgExt.Action
                {
                        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);
+                       var title = _("'%s' is not a Git repository.").printf(repo_name);
+                       show_infobar(title, e.message, Gtk.MessageType.WARNING);
 
                        return;
                }
diff --git a/gitg/resources/gitg-resources.xml b/gitg/resources/gitg-resources.xml
index f913934..eefd833 100644
--- a/gitg/resources/gitg-resources.xml
+++ b/gitg/resources/gitg-resources.xml
@@ -2,6 +2,7 @@
 <gresources>
   <gresource prefix="/org/gnome/gitg">
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-window.ui</file>
+    <file compressed="true" preprocess="xml-stripblanks">ui/gitg-info-bar.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-menus.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences-history.ui</file>
     <file compressed="true" preprocess="xml-stripblanks">ui/gitg-preferences-commit.ui</file>
diff --git a/gitg/resources/ui/gitg-info-bar.ui b/gitg/resources/ui/gitg-info-bar.ui
new file mode 100644
index 0000000..32df547
--- /dev/null
+++ b/gitg/resources/ui/gitg-info-bar.ui
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.3 -->
+  <!-- interface-requires gitg 0.0 -->
+  <template class="GitgInfoBar" parent="GtkInfoBar">
+    <child internal-child="content_area">
+      <object class="GtkBox" id="content_area">
+        <property name="visible">True</property>
+        <property name="border_width">8</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">16</property>
+        <child>
+          <object class="GtkLabel" id="d_title_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="d_message_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>
+      </object>
+    </child>
+  </template>
+</interface>
+<!-- vi:ts=2:et -->


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