[gnome-maps] Add button template to MapBubble
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Add button template to MapBubble
- Date: Sat, 1 Nov 2014 11:41:27 +0000 (UTC)
commit 572fdf84ffb09f8083b01a35468e93a783becdc3
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date: Thu Oct 16 01:00:44 2014 -0400
Add button template to MapBubble
This adds a template ui to MapBubble with an icon, a content area
and a button area.
The button area contains standard buttons, which bubble sub classes
will opt-in to using the buttons parameter:
params.buttons = MapBubble.button.ROUTE | ... ;
this.parent(params);
Bubble sub classes add their own content by:
this.image.[property] = ...;
this.content.add(...);
https://bugzilla.gnome.org/show_bug.cgi?id=737775
src/gnome-maps.data.gresource.xml | 1 +
src/map-bubble.ui | 64 +++++++++++++++++++++++++++++++++++++
src/mapBubble.js | 32 +++++++++++++++++-
src/search-result-bubble.ui | 32 +------------------
src/searchResultBubble.js | 16 ++++-----
src/turn-point-bubble.ui | 31 +-----------------
src/turnPointBubble.js | 10 ++---
src/user-location-bubble.ui | 32 +------------------
src/userLocationBubble.js | 9 +++--
9 files changed, 115 insertions(+), 112 deletions(-)
---
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index 2a37409..7e70944 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -11,6 +11,7 @@
<file preprocess="xml-stripblanks">layers-popover.ui</file>
<file preprocess="xml-stripblanks">notification.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">turn-point-bubble.ui</file>
<file preprocess="xml-stripblanks">user-location-bubble.ui</file>
diff --git a/src/map-bubble.ui b/src/map-bubble.ui
new file mode 100644
index 0000000..b809aa0
--- /dev/null
+++ b/src/map-bubble.ui
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
+<interface>
+ <requires lib="gtk+" version="3.12"/>
+ <object class="GtkGrid" id="bubble-main-grid">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">10</property>
+ <property name="margin_end">10</property>
+ <property name="margin_top">10</property>
+ <property name="margin_bottom">10</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkImage" id="bubble-image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="valign">start</property>
+ <property name="margin_top">5</property>
+ <property name="pixel_size">0</property>
+ <property name="icon_size">16</property>
+ <property name="margin-end">15</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="bubble-content-area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="bubble-button-area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin-top">10</property>
+ <child>
+ <object class="GtkBox" id="bubble-standard-button-area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">horizontal</property>
+ <style>
+ <class name="linked" />
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index f747327..49fd676 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -21,9 +21,15 @@
*/
const Gtk = imports.gi.Gtk;
-
const Lang = imports.lang;
+const Application = imports.application;
+const Utils = imports.utils;
+
+const Button = {
+ NONE: 0
+};
+
const MapBubble = new Lang.Class({
Name: "MapBubble",
Extends: Gtk.Popover,
@@ -37,12 +43,34 @@ const MapBubble = new Lang.Class({
params.relative_to = params.mapView;
delete params.mapView;
+ let buttonFlags = params.buttons || Button.NONE;
+ delete params.buttons;
+
params.modal = false;
this.parent(params);
+ let ui = Utils.getUIObject('map-bubble', [ 'bubble-main-grid',
+ 'bubble-image',
+ 'bubble-content-area',
+ 'bubble-button-area']);
+ this._image = ui.bubbleImage;
+ this._content = ui.bubbleContentArea;
+
+ if (!buttonFlags)
+ ui.bubbleButtonArea.visible = false;
+
+ this.add(ui.bubbleMainGrid);
+ },
+
+ get image() {
+ return this._image;
},
get place() {
return this._place;
+ },
+
+ get content() {
+ return this._content;
}
-});
\ No newline at end of file
+});
diff --git a/src/search-result-bubble.ui b/src/search-result-bubble.ui
index b1aaa00..d92fe06 100644
--- a/src/search-result-bubble.ui
+++ b/src/search-result-bubble.ui
@@ -2,34 +2,10 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <object class="GtkGrid" id="grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">10</property>
- <property name="margin_end">15</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">15</property>
- <child>
- <object class="GtkImage" id="image">
+ <object class="GtkBox" id="box-content">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_top">5</property>
- <property name="pixel_size">0</property>
- <property name="icon_size">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="box-right">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">15</property>
<property name="orientation">vertical</property>
- <property name="spacing">3</property>
<child>
<object class="GtkLabel" id="label-title">
<property name="visible">True</property>
@@ -47,10 +23,4 @@
</packing>
</child>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
</interface>
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index 83d7a78..08b057a 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -35,15 +35,13 @@ const SearchResultBubble = new Lang.Class({
_init: function(params) {
this.parent(params);
- let ui = Utils.getUIObject('search-result-bubble', [ 'grid',
- 'box-right',
- 'image',
- 'label-title' ]);
+ let ui = Utils.getUIObject('search-result-bubble', [ 'box-content',
+ 'label-title']);
let place = this.place;
- Utils.load_icon(this.place.icon, 48, function(pixbuf) {
- ui.image.pixbuf = pixbuf;
- });
+ Utils.load_icon(this.place.icon, 48, (function(pixbuf) {
+ this.image.pixbuf = pixbuf;
+ }).bind(this));
let title = null;
let content = [];
@@ -82,10 +80,10 @@ const SearchResultBubble = new Lang.Class({
let label = new Gtk.Label({ label: c,
visible: true,
halign: Gtk.Align.START });
- ui.boxRight.pack_start(label, false, true, 0);
+ ui.boxContent.pack_start(label, false, true, 0);
});
- this.add(ui.grid);
+ this.content.add(ui.boxContent);
},
_isBrokenPlace: function(place) {
diff --git a/src/turn-point-bubble.ui b/src/turn-point-bubble.ui
index 7fa0603..7840f01 100644
--- a/src/turn-point-bubble.ui
+++ b/src/turn-point-bubble.ui
@@ -2,32 +2,9 @@
<!-- Generated with glade 3.18.1 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <object class="GtkGrid" id="grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">10</property>
- <property name="margin_end">15</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">15</property>
- <child>
- <object class="GtkImage" id="image">
+ <object class="GtkGrid" id="grid-content">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_top">5</property>
- <property name="pixel_size">0</property>
- <property name="icon_size">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="box-right">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">15</property>
<child>
<object class="GtkLabel" id="label-title">
<property name="visible">True</property>
@@ -40,10 +17,4 @@
</object>
</child>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
</interface>
diff --git a/src/turnPointBubble.js b/src/turnPointBubble.js
index 9168955..837e7e0 100644
--- a/src/turnPointBubble.js
+++ b/src/turnPointBubble.js
@@ -35,13 +35,11 @@ const TurnPointBubble = new Lang.Class({
this.parent(params);
- let ui = Utils.getUIObject('turn-point-bubble', [ 'grid',
- 'box-right',
- 'image',
- 'label-title' ]);
- ui.image.icon_name = turnPoint.iconName;
+ let ui = Utils.getUIObject('turn-point-bubble', [ 'grid-content',
+ 'label-title']);
+ this.image.icon_name = turnPoint.iconName;
ui.labelTitle.label = turnPoint.instruction;
- this.add(ui.grid);
+ this.content.add(ui.gridContent);
}
});
diff --git a/src/user-location-bubble.ui b/src/user-location-bubble.ui
index a7e3e2b..085cca2 100644
--- a/src/user-location-bubble.ui
+++ b/src/user-location-bubble.ui
@@ -2,33 +2,9 @@
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
- <object class="GtkGrid" id="grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">10</property>
- <property name="margin_end">15</property>
- <property name="margin_top">10</property>
- <property name="margin_bottom">15</property>
- <child>
- <object class="GtkImage" id="image-user-location">
+ <object class="GtkGrid" id="grid-content">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="valign">start</property>
- <property name="margin_top">5</property>
- <property name="pixel_size">48</property>
- <property name="icon_name">find-location-symbolic</property>
- <property name="icon_size">0</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="grid-right">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_start">10</property>
<child>
<object class="GtkLabel" id="label-title">
<property name="visible">True</property>
@@ -76,10 +52,4 @@
</packing>
</child>
</object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
</interface>
diff --git a/src/userLocationBubble.js b/src/userLocationBubble.js
index cb92dc4..0c08233 100644
--- a/src/userLocationBubble.js
+++ b/src/userLocationBubble.js
@@ -32,16 +32,19 @@ const UserLocationBubble = new Lang.Class({
_init: function(params) {
this.parent(params);
- let ui = Utils.getUIObject('user-location-bubble', [ 'grid',
+ let ui = Utils.getUIObject('user-location-bubble', [ 'grid-content',
'label-accuracy',
'label-coordinates' ]);
+ this.image.icon_name = 'find-location-symbolic';
+ this.image.pixel_size = 48;
+
let accuracyDescription = Utils.getAccuracyDescription(this.place.location.accuracy);
ui.labelAccuracy.label = ui.labelAccuracy.label.format(accuracyDescription);
ui.labelCoordinates.label = this.place.location.latitude.toFixed(5)
+ ', '
+ this.place.location.longitude.toFixed(5);
- this.add(ui.grid);
+ this.content.add(ui.gridContent);
}
-});
\ No newline at end of file
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]