コード例 #1
0
ファイル: ManagerDeviceList.py プロジェクト: moontide/blueman
    def on_event_clicked(self, _widget: Gtk.Widget, event: Gdk.Event) -> bool:
        if event.type not in (Gdk.EventType._2BUTTON_PRESS,
                              Gdk.EventType.BUTTON_PRESS):
            return False

        path = self.get_path_at_pos(int(cast(Gdk.EventButton, event).x),
                                    int(cast(Gdk.EventButton, event).y))
        if path is None:
            return False

        assert path[0] is not None
        row = self.get(path[0], "device", "connected")
        if not row:
            return False

        if self.Blueman is None:
            return False

        if self.menu is None:
            self.menu = ManagerDeviceMenu(self.Blueman)

        if event.type == Gdk.EventType._2BUTTON_PRESS and cast(
                Gdk.EventButton, event).button == 1:
            if self.menu.show_generic_connect_calc(row["device"]['UUIDs']):
                self.menu.generic_connect(None,
                                          device=row["device"],
                                          connect=not row["connected"])

        if event.type == Gdk.EventType.BUTTON_PRESS and cast(
                Gdk.EventButton, event).button == 3:
            self.menu.popup_at_pointer(event)

        return False
コード例 #2
0
    def on_event_clicked(self, _widget: Gtk.Widget, event: Gdk.Event) -> bool:
        if event.type not in (Gdk.EventType._2BUTTON_PRESS, Gdk.EventType.BUTTON_PRESS):
            return False

        posdata = self.get_path_at_pos(int(cast(Gdk.EventButton, event).x), int(cast(Gdk.EventButton, event).y))
        if posdata is None:
            return False
        else:
            path = posdata[0]
            assert path is not None

        childpath = self.filter.convert_path_to_child_path(path)
        assert childpath is not None
        row = self.get(childpath, "device", "connected")
        if not row:
            return False

        if self.Blueman is None:
            return False

        if self.menu is None:
            self.menu = ManagerDeviceMenu(self.Blueman)

        if event.type == Gdk.EventType._2BUTTON_PRESS and cast(Gdk.EventButton, event).button == 1:
            if self.menu.show_generic_connect_calc(row["device"]['UUIDs']):
                if row["connected"]:
                    self.menu.disconnect_service(row["device"])
                else:
                    self.menu.connect_service(row["device"])

        if event.type == Gdk.EventType.BUTTON_PRESS and cast(Gdk.EventButton, event).button == 3:
            self.menu.popup_at_pointer(event)

        return False
コード例 #3
0
ファイル: ManagerDeviceList.py プロジェクト: geosp/blueman
    def on_event_clicked(self, widget, event):
        if event.type not in (Gdk.EventType._2BUTTON_PRESS,
                              Gdk.EventType.BUTTON_PRESS):
            return

        path = self.get_path_at_pos(int(event.x), int(event.y))
        if path is None:
            return

        row = self.get(path[0], "device", "connected")
        if not row:
            return

        if self.Blueman is None:
            return

        if self.menu is None:
            self.menu = ManagerDeviceMenu(self.Blueman)

        if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
            if self.menu.show_generic_connect_calc(row["device"]['UUIDs']):
                self.menu.generic_connect(item=None,
                                          device=row["device"],
                                          connect=not row["connected"])

        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
            self.menu.popup_at_pointer(event)
コード例 #4
0
    def on_device_selected(self, List, device, iter):
        if iter and device:
            self.item_device.props.sensitive = True

            if self.device_menu == None:
                self.device_menu = ManagerDeviceMenu(self.blueman)
                self.item_device.set_submenu(self.device_menu)
            else:
                GObject.idle_add(self.device_menu.Generate, priority=GObject.PRIORITY_LOW)

        else:
            self.item_device.props.sensitive = False
コード例 #5
0
ファイル: ManagerMenu.py プロジェクト: WilliamMajanja/blueman
    def on_device_selected(self, lst, device, tree_iter):
        if tree_iter and device:
            self.item_device.props.sensitive = True

            if self.device_menu is None:
                self.device_menu = ManagerDeviceMenu(self.blueman)
                self.item_device.set_submenu(self.device_menu)
            else:
                GLib.idle_add(self.device_menu.generate, priority=GLib.PRIORITY_LOW)

        else:
            self.item_device.props.sensitive = False
コード例 #6
0
    def on_event_clicked(self, widget, event):

        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 3:
            path = self.get_path_at_pos(int(event.x), int(event.y))
            if path is not None:
                row = self.get(path[0], "device")

                if row:
                    if self.Blueman is not None:
                        if self.menu is None:
                            self.menu = ManagerDeviceMenu(self.Blueman)

                        self.menu.popup(None, None, None, None, event.button, event.time)
コード例 #7
0
    def _on_popup_menu(self, _widget: Gtk.Widget) -> bool:
        if self.Blueman is None:
            return False

        if self.menu is None:
            self.menu = ManagerDeviceMenu(self.Blueman)

        window = self.get_window()
        assert window is not None
        selected = self.selected()
        assert selected is not None
        rect = self.get_cell_area(self.liststore.get_path(selected), self.get_column(1))
        self.menu.popup_at_rect(window, rect, Gdk.Gravity.CENTER, Gdk.Gravity.NORTH)

        return True
コード例 #8
0
    def on_event_clicked(self, widget, event):

        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
            path = self.get_path_at_pos(int(event.x), int(event.y))
            if path != None:
                row = self.get(path[0][0], "device")

                if row:
                    device = row["device"]
                    if self.Blueman != None:
                        if self.menu == None:
                            self.menu = ManagerDeviceMenu(self.Blueman)

                        self.menu.popup(None, None, None, event.button,
                                        event.time)
コード例 #9
0
    def on_device_selected(self, _lst: ManagerDeviceList, device: Device, tree_iter: Gtk.TreeIter) -> None:
        if tree_iter and device:
            self.item_device.props.sensitive = True

            if self.device_menu is None:
                self.device_menu = ManagerDeviceMenu(self.blueman)
                self.item_device.set_submenu(self.device_menu)
            else:
                def idle() -> bool:
                    assert self.device_menu is not None  # https://github.com/python/mypy/issues/2608
                    self.device_menu.generate()
                    return False
                GLib.idle_add(idle, priority=GLib.PRIORITY_LOW)

        else:
            self.item_device.props.sensitive = False