def xdg_screensaver(self, action): command = "xdg-screensaver %s %s" % (action, self.root_window_id) if action == "resume": if self.wake_lock <= 0: self.wake_lock = 0 elif self.wake_lock > 1: self.wake_lock -= 1 else: ret = launch(command, sn=False) if ret: self.wake_lock -= 1 else: logging.error("%s failed" % action) elif action == "suspend": if self.wake_lock >= 1: self.wake_lock += 1 else: ret = launch(command, sn=False) if ret: self.wake_lock += 1 else: logging.error("%s failed" % action) logging.info("Number of locks: %s" % self.wake_lock)
def _on_plugins_changed(self, _plugins, _name): implementation = self._get_status_icon_implementation() if not self._implementation or self._implementation != implementation: self._implementation = implementation if self.parent.manager_state: launch('blueman-tray', icon_name='blueman', sn=False)
def _on_plugins_changed(self, _plugins: PluginManager, _name: str) -> None: implementations = self._get_status_icon_implementations() if not self._implementations or self._implementations != implementations: self._implementations = implementations if self.parent.manager_state: launch('blueman-tray', icon_name='blueman', sn=False)
def on_devices(self, menu_item): lockfile = get_lockfile('blueman-manager') pid = get_pid(lockfile) if lockfile and pid and is_running('blueman-manager', pid): os.kill(pid, signal.SIGTERM) else: launch("blueman-manager", None, False, "blueman", _("Device Manager"))
def xdg_screensaver(self, action: str) -> None: command = f"xdg-screensaver {action} {self.root_window_id}" if action == "resume": if self.wake_lock <= 0: self.wake_lock = 0 elif self.wake_lock > 1: self.wake_lock -= 1 else: ret = launch(command, sn=False) if ret: self.wake_lock -= 1 else: logging.error(f"{action} failed") elif action == "suspend": if self.wake_lock >= 1: self.wake_lock += 1 else: ret = launch(command, sn=False) if ret: self.wake_lock += 1 else: logging.error(f"{action} failed") logging.info(f"Number of locks: {self.wake_lock}")
def _on_plugins_changed(self, _plugins, _name): implementation = self._get_status_icon_implementation() if not self._implementation or self._implementation != implementation: self._implementation = implementation pid = get_pid(get_lockfile('blueman-tray')) if pid: kill(pid, 'blueman-tray') launch('blueman-tray', icon_name='blueman', sn=False)
def drag_recv(self, _widget: Gtk.Widget, context: Gdk.DragContext, x: int, y: int, selection: Gtk.SelectionData, _info: int, time: int) -> None: uris = list(selection.get_uris()) context.finish(True, False, time) path = self.get_path_at_pos(x, y) if path: tree_iter = self.get_iter(path[0]) device = self.get(tree_iter, "device")["device"] command = f"blueman-sendto --device={device['Address']}" launch(command, paths=uris, name=_("File Sender")) context.finish(True, False, time) else: context.finish(False, False, time)
def drag_recv(self, widget, context, x, y, selection, target_type, time): uris = list(selection.get_uris()) context.finish(True, False, time) path = self.get_path_at_pos(x, y) if path: tree_iter = self.get_iter(path[0]) device = self.get(tree_iter, "device")["device"] command = "blueman-sendto --device=%s" % device['Address'] launch(command, uris, False, "blueman", _("File Sender")) context.finish(True, False, time) else: context.finish(False, False, time) return True
def send_note_cb(dialog, response_id, device_address, text_view): text = text_view.get_buffer().props.text dialog.destroy() if response_id == Gtk.ResponseType.CANCEL: return date = datetime.datetime.now().strftime('%Y%m%dT%H%M00') data = ('BEGIN:VNOTE \n' 'VERSION:1.1 \n' 'BODY;CHARSET=UTF-8: %s \n' 'DCREATED:%s \n' 'LAST-MODIFIED:%s \n' 'CLASS:PUBLIC \n' 'X-IRMC-LUID:000001000000 \n' 'END:VNOTE \n' % (' '.join(text.splitlines()), date, date)) tempfile = NamedTemporaryFile(suffix='.vnt', prefix='note', delete=False) tempfile.write(data.encode('utf-8')) tempfile.close() launch('blueman-sendto --delete --device=%s' % device_address, [tempfile.name], False, 'blueman')
def on_manager_state_changed(self, state: bool) -> None: self.query_visibility() if state: launch('blueman-tray', icon_name='blueman', sn=False)
def on_open(_action: str) -> None: self._notification = None logging.info("open") launch("xdg-open", paths=[path], system=True)
def on_devices(self): lockfile = get_lockfile('blueman-manager') pid = get_pid(lockfile) if not lockfile or not kill(pid, 'blueman-manager'): launch("blueman-manager", None, False, "blueman", _("Device Manager"))
def on_open(*_args): print("open") launch("xdg-open", [path], True)
def on_devices(self, menu_item): launch("blueman-manager", None, False, "blueman", _("Device Manager"))
def on_setup_new(self, menu_item): launch("blueman-assistant", None, False, "blueman", _("Bluetooth Assistant"))
def on_adapters(self, menu_item): launch("blueman-adapters", None, False, "blueman", _("Adapter Preferences"))
def __init__(self, blueman): self.blueman = blueman self.Config = Config("org.blueman.general") self.adapter_items = {} self._adapters_group = [] self._insert_adapter_item_pos = 2 self.Search = None self.item_adapter = self.blueman.Builder.get_object("item_adapter") self.item_device = self.blueman.Builder.get_object("item_device") self.item_view = self.blueman.Builder.get_object("item_view") self.item_help = self.blueman.Builder.get_object("item_help") help_menu = Gtk.Menu() self.item_help.set_submenu(help_menu) help_menu.show() report_item = create_menuitem(_("_Report a Problem"), "dialog-warning") report_item.show() help_menu.append(report_item) report_item.connect("activate", lambda x: launch("xdg-open %s/issues" % WEBSITE, None, True)) sep = Gtk.SeparatorMenuItem() sep.show() help_menu.append(sep) help_item = create_menuitem("_Help", "help-about") help_item.show() help_menu.append(help_item) help_item.connect("activate", lambda x: show_about_dialog('Blueman ' + _('Device Manager'), parent=self.blueman.get_toplevel())) view_menu = Gtk.Menu() self.item_view.set_submenu(view_menu) view_menu.show() item_toolbar = Gtk.CheckMenuItem.new_with_mnemonic(_("Show _Toolbar")) item_toolbar.show() view_menu.append(item_toolbar) self.blueman.Config.bind_to_widget("show-toolbar", item_toolbar, "active") item_statusbar = Gtk.CheckMenuItem.new_with_mnemonic(_("Show _Statusbar")) item_statusbar.show() view_menu.append(item_statusbar) self.blueman.Config.bind_to_widget("show-statusbar", item_statusbar, "active") item_services = Gtk.SeparatorMenuItem() view_menu.append(item_services) item_services.show() sorting_group = [] item_sort = Gtk.MenuItem.new_with_mnemonic(_("S_ort By")) view_menu.append(item_sort) item_sort.show() sorting_menu = Gtk.Menu() item_sort.set_submenu(sorting_menu) self._sort_alias_item = Gtk.RadioMenuItem.new_with_mnemonic(sorting_group, _("_Name")) self._sort_alias_item.show() sorting_group = self._sort_alias_item.get_group() sorting_menu.append(self._sort_alias_item) self._sort_timestamp_item = Gtk.RadioMenuItem.new_with_mnemonic(sorting_group, _("_Added")) self._sort_timestamp_item.show() sorting_menu.append(self._sort_timestamp_item) sort_config = self.Config['sort-by'] if sort_config == "alias": self._sort_alias_item.props.active = True else: self._sort_timestamp_item.props.active = True sort_sep = Gtk.SeparatorMenuItem() sort_sep.show() sorting_menu.append(sort_sep) self._sort_type_item = Gtk.CheckMenuItem.new_with_mnemonic(_("_Descending")) self._sort_type_item.show() sorting_menu.append(self._sort_type_item) if self.Config['sort-order'] == "ascending": self._sort_type_item.props.active = False else: self._sort_type_item.props.active = True sep = Gtk.SeparatorMenuItem() sep.show() view_menu.append(sep) item_plugins = create_menuitem(_("_Plugins"), 'blueman-plugin') item_plugins.show() view_menu.append(item_plugins) item_plugins.connect('activate', self._on_plugin_dialog_activate) item_services = create_menuitem(_("_Local Services") + "...", "preferences-desktop") item_services.connect('activate', lambda *args: launch("blueman-services", None, False, "blueman", _("Service Preferences"))) view_menu.append(item_services) item_services.show() adapter_menu = Gtk.Menu() self.item_adapter.set_submenu(adapter_menu) self.item_adapter.props.sensitive = False search_item = create_menuitem(_("_Search"), "edit-find") search_item.connect("activate", lambda x: self.blueman.inquiry()) search_item.show() adapter_menu.prepend(search_item) self.Search = search_item sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) adapter_settings = create_menuitem("_Preferences", "preferences-system") adapter_settings.connect("activate", lambda x: self.blueman.adapter_properties()) adapter_settings.show() adapter_menu.append(adapter_settings) sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) exit_item = create_menuitem("_Exit", "application-exit") exit_item.connect("activate", lambda x: Gtk.main_quit()) exit_item.show() adapter_menu.append(exit_item) self.item_adapter.show() self.item_view.show() self.item_help.show() self.item_device.show() self.item_device.props.sensitive = False self._manager = bluez.Manager() self._manager.connect_signal("adapter-added", self.on_adapter_added) self._manager.connect_signal("adapter-removed", self.on_adapter_removed) blueman.List.connect("device-selected", self.on_device_selected) for adapter in self._manager.get_adapters(): self.on_adapter_added(None, adapter.get_object_path()) self.device_menu = None self.Config.connect("changed", self._on_settings_changed) self._sort_alias_item.connect("activate", self._on_sorting_changed, "alias") self._sort_timestamp_item.connect("activate", self._on_sorting_changed, "timestamp") self._sort_type_item.connect("activate", self._on_sorting_changed, "sort-type")
def on_setup_new(self): launch("blueman-assistant", name=_("Bluetooth Assistant"))
def __init__(self, blueman): self.blueman = blueman self.Config = Config("org.blueman.general") self.adapter_items: Dict[str, Tuple[Gtk.RadioMenuItem, Adapter]] = {} self._adapters_group: List[Gtk.RadioMenuItem] = [] self._insert_adapter_item_pos = 2 self.Search = None self.item_adapter = self.blueman.Builder.get_object("item_adapter") self.item_device = self.blueman.Builder.get_object("item_device") self.item_view = self.blueman.Builder.get_object("item_view") self.item_help = self.blueman.Builder.get_object("item_help") help_menu = Gtk.Menu() self.item_help.set_submenu(help_menu) help_menu.show() report_item = create_menuitem(_("_Report a Problem"), "dialog-warning") report_item.show() help_menu.append(report_item) report_item.connect("activate", lambda x: launch(f"xdg-open {WEBSITE}/issues")) sep = Gtk.SeparatorMenuItem() sep.show() help_menu.append(sep) help_item = create_menuitem(_("_Help"), "help-about") help_item.show() help_menu.append(help_item) help_item.connect( "activate", lambda x: show_about_dialog('Blueman ' + _('Device Manager'), parent=self.blueman.get_toplevel())) view_menu = Gtk.Menu() self.item_view.set_submenu(view_menu) view_menu.show() item_toolbar = Gtk.CheckMenuItem.new_with_mnemonic(_("Show _Toolbar")) item_toolbar.show() view_menu.append(item_toolbar) self.blueman.Config.bind_to_widget("show-toolbar", item_toolbar, "active") item_statusbar = Gtk.CheckMenuItem.new_with_mnemonic( _("Show _Statusbar")) item_statusbar.show() view_menu.append(item_statusbar) self.blueman.Config.bind_to_widget("show-statusbar", item_statusbar, "active") item_services = Gtk.SeparatorMenuItem() view_menu.append(item_services) item_services.show() sorting_group: List[Gtk.RadioMenuItem] = [] item_sort = Gtk.MenuItem.new_with_mnemonic(_("S_ort By")) view_menu.append(item_sort) item_sort.show() sorting_menu = Gtk.Menu() item_sort.set_submenu(sorting_menu) self._sort_alias_item = Gtk.RadioMenuItem.new_with_mnemonic( sorting_group, _("_Name")) self._sort_alias_item.show() sorting_group = self._sort_alias_item.get_group() sorting_menu.append(self._sort_alias_item) self._sort_timestamp_item = Gtk.RadioMenuItem.new_with_mnemonic( sorting_group, _("_Added")) self._sort_timestamp_item.show() sorting_menu.append(self._sort_timestamp_item) sort_config = self.Config['sort-by'] if sort_config == "alias": self._sort_alias_item.props.active = True else: self._sort_timestamp_item.props.active = True sort_sep = Gtk.SeparatorMenuItem() sort_sep.show() sorting_menu.append(sort_sep) self._sort_type_item = Gtk.CheckMenuItem.new_with_mnemonic( _("_Descending")) self._sort_type_item.show() sorting_menu.append(self._sort_type_item) if self.Config['sort-order'] == "ascending": self._sort_type_item.props.active = False else: self._sort_type_item.props.active = True sep = Gtk.SeparatorMenuItem() sep.show() view_menu.append(sep) item_plugins = create_menuitem(_("_Plugins"), 'blueman-plugin') item_plugins.show() view_menu.append(item_plugins) item_plugins.connect('activate', self._on_plugin_dialog_activate) item_services = create_menuitem( _("_Local Services") + "…", "preferences-desktop") item_services.connect( 'activate', lambda *args: launch("blueman-services", name=_("Service Preferences"))) view_menu.append(item_services) item_services.show() adapter_menu = Gtk.Menu() self.item_adapter.set_submenu(adapter_menu) self.item_adapter.props.sensitive = False search_item = create_menuitem(_("_Search"), "edit-find") search_item.connect("activate", lambda x: self.blueman.inquiry()) search_item.show() adapter_menu.prepend(search_item) self.Search = search_item sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) adapter_settings = create_menuitem(_("_Preferences"), "preferences-system") adapter_settings.connect("activate", lambda x: self.blueman.adapter_properties()) adapter_settings.show() adapter_menu.append(adapter_settings) sep = Gtk.SeparatorMenuItem() sep.show() adapter_menu.append(sep) exit_item = create_menuitem(_("_Exit"), "application-exit") exit_item.connect("activate", lambda x: Gtk.main_quit()) exit_item.show() adapter_menu.append(exit_item) self.item_adapter.show() self.item_view.show() self.item_help.show() self.item_device.show() self.item_device.props.sensitive = False self._manager = Manager() self._manager.connect_signal("adapter-added", self.on_adapter_added) self._manager.connect_signal("adapter-removed", self.on_adapter_removed) blueman.List.connect("device-selected", self.on_device_selected) for adapter in self._manager.get_adapters(): self.on_adapter_added(None, adapter.get_object_path()) self.device_menu = None self.Config.connect("changed", self._on_settings_changed) self._sort_alias_item.connect("activate", self._on_sorting_changed, "alias") self._sort_timestamp_item.connect("activate", self._on_sorting_changed, "timestamp") self._sort_type_item.connect("activate", self._on_sorting_changed, "sort-type")
def _on_plugins_changed(self, _plugins, _name): implementation = self.GetStatusIconImplementation() if not self._implementation or self._implementation != implementation: self._implementation = implementation kill(get_pid(get_lockfile('blueman-tray')), 'blueman-tray') launch('blueman-tray', icon_name='blueman', sn=False)
def on_devices(self): lockfile = get_lockfile('blueman-manager') pid = get_pid(lockfile) if not pid or not kill(pid, 'blueman-manager'): launch("blueman-manager", name=_("Device Manager"))
def on_open(*_args): logging.info("open") launch("xdg-open", [path], True)
def on_local_services(self, menu_item): launch("blueman-services", None, False, "blueman", _("Service Preferences"))
def _on_plugins_changed(self, _plugins, _name): implementation = self._get_status_icon_implementation() if not self._implementation or self._implementation != implementation: self._implementation = implementation kill(get_pid(get_lockfile('blueman-tray')), 'blueman-tray') launch('blueman-tray', icon_name='blueman', sn=False)
def on_send(self, menu_item): launch("blueman-sendto", None, False, "blueman", _("File Sender"))
def on_open(*_args): self._notification = None logging.info("open") launch("xdg-open", paths=[path], system=True)
def on_open(*_args): self._notification = None logging.info("open") launch("xdg-open", [path], True)
def on_browse(self, menu_item): launch("blueman-browse", None, False, "blueman", _("File Browser"))
def on_adapters(self) -> None: launch("blueman-adapters", name=_("Adapter Preferences"))
def on_local_services(self) -> None: launch("blueman-services", name=_("Service Preferences"))
def on_send(self) -> None: launch("blueman-sendto", name=_("File Sender"))