[gnome-maps] Use an .ui file for the main window structure
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Use an .ui file for the main window structure
- Date: Fri, 19 Apr 2013 06:57:38 +0000 (UTC)
commit 0bac90a29c837181ef74ce833b978a97de7e5813
Author: Paolo Borelli <pborelli gnome org>
Date: Tue Apr 16 17:09:12 2013 +0200
Use an .ui file for the main window structure
po/POTFILES.in | 1 +
src/application.js | 3 +++
src/gnome-maps.gresource.xml | 1 +
src/main-window.ui | 30 ++++++++++++++++++++++++++++++
src/mainWindow.js | 17 +++++++----------
5 files changed, 42 insertions(+), 10 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 4264f2e..9027659 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -4,6 +4,7 @@ data/org.gnome.maps.gschema.xml.in
src/application.js
[type: gettext/glade]src/app-menu.ui
src/mainWindow.js
+[type: gettext/glade]src/main-window.ui
src/properties.js
src/userLocation.js
src/utils.js
diff --git a/src/application.js b/src/application.js
index 5eda1ae..24caefc 100644
--- a/src/application.js
+++ b/src/application.js
@@ -28,6 +28,7 @@ const _ = imports.gettext.gettext;
const GtkClutter = imports.gi.GtkClutter;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
+const Gd = imports.gi.Gd;
const GLib = imports.gi.GLib;
const Main = imports.main;
@@ -50,6 +51,8 @@ const Application = new Lang.Class({
GLib.set_prgname('gnome-maps');
GLib.set_application_name(_("Maps"));
+ Gd.ensure_types();
+
this.parent({ application_id: 'org.gnome.Maps' });
},
diff --git a/src/gnome-maps.gresource.xml b/src/gnome-maps.gresource.xml
index 438576e..5916d8f 100644
--- a/src/gnome-maps.gresource.xml
+++ b/src/gnome-maps.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/maps">
<file preprocess="xml-stripblanks">app-menu.ui</file>
+ <file preprocess="xml-stripblanks">main-window.ui</file>
<file alias="application.css">../data/gnome-maps.css</file>
</gresource>
</gresources>
diff --git a/src/main-window.ui b/src/main-window.ui
new file mode 100644
index 0000000..1dd6bd8
--- /dev/null
+++ b/src/main-window.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkGrid" id="window-content">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GdHeaderBar" id="header-bar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child type="title">
+ <object class="GdTaggedEntry" id="search-entry">
+ <property name="visible">True</property>
+ <property name="width_request">500</property>
+ </object>
+ </child>
+ <child>
+ <object class="GdHeaderToggleButton" id="track-user-button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="symbolic-icon-name">find-location-symbolic</property>
+ </object>
+ <packing>
+ <property name="pack_type">start</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+</interface>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index cb75fec..b143f20 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -86,24 +86,24 @@ const MainWindow = new Lang.Class({
this.window.connect('window-state-event',
Lang.bind(this, this._onWindowStateEvent));
- let grid = new Gtk.Grid ();
+ let builder = new Gtk.Builder();
+ builder.add_from_resource('/org/gnome/maps/main-window.ui');
+
+ let grid = builder.get_object('window-content');
grid.set_orientation (Gtk.Orientation.VERTICAL);
this.window.add(grid);
- this._searchEntry = new Gd.TaggedEntry({ width_request: 500 });
+ this._searchEntry = builder.get_object('search-entry');
this._searchEntry.connect('activate', Lang.bind(this, this._onSearchActivate));
- let headerBar = new Gd.HeaderBar();
- headerBar.set_custom_title(this._searchEntry);
-
this.mapView = new MapView.MapView();
let trackUserLocation = Application.settings.get_boolean('track-user-location');
if (trackUserLocation)
this.mapView.gotoUserLocation(false);
- let toggle = new Gd.HeaderToggleButton({ symbolic_icon_name: 'find-location-symbolic',
- active: trackUserLocation });
+ let toggle = builder.get_object('track-user-button');
+ toggle.active = trackUserLocation;
let onViewMoved = Lang.bind(this,
function () {
@@ -131,9 +131,6 @@ const MainWindow = new Lang.Class({
Application.settings.set_boolean('track-user-location', toggle.active);
}));
- headerBar.pack_start(toggle);
-
- grid.add(headerBar);
grid.add(this.mapView);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]