[gnome-maps/wip/search-props: 12/12] wip: Add search properties view



commit 8026afbbe79119365e2334444896dc01594bd6e1
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Apr 1 21:03:10 2013 -0400

    wip: Add search properties view

 configure.ac       |    1 +
 src/Makefile-js.am |    1 +
 src/mainWindow.js  |    7 ++--
 src/mapView.js     |   88 +++++++++++++++++++++++++++++++++++++++++++++--
 src/properties.js  |   98 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 189 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d8cc06d..680a113 100644
--- a/configure.ac
+++ b/configure.ac
@@ -41,6 +41,7 @@ AC_SUBST(GLIB_COMPILE_RESOURCES)
 
 LIBGD_INIT([
   header-bar
+  revealer
   tagged-entry
   gir
 ])
diff --git a/src/Makefile-js.am b/src/Makefile-js.am
index 2b0d22f..4cd2737 100644
--- a/src/Makefile-js.am
+++ b/src/Makefile-js.am
@@ -6,6 +6,7 @@ dist_js_DATA = \
     mainToolbar.js \
     mapView.js \
     path.js \
+    properties.js \
     utils.js
 
 BUILT_SOURCES += \
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 7188a03..f81191e 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -23,7 +23,6 @@ const Gdk = imports.gi.Gdk;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Champlain = imports.gi.Champlain;
-const GtkChamplain = imports.gi.GtkChamplain;
 const Geocode = imports.gi.GeocodeGlib;
 
 const Lang = imports.lang;
@@ -94,8 +93,10 @@ const MainWindow = new Lang.Class({
         this._toolbar = new MainToolbar.MainToolbar(this);
         grid.add(this._toolbar.widget);
 
-        this.mapView = new MapView.MapView();
-        grid.add(this.mapView.widget);
+        this._embed = new MapView.ViewEmbed();
+        grid.add(this._embed);
+
+        this.mapView = this._embed.mapView;
 
         grid.show_all();
     },
diff --git a/src/mapView.js b/src/mapView.js
index 3f3c3d3..17ca759 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -22,8 +22,11 @@ const Gdk = imports.gi.Gdk;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Champlain = imports.gi.Champlain;
-const GtkChamplain = imports.gi.GtkChamplain;
+const Clutter = imports.gi.Clutter;
 const Geocode = imports.gi.GeocodeGlib;
+const Gd = imports.gi.Gd;
+const GtkClutter = imports.gi.GtkClutter;
+const Properties = imports.properties;
 
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
@@ -32,12 +35,91 @@ const Application = imports.application;
 const Utils = imports.utils;
 const _ = imports.gettext.gettext;
 
+const ViewEmbed = new Lang.Class({
+    Name: 'ViewEmbed',
+    Extends: GtkClutter.Embed,
+
+    _init: function() {
+        this.parent();
+
+        this._cursorHandOpen = Gdk.Cursor.new(Gdk.CursorType.HAND1);
+        this._cursorHandClosed = Gdk.Cursor.new(Gdk.CursorType.FLEUR);
+
+        this.mapView = new MapView();
+        this._layout = new Clutter.BinLayout();
+        this._actor = new Clutter.Actor({ layout_manager: this._layout,
+                                          x_expand: true,
+                                          y_expand: true });
+
+        this.mapView.actor.x_expand = true;
+        this.mapView.actor.y_expand = true;
+        this._actor.add_child(this.mapView.actor);
+
+        this._properties = new Properties.Properties();
+        this._actor.add_child(this._properties.actor);
+
+        let stage = this.get_stage();
+        stage.add_actor(this._actor);
+
+        this.connect('button-press-event', Lang.bind(this, this._onButtonPress));
+        this.connect('button-release-event', Lang.bind(this, this._onButtonRelease));
+    },
+
+    vfunc_realize: function(params) {
+        this.parent(params);
+        this._updateViewStyle();
+    },
+
+    vfunc_style_updated: function(params) {
+        this.parent(params);
+        this._updateViewStyle();
+    },
+
+    vfunc_size_allocate: function(params) {
+        this.parent(params);
+
+        let allocation = this.get_allocation();
+
+        this.mapView.actor.set_size(allocation.width,
+                                    allocation.height);
+    },
+
+    _onButtonPress: function(event) {
+        this.get_window().set_cursor(this._cursorHandClosed);
+        return false;
+    },
+
+    _onButtonRelease: function() {
+        this.get_window().set_cursor(this._cursorHandOpen);
+        return false;
+    },
+
+    _updateViewStyle: function() {
+        function clutterColorFromRGBA(rgba) {
+            return new Clutter.Color({ red: rgba.red * 255,
+                                       green: rgba.green * 255,
+                                       blue: rgba.blue * 255,
+                                       alpha: rgba.alpha * 255 });
+        }
+
+        let context = this.get_style_context();
+        let rgba = context.get_color(Gtk.StateFlags.SELECTED);
+        let color = clutterColorFromRGBA(rgba);
+        Champlain.Marker.set_selection_text_color(color);
+
+        rgba = context.get_background_color(Gtk.StateFlags.SELECTED);
+        color = clutterColorFromRGBA(rgba);
+        Champlain.Marker.set_selection_color(color);
+
+        this.get_window().set_cursor(this._cursorHandOpen);
+    }
+});
+
 const MapView = new Lang.Class({
     Name: 'MapView',
 
     _init: function(app) {
-        this.widget = new GtkChamplain.Embed();
-        this.actor = this.widget.get_view();
+        this.actor = new Champlain.View();
 
         this._view = this.actor;
 
diff --git a/src/properties.js b/src/properties.js
new file mode 100644
index 0000000..974ccfc
--- /dev/null
+++ b/src/properties.js
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2011, 2012, 2013 Red Hat, Inc.
+ *
+ * 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: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ */
+
+const Clutter = imports.gi.Clutter;
+const Gdk = imports.gi.Gdk;
+const GLib = imports.gi.GLib;
+const Gtk = imports.gi.Gtk;
+const Champlain = imports.gi.Champlain;
+const GtkClutter = imports.gi.GtkClutter;
+const Geocode = imports.gi.GeocodeGlib;
+const Gd = imports.gi.Gd;
+
+const Lang = imports.lang;
+const Mainloop = imports.mainloop;
+
+const Utils = imports.utils;
+const _ = imports.gettext.gettext;
+
+const Properties = new Lang.Class({
+    Name: 'Properties',
+
+    _init: function() {
+        function clearBg(widget) {
+            widget.override_background_color(0, new Gdk.RGBA({ red: 0,
+                                                               green: 0,
+                                                               blue: 0,
+                                                               alpha: 0 }));
+        }
+
+        this.actor = new Clutter.Actor({ layout_manager: new Clutter.BoxLayout({ spacing: 12 }),
+                                         y_expand: true,
+                                         x_align: Clutter.ActorAlign.END });
+
+        // create the button
+        let revealButton = new Gd.HeaderSimpleButton({ symbolic_icon_name: 'go-previous-symbolic',
+                                                       valign: Gtk.Align.CENTER });
+        revealButton.get_style_context().add_class('osd');
+        revealButton.show();
+
+        // then the sidebar itself, packed into the revealer
+        let propsGrid = new Gtk.Grid({ vexpand: true,
+                                       valign: Gtk.Align.FILL });
+        propsGrid.set_orientation(Gtk.Orientation.VERTICAL);
+
+        let label = new Gtk.Label({ label: "Map Type" });
+        propsGrid.add(label);
+
+        let propsContainer = new Gtk.Frame({ child: propsGrid,
+                                             shadow_type: Gtk.ShadowType.NONE });
+        propsContainer.get_style_context().add_class('background');
+        propsContainer.get_style_context().add_class('osd');
+
+        let revealer = new Gd.Revealer({ child: propsContainer,
+                                         reveal_child: false,
+                                         orientation: Gtk.Orientation.VERTICAL });
+        revealer.show_all();
+
+        revealButton.connect('clicked', Lang.bind(this, function() {
+            if (revealer.reveal_child) {
+                revealer.reveal_child = false;
+                revealButton.symbolic_icon_name = 'go-previous-symbolic';
+            } else {
+                revealer.reveal_child = true;
+                revealButton.symbolic_icon_name = 'go-next-symbolic';
+            }
+        }));
+
+        // now create actors
+        let buttonActor = new GtkClutter.Actor({ contents: revealButton,
+                                                 x_align: Clutter.ActorAlign.END });
+        clearBg(buttonActor.get_widget());
+        this.actor.add_child(buttonActor);
+
+        let revealerActor = new GtkClutter.Actor({ contents: revealer,
+                                                   x_align: Clutter.ActorAlign.END,
+                                                   x_expand: true,
+                                                   y_expand: true });
+        clearBg(revealerActor.get_widget());
+        this.actor.add_child(revealerActor);
+    }
+});


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