~ubuntu-branches/ubuntu/vivid/blueman/vivid-proposed

« back to all changes in this revision

Viewing changes to blueman/gui/manager/ManagerDeviceList.py

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-12-24 18:33:36 UTC
  • mfrom: (2.3.8 sid)
  • Revision ID: package-import@ubuntu.com-20141224183336-cyb82ot0y8tz8flq
Tags: 1.99~alpha1-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/patches/01_dont_autostart_lxde.patch:
    + Don't autostart the applet in LXDE.
  - debian/patches/03_filemanager_fix.patch:
    + Add support for more filemanagers.
* debian/patches/02_dont_crash_on_non-bluetooth_card.patch:
  - Dropped, no longer applicable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from blueman.gui.manager.ManagerDeviceMenu import ManagerDeviceMenu
26
26
from blueman.Sdp import *
27
27
 
28
 
import gtk
29
 
import pango
 
28
from gi.repository import Gtk
 
29
from gi.repository import Gdk
 
30
from gi.repository import Pango
30
31
from blueman.Constants import *
31
32
from blueman.Functions import *
32
33
import cgi
36
37
class ManagerDeviceList(DeviceList):
37
38
        
38
39
        def __init__(self, adapter=None, inst=None):
39
 
                cr = gtk.CellRendererText()
40
 
                cr.props.ellipsize = pango.ELLIPSIZE_END
 
40
                cr = Gtk.CellRendererText()
 
41
                cr.props.ellipsize = Pango.EllipsizeMode.END
41
42
                data = [
42
43
                        #device picture
43
 
                        ["device_pb", 'GdkPixbuf', gtk.CellRendererPixbuf(), {"pixbuf":0}, None],
 
44
                        ["device_pb", 'GdkPixbuf', Gtk.CellRendererPixbuf(), {"pixbuf":0}, None],
44
45
                        
45
46
                        #device caption
46
47
                        ["caption", str, cr, {"markup":1}, None, {"expand": True}],
47
48
 
48
49
                        
49
 
                        ["rssi_pb", 'GdkPixbuf', gtk.CellRendererPixbuf(), {"pixbuf":2}, None, {"spacing": 0}],
50
 
                        ["lq_pb", 'GdkPixbuf', gtk.CellRendererPixbuf(), {"pixbuf":3}, None, {"spacing": 0}],
51
 
                        ["tpl_pb", 'GdkPixbuf', gtk.CellRendererPixbuf(), {"pixbuf":4}, None, {"spacing": 0}],
 
50
                        ["rssi_pb", 'GdkPixbuf', Gtk.CellRendererPixbuf(), {"pixbuf":2}, None, {"spacing": 0}],
 
51
                        ["lq_pb", 'GdkPixbuf', Gtk.CellRendererPixbuf(), {"pixbuf":3}, None, {"spacing": 0}],
 
52
                        ["tpl_pb", 'GdkPixbuf', Gtk.CellRendererPixbuf(), {"pixbuf":4}, None, {"spacing": 0}],
52
53
                        
53
54
                        #trusted/bonded icons
54
55
                        #["tb_icons", 'PyObject', CellRendererPixbufTable(), {"pixbuffs":5}, None],
63
64
                        ["lq", float],
64
65
                        ["tpl", float],
65
66
                        ["orig_icon", 'GdkPixbuf'],
66
 
                        ["cell_fader", gobject.TYPE_PYOBJECT],
67
 
                        ["row_fader", gobject.TYPE_PYOBJECT],
 
67
                        ["cell_fader", GObject.TYPE_PYOBJECT],
 
68
                        ["row_fader", GObject.TYPE_PYOBJECT],
68
69
                        ["levels_visible", bool],
69
70
                        ["initial_anim", bool],
70
71
                ]
74
75
                self.Blueman = inst
75
76
                
76
77
                self.connect("query-tooltip", self.tooltip_query)               
77
 
                self.tooltip_row = -1
 
78
                self.tooltip_row = None
78
79
                self.tooltip_col = None
79
80
                
80
81
                self.connect("button_press_event", self.on_event_clicked)
85
86
                self.connect("drag_data_received", self.drag_recv)
86
87
                self.connect("drag-motion", self.drag_motion)
87
88
 
88
 
                self.drag_dest_set(gtk.DEST_DEFAULT_ALL, [], gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_DEFAULT)
89
 
                self.drag_dest_add_uri_targets()
 
89
                Gtk.Widget.drag_dest_set(self, Gtk.DestDefaults.ALL, [], Gdk.DragAction.COPY|Gdk.DragAction.DEFAULT)
 
90
                Gtk.Widget.drag_dest_add_uri_targets(self)
90
91
                
91
 
                self.set_search_equal_func(self.search_func)
 
92
                self.set_search_equal_func(self.search_func, None)
92
93
                
93
94
        def do_device_found(self, device):
94
95
                iter = self.find_device(device)
95
96
                if iter:
96
 
                        anim = TreeRowColorFade(self, self.props.model.get_path(iter), gtk.gdk.color_parse("blue"))
 
97
                        anim = TreeRowColorFade(self, self.props.model.get_path(iter), Gdk.color_parse("blue"))
97
98
                        anim.animate(start=0.8, end=1.0)
98
99
                
99
100
                
113
114
                
114
115
                path = self.get_path_at_pos(x, y)
115
116
                if path:
116
 
                        iter = self.get_iter(path[0][0])
 
117
                        iter = self.get_iter(path[0])
117
118
                        device = self.get(iter, "device")["device"]
118
119
                        uris.insert(0, "blueman-sendto")
119
120
                        uris.insert(1, "--device=%s" % device.Address)
129
130
        def drag_motion(self, widget, drag_context, x, y, timestamp):
130
131
                path = self.get_path_at_pos(x, y)
131
132
                if path != None:
132
 
                        if path[0][0] != self.selected():
133
 
                                iter = self.get_iter(path[0][0])
 
133
                        if path[0] != self.selected():
 
134
                                iter = self.get_iter(path[0])
134
135
                                device = self.get(iter, "device")["device"]
135
136
                                if not device.Fake:     
136
137
                                        found = False
140
141
                                                        found = True
141
142
                                                        break
142
143
                                        if found:
143
 
                                                drag_context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
 
144
                                                drag_context.drag_status(Gdk.DragAction.COPY, timestamp)
144
145
                                                self.set_cursor(path[0])
145
146
                                                return True
146
147
                                        else:
147
 
                                                drag_context.drag_status(gtk.gdk.ACTION_DEFAULT, timestamp)
 
148
                                                drag_context.drag_status(Gdk.DragAction.DEFAULT, timestamp)
148
149
                                                return False
149
150
                                else:
150
 
                                        drag_context.drag_status(gtk.gdk.ACTION_COPY, timestamp)
 
151
                                        drag_context.drag_status(Gdk.DragAction.COPY, timestamp)
151
152
                                        self.set_cursor(path[0])
152
153
                                        return True
153
154
                else:
154
 
                        drag_context.drag_status(gtk.gdk.ACTION_DEFAULT, timestamp)
 
155
                        drag_context.drag_status(Gdk.DragAction.DEFAULT, timestamp)
155
156
                        return False                    
156
157
 
157
158
        
158
159
        def on_event_clicked(self, widget, event):
159
160
 
160
 
                if event.type==gtk.gdk.BUTTON_PRESS and event.button==3:
 
161
                if event.type==Gdk.EventType.BUTTON_PRESS and event.button==3:
161
162
                        path = self.get_path_at_pos(int(event.x), int(event.y))
162
163
                        if path != None:
163
 
                                row = self.get(path[0][0], "device")
 
164
                                row = self.get(path[0], "device")
164
165
                        
165
166
                                if row:
166
167
                                        device = row["device"]
168
169
                                                if self.menu == None:
169
170
                                                        self.menu = ManagerDeviceMenu(self.Blueman)
170
171
                                        
171
 
                                                self.menu.popup(None, None, None, event.button, event.time)
 
172
                                                self.menu.popup(None, None, None, None, event.button, event.time)
 
173
 
172
174
        
173
175
        
174
176
        
215
217
        def device_add_event(self, device):
216
218
                if device.Fake:
217
219
                        self.PrependDevice(device)
218
 
                        gobject.idle_add(self.props.vadjustment.set_value , 0)
 
220
                        GObject.idle_add(self.props.vadjustment.set_value , 0)
219
221
                        return
220
222
 
221
223
                if self.Blueman.Config.props.latest_last:
442
444
 
443
445
                path = self.get_path_at_pos(x, y)
444
446
 
445
 
 
446
 
                if path:
447
 
                        if path[0][0] != self.tooltip_row or path[1] != self.tooltip_col:
448
 
                                self.tooltip_row = path[0][0]
 
447
                if path is not None:
 
448
                        if path[0] != self.tooltip_row or path[1] != self.tooltip_col:
 
449
                                self.tooltip_row = path[0]
449
450
                                self.tooltip_col = path[1]
450
451
                                return False
451
452
                        
452
453
                        if path[1] == self.columns["device_pb"]:
453
 
                                iter = self.get_iter(path[0][0])
 
454
                                iter = self.get_iter(path[0])
454
455
                                
455
456
                                row = self.get(iter, "trusted", "bonded")
456
457
                                trusted = row["trusted"]
465
466
                                        return False
466
467
                                
467
468
                                        
468
 
                                self.tooltip_row = path[0][0]
 
469
                                self.tooltip_row = path[0]
469
470
                                self.tooltip_col = path[1]
470
471
                                return True
471
472
 
472
473
                        
473
474
                        if path[1] == self.columns["tpl_pb"] or path[1] == self.columns["lq_pb"] or path[1] == self.columns["rssi_pb"]:
474
 
                                iter = self.get_iter(path[0][0])
 
475
                                iter = self.get_iter(path[0])
475
476
 
476
477
                                dt = self.get(iter, "connected")["connected"]
477
478
                                #print dt
518
519
                                        elif path[1] == self.columns["rssi_pb"]:
519
520
                                                tooltip.set_markup(_("<b>Connected</b>\n<b>Received Signal Strength: %(rssi)u%%</b> <i>(%(rssi_state)s)</i>\nLink Quality: %(lq)u%%\nTransmit Power Level: %(tpl)u%% <i>(%(tpl_state)s)</i>") % {"rssi_state": rssi_state, "rssi":rssi, "lq":lq, "tpl":tpl, "tpl_state": tpl_state})
520
521
                                        
521
 
                                        self.tooltip_row = path[0][0]
 
522
                                        self.tooltip_row = path[0]
522
523
                                        self.tooltip_col = path[1]
523
524
                                        return True     
524
525
                return False