def get_folders(): configuration = Configuration() folders = [] for folder in configuration.get_folders(): folder['mounted'] = is_folder_mounted(folder['encfs-path']) folders.append(folder) return folders
def show_statistics(self, widget): widget.set_sensitive(False) if self.is_monitoring and self.monitor is not None: self.monitor.save() title = _('Habits') subtitle = _('Mouse and keyboard') configuration = Configuration() stats = configuration.get('stats') days = [] distance = [] clics = [] keys = [] for day in stats: days.append(day) if 'distance' in stats[day].keys(): distance.append(stats[day]['distance']/1000.0) else: distance.append(0) if 'clics' in stats[day].keys(): clics.append(stats[day]['clics']) else: clics.append(0) if 'keys' in stats[day].keys(): keys.append(stats[day]['keys']) else: keys.append(0) graph = Graph(title, subtitle, days, distance, clics, keys) graph.run() graph.destroy() widget.set_sensitive(True)
def start(self): configuration = Configuration() preferences = configuration.get('preferences') https_protocol = preferences['https_protocol'] base_url = preferences['base_url'] application_name = preferences['application_name'] application_token = preferences['application_token'] client_token = preferences['client_token'] if base_url and application_name and application_token \ and client_token: self.gotify_client = GotifyClient(https_protocol, base_url, application_name, application_token, client_token, self.on_message, True) self.gotify_client.set_icon_callback(self.set_icon) self.gotify_client.start() self.menu_toggle_service.set_label(_('Stop service')) return True message = _('Please configure Gotify Indicator') icon = os.path.join(config.ICONDIR, 'gotify-indicator.svg') self.notification.update('Gofify-Indictator', message, icon) self.notification.show()
def set_active(self): self.store.clear() configuration = Configuration() calendars_options = configuration.get('calendars') if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file=comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() for calendar in calendars: calendar_options = get_calendar_from_options( configuration.get('calendars'), calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex() foreground_color = contraste(background_color) visible = True calendar_name = calendar['summary'] self.store.append([ calendar['summary'], background_color, foreground_color, calendar['id'], visible, calendar_name ])
def __init__(self, ): configuration = Configuration() preferences = configuration.get("preferences") parent_folder = Path(os.path.expanduser( preferences["todo-file"])).parent.as_posix() self.todo_histoy = parent_folder + os.sep + "todo.history.txt" self.export_file = parent_folder + os.sep + "export.csv"
def load(self): configuration = Configuration() preferences = configuration.get('preferences') projects = preferences['projects'] contexts = preferences['contexts'] project_store = self.project.get_model() project_store.clear() project_store.append(['-', '-']) if projects: for project in projects: project_store.append([project, project]) self.project.set_model(project_store) context_store = self.context.get_model() context_store.clear() context_store.append(['-', '-']) if contexts: for context in contexts: context_store.append([context, context]) self.context.set_model(context_store) select_value_in_combo(self.priority, -1) select_value_in_combo(self.project, '-') select_value_in_combo(self.context, '-') todo_file = Path(os.path.expanduser(preferences['todo-file'])) if not todo_file.exists(): if not todo_file.parent.exists(): os.makedirs(todo_file.parent) todo_file.touch() self.todo_file = todo_file.as_posix() self.load_todos()
def load_preferences(self): configuration = Configuration() preferences = configuration.get('preferences') self.theme_light = preferences['theme-light'] self.application_name = preferences['application_name'] self.stop() self.start()
def __init__(self, title=""): configuration = Configuration() preferences = configuration.get("preferences") self.todo_histoy = (Path(os.path.expanduser( preferences["todo-file"])).parent.as_posix() + os.sep + "todo.history.txt") BaseGraph.__init__(self, title, "") self.subtitle = ""
def on_options_changed(self, widget, data): configuration = Configuration() configuration.set('time', self.options['time'].get_value()) if self.options['theme'].get_active(): configuration.set('theme', 'dark') else: configuration.set('theme', 'light') configuration.save()
def check_status_from_resume(self): configuration = Configuration() self.touchpad_enabled = configuration.get('touchpad_enabled') if self.touchpad_enabled != self.touchpad.are_all_touchpad_enabled(): self.set_touch_enabled(self.touchpad_enabled) if self.on_mouse_plugged and not self.touchpad_enabled: if not is_mouse_plugged(): self.set_touch_enabled(True)
def set_active(self): configuration = Configuration() self.options['time'].set_value(configuration.get('time')) self.options['theme'].set_active(configuration.get('theme') == 'light') filestart = os.path.join( os.getenv("HOME"), ".config/autostart/calendar-indicator-autostart.desktop") self.options['autostart'].set_active(os.path.exists(filestart))
def getNotificationSound(self): path = os.path.join(config.SOUNDDIR, 'default.mp3') configuration = Configuration() preferences = configuration.get('preferences') custom_path = preferences['notification_sound'] if custom_path: path = custom_path return AudioSegment.from_mp3(path)
def load_preferences(self): configuration = Configuration() self.show_disks.set_active(configuration.get('show-hdd')) self.show_net.set_active(configuration.get('show-net')) filestart = os.path.join( os.getenv("HOME"), ".config/autostart/indicator-usb-autostart.desktop") self.autostart.set_active(os.path.exists(filestart))
def load_preferences(self): configuration = Configuration() self.time = configuration.get('time') self.theme = configuration.get('theme') self.calendars = configuration.get('calendars') self.visible_calendars = [] for calendar in self.calendars: if calendar['visible']: self.visible_calendars.append(calendar['id'])
def _build_plugins(self, ): page06 = self._new_page("Plugins") plugins = ListBoxPlugins() configuration = Configuration() plugins.add_all(configuration.get_plugins()) plugins.set_size_request(300, 300) self.plugins = plugins page06.attach(plugins, 0, 0, 1, 1)
def import_folder(epath, mpoint, secret, automount, autodelete): if _get_items(epath=epath): return True configuration = Configuration() configuration.create_folder(epath,mpoint,automount,autodelete) configuration.save() cfipm = CFIPasswordManager() ans = cfipm.createEncriptedFolder(epath,secret) return True
def __init__(self): configuration = Configuration() preferences = configuration.get("preferences") self.todo_histoy = (Path(os.path.expanduser( preferences["todo-file"])).parent.as_posix() + os.sep + "todo.history.txt") todo_histoy_path = Path(self.todo_histoy) if not todo_histoy_path.exists(): todo_histoy_path.touch()
def __init__(self, title='', subtitle=''): self.title = _(title) self.configuration = Configuration() preferences = self.configuration.get('preferences') todo_file = Path(os.path.expanduser(preferences['todo-file'])) self.todo_file = todo_file.as_posix() self.subtitle = _(subtitle) BaseDialog.__init__(self, title, None, ok_button=False, cancel_button=False)
def load_preferences(self): configuration = Configuration() model = self.treeview.get_model() model.clear() folders = configuration.get('folders') for folder in folders: scan = folder['scan'] recursive = folder['recursive'] folder_name = folder['name'] model.append([scan, recursive, folder_name])
def on_button_on_clicked(self, widget): configuration = Configuration() x, y = self.get_position() cameras = configuration.get('cameras') for index, acamera in enumerate(cameras): if acamera['url'] == self.camera['url']: acamera['on'] = False cameras[index] = acamera configuration.save() self.stop()
def save_preferences(self): configuration = Configuration() x, y = self.get_position() cameras = configuration.get('cameras') for index, acamera in enumerate(cameras): if acamera['url'] == self.camera['url']: acamera['x'] = x acamera['y'] = y acamera['onwidgettop'] = self.is_above cameras[index] = acamera configuration.save()
def main(): GObject.threads_init() configuration = Configuration() cameras = configuration.get('cameras') if len(cameras) > 0: for acamera in cameras: cm = CameraWidget(acamera) cm.show() cm.start_updater() Gtk.main() exit(0)
def change_wallpaper(): configuration = Configuration() source = configuration.get('source') if source == 'national-geographic': set_national_geographic_wallpaper() elif source == 'bing': set_bing_wallpaper() elif source == 'gopro': set_gopro_wallpaper() elif source == 'powder': set_powder_wallpaper()
def instanciate(): configuration = Configuration() preferences = configuration.get('preferences') https_protocol = preferences['https_protocol'] base_url = preferences['base_url'] client_token = preferences['client_token'] cache = Cache(https_protocol, base_url, client_token) cache.startCaching()
def set_events(self, events): configuration = Configuration() self.store.clear() for event in events: label = '' if 'summary' in event.keys(): label = event['summary'] if configuration.has(event['calendar_id']): color = configuration.get(event['calendar_id']) else: color = '#AFDEDF' self.store.append([label, event, color])
def set_events(self,events): configuration = Configuration() self.store.clear() for event in events: label = '' if 'summary' in event.keys(): label = event['summary'] if configuration.has(event['calendar_id']): color = configuration.get(event['calendar_id']) else: color = '#AFDEDF' self.store.append([label,event,color])
def load_changed(self, widget, load_event): if load_event == WebKit2.LoadEvent.FINISHED: self.update() configuration = Configuration() preferences = configuration.get('preferences') distance_color = preferences['distance-color'] clics_color = preferences['clics-color'] keys_color = preferences['keys-color'] self.web_send('set_colors("{}", "{}", "{}");'.format( distance_color, clics_color, keys_color)) while Gtk.events_pending(): Gtk.main_iteration()
def on_quit_item(self, widget, data=None): if self.the_watchdog != None: self.the_watchdog.kill() if self.enable_on_exit: self.touchpad.enable_all_touchpads() if self.disable_on_exit: self.touchpad.disable_all_touchpads() configuration = Configuration() configuration.set('is_working',False) configuration.save() # Actions to do on init self.syndaemon.stop() exit(0)
def start(self): configuration = Configuration() if configuration.get('webcam-show'): self.wcw = WebcamWidget() self.wcw.connect('preferences', self.on_preferences) self.wcw.show() cameras = configuration.get('cameras') if len(cameras) > 0: for acamera in cameras: if 'on' not in acamera.keys() or acamera['on'] is True: cm = CameraWidget(acamera) cm.connect('preferences', self.on_preferences) cm.show() cm.start_updater() self.cameras.append(cm)
def update(self): configuration = Configuration() preferences = configuration.get('preferences') units = preferences['units'] distance = [] if units == 'feets': for i in self.distance: distance.append(i / 3.28084) else: distance = self.distance self.web_send('title="{}";subtitle="{}";days={};distance={};\ clics={};keys={};draw_graph(title,subtitle,days,distance,\ clics, keys);'.format(self.title, self.subtitle, self.days, distance, self.clics, self.keys))
def change_state(self): if not self.on_mouse_plugged or\ not is_mouse_plugged(): is_touch_enabled = self.touchpad.are_all_touchpad_enabled() if self.disable_on_typing is True: print('1', is_touch_enabled) configuration = Configuration() is_touch_enabled = configuration.get('touchpad_enabled') print('2', is_touch_enabled) print('3 {0} touchpad'.format( 'Enable' if not is_touch_enabled else 'Disable')) self.set_touch_enabled(not is_touch_enabled) self.keyboardMonitor.set_on(not is_touch_enabled) else: self.set_touch_enabled(not is_touch_enabled)
def add_folder(epath, mpoint, secret, automount, autodelete): print(is_folder_encrypted(epath)) if is_folder_encrypted(epath): raise AlreadyEncrypted() return False """Add new EncFS item to keyring.""" print(_get_items(epath=epath)) if _get_items(epath=epath): return True configuration = Configuration() configuration.create_folder(epath,mpoint,automount,autodelete) configuration.save() cfipm = CFIPasswordManager() cfipm.createEncriptedFolder(epath,secret) # return create_crypted_folder(epath, mpoint, secret)
def show_statistics(self, widget): widget.set_sensitive(False) title = _('Tasker') subtitle = _('Tasks statistics') configuration = Configuration() preferences = self.configuration.get('preferences') mc = CURRENCIES[self.main_currency] currencies = [] for i in range(0, 5): currencies.append(CURRENCIES[self.currencies[i]]) days = [] c0 = [] c1 = [] c2 = [] c3 = [] c4 = [] for aday in self.exchange.data: days.append(aday['date']) mc = aday[self.main_currency.lower()] c0.append(round(aday[self.currencies[0].lower()] / mc)) c1.append(round(aday[self.currencies[1].lower()] / mc)) c2.append(round(aday[self.currencies[2].lower()] / mc)) c3.append(round(aday[self.currencies[3].lower()] / mc)) c4.append(round(aday[self.currencies[4].lower()] / mc)) graph = Graph(title, subtitle, currencies, days, c0, c1, c2, c3, c4) graph.run() graph.destroy() widget.set_sensitive(True)
def __init__(self, parent): wx.Notebook.__init__(self, parent, id=-1, style=wx.NB_LEFT, name='NotebookNameStr') # initialize notebook self.cfg = Configuration(self) # get default configuration settings self.configPanel = configPanel( self, mon_num=1, cfg=self.cfg) # create configuration page self.AddPage(self.configPanel, 'Configuration') self.maskPanel = maskPanel(self) # create mask maker page self.AddPage(self.maskPanel, 'Masks') self.acquirePanel = acquirePanel(self, self.cfg) # create acquire page self.AddPage(self.acquirePanel, 'Acquire') self.binningPanel = binningPanel(self) # create binning page self.AddPage(self.binningPanel, 'DAM File Scan 110X') self.SCAMPPanel = SCAMPPanel(self) # create SCAMP page self.AddPage(self.SCAMPPanel, 'SCAMP') # self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging) self.Layout()
def save_preferences(self): if not self.from_filebrowser: folders = [] model = self.treeview.get_model() itera = model.get_iter_first() while(itera is not None): folder = {} folder['scan'] = model.get(itera, 0)[0] folder['recursive'] = model.get(itera, 1)[0] folder['name'] = model.get(itera, 2)[0] folders.append(folder) itera = model.iter_next(itera) if len(folders) > 0: configuration = Configuration() configuration.set('folders', folders) configuration.save()
def load_preferences(self,tasks): self.switch1.set_active(os.path.exists(comun.TOKEN_FILE)) configuration = Configuration() if os.path.exists(os.path.join(os.getenv("HOME"),".config/autostart/google-tasks-indicator-autostart.desktop")): self.switch4.set_active(True) if configuration.get('local') == 0: self.option_tlo['copy'].set_active(True) elif configuration.get('local') == 1: self.option_tlo['delete'].set_active(True) else: self.option_tlo['none'].set_active(True) # if configuration.get('external') == 0: self.option_teo['copy'].set_active(True) elif configuration.get('external') == 1: self.option_teo['delete'].set_active(True) else: self.option_teo['none'].set_active(True) # if configuration.get('both') == 0: self.option_tb['copy local'].set_active(True) elif configuration.get('both') == 1: self.option_tb['copy external'].set_active(True) else: self.option_tb['none'].set_active(True) # if configuration.get('theme') == 'light': self.switch5.set_active(True) else: self.switch5.set_active(False) tasklist_id = configuration.get('tasklist_id') if tasks is not None: self.liststore.clear() self.liststore.append([_('All'),None]) for tasklist in tasks.tasklists.values(): self.liststore.append([tasklist['title'],tasklist['id']]) if tasklist_id is None: self.entry2.set_active(0) else: for i,item in enumerate(self.liststore): print(tasklist_id,item[1]) if tasklist_id == item[1]: self.entry2.set_active(i) break if os.path.exists(comun.TOKEN_FILE): gta = GTAService(token_file = comun.TOKEN_FILE)
class BaseGraph(BaseDialog): """ Class that allows the visualization of graphs with highcharts.js To implement your own graphs, simply override the get_data method or use get_keys and get_values that are related to each other """ def __init__(self, title='', subtitle=''): self.title = _(title) self.configuration = Configuration() preferences = self.configuration.get('preferences') todo_file = Path(os.path.expanduser(preferences['todo-file'])) self.todo_file = todo_file.as_posix() self.subtitle = _(subtitle) BaseDialog.__init__(self, title, None, ok_button=False, cancel_button=False) def init_ui(self): BaseDialog.init_ui(self) self.scrolledwindow1 = Gtk.ScrolledWindow() self.scrolledwindow1.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.grid.attach(self.scrolledwindow1, 0, 0, 1, 1) self.viewer = WebKit2.WebView() self.scrolledwindow1.add(self.viewer) self.scrolledwindow1.set_size_request(1300, 600) self.viewer.load_uri('file://' + config.HTML_GRAPH) self.viewer.connect('load-changed', self.load_changed) self.set_focus(self.viewer) def load_changed(self, widget, load_event): if load_event == WebKit2.LoadEvent.FINISHED: self.send_data() def send_data(self): message = 'draw_graph("{}", "{}", {});'.format(self.title, self.subtitle, self.get_data()) self.viewer.run_javascript(message, None, None, None) def get_data(self, ): plaindata = self.get_plaindata() keys = self.get_keys(plaindata) values = self.get_values(keys, plaindata) return {'keys': keys, 'values': values} def get_plaindata(self, ): return todotxtio.from_file(self.todo_file) def get_keys(self, plaindata): return super().get_keys(plaindata) def get_values(self, keys, plaindata): return super().get_values(keys, plaindata)
def read_preferences(self): error = True while error: try: configuration = Configuration() self.tasklist_id = configuration.get('tasklist_id') self.theme = configuration.get('theme') error = False except Exception as e: print(e) error = True p = Preferences() if p.run() == Gtk.ResponseType.ACCEPT: p.save_preferences() else: exit(1) p.destroy()
def on_quit_item(self, widget, data=None): print(1) if self.the_watchdog is not None: self.the_watchdog.kill() if self.keyboardMonitor is not None: self.keyboardMonitor.end() self.keyboardMonitor = None if self.on_end == 1: self.touchpad.enable_all_touchpads() elif self.on_end == -1: self.touchpad.disable_all_touchpads() configuration = Configuration() configuration.set('is_working', False) configuration.save() exit(0)
def save_preferences(self): configuration = Configuration() language = self.model1.get_value(self.combobox1.get_active_iter(),1) dictionary = self.model2.get_value(self.combobox2.get_active_iter(),1) configuration.set('language',language) configuration.set('dictionary',dictionary) configuration.save()
def set_events(self,events): configuration = Configuration() self.store.clear() for event in events: label = '' if 'summary' in event.keys(): label = event['summary'] calendar_options = get_calendar_from_options(configuration.get('calendars'),event['calendar_id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] else: background_color = tohex(random.randint(0, 16777215)) foreground_color = tohex(random.randint(0, 16777215)) visible = True if event is not None: self.store.append([label,event,background_color,foreground_color])
def load_preferences(self): configuration = Configuration() self.sample_time.set_value(configuration.get("frames")) self.scale.set_active(configuration.get("scale")) self.modify_width.set_active(configuration.get("modify-width")) self.width.set_value(configuration.get("width")) self.modify_height.set_active(configuration.get("modify-height")) self.height.set_value(configuration.get("height"))
def on_button1_clicked(self, widget): iters_removed = [] infected = [] model = self.treeview.get_model() itera = model.get_iter_first() if not os.path.exists(comun.QUARENTINE_DIR): os.mkdir(comun.QUARENTINE_DIR) while(itera is not None): delete = model.get(itera, 0)[0] quarentine = model.get(itera, 1)[0] filename = model.get(itera, 2)[0] virus = model.get(itera, 3)[0] if delete: if os.path.exists(filename): os.remove(filename) iters_removed.append(itera) elif quarentine: if os.path.exists(filename): try: shutil.move(filename, comun.QUARENTINE_DIR) infected_file = {'file': filename, 'virus': virus} infected.append(infected_file) except shutil.Error: md = Gtk.MessageDialog( self, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.YES_NO, _('There is a file like this in quarentine,\ remove this new file?')) md.set_title('Antiviral') if md.run() == Gtk.ResponseType.YES: os.remove(filename) infected_file = {'file': filename, 'virus': virus} infected.append(infected_file) md.destroy() iters_removed.append(itera) itera = model.iter_next(itera) for iter_removed in iters_removed: model.remove(iter_removed) if infected and len(infected) > 0: configuration = Configuration() configuration.set('infected', infected) configuration.save()
def remove_folder(epath): """Remove EncFS item from keyring.""" if is_folder_mounted(epath) == True: print('Is folder mounted') if unmount_folder(epath) == False: raise NotUnmount() ''' if delete_it(epath) == False: raise NotUnmount() ''' folder = _get_items(epath) if folder: mpoint = folder['mount-point'] if delete_it(mpoint) == False: raise NotUnmount() configuration = Configuration() configuration.delete_folder(epath) configuration.save() cfipm = CFIPasswordManager() cfipm.removeEncriptedFolder(epath) return True
def __init__(self): bus_name = dbus.service.BusName('es.atareao.TouchpadIndicator', bus = dbus.SessionBus()) dbus.service.Object.__init__(self, bus_name, '/es/atareao/TouchpadIndicator') self.about_dialog = None self.the_watchdog = None self.icon = comun.ICON self.active_icon = None self.attention_icon = None self.synclient = Synclient() self.syndaemon = Syndaemon() self.read_preferences() self.notification = Notify.Notification.new('','', None) self.indicator = appindicator.Indicator.new ('Touchpad-Indicator',\ self.active_icon, appindicator.IndicatorCategory.HARDWARE) self.indicator.set_attention_icon(self.attention_icon) if not self.start_hidden: self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE) self.touchpad = Touchpad() menu = self.get_menu() self.indicator.set_menu(menu) self.indicator.connect('scroll-event', self.on_scroll) if self.touchpad.are_all_touchpad_enabled(): self.change_state_item.set_label(_('Disable Touchpad')) else: self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status() != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status(appindicator.IndicatorStatus.ATTENTION) self.on_mouse_plugged_change(self.on_mouse_plugged) if self.touchpad.are_all_touchpad_enabled() and self.disable_touchpad_on_start_indicator: self.set_touch_enabled(False) configuration = Configuration() configuration.set('is_working',True) configuration.save()
def load_preferences(self): self.switch1.set_active(os.path.exists(comun.TOKEN_FILE)) configuration = Configuration() time = configuration.get('time') theme = configuration.get('theme') calendars_options = configuration.get('calendars') self.spin3.set_value(time) if os.path.exists(os.path.join(os.getenv("HOME"),".config/autostart/calendar-indicator-autostart.desktop")): self.switch4.set_active(True) if theme == 'light': self.switch5.set_active(True) else: self.switch5.set_active(False) if os.path.exists(comun.TOKEN_FILE): if self.googlecalendar is not None: calendars = self.googlecalendar.calendars.values() else: gca = GoogleCalendar(token_file = comun.TOKEN_FILE) gca.read() calendars = gca.get_calendars().values() self.store.clear() for calendar in calendars: calendar_options = get_calendar_from_options(configuration.get('calendars'),calendar['id']) if calendar_options: background_color = calendar_options['background'] foreground_color = calendar_options['foreground'] visible = calendar_options['visible'] if 'name' in calendar_options.keys(): calendar_name = calendar_options['name'] else: calendar_name = calendar['summary'] else: background_color = tohex(random.randint(0, 16777215)) foreground_color = tohex(random.randint(0, 16777215)) visible = True calendar_name = calendar['summary'] self.store.append([calendar['summary'],background_color,foreground_color,calendar['id'],visible,calendar_name])
def load_preferences(self): configuration = Configuration() language = configuration.get('language') dictionary = configuration.get('dictionary') print(language) print(dictionary) itera = self.model1.get_iter_first() while itera != None: if self.model1.get_value(itera,1) == language: break itera = self.model1.iter_next(itera) if itera != None: self.combobox1.set_active_iter(itera) else: self.combobox1.set_active(0) itera = self.model2.get_iter_first() while itera != None: if self.model2.get_value(itera,1) == dictionary: break itera = self.model2.iter_next(itera) if itera != None: self.combobox2.set_active_iter(itera) else: self.combobox2.set_active(0)
def set_touch_enabled(self, enabled): """Enable or disable the touchpads and update the indicator status and menu items. :param enabled: If True enable the touchpads.""" if enabled and not self.touchpad.are_all_touchpad_enabled(): if self.touchpad.enable_all_touchpads(): if self.show_notifications: self.show_notification('enabled') self.change_state_item.set_label(_('Disable Touchpad')) if self.indicator.get_status() != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status(appindicator.IndicatorStatus.ACTIVE) configuration = Configuration() configuration.set('touchpad_enabled',self.touchpad.are_all_touchpad_enabled()) configuration.save() elif not enabled and self.touchpad.are_all_touchpad_enabled(): if self.touchpad.disable_all_touchpads(): if self.show_notifications: self.show_notification('disabled') self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status() != appindicator.IndicatorStatus.PASSIVE: self.indicator.set_status(appindicator.IndicatorStatus.ATTENTION) configuration = Configuration() configuration.set('touchpad_enabled',self.touchpad.are_all_touchpad_enabled()) configuration.save()
def save_preferences(self): configuration = Configuration() configuration.set('show-hdd', self.show_disks.get_active()) configuration.set('show-net', self.show_net.get_active()) configuration.save() filestart = os.path.join( os.getenv("HOME"), ".config/autostart/indicator-usb-autostart.desktop") if self.autostart.get_active(): if not os.path.exists(os.path.dirname(filestart)): os.makedirs(os.path.dirname(filestart)) shutil.copyfile(comun.AUTOSTART, filestart) else: if os.path.exists(filestart): os.remove(filestart)
def read_preferences(self): configuration = Configuration() self.first_time = configuration.get('first-time') self.version = configuration.get('version') self.theme = configuration.get('theme') self.monitor_clipboard = configuration.get('monitor-clipboard') self.downloaddir = configuration.get('download-dir') if self.monitor_clipboard: self.menu_capture.set_label(_('Not capture')) self.indicator.set_icon(comun.STATUS_ICON[self.theme]) else: self.menu_capture.set_label(_('Capture')) self.indicator.set_icon(comun.DISABLED_ICON[self.theme])
def load_preferences(self): configuration = Configuration() x = configuration.get('webcam-x') y = configuration.get('webcam-y') self.is_above = configuration.get('webcam-onwidgettop') self.showintaskbar = configuration.get('webcam-showintaskbar') self.onalldesktop = configuration.get('webcam-onalldesktop') self.is_on = configuration.get('webcam-on') self.set_keep_above(self.is_above) self.is_set_keep_above(self.is_above) self.set_keep_below(not self.is_above) if self.onalldesktop: self.stick() else: self.unstick() self.move(x, y)