[gnome-maps/wip/drag-n-drop: 1/4] Add RouteEntry module



commit d5a66d5bd24daaecfd24a7b2b5e2763db592bda5
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Thu Nov 27 07:20:19 2014 -0500

    Add RouteEntry module

 src/gnome-maps.data.gresource.xml |    1 +
 src/gnome-maps.js.gresource.xml   |    1 +
 src/route-entry.js                |   48 +++++++++++++++++++
 src/routeEntry.js                 |   95 +++++++++++++++++++++++++++++++++++++
 4 files changed, 145 insertions(+), 0 deletions(-)
---
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index 0512a79..22c4867 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -12,6 +12,7 @@
     <file preprocess="xml-stripblanks">context-menu.ui</file>
     <file preprocess="xml-stripblanks">layers-popover.ui</file>
     <file preprocess="xml-stripblanks">notification.ui</file>
+    <file preprocess="xml-stripblanks">route-entry.ui</file>
     <file preprocess="xml-stripblanks">route-via-row.ui</file>
     <file preprocess="xml-stripblanks">map-bubble.ui</file>
     <file preprocess="xml-stripblanks">search-result-bubble.ui</file>
diff --git a/src/gnome-maps.js.gresource.xml b/src/gnome-maps.js.gresource.xml
index ce962cc..b06b5da 100644
--- a/src/gnome-maps.js.gresource.xml
+++ b/src/gnome-maps.js.gresource.xml
@@ -26,6 +26,7 @@
     <file>placeListRow.js</file>
     <file>placeStore.js</file>
     <file>route.js</file>
+    <file>routeEntry.js</file>
     <file>routeQuery.js</file>
     <file>routeService.js</file>
     <file>searchPopup.js</file>
diff --git a/src/route-entry.js b/src/route-entry.js
new file mode 100644
index 0000000..8c35d27
--- /dev/null
+++ b/src/route-entry.js
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.10"/>
+  <template class="Gjs_RouteEntry" parent="GtkGrid">
+    <property name="visible">True</property>
+    <property name="orientation">horizontal</property>
+    <property name="hexpand">False</property>
+    <child>
+      <object class="GtkEventBox" id="iconEventBox">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkImage" id="icon">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin-end">8</property>
+            <property name="margin-start">13</property>
+            <property name="width-request">16</property>
+            <property name="icon-name">maps-point-end-symbolic</property>
+          </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkGrid" id="entryGrid">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="hexpand">True</property>
+      </object>
+    </child>
+    <child>
+      <object class="GtkButton" id="button">
+        <property name="visible">False</property>
+        <property name="no_show_all">True</property>
+        <property name="can-focus">True</property>
+        <property name="valign">center</property>
+        <property name="height-request">31</property>
+        <property name="margin-start">4</property>
+        <property name="margin-end">10</property>
+        <child>
+          <object class="GtkImage" id="buttonImage">
+            <property name="visible">True</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/routeEntry.js b/src/routeEntry.js
new file mode 100644
index 0000000..2da6d73
--- /dev/null
+++ b/src/routeEntry.js
@@ -0,0 +1,95 @@
+/* -*- 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 GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const Application = imports.application;
+const PlaceEntry = imports.placeEntry;
+
+const Type = {
+    FROM: 0,
+    TO: 1,
+    VIA: 2
+};
+
+const RouteEntry = new Lang.Class({
+    Name: 'RouteEntry',
+    Extends: Gtk.Grid,
+    Template: 'resource:///org/gnome/maps/route-entry.ui',
+    Children: [ 'iconEventBox' ],
+    InternalChildren: [ 'entryGrid',
+                        'icon',
+                        'button',
+                        'buttonImage' ],
+
+    _init: function(params) {
+        this._type = params.type;
+        delete params.type;
+
+        this._point = params.point || null;
+        delete params.point;
+
+        this._mapView = params.mapView || null;
+        delete params.mapView;
+
+        this.parent(params);
+
+        this.entry = new PlaceEntry.PlaceEntry({ visible: true,
+                                                 can_focus: true,
+                                                 hexpand: true,
+                                                 receives_default: true,
+                                                 mapView: this._mapView,
+                                                 parseOnFocusOut: true,
+                                                 maxChars: 15 });
+        if (this._point) {
+            this.entry.bind_property('place',
+                                     this._point, 'place',
+                                     GObject.BindingFlags.BIDIRECTIONAL);
+        }
+        this._entryGrid.add(this.entry);
+
+        switch(this._type) {
+            case Type.FROM:
+                this._buttonImage.icon_name = 'list-add-symbolic';
+                this._icon.icon_name = 'maps-point-start-symbolic';
+                this._button.show();
+                break;
+            case Type.VIA:
+                this._buttonImage.icon_name = 'list-remove-symbolic';
+                this._icon.icon_name = 'maps-point-end-symbolic';
+                this._button.show();
+                break;
+            case Type.TO:
+                this._icon.icon_name = 'maps-point-end-symbolic';
+                this._button.hide();
+                break;
+        }
+    },
+
+    get button() {
+        return this._button;
+    },
+
+    get point() {
+        return this._point;
+    }
+});


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