[gnome-maps] MapBubble: Add share button



commit 210c9c80a970a893f80d739a790a29e2afc7d2f9
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Wed Nov 19 02:03:47 2014 -0500

    MapBubble: Add share button
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728117

 src/map-bubble.ui |   16 ++++++++++++++++
 src/mapBubble.js  |   24 ++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/src/map-bubble.ui b/src/map-bubble.ui
index e821776..1cbb149 100644
--- a/src/map-bubble.ui
+++ b/src/map-bubble.ui
@@ -62,6 +62,22 @@
                 </child>
               </object>
             </child>
+            <child>
+              <object class="GtkButton" id="bubble-share-button">
+                <property name="name">bubble-share-button</property>
+                <property name="visible">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <child>
+                  <object class="GtkImage" id="bubble-share-button-image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon-name">folder-publicshare-symbolic</property>
+                    <property name="pixel_size">16</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left_attach">0</property>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index d08f532..4182a6d 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -20,16 +20,20 @@
  * Author: Damián Nohales <damiannohales gmail com>
  */
 
+const Gio = imports.gi.Gio;
+const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
+const ShareDialog = imports.shareDialog;
 const Utils = imports.utils;
 
 const Button = {
     NONE: 0,
-    ROUTE: 2
+    ROUTE: 2,
+    SHARE: 4
 };
 
 const MapBubble = new Lang.Class({
@@ -58,7 +62,8 @@ const MapBubble = new Lang.Class({
                                                    'bubble-image',
                                                    'bubble-content-area',
                                                    'bubble-button-area',
-                                                   'bubble-route-button']);
+                                                   'bubble-route-button',
+                                                   'bubble-share-button' ]);
         this._image = ui.bubbleImage;
         this._content = ui.bubbleContentArea;
 
@@ -67,6 +72,8 @@ const MapBubble = new Lang.Class({
         else {
             if (buttonFlags & Button.ROUTE)
                 this._initRouteButton(ui.bubbleRouteButton, routeFrom);
+            if (buttonFlags & Button.SHARE)
+                this._initShareButton(ui.bubbleShareButton);
         }
 
         this.add(ui.bubbleMainGrid);
@@ -84,6 +91,19 @@ const MapBubble = new Lang.Class({
         return this._content;
     },
 
+    _initShareButton: function(button) {
+        let dialog = new ShareDialog.ShareDialog({ transient_for: this.get_toplevel(),
+                                                   place: this._place });
+        if (!dialog.ensureShares())
+            return;
+
+        button.visible = true;
+        button.connect('clicked', function() {
+            dialog.run();
+            dialog.hide();
+        });
+    },
+
     _initRouteButton: function(button, routeFrom) {
         let query = Application.routeService.query;
         let route = Application.routeService.route;


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