[gnome-maps/wip/drag-n-drop: 2/3] sidebar: Add all entries to listbox
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/drag-n-drop: 2/3] sidebar: Add all entries to listbox
- Date: Mon, 8 Dec 2014 07:28:56 +0000 (UTC)
commit d3b883b374fa77e15d515f761be29d845b58cee4
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Thu Nov 27 07:21:09 2014 -0500
sidebar: Add all entries to listbox
Keep all route entries in the listbox. And use the new RouteEntry
module to represent each row.
https://bugzilla.gnome.org/show_bug.cgi?id=737321
data/gnome-maps.css | 12 ++--
src/gnome-maps.data.gresource.xml | 1 -
src/route-via-row.ui | 40 --------------
src/sidebar.js | 105 ++++++++++++++----------------------
src/sidebar.ui | 80 +---------------------------
5 files changed, 49 insertions(+), 189 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index 629d5a6..d655e3a 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -29,27 +29,27 @@
font-weight: bold;
}
-#via-grid-container {
+#sidebar-entry-list {
background-color: transparent;
}
-#via-grid-container .list-row:hover {
+#sidebar-entry-list .list-row:hover {
background-color: transparent;
}
-#via-grid-container .list-row:focus {
+#sidebar-entry-list .list-row:focus {
outline: 0;
}
-#via-grid-container > GtkLabel {
+#sidebar-entry-list > GtkLabel {
padding-right: 6px;
}
-#via-grid-container > GtkLabel:dir(rtl) {
+#sidebar-entry-list > GtkLabel:dir(rtl) {
padding-left: 6px;
}
-#via-grid-container .transportation-mode-button > GtkImage {
+#sidebar-entry-list .transportation-mode-button > GtkImage {
padding-left: 7px;
padding-right: 7px;
padding-top: 4px;
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index 22c4867..b19a625 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -13,7 +13,6 @@
<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>
<file preprocess="xml-stripblanks">share-dialog.ui</file>
diff --git a/src/sidebar.js b/src/sidebar.js
index 5434c53..2f585bb 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -27,7 +27,7 @@ const Lang = imports.lang;
const _ = imports.gettext.gettext;
const Application = imports.application;
-const PlaceEntry = imports.placeEntry;
+const RouteEntry = imports.routeEntry;
const RouteQuery = imports.routeQuery;
const Utils = imports.utils;
@@ -70,7 +70,7 @@ const Sidebar = new Lang.Class({
this.get_style_context().add_class('maps-sidebar');
let ui = Utils.getUIObject('sidebar', [ 'sidebar',
- 'via-grid-container',
+ 'entry-list',
'instruction-list-scrolled',
'instruction-stack',
'instruction-spinner',
@@ -79,13 +79,10 @@ const Sidebar = new Lang.Class({
'mode-bike-toggle',
'mode-car-toggle',
'time-info',
- 'distance-info',
- 'from-entry-grid',
- 'to-entry-grid',
- 'via-add-button']);
+ 'distance-info' ]);
this._mapView = mapView;
- this._viaGridContainer = ui.viaGridContainer;
+ this._entryList = ui.entryList;
this._instructionList = ui.instructionList;
this._instructionStack = ui.instructionStack;
this._instructionWindow = ui.instructionListScrolled;
@@ -98,24 +95,12 @@ const Sidebar = new Lang.Class({
this._initTransportationToggles(ui.modePedestrianToggle,
ui.modeBikeToggle,
ui.modeCarToggle);
+ this._initQuerySignals();
let query = Application.routeService.query;
query.addPoint(0);
- let fromEntry = this._initRouteEntry(ui.fromEntryGrid, 0);
-
query.addPoint(1);
- this._initRouteEntry(ui.toEntryGrid, 1);
-
- this._initQuerySignals(ui.viaGridContainer);
-
- this.bind_property('child-revealed',
- fromEntry, 'has_focus',
- GObject.BindingFlags.DEFAULT);
-
- ui.viaAddButton.connect('clicked', (function() {
- query.addPoint(-1);
- }).bind(this));
this.add(ui.sidebar);
},
@@ -150,58 +135,48 @@ const Sidebar = new Lang.Class({
query.connect('notify::transportation', setToggles);
},
- _initQuerySignals: function(listbox) {
+ _initQuerySignals: function() {
let query = Application.routeService.query;
- // Do nothing for the From and To points.
query.connect('point-added', (function(obj, point, index) {
- if (index !== 0 && index !== query.points.length - 1)
- this._createViaRow(listbox, index);
+ this._createRouteEntry(index, point);
}).bind(this));
query.connect('point-removed', (function(obj, point, index) {
- let row = listbox.get_row_at_index(index - 1);
+ let row = this._entryList.get_row_at_index(index);
row.destroy();
}).bind(this));
},
- _createPlaceEntry: function() {
- return new PlaceEntry.PlaceEntry({ visible: true,
- can_focus: true,
- hexpand: true,
- receives_default: true,
- mapView: this._mapView,
- parseOnFocusOut: true,
- maxChars: 15 });
- },
-
- _createViaRow: function(listbox, index) {
- let ui = Utils.getUIObject('route-via-row', [ 'via-grid',
- 'via-remove-button',
- 'via-entry-grid' ]);
- let insertIndex = index - 1;
- let entry = this._createPlaceEntry();
-
- this._initRouteEntry(ui.viaEntryGrid, index);
- listbox.insert(ui.viaGrid, insertIndex);
-
- ui.viaRemoveButton.connect('clicked', function() {
- let row = ui.viaGrid.get_parent();
- let pointIndex = row.get_index();
- Application.routeService.query.removePoint(pointIndex + 1);
- });
- },
-
- _initRouteEntry: function(container, pointIndex) {
- let entry = this._createPlaceEntry();
- container.add(entry);
-
- let point = Application.routeService.query.points[pointIndex];
- entry.bind_property('place',
- point, 'place',
- GObject.BindingFlags.BIDIRECTIONAL);
+ _createRouteEntry: function(index, point) {
+ let type;
+ if (index === 0)
+ type = RouteEntry.Type.FROM;
+ else if (index === this._entryList.get_children().length)
+ type = RouteEntry.Type.TO;
+ else
+ type = RouteEntry.Type.VIA;
+
+ let routeEntry = new RouteEntry.RouteEntry({ type: type,
+ point: point,
+ mapView: this._mapView });
+ this._entryList.insert(routeEntry, index);
+
+ if (type === RouteEntry.Type.FROM) {
+ routeEntry.button.connect('clicked', (function() {
+ let lastIndex = this._entryList.get_children().length;
+ Application.routeService.query.addPoint(lastIndex - 1);
+ }).bind(this));
- return entry;
+ this.bind_property('child-revealed',
+ routeEntry.entry, 'has_focus',
+ GObject.BindingFlags.DEFAULT);
+ } else if (type === RouteEntry.Type.VIA) {
+ routeEntry.button.connect('clicked', function() {
+ let row = routeEntry.get_parent();
+ Application.routeService.query.removePoint(row.get_index());
+ });
+ }
},
_initInstructionList: function() {
@@ -211,9 +186,11 @@ const Sidebar = new Lang.Class({
route.connect('reset', (function() {
this._clearInstructions();
this._instructionStack.visible_child = this._instructionWindow;
- this._viaGridContainer.get_children().forEach((function(row) {
- query.removePoint(row.get_index() + 1);
- }).bind(this));
+
+ let length = this._entryList.get_children().length;
+ for (let index = 1; index < (length - 1); index++) {
+ query.removePoint(index);
+ }
}).bind(this));
query.connect('notify', (function() {
diff --git a/src/sidebar.ui b/src/sidebar.ui
index 2a19d40..15fc36b 100644
--- a/src/sidebar.ui
+++ b/src/sidebar.ui
@@ -90,90 +90,14 @@
</object>
</child>
<child>
- <object class="GtkGrid" id="from-grid">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="margin_top">12</property>
- <property name="hexpand">False</property>
- <child>
- <object class="GtkImage" id="from-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-start">15</property>
- <property name="margin-end">8</property>
- <property name="width-request">16</property>
- <property name="icon-name">maps-point-start-symbolic</property>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="from-entry-grid">
- <property name="visible">True</property>
- <property name="hexpand">True</property>
- <property name="can_focus">False</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="via-add-button">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="valign">center</property>
- <property name="margin-start">4</property>
- <property name="margin-end">12</property>
- <property name="height-request">31</property>
- <property name="width-request">31</property>
- <child>
- <object class="GtkImage" id="via-add-image">
- <property name="visible">True</property>
- <property name="icon-name">list-add-symbolic</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="via-grid-container">
- <property name="name">via-grid-container</property>
+ <object class="GtkListBox" id="entry-list">
+ <property name="name">sidebar-entry-list</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="selection-mode">GTK_SELECTION_NONE</property>
</object>
</child>
<child>
- <object class="GtkGrid" id="to-grid">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="vexpand">False</property>
- <property name="hexpand">False</property>
- <child>
- <object class="GtkImage" id="to-image">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin-start">15</property>
- <property name="margin-end">8</property>
- <property name="width-request">16</property>
- <property name="icon-name">maps-point-end-symbolic</property>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="to-entry-grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hexpand">True</property>
- </object>
- </child>
- <child>
- <object class="GtkGrid" id="to-placeholder-grid">
- <property name="visible">True</property>
- <property name="can-focus">True</property>
- <property name="margin-end">19</property>
- <property name="height-request">31</property>
- <property name="width-request">31</property>
- </object>
- </child>
- </object>
- </child>
- <child>
<object class="GtkGrid" id="sidebar-route-info-wrapper">
<property name="visible">True</property>
<property name="hexpand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]