def notify_dbus(self, option): from .options import OptionItem for location in self.locations: value = option.value if isinstance(option, OptionItem): signal = 'CONFIG_CHANGED' else: signal = 'CONFIG_EXTRA_CHANGED' if option.no_submit: value = None message = SignalMessage(self.dbus_path, self.dbus_ns, signal) signature = 'ssv' if isinstance(value, dict) and not len(value): # emptry dicts can't be detected signature = 'a{ss}' elif isinstance(value, (tuple, list)) and not len(value): # empty lists can't be detected, so we assume # list of strings signature = "ssas" message.append(workspace_name(), option.name, value, signature=signature) location[0].send_message(message)
def notify_dbus(self, option): from .options import OptionItem for location in self.locations: value = option.value if isinstance(option, OptionItem): signal = 'CONFIG_CHANGED' else: signal = 'CONFIG_EXTRA_CHANGED' if option.no_submit: value = None message = SignalMessage(self.dbus_path, self.dbus_ns, signal) signature = 'ssv' if isinstance(value, dict) and not len(value): # emptry dicts can't be detected signature = 'a{ss}' elif isinstance(value, (tuple, list)) and not len(value): # empty lists can't be detected, so we assume # list of strings signature = "ssas" message.append(workspace_name(), option.name, value, signature=signature) location[0].send_message(message)
def get_instance_status(self): return dumps({ 'pid': os.getpid(), 'workspace': workspace_name(), 'buffers': self.svc.boss.cmd('buffer', 'get_buffer_names'), 'project': getattr( self.svc.boss.cmd('project','get_current_project'), 'name', ''), }, indent=2)
def on_config_changed(self, workspace, name, value, sender=None): if sender == BUS.get_unique_name(): return try: opt = self.get_option(str(name)) except KeyError as e: return if (opt.workspace and workspace_name() == workspace) or \ not opt.workspace: self.set_value(name, value, save=False, dbus_notify=False)
def update_title(self, document=None): if self._title_template is None: self._title_template = string.Template(self.opt('window_title')) if document is None: document = self.boss.cmd('buffer', 'get_current') subs = {'basename': document.basename or _('New Document'), 'filepath': document.filename or _('New Document'), 'directory': document.directory or '', 'workspace': workspace_name(), 'project_path': document.project and document.project.data_dir or '', 'project_name': document.project_name } self.window.set_title(self._title_template.safe_substitute(subs))
def create_ui(self): console = Console(locals=self.svc.get_local_dict(), banner=_("PIDA Shell. Keep breathing."), use_rlcompleter=False) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(console) sw.show_all() self.add_main_widget(sw) for path in (py.path.local(__file__).dirpath() / "manholerc.py", home() / "manhole.rc", home() / ("manhole.%s.rc" % workspace_name())): if path.check(): #console.do_raw_input(line) console.execfile(str(path))
class DbusOptionsManagerReal(Object): __dbus_mapping = { bool: 'b', str: 's', unicode: 's', int: 'i', long: 'x', float: 'd', list: 'as', file: 's', Font: 's', } dbus_no_activate = () def __init__(self, service): self.svc = service path = DBUS_PATH(service.get_name(), self.dbus_path) ns = DBUS_NS(service.get_name(), self.dbus_path) self.dbus_ns = ns self.dbus_path = path Object.__init__(self, BUS_NAME, path) self.config_match = BUS.add_signal_receiver( self.on_config_changed, 'CONFIG_CHANGED', ns, None, path, sender_keyword='sender') self.config_extra_match = BUS.add_signal_receiver( self.on_config_changed_extra, 'CONFIG_EXTRA_CHANGED', ns, None, path, sender_keyword='sender') def unload(self): self.config_match.remove() self.config_extra_match.remove() self.remove_from_connection() def on_config_changed(self, workspace, name, value, sender=None): if sender == BUS.get_unique_name(): return try: opt = self.get_option(str(name)) except KeyError, e: return from .options import ExtraOptionItem if (opt.workspace and workspace_name() == workspace) or \ not opt.workspace: self.set_value(name, value, save=False, dbus_notify=False)
def update_title(self, document=None): if self._title_template is None: self._title_template = string.Template(self.opt('window_title')) if document is None: document = self.boss.cmd('buffer', 'get_current') subs = { 'basename': document.basename or _('New Document'), 'filepath': document.filename or _('New Document'), 'directory': document.directory or '', 'workspace': workspace_name(), 'project_path': document.project and document.project.data_dir or '', 'project_name': document.project_name } self.window.set_title(self._title_template.safe_substitute(subs))
def state_config(self): return settings_dir().join('workspaces', workspace_name(), "window.state.json")
def state_config(self): return settings_dir().join('workspaces', workspace_name(), "window.state.json")
def prio_path(): return environment.settings_dir().join( 'workspaces', environment.workspace_name(), 'language_extra_plugin_priorities.json')
def get_workspace_name(self): return workspace_name()
except KeyError, e: return from .options import ExtraOptionItem if (opt.workspace and workspace_name() == workspace) or \ not opt.workspace: self.set_value(name, value, save=False, dbus_notify=False) def on_config_changed_extra(self, workspace, name, value, sender=None): if sender == BUS.get_unique_name(): return try: opt = self.get_extra_option(str(name)) except KeyError, e: return if (opt.workspace and workspace_name() == workspace) or \ not opt.workspace: if opt.no_submit: opt.dirty = True else: self.set_extra_value(name, value, save=False, dbus_notify=False) def notify_dbus(self, option): from .options import OptionItem for location in self.locations: value = option.value if isinstance(option, OptionItem): signal = 'CONFIG_CHANGED' else: signal = 'CONFIG_EXTRA_CHANGED' if option.no_submit: