~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to qreator/qrcodes/QRCodeLocationGtk.py

  • Committer: David Planella
  • Date: 2012-06-09 00:06:51 UTC
  • mfrom: (81.2.8 VCARD_support)
  • Revision ID: david.planella@ubuntu.com-20120609000651-ehe6bkiw3d724wc2
Merged VCARD QR code support from lp:stefan-schwarzburg/qreator/VCARD_support, with a bunch of UI changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
### BEGIN LICENSE
3
3
# Copyright (C) 2012 David Planella <david.planella@ubuntu.com>
4
 
# This program is free software: you can redistribute it and/or modify it 
5
 
# under the terms of the GNU General Public License version 3, as published 
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
6
6
# by the Free Software Foundation.
7
 
8
 
# This program is distributed in the hope that it will be useful, but 
9
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
10
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
11
# PURPOSE.  See the GNU General Public License for more details.
12
 
13
 
# You should have received a copy of the GNU General Public License along 
 
12
#
 
13
# You should have received a copy of the GNU General Public License along
14
14
# with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
### END LICENSE
16
16
 
67
67
    def on_activated(self):
68
68
        pass
69
69
 
70
 
    def on_prepared(self):
71
 
        pass
72
 
 
73
70
    def on_map_widget_button_press_event(self, actor, event, view):
74
71
        x, y = event.get_coords()
75
 
        lon, lat = view.x_to_longitude(x), view.y_to_latitude(y)
 
72
        lat, lon = view.x_to_longitude(x), view.y_to_latitude(y)
76
73
 
77
74
        self.builder.get_object('lat_entry').set_text(str(lat))
78
75
        self.builder.get_object('lon_entry').set_text(str(lon))
79
76
 
80
 
        self.qr_code_update_func('geo:{0},{1}'.format(str(lat), str(lon)))
 
77
        self.qr_code_update_func('geo:{0},{1}'.format(str(lon), str(lat)))
81
78
 
82
79
        return True
83
80
 
94
91
 
95
92
    import dbus
96
93
    bus = dbus.SessionBus()
97
 
 
98
 
    # For now we default to the UbuntuGeoIP provider and we fall back to
99
 
    # Hostip. We should probably be cleverer about provider detection, but
100
 
    # this solution works for now and does not rely solely on UbuntuGeoIP,
101
 
    # which means qreator can run on other distros
102
 
    try:
103
 
        geoclue = bus.get_object(
104
 
            'org.freedesktop.Geoclue.Providers.UbuntuGeoIP',
105
 
            '/org/freedesktop/Geoclue/Providers/UbuntuGeoIP')
106
 
    except dbus.exceptions.DBusException:
107
 
        geoclue = bus.get_object(
108
 
            'org.freedesktop.Geoclue.Providers.Hostip',
109
 
            '/org/freedesktop/Geoclue/Providers/Hostip')
 
94
    geoclue = bus.get_object(
 
95
        'org.freedesktop.Geoclue.Providers.UbuntuGeoIP',
 
96
        '/org/freedesktop/Geoclue/Providers/UbuntuGeoIP')
110
97
    position_info = geoclue.GetPosition(
111
98
        dbus_interface='org.freedesktop.Geoclue.Position')
112
99