[gnome-maps/wip/routing: 1/2] Add infobar



commit ccbbf8689cd8d1d43a59b5428dbdd86148b6b6a6
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Tue Feb 4 13:50:46 2014 +0100

    Add infobar

 src/gnome-maps.data.gresource.xml |    1 +
 src/gnome-maps.js.gresource.xml   |    1 +
 src/infobar.js                    |   62 +++++++++++++++++++++++++++++++++++++
 src/infobar.ui                    |   36 +++++++++++++++++++++
 src/mainWindow.js                 |    4 ++
 5 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index d30b5eb..b23c9c7 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -7,6 +7,7 @@
     <file preprocess="xml-stripblanks">search-popup.ui</file>
     <file preprocess="xml-stripblanks">context-menu.ui</file>
     <file preprocess="xml-stripblanks">map-location.ui</file>
+    <file preprocess="xml-stripblanks">infobar.ui</file>
     <file alias="application.css">../data/gnome-maps.css</file>
     <file alias="zoom-in.png">../data/media/zoom-in.png</file>
     <file alias="zoom-out.png">../data/media/zoom-out.png</file>
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index 4294679..07e88b1 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -6,6 +6,7 @@
     <file>contextMenu.js</file>
     <file>geoclue.js</file>
     <file>http.js</file>
+    <file>infobar.js</file>
     <file>main.js</file>
     <file>mainWindow.js</file>
     <file>mapLocation.js</file>
diff --git a/src/infobar.js b/src/infobar.js
new file mode 100644
index 0000000..f10cbf0
--- /dev/null
+++ b/src/infobar.js
@@ -0,0 +1,62 @@
+/* -*- Mode: JS2; indent-tabs-mode: nil; js2-basic-offset: 4 -*- */
+/* vim: set et ts=4 sw=4: */
+/*
+ * GNOME Maps 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.
+ *
+ * GNOME Maps 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 GNOME Maps; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Jonas Danielsson <jonas threetimestwo org>
+ */
+
+const Lang = imports.lang;
+
+const Gtk = imports.gi.Gtk;
+const Utils = imports.utils;
+
+const Infobar = new Lang.Class({
+    Name: 'Infobar',
+    Extends: Gtk.Bin,
+
+    _init: function () {
+        this.parent({ visible: false,
+                      no_show_all: true });
+
+        let ui = Utils.getUIObject('infobar', ['infobar',
+                                               'infobar-button',
+                                               'infobar-label']);
+        this._infobar = ui.infobar;
+        this._label = ui.infobarLabel;
+
+        ui.infobarButton.connect('clicked', this.hide.bind(this));
+
+        this.add(this._infobar);
+    },
+
+    showError: function(msg) {
+        this._infobar.message_type = Gtk.MessageType.ERROR;
+        this._label.set_text(msg);
+        this.show();
+    },
+
+    showWarning: function(msg) {
+        this._infobar.message_type = Gtk.MessageType.WARNING;
+        this._label.set_text(msg);
+        this.show();
+    },
+
+    showInfo: function(msg) {
+        this._infobar.message_type = Gtk.MessageType.INFO;
+        this._label.set_text(msg);
+        this.show();
+    }
+});
diff --git a/src/infobar.ui b/src/infobar.ui
new file mode 100644
index 0000000..fb96b30
--- /dev/null
+++ b/src/infobar.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.10 -->
+  <object class="GtkInfoBar" id="infobar">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child internal-child="action_area">
+      <object class="GtkButtonBox" id="infobar-action_area">
+        <property name="can_focus">False</property>
+        <property name="spacing">6</property>
+        <property name="layout_style">end</property>
+        <child>
+          <object class="GtkButton" id="infobar-button">
+            <property name="label" translatable="yes">Ok</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">True</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child internal-child="content_area">
+      <object class="GtkBox" id="infobar-content_area">
+        <property name="can_focus">False</property>
+        <property name="spacing">16</property>
+        <child>
+          <object class="GtkLabel" id="infobar-label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes"></property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index dfcab1d..cd93359 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -58,6 +58,7 @@ const MainWindow = new Lang.Class({
         this.window = ui.appWindow;
         this.window.application = app;
 
+        this._infobar = new Infobar.Infobar();
         this._mapOverlay = new Gtk.Overlay({ visible: true });
         this.mapView = new MapView.MapView(this._mapOverlay);
         this._mapOverlay.add(this.mapView);
@@ -72,6 +73,9 @@ const MainWindow = new Lang.Class({
         this._initSignals();
         this._restoreWindowGeometry();
 
+        this._mapOverlay.add_overlay(this._sidebar);
+
+        grid.add(this._infobar);
         grid.add(this._mapOverlay);
 
         grid.show_all();


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