25
25
from blueman.gui.manager.ManagerDeviceMenu import ManagerDeviceMenu
26
26
from blueman.Sdp import *
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 *
36
37
class ManagerDeviceList(DeviceList):
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
43
["device_pb", 'GdkPixbuf', gtk.CellRendererPixbuf(), {"pixbuf":0}, None],
44
["device_pb", 'GdkPixbuf', Gtk.CellRendererPixbuf(), {"pixbuf":0}, None],
46
47
["caption", str, cr, {"markup":1}, None, {"expand": True}],
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}],
53
54
#trusted/bonded icons
54
55
#["tb_icons", 'PyObject', CellRendererPixbufTable(), {"pixbuffs":5}, None],
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],
85
86
self.connect("drag_data_received", self.drag_recv)
86
87
self.connect("drag-motion", self.drag_motion)
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)
91
self.set_search_equal_func(self.search_func)
92
self.set_search_equal_func(self.search_func, None)
93
94
def do_device_found(self, device):
94
95
iter = self.find_device(device)
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)
114
115
path = self.get_path_at_pos(x, y)
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)
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:
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])
147
drag_context.drag_status(gtk.gdk.ACTION_DEFAULT, timestamp)
148
drag_context.drag_status(Gdk.DragAction.DEFAULT, timestamp)
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])
154
drag_context.drag_status(gtk.gdk.ACTION_DEFAULT, timestamp)
155
drag_context.drag_status(Gdk.DragAction.DEFAULT, timestamp)
158
159
def on_event_clicked(self, widget, event):
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))
163
row = self.get(path[0][0], "device")
164
row = self.get(path[0], "device")
166
167
device = row["device"]
168
169
if self.menu == None:
169
170
self.menu = ManagerDeviceMenu(self.Blueman)
171
self.menu.popup(None, None, None, event.button, event.time)
172
self.menu.popup(None, None, None, None, event.button, event.time)
215
217
def device_add_event(self, device):
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)
221
223
if self.Blueman.Config.props.latest_last:
443
445
path = self.get_path_at_pos(x, y)
447
if path[0][0] != self.tooltip_row or path[1] != self.tooltip_col:
448
self.tooltip_row = path[0][0]
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]
452
453
if path[1] == self.columns["device_pb"]:
453
iter = self.get_iter(path[0][0])
454
iter = self.get_iter(path[0])
455
456
row = self.get(iter, "trusted", "bonded")
456
457
trusted = row["trusted"]
468
self.tooltip_row = path[0][0]
469
self.tooltip_row = path[0]
469
470
self.tooltip_col = path[1]
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])
476
477
dt = self.get(iter, "connected")["connected"]
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})
521
self.tooltip_row = path[0][0]
522
self.tooltip_row = path[0]
522
523
self.tooltip_col = path[1]