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 save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['https_protocol'] = self.https_protocol.get_active() preferences['base_url'] = self.base_url.get_text() preferences['application_name'] = self.application_name.get_text() preferences['application_token'] = self.application_token.get_text() preferences['client_token'] = self.client_token.get_text() preferences['theme-light'] = self.theme_light.get_active() configuration.set('preferences', preferences) configuration.save() autostart_file = 'gotify-indicator-autostart.desktop' autostart_file = os.path.join(os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def save_preferences(self): if os.path.exists(comun.TOKEN_FILE): configuration = Configuration() configuration.set('version',comun.VERSION) configuration.set('time',self.spin3.get_value()) if self.switch5.get_active(): configuration.set('theme','light') else: configuration.set('theme','dark') calendars = [] aiter = self.store.get_iter_first() while(aiter is not None): calendar = {} calendar['id'] = self.store.get_value(aiter,3) calendar['background'] = self.store.get_value(aiter,1) calendar['foreground'] = self.store.get_value(aiter,2) calendar['visible'] = self.store.get_value(aiter,4) calendar['name'] = self.store.get_value(aiter,5) calendars.append(calendar) aiter = self.store.iter_next(aiter) configuration.set('calendars',calendars) configuration.save() filestart = os.path.join(os.getenv("HOME"),".config/autostart/calendar-indicator-autostart.desktop") if self.switch4.get_active(): if not os.path.exists(filestart): if not os.path.exists(os.path.dirname(filestart)): os.makedirs(os.path.dirname(filestart)) shutil.copyfile('/opt/extras.ubuntu.com/calendar-indicator/share/calendar-indicator/calendar-indicator-autostart.desktop',filestart) else: if os.path.exists(filestart): os.remove(filestart)
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): if os.path.exists(comun.TOKEN_FILE): configuration = Configuration() configuration.set('version', comun.VERSION) configuration.set('time', self.spin3.get_value()) if self.switch5.get_active(): configuration.set('theme', 'light') else: configuration.set('theme', 'dark') calendars = [] aiter = self.store.get_iter_first() while (aiter is not None): calendar = {} calendar['id'] = self.store.get_value(aiter, 3) calendar['background'] = self.store.get_value(aiter, 1) calendar['foreground'] = self.store.get_value(aiter, 2) calendar['visible'] = self.store.get_value(aiter, 4) calendar['name'] = self.store.get_value(aiter, 5) calendars.append(calendar) aiter = self.store.iter_next(aiter) configuration.set('calendars', calendars) configuration.save() filestart = os.path.join( os.getenv("HOME"), ".config/autostart/calendar-indicator-autostart.desktop") if self.switch4.get_active(): if not os.path.exists(filestart): if not os.path.exists(os.path.dirname(filestart)): os.makedirs(os.path.dirname(filestart)) shutil.copyfile( '/opt/extras.ubuntu.com/calendar-indicator/share/calendar-indicator/calendar-indicator-autostart.desktop', filestart) else: if os.path.exists(filestart): os.remove(filestart)
def save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['theme-light'] = self.theme_light.get_active() preferences['todos'] = int(self.todos.get_value()) preferences['todo-file'] = self.todo_file.get_file().get_path() preferences['projects'] = self.projects.get_items() preferences['contexts'] = self.contexts.get_items() preferences['tags'] = self.tags.get_items() preferences['hide-completed'] = self.hide_completed.get_active() preferences['filter-projects'] = self.filter_projects.get_active() preferences['keybindings'] = [ { 'name': 'new_task', 'keybind': self.new_task_keybinding.get_text() }, { 'name': 'show_tasks', 'keybind': self.show_tasks_keybinding.get_text() }, ] configuration.set('preferences', preferences) configuration.save() autostart_file = 'todotxt-indicator-autostart.desktop' autostart_file = os.path.join(os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def save(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['theme-light'] = self.theme_light.get_active() preferences['start-actived'] = self.start_actived.get_active() preferences['units'] = get_selected_value_in_combo(self.units) preferences['distance-color'] = convert_rgb2hex( self.distance_color.get_rgba()) preferences['clics-color'] = convert_rgb2hex( self.clics_color.get_rgba()) preferences['keys-color'] = convert_rgb2hex( self.keys_color.get_rgba()) configuration.set('preferences', preferences) configuration.save() autostart_file = 'habits-autostart.desktop' autostart_file = os.path.join( os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file)
def save(self): configuration = Configuration() stats = configuration.get('stats') for day in self.data.keys(): stats[day] = self.data[day] configuration.set('stats', stats) configuration.save()
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 save_preferences(self): try: configuration = Configuration() x, y = self.get_position() configuration.set('webcam-x', x) configuration.set('webcam-y', y) configuration.set('webcam-onwidgettop', self.is_above) configuration.set('webcam-showintaskbar', self.showintaskbar) configuration.set('webcam-onalldesktop', self.onalldesktop) configuration.set('webcam-on', self.is_on) configuration.save() except Exception as e: print(e)
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 save(self): configuration = Configuration() preferences = configuration.get("preferences") preferences["theme-light"] = self.theme_light.get_active() preferences["todos"] = int(self.todos.get_value()) preferences["todo-file"] = self.todo_file.get_file().get_path() preferences["projects"] = self.projects.get_items() preferences["contexts"] = self.contexts.get_items() preferences["tags"] = self.tags.get_items() preferences["hide-completed"] = self.hide_completed.get_active() preferences["filter-projects"] = self.filter_projects.get_active() preferences["filter-contexts"] = self.filter_contexts.get_active() preferences["show-hidden-tags"] = self.show_hidden_tags.get_active() preferences["keybindings"] = [ { "name": "new_task", "keybind": self.new_task_keybinding.get_text(), }, { "name": "show_tasks", "keybind": self.show_tasks_keybinding.get_text(), }, ] configuration.set("preferences", preferences) configuration.save() autostart_file = "todotxt-indicator-autostart.desktop" autostart_file = os.path.join(os.getenv("HOME"), ".config/autostart", autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file) for plugin in self.plugins.get_items(): try: if plugin["installed"]: shutil.move( configuration.get_plugin_to_load_dir() + "/" + plugin["name"], configuration.get_plugin_dir(), ) else: shutil.move( configuration.get_plugin_dir() + "/" + plugin["name"], configuration.get_plugin_to_load_dir(), ) except Exception as e: print("Ignore error. Maybe no operation needed. %s" % e)
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 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 on_change(self): if os.path.exists(comun.TOKEN_FILE): configuration = Configuration() calendars = [] aiter = self.store.get_iter_first() while (aiter is not None): calendar = {} calendar['id'] = self.store.get_value(aiter, 3) calendar['background'] = self.store.get_value(aiter, 1) calendar['foreground'] = self.store.get_value(aiter, 2) calendar['visible'] = self.store.get_value(aiter, 4) calendar['name'] = self.store.get_value(aiter, 5) calendars.append(calendar) aiter = self.store.iter_next(aiter) configuration.set('calendars', calendars) configuration.save()
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(self): configuration = Configuration() preferences = configuration.get('preferences') preferences['theme-light'] = self.theme_light.get_active() preferences['todos'] = int(self.todos.get_value()) preferences['todo-file'] = self.todo_file.get_file().get_path() preferences['projects'] = self.projects.get_items() preferences['contexts'] = self.contexts.get_items() preferences['tags'] = self.tags.get_items() preferences['hide-completed'] = self.hide_completed.get_active() preferences['filter-projects'] = self.filter_projects.get_active() preferences['keybindings'] = [ { 'name': 'new_task', 'keybind': self.new_task_keybinding.get_text() }, { 'name': 'show_tasks', 'keybind': self.show_tasks_keybinding.get_text() }, ] configuration.set('preferences', preferences) configuration.save() autostart_file = 'todotxt-indicator-autostart.desktop' autostart_file = os.path.join(os.getenv('HOME'), '.config/autostart', autostart_file) if self.autostart.get_active(): if not os.path.exists(os.path.dirname(autostart_file)): os.makedirs(os.path.dirname(autostart_file)) shutil.copyfile(config.AUTOSTART, autostart_file) else: if os.path.exists(autostart_file): os.remove(autostart_file) for plugin in self.plugins.get_items(): try: if plugin['installed']: shutil.move( configuration.get_plugin_to_load_dir() + '/' + plugin['name'], configuration.get_plugin_dir()) else: shutil.move( configuration.get_plugin_dir() + '/' + plugin['name'], configuration.get_plugin_to_load_dir()) except Exception as e: print("Ignore error. Maybe no operation needed. %s" % e)
def save_preferences(self): configuration = Configuration() configuration.set('monitor-clipboard', self.switch1.get_active()) create_or_remove_autostart(self.switch2.get_active()) if self.switch3.get_active() is True: configuration.set('theme', 'light') else: configuration.set('theme', 'dark') configuration.set('download-dir', self.downloaddir.get_text()) configuration.save()
def save_preferences(self): configuration = Configuration() x,y = self.get_position() if self.widgetnumber == 1: configuration.set('wp1-x',x) configuration.set('wp1-y',y) configuration.set('onwidget1top',self.is_above) else: configuration.set('wp2-x',x) configuration.set('wp2-y',y) configuration.set('onwidget2top',self.is_above) configuration.save()
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 save_preferences(self): configuration = Configuration() x, y = self.get_position() if self.widgetnumber == 0: configuration.set("wp1-x", x) configuration.set("wp1-y", y) configuration.set("onwidget1top", self.is_above) else: configuration.set("wp2-x", x) configuration.set("wp2-y", y) configuration.set("onwidget2top", self.is_above) configuration.save()
def save_preferences(self): configuration = Configuration() x, y = self.get_position() if self.widgetnumber == 1: configuration.set('wp1-x', x) configuration.set('wp1-y', y) configuration.set('onwidget1top', self.is_above) else: configuration.set('wp2-x', x) configuration.set('wp2-y', y) configuration.set('onwidget2top', self.is_above) configuration.save()
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 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 __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 __init__(self): if dbus.SessionBus().request_name('es.atareao.MyWeatherIndicator') != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: print("application already running") exit(0) # self.last_notification = 0 self.actualization_time = 0 self.current_conditions = None self.current_conditions2 = None self.preferences_out = False self.forecast_out = False # self.notification = Notify.Notification.new('','', None) self.indicator = appindicator.Indicator.new('My-Weather-Indicator', 'My-Weather-Indicator', appindicator.IndicatorCategory.APPLICATION_STATUS) self.notification2 = Notify.Notification.new('','', None) self.indicator2 = appindicator.Indicator.new('My-Weather-Indicator2', 'My-Weather-Indicator', appindicator.IndicatorCategory.APPLICATION_STATUS) # self.create_menu() self.create_menu2() # while internet_on() == False: wait(1) print(comun.CONFIG_FILE,os.path.exists(comun.CONFIG_FILE)) if not os.path.exists(comun.CONFIG_FILE): configuration = Configuration() configuration.reset() latitude,longitude = ipaddress.get_current_location() city = geocodeapi.get_inv_direction(latitude,longitude) configuration.set('latitude',latitude) configuration.set('longitude',longitude) if city is not None: configuration.set('location',city['city']) configuration.save() cm=preferences.CM() if cm.run() == Gtk.ResponseType.ACCEPT: cm.save_preferences() else: exit(0) cm.hide() cm.destroy() self.WW1 = None self.WW2 = None self.load_preferences() self.actualization_time = 0 self.seclast = 60 self.work() ''' while(datetime.now().second !=0): wait(0.1) utcnow = datetime.utcnow() if self.WW1 is not None: self.WW1.set_datetime(utcnow) if self.WW2 is not None: self.WW2.set_datetime(utcnow) ''' GLib.timeout_add(500, self.update_widgets) GLib.timeout_add(60000, self.work)
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('backlight', self.backlight) configuration.save()
else: check_status = touchpad_indicator_service.get_dbus_method('check_status', 'es.atareao.TouchpadIndicator') check_status() print('Touchpad-Indicator is working') except dbus.exceptions.DBusException as argument: print(argument) touchpad = Touchpad() configuration = Configuration() touchpad_enabled = configuration.get('touchpad_enabled') touchpad_indicator_working = configuration.get('is_working') status = touchpad.are_all_touchpad_enabled() if touchpad_indicator_working: print('Touchpad-Indicator is working') if touchpad_enabled != status: if touchpad_enabled: touchpad.enable_all_touchpads() else: touchpad.disable_all_touchpads() newstatus = touchpad.are_all_touchpad_enabled() if status != newstatus: configuration.set('touchpad_enabled',newstatus) configuration.save() status = newstatus else: print('Touchpad-Indicator is not working') if status: print('Touchpad is enabled') else: print('Touchpad is disabled') exit(0)
def __init__(self): if dbus.SessionBus().request_name('es.atareao.MyWeatherIndicator') !=\ dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: print("application already running") exit(0) # self.weather_updater = 0 self.widgets_updater = 0 self.menus = [] self.indicators = [] self.notifications = [] self.widgets = [] self.weatherservices = [] self.weathers = [] self.current_conditions = [] self.preferences = [] self.last_update_time = 0 # Iniciate variables for i in range(INDICATORS): self.menus.append(None) self.indicators.append(None) self.notifications.append(None) self.widgets.append(None) self.weatherservices.append(None) self.weathers.append(None) self.current_conditions.append(None) self.preferences.append(None) # status = appindicator.IndicatorCategory.APPLICATION_STATUS self.notifications[0] = Notify.Notification.new('', '', None) self.indicators[0] = appindicator.Indicator.new( 'My-Weather-Indicator', 'My-Weather-Indicator', status) self.notifications[1] = Notify.Notification.new('', '', None) self.indicators[1] = appindicator.Indicator.new( 'My-Weather-Indicator2', 'My-Weather-Indicator', status) # for i in range(INDICATORS): self.create_menu(i) # if not os.path.exists(comun.CONFIG_FILE): if internet_on(): configuration = Configuration() configuration.reset() latitude, longitude = ipaddress.get_current_location() city = geocodeapi.get_inv_direction( latitude, longitude)['city'] if city is None: city = '' configuration.set('latitude', latitude) configuration.set('longitude', longitude) configuration.set('location', city) configuration.save() cm = preferences.CM() if cm.run() == Gtk.ResponseType.ACCEPT: cm.save_preferences() else: exit(0) cm.hide() cm.destroy() for i in range(INDICATORS): self.widgets[i] = None self.load_preferences()
def save_preferences(self): configuration = Configuration() configuration.set('source', get_selected_value_in_combo(self.combobox_source)) configuration.save()
def set_touch_enabled(self, enabled, isforwriting=False): """Enable or disable the touchpads and update the indicator status and menu items. :param enabled: If True enable the touchpads.""" print('==== start set_touch_enabled =====') print('set_touch_enabled:', enabled) print('are_all_touchpad_enabled: ', self.touchpad.are_all_touchpad_enabled()) if enabled and not self.touchpad.are_all_touchpad_enabled(): print('==|==') if self.touchpad.enable_all_touchpads(): print('==|== 1') if self.show_notifications and not isforwriting: print('==|== 2') self.show_notification('enabled') self.change_state_item.set_label(_('Disable Touchpad')) if self.indicator.get_status() !=\ appindicator.IndicatorStatus.PASSIVE: GLib.idle_add(self.indicator.set_status, appindicator.IndicatorStatus.ACTIVE) if not isforwriting: configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save() elif enabled and self.touchpad.are_all_touchpad_enabled(): if self.show_notifications and not isforwriting: self.show_notification('enabled') self.change_state_item.set_label(_('Disable Touchpad')) if self.indicator.get_status() !=\ appindicator.IndicatorStatus.PASSIVE: GLib.idle_add(self.indicator.set_status, appindicator.IndicatorStatus.ACTIVE) if not isforwriting: configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save() elif not enabled and self.touchpad.are_all_touchpad_enabled(): print('==?==') if self.touchpad.disable_all_touchpads(): print('==?== 1') if self.show_notifications and not isforwriting: print('==?== 2') self.show_notification('disabled') self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status() !=\ appindicator.IndicatorStatus.PASSIVE: GLib.idle_add(self.indicator.set_status, appindicator.IndicatorStatus.ATTENTION) if not isforwriting: configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save() elif not enabled and not self.touchpad.are_all_touchpad_enabled(): if self.show_notifications and not isforwriting: self.show_notification('disabled') self.change_state_item.set_label(_('Enable Touchpad')) if self.indicator.get_status() !=\ appindicator.IndicatorStatus.PASSIVE: GLib.idle_add(self.indicator.set_status, appindicator.IndicatorStatus.ATTENTION) if not isforwriting: configuration = Configuration() configuration.set('touchpad_enabled', self.touchpad.are_all_touchpad_enabled()) configuration.save()
def save_preferences(self): configuration = Configuration() cameras = configuration.get('cameras') create_or_remove_autostart(self.switch1.get_active()) if self.switch2.get_active() is True: configuration.set('theme', 'light') else: configuration.set('theme', 'dark') configuration.set('webcam-show', self.webcam_show.get_active()) configuration.set('webcam-onwidgettop', self.webcam_onwidgettop.get_active()) configuration.set('webcam-showintaskbar', self.webcam_showintaskbar.get_active()) configuration.set('webcam-onalldesktop', self.webcam_onalldesktop.get_active()) new_cameras = [] for awidget in self.widgets: exists = False if len(awidget['url'].get_text()) > 0: for old_camera in cameras: if old_camera['url'] == awidget['url'].get_text(): exists = True old_camera['scale'] = awidget['scale'].get_value() old_camera['onwidgettop'] =\ awidget['onwidgettop'].get_active() old_camera['showintaskbar'] =\ awidget['showintaskbar'].get_active() old_camera['onalldesktop'] =\ awidget['onalldesktop'].get_active() old_camera['refresh-time'] =\ awidget['refresh-time'].get_value() old_camera['on'] =\ awidget['on'].get_active() new_cameras.append(old_camera) if exists is False: new_camera = {} new_camera['url'] = awidget['url'].get_text() if not new_camera['url'].startswith('http://') and\ not new_camera['url'].startswith('https://'): new_camera['url'] = 'http://' + new_camera['url'] new_camera['scale'] = awidget['scale'].get_value() new_camera['x'] = 100 new_camera['y'] = 100 new_camera['onwidgettop'] = \ awidget['onwidgettop'].get_active() new_camera['showintaskbar'] = \ awidget['showintaskbar'].get_active() new_camera['onalldesktop'] = \ awidget['onalldesktop'].get_active() new_camera['refresh-time'] = \ awidget['refresh-time'].get_value() new_camera['on'] = \ awidget['on'].get_active() new_cameras.append(new_camera) configuration.set('cameras', new_cameras) configuration.save()
check_status = touchpad_indicator_service.get_dbus_method( 'check_status', 'es.atareao.TouchpadIndicator') check_status() print('Touchpad-Indicator is working') except dbus.exceptions.DBusException as argument: print(argument) touchpad = Touchpad() configuration = Configuration() touchpad_enabled = configuration.get('touchpad_enabled') touchpad_indicator_working = configuration.get('is_working') status = touchpad.are_all_touchpad_enabled() if touchpad_indicator_working: print('Touchpad-Indicator is working') if touchpad_enabled != status: if touchpad_enabled: touchpad.enable_all_touchpads() else: touchpad.disable_all_touchpads() newstatus = touchpad.are_all_touchpad_enabled() if status != newstatus: configuration.set('touchpad_enabled', newstatus) configuration.save() status = newstatus else: print('Touchpad-Indicator is not working') if status: print('Touchpad is enabled') else: print('Touchpad is disabled') exit(0)
def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) if self.radiobutton1.get_active() is True: configuration.set('theme', 'light') elif self.radiobutton2.get_active() is True: configuration.set('theme', 'dark') else: configuration.set('theme', 'normal') if self.on_start['none'].get_active() is True: configuration.set('on_start', 0) elif self.on_start['enable'].get_active() is True: configuration.set('on_start', 1) else: configuration.set('on_start', -1) if self.on_end['none'].get_active() is True: configuration.set('on_end', 0) elif self.on_end['enable'].get_active() is True: configuration.set('on_end', 1) else: configuration.set('on_end', -1) configuration.set('autostart', self.checkbutton1.get_active()) set_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged', self.checkbutton2.get_active()) configuration.set('start_hidden', self.checkbutton5.get_active()) configuration.set('show_notifications', self.checkbutton6.get_active()) configuration.set('disable_on_typing', self.checkbutton8.get_active()) configuration.set('interval', self.interval.get_value()) configuration.set('natural_scrolling', self.checkbutton46.get_active()) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp._get_type(tp._get_ids()[0]) if tipo == SYNAPTICS: configuration.set('two_finger_scrolling', self.two_finger_scrolling.get_active()) configuration.set('edge_scrolling', self.edge_scrolling.get_active()) configuration.set('cicular_scrolling', self.cicular_scrolling.get_active()) elif tipo == LIBINPUT: if tp.can_two_finger_scrolling(): configuration.set('two_finger_scrolling', self.two_finger_scrolling.get_active()) if tp.can_edge_scrolling(): configuration.set('edge_scrolling', self.edge_scrolling.get_active()) if tp.has_tapping(): configuration.set('tapping', self.tapping.get_active()) configuration.set('speed', self.speed.get_value()) elif tipo == EVDEV: configuration.set('speed', self.speed.get_value()) configuration.save() desktop_environment = get_desktop_environment() if desktop_environment in ['gnome', 'unity', 'cinnamon', 'mate']: self.ctrl.set_active(True) self.alt.set_active(True) print(desktop_environment) if desktop_environment in ['gnome', 'unity']: dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) if key not in shortcuts: shortcuts.append(key) dcm.set_value('custom-keybindings', shortcuts) dcm = DConfManager( 'org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value( 'command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) elif desktop_environment == 'cinnamon': dcm = DConfManager('org.cinnamon.desktop.keybindings.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', [key1]) dcm.set_value( 'command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) if 'touchpad-indicator' not in shortcuts: shortcuts.append('touchpad-indicator') dcm.set_value('custom-list', shortcuts) else: dcm.set_value('binding', []) dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) elif desktop_environment == 'mate': dcm = DConfManager('org.mate.desktop.keybindings.\ touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value( 'action', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith( '/commands/custom/', '/usr/share/\ touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>', '<Control>') xfceconf.set_property( '/commands/custom/' + key, '/usr/share/\ touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) configuration.set('number_of_pomodoros', self.spinbutton0.get_value()) configuration.set('session_length', self.spinbutton1.get_value()) configuration.set('break_length', self.spinbutton2.get_value()) configuration.set('long_break_length', self.spinbutton3.get_value()) configuration.set('play_sounds', self.switch4.get_active()) configuration.set('session_sound_file', get_selected_value_in_combo(self.comboboxsound5)) configuration.set('break_sound_file', get_selected_value_in_combo(self.comboboxsound6)) create_or_remove_autostart(self.switch7.get_active()) if self.switch8.get_active(): configuration.set('theme', 'light') else: configuration.set('theme', 'dark') configuration.save()
class Indicator(object): def __init__(self): self.indicator = AppIndicator3.Indicator.new( 'tasker', 'tasker', AppIndicator3.IndicatorCategory.APPLICATION_STATUS) self.load_preferences() self.indicator.set_menu(self.build_menu()) self.indicator.set_label('', '') self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) self.set_icon(True) self.load_todos() Keybinder.init() Keybinder.bind('<Super><Ctrl>T', self.callback) Gtk.main() def callback(self, widget): addTodoDialog = AddTodoDialog() if addTodoDialog.run() == Gtk.ResponseType.ACCEPT: todo = addTodoDialog.get_task() list_of_todos = todotxtio.from_file(self.todo_file) for atodo in list_of_todos: if todo.text == atodo.text: return list_of_todos.append(todo) todotxtio.to_file(self.todo_file, list_of_todos) self.load_todos() addTodoDialog.destroy() def set_icon(self, active=True): if active: if self.theme_light: icon = config.ICON_ACTIVED_LIGHT else: icon = config.ICON_ACTIVED_DARK else: if self.theme_light: icon = config.ICON_PAUSED_LIGHT else: icon = config.ICON_PAUSED_DARK self.indicator.set_icon(icon) def load_preferences(self): self.configuration = Configuration() preferences = self.configuration.get('preferences') self.theme_light = preferences['theme-light'] self.todos = preferences['todos'] 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() projects = preferences['projects'] contexts = preferences['contexts'] tags = preferences['tags'] self.hide_completed = preferences.get('hide-completed', False) list_of_todos = todotxtio.from_file(self.todo_file) pattern = r'^\d{4}-\d{2}-\d{2}$' for todo in list_of_todos: for aproject in todo.projects: if aproject not in projects: projects.append(aproject) for acontext in todo.contexts: if acontext not in contexts: contexts.append(acontext) for atag in todo.tags: if atag not in [tag['name'] for tag in tags]: if re.search(pattern, todo.tags[atag]): tags.append({'name': atag, 'type': 'date'}) elif todo.tags[atag].lower() in ['true', 'false']: tags.append({'name': atag, 'type': 'boolean'}) elif todo.tags[atag].lower() in ['true', 'false']: tags.append({'name': atag, 'type': 'boolean'}) else: tags.append({'name': atag, 'type': 'string'}) preferences['projects'] = projects preferences['contexts'] = contexts preferences['tags'] = tags self.configuration.set('preferences', preferences) self.configuration.save() self.set_icon(True) def on_popped(self, widget, display): pass def on_menu_todo_toggled(self, widget): list_of_todos = todotxtio.from_file(self.todo_file) list_of_todos[widget.file_index].completed = widget.get_active() if widget.get_active(): list_of_todos[ widget. file_index].completion_date = creation_date = datetime.datetime.now( ).strftime('%Y-%m-%d') else: list_of_todos[widget.file_index].completion_date = None todotxtio.to_file(self.todo_file, list_of_todos) if self.hide_completed: widget.hide() def sort(self, todo): if todo.priority: order = '000' + str(ord(todo.priority.upper())) return order[-3:] + todo.text.lower() return '999' + todo.text.lower() def load_todos(self): list_of_todos = todotxtio.from_file(self.todo_file) list_of_todos.sort(reverse=False, key=self.sort) while self.todos > len(self.menu_todos): self.menu_todos.append(Gtk.CheckMenuItem.new_with_label('')) for i in range(0, min(len(list_of_todos), self.todos)): if list_of_todos[i].priority: text = '({}) {}'.format(list_of_todos[i].priority, list_of_todos[i].text) else: text = list_of_todos[i].text self.menu_todos[i].file_index = i self.menu_todos[i].set_label(text) self.menu_todos[i].set_active(list_of_todos[i].completed) self.menu_todos[i].connect('toggled', self.on_menu_todo_toggled) if self.hide_completed and list_of_todos[i].completed: self.menu_todos[i].hide() else: self.menu_todos[i].show() if len(list_of_todos) < self.todos: for i in range(len(list_of_todos), self.todos): self.menu_todos[i].hide() def build_menu(self): menu = Gtk.Menu() menu.connect('draw', self.on_popped) self.menu_todos = [] for i in range(0, self.todos): self.menu_todos.append(Gtk.CheckMenuItem.new_with_label('')) menu.append(self.menu_todos[i]) menu.append(Gtk.SeparatorMenuItem()) menu_add_todo = Gtk.MenuItem.new_with_label(_('Add task')) menu_add_todo.connect('activate', self.on_menu_add_todo_activate) menu.append(menu_add_todo) menu_list_todos = Gtk.MenuItem.new_with_label(_('Tasks')) menu_list_todos.connect('activate', self.on_menu_list_todos_activate) menu.append(menu_list_todos) # menu.append(Gtk.SeparatorMenuItem()) # menu_show_statistics = Gtk.MenuItem.new_with_label( # _('Statistics')) # menu_show_statistics.connect('activate', self.show_statistics) # menu.append(menu_show_statistics) menu.append(Gtk.SeparatorMenuItem()) menu_preferences = Gtk.MenuItem.new_with_label(_('Preferences')) menu_preferences.connect('activate', self.show_preferences) menu.append(menu_preferences) menus_help = Gtk.MenuItem.new_with_label(_('Help')) menus_help.set_submenu(self.get_help_menu()) menu.append(menus_help) menu.append(Gtk.SeparatorMenuItem()) menu_quit = Gtk.MenuItem.new_with_label(_('Quit')) menu_quit.connect('activate', self.quit) menu.append(menu_quit) menu.show_all() return menu def on_menu_list_todos_activate(self, widget): listTodos = ListTodos() if listTodos.run() == Gtk.ResponseType.ACCEPT: listTodos.save() self.load_todos() listTodos.destroy() def on_menu_add_todo_activate(self, widget): addTodoDialog = AddTodoDialog() if addTodoDialog.run() == Gtk.ResponseType.ACCEPT: todo = addTodoDialog.get_task() list_of_todos = todotxtio.from_file(self.todo_file) for atodo in list_of_todos: if todo.text == atodo.text: return list_of_todos.append(todo) todotxtio.to_file(self.todo_file, list_of_todos) self.load_todos() addTodoDialog.destroy() def show_change(self, widget): change = Change() response = change.run() change.destroy() def show_preferences(self, widget): widget.set_sensitive(False) preferences = Preferences() response = preferences.run() if response == Gtk.ResponseType.ACCEPT: preferences.save() self.load_preferences() self.load_todos() self.set_icon(True) preferences.destroy() widget.set_sensitive(True) 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 get_help_menu(self): help_menu = Gtk.Menu() homepage_item = Gtk.MenuItem.new_with_label(_('Homepage')) homepage_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(homepage_item) help_item = Gtk.MenuItem.new_with_label(_('Get help online...')) help_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(help_item) translate_item = Gtk.MenuItem.new_with_label( _('Translate this application...')) translate_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(translate_item) bug_item = Gtk.MenuItem.new_with_label(_('Report a bug...')) bug_item.connect( 'activate', lambda x: webbrowser.open('https://github.com/atareao\ /tasker/issues')) help_menu.append(bug_item) help_menu.append(Gtk.SeparatorMenuItem()) twitter_item = Gtk.MenuItem.new_with_label(_('Found me in Twitter')) twitter_item.connect( 'activate', lambda x: webbrowser.open('https://twitter.com/atareao')) help_menu.append(twitter_item) # github_item = Gtk.MenuItem.new_with_label(_('Found me in GitHub')) github_item.connect( 'activate', lambda x: webbrowser.open('https://github.com/atareao')) help_menu.append(github_item) mastodon_item = Gtk.MenuItem.new_with_label(_('Found me in Mastodon')) mastodon_item.connect( 'activate', lambda x: webbrowser.open('https://mastodon.social/@atareao')) help_menu.append(mastodon_item) about_item = Gtk.MenuItem.new_with_label(_('About')) about_item.connect('activate', self.menu_about_response) help_menu.append(Gtk.SeparatorMenuItem()) help_menu.append(about_item) return help_menu def menu_about_response(self, widget): widget.set_sensitive(False) ad = Gtk.AboutDialog() ad.set_name(config.APPNAME) ad.set_version(config.VERSION) ad.set_copyright('Copyrignt (c) 2020\nLorenzo Carbonell') ad.set_comments(_('Tasker')) ad.set_license(''' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''') ad.set_website('') ad.set_website_label('http://www.atareao.es') ad.set_authors(['Lorenzo Carbonell Cerezo <a.k.a. atareao>']) ad.set_translator_credits('Lorenzo Carbonell Cerezo <a.k.a. atareao>') ad.set_documenters(['Lorenzo Carbonell Cerezo <a.k.a. atareao>']) ad.set_artists(['Freepik <https://www.flaticon.com/authors/freepik>']) ad.set_logo(GdkPixbuf.Pixbuf.new_from_file(config.ICON)) ad.set_icon(GdkPixbuf.Pixbuf.new_from_file(config.ICON)) ad.set_program_name(config.APPNAME) monitor = Gdk.Display.get_primary_monitor(Gdk.Display.get_default()) scale = monitor.get_scale_factor() monitor_width = monitor.get_geometry().width / scale monitor_height = monitor.get_geometry().height / scale width = ad.get_preferred_width()[0] height = ad.get_preferred_height()[0] ad.move((monitor_width - width) / 2, (monitor_height - height) / 2) ad.run() ad.destroy() widget.set_sensitive(True) def quit(self, menu_item): Gtk.main_quit() # If Gtk throws an error or just a warning, main_quit() might not # actually close the app sys.exit(0)
def save_preferences(self): configuration = Configuration() if self.checkbutton11.get_active() and\ (len(self.entry11.get_text()) == 0 or self.latitude is None or self.latitude == 0 or self.longitude is None or self.longitude == 0): self.latitude, self.longitude = ipaddress.get_current_location() ans = geocodeapi.get_inv_direction(self.latitude, self.longitude) if ans is not None and 'locality' in ans.keys(): self.location = ans['locality'] if self.checkbutton21.get_active() and\ (len(self.entry21.get_text()) == 0 or self.latitude2 is None or self.latitude2 == 0 or self.longitude2 is None or self.longitude2 == 0): self.latitude2, self.longitude2 = ipaddress.get_current_location() ans = geocodeapi.get_inv_direction(self.latitude2, self.longitude2) if ans is not None and 'locality' in ans.keys(): self.location2 = ans['locality'] if len(self.entry11.get_text()) > 0: self.location = self.entry11.get_text() if len(self.entry21.get_text()) > 0: self.location2 = self.entry21.get_text() configuration.set('first-time', False) configuration.set('version', comun.VERSION) configuration.set('main-location', self.checkbutton11.get_active()) configuration.set('autolocation', self.checkbutton10.get_active()) configuration.set('location', self.location) configuration.set('latitude', self.latitude) configuration.set('longitude', self.longitude) configuration.set('show-temperature', self.checkbutton12.get_active()) configuration.set('show-notifications', self.checkbutton13.get_active()) configuration.set('widget1', self.checkbutton14.get_active()) configuration.set('onwidget1hide', self.checkbutton15.get_active()) configuration.set('onwidget1top', self.checkbutton16.get_active()) configuration.set('showintaskbar1', self.checkbutton17.get_active()) configuration.set('onalldesktop1', self.checkbutton18.get_active()) configuration.set('skin1', get_selected_value_in_combo(self.comboboxskin1)) # configuration.set('second-location', self.checkbutton21.get_active()) configuration.set('location2', self.location2) configuration.set('latitude2', self.latitude2) configuration.set('longitude2', self.longitude2) configuration.set('show-temperature2', self.checkbutton22.get_active()) configuration.set('show-notifications2', self.checkbutton23.get_active()) configuration.set('widget2', self.checkbutton24.get_active()) configuration.set('onwidget2hide', self.checkbutton25.get_active()) configuration.set('onwidget2top', self.checkbutton26.get_active()) configuration.set('showintaskbar2', self.checkbutton27.get_active()) configuration.set('onalldesktop2', self.checkbutton28.get_active()) configuration.set('skin2', get_selected_value_in_combo(self.comboboxskin2)) # if self.radiobutton251.get_active(): configuration.set('weather-service', 'yahoo') elif self.radiobutton253.get_active(): configuration.set('weather-service', 'openweathermap') # wwokey = self.wwokey.get_text() if len(wwokey) > 0: wwo = WorldWeatherOnlineService(key=wwokey) if wwo.test_connection(): configuration.set('wwo-key', wwokey) if self.radiobutton252.get_active(): configuration.set('weather-service', 'worldweatheronline') else: if self.radiobutton252.get_active(): configuration.set('weather-service', 'openweathermap') wukey = self.wukey.get_text() if len(wukey) > 0: wu = UndergroundWeatherService(key=wukey) if wu.test_connection(): configuration.set('wu-key', wukey) if self.radiobutton254.get_active(): configuration.set('weather-service', 'wunderground') else: if self.radiobutton254.get_active(): configuration.set('weather-service', 'openweathermap') configuration.set( 'temperature', get_selected_value_in_combo(self.combobox3)) configuration.set( 'pressure', get_selected_value_in_combo(self.combobox32)) configuration.set( 'visibility', get_selected_value_in_combo(self.combobox33)) configuration.set( 'wind', get_selected_value_in_combo(self.combobox31)) configuration.set( 'rain', get_selected_value_in_combo(self.combobox34)) configuration.set( 'snow', get_selected_value_in_combo(self.combobox35)) configuration.set( '24h', get_selected_value_in_combo(self.combobox36)) configuration.set( 'refresh', get_selected_value_in_combo(self.combobox45)) configuration.set('icon-light', self.radiobutton31.get_active()) print('Saving...') configuration.save() # filestart = os.path.join( os.getenv("HOME"), ".config/autostart/my-weather-indicator-autostart.desktop") if self.checkbutton1.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 save_preferences(self): configuration = Configuration() configuration.set( 'markdown_editor.show_line_numbers', self.switch21.get_active()) configuration.set( 'markdown_editor.show_line_marks', self.switch22.get_active()) configuration.set( 'markdown_editor.spaces', self.switch23.get_active()) configuration.set( 'markdown_editor.tab_width', self.spinbutton24.get_value()) configuration.set( 'markdown_editor.auto_indent', self.switch25.get_active()) configuration.set( 'markdown_editor.highlight_current_line', self.switch26.get_active()) configuration.set( 'markdown_editor.font', self.button27.get_label()) configuration.set( 'html_viewer.show_line_numbers', self.switch31.get_active()) configuration.set( 'html_viewer.show_line_marks', self.switch32.get_active()) configuration.set( 'html_viewer.spaces', self.switch33.get_active()) configuration.set( 'html_viewer.tab_width', self.spinbutton34.get_value()) configuration.set( 'html_viewer.auto_indent', self.switch35.get_active()) configuration.set( 'html_viewer.highlight_current_line', self.switch36.get_active()) configuration.set( 'html_viewer.preview_theme', get_selected_value_in_combo(self.combobox_preview_theme)) configuration.set('autosave', self.switch41.get_active()) configuration.set('spellcheck', self.switch42.get_active()) configuration.set('mathjax', self.switch43.get_active()) configuration.save()
def save_configuration(self): configuration = Configuration() configuration.set('hostname', self.hostname.get_text()) configuration.set('port', self.port.get_text()) configuration.set('username', self.username.get_text()) configuration.set('password', self.password.get_text()) configuration.set('keyfilename', self.keyfile.get_filename()) configuration.set('credentials_by_password', self.connection_option.get_state()) if self.test_connection.get_label() == _('OK'): configuration.set('checked_connection', True) else: configuration.set('checked_connection', False) configuration.save()
def load_preferences(self): if not os.path.exists(comun.CONFIG_FILE): if internet_on(): configuration = Configuration() configuration.reset() latitude, longitude = ipaddress.get_current_location() city = geocodeapi.get_inv_direction( latitude, longitude)['city'] if city is None: city = '' configuration.set('latitude', latitude) configuration.set('longitude', longitude) configuration.set('location', city) configuration.save() cm = preferences.CM() if cm.run() == Gtk.ResponseType.ACCEPT: cm.save_preferences() else: exit(0) cm.hide() cm.destroy() configuration = Configuration() self.first_time = configuration.get('first-time') self.refresh = configuration.get('refresh') self.version = configuration.get('version') # self.preferences[0] = {} self.preferences[0]['show'] = configuration.get('main-location') self.preferences[0]['autolocation'] = configuration.get('autolocation') self.preferences[0]['location'] = configuration.get('location') self.preferences[0]['latitude'] = configuration.get('latitude') self.preferences[0]['longitude'] = configuration.get('longitude') self.preferences[0]['show-temperature'] =\ configuration.get('show-temperature') self.preferences[0]['show-notifications'] =\ configuration.get('show-notifications') self.preferences[0]['widget'] = configuration.get('widget1') # self.preferences[1] = {} self.preferences[1]['show'] = configuration.get('second-location') self.preferences[1]['autolocation'] = False self.preferences[1]['location'] = configuration.get('location2') self.preferences[1]['latitude'] = configuration.get('latitude2') self.preferences[1]['longitude'] = configuration.get('longitude2') self.preferences[1]['show-temperature'] =\ configuration.get('show-temperature2') self.preferences[1]['show-notifications'] =\ configuration.get('show-notifications2') self.preferences[1]['widget'] = configuration.get('widget2') # temperature = configuration.get('temperature') pressure = configuration.get('pressure') visibility = configuration.get('visibility') wind = configuration.get('wind') snow = configuration.get('snow') rain = configuration.get('rain') ampm = not configuration.get('24h') self.units = weatherservice.Units(temperature=temperature, wind=wind, pressure=pressure, visibility=visibility, snow=snow, rain=rain, ampm=ampm) self.ws = configuration.get('weather-service') if self.ws == 'yahoo': self.key = '' for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] = wyahooapi.YahooWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units) self.menus[i]['evolution'].hide() elif self.ws == 'worldweatheronline': self.key = configuration.get('wwo-key') for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ worldweatheronlineapi.WorldWeatherOnlineService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units, key=self.key) self.menus[i]['evolution'].hide() elif self.ws == 'openweathermap': self.key = '' for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ wopenweathermapapi.OWMWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units) self.menus[i]['evolution'].show() elif self.ws == 'wunderground': self.key = configuration.get('wu-key') for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ wundergroundapi.UndergroundWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units, key=self.key) self.menus[i]['evolution'].hide() # self.icon_light = configuration.get('icon-light') # utcnow = datetime.utcnow() for i in range(INDICATORS): if self.preferences[i]['show'] and\ self.preferences[i]['widget']: if self.widgets[i] is not None: self.widgets[i].hide() self.widgets[i].destroy() self.widgets[i] = None self.widgets[i] = WeatherWidget(self.indicators[i], i) self.widgets[i].set_datetime(utcnow) self.widgets[i].set_location(self.preferences[i]['location']) self.widgets[i].connect('pinit', self.on_pinit, i) elif self.widgets[i] is not None: self.widgets[i].hide() self.widgets[i].destroy() self.widgets[i] = None print(1) self.update_weather() self.start_looking_for_internet()
def menu_exit_response(self,widget): configuration = Configuration() configuration.set('tasklist_id',self.tasklist_id) configuration.save() self.tasks.backup() exit(0)
def __init__(self): if dbus.SessionBus().request_name('es.atareao.MyWeatherIndicator') !=\ dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER: print("application already running") exit(0) # self.weather_updater = 0 self.widgets_updater = 0 self.menus = [] self.indicators = [] self.notifications = [] self.widgets = [] self.weatherservices = [] self.weathers = [] self.current_conditions = [] self.preferences = [] # Iniciate variables for i in range(INDICATORS): self.menus.append(None) self.indicators.append(None) self.notifications.append(None) self.widgets.append(None) self.weatherservices.append(None) self.weathers.append(None) self.current_conditions.append(None) self.preferences.append(None) # status = appindicator.IndicatorCategory.APPLICATION_STATUS self.notifications[0] = Notify.Notification.new('', '', None) self.indicators[0] = appindicator.Indicator.new( 'My-Weather-Indicator', 'My-Weather-Indicator', status) self.notifications[1] = Notify.Notification.new('', '', None) self.indicators[1] = appindicator.Indicator.new( 'My-Weather-Indicator2', 'My-Weather-Indicator', status) # for i in range(INDICATORS): self.create_menu(i) # ''' while internet_on() == False: print('Waiting for internet') time_start = time.time() time_end = (time_start + 1) while time_end > time.time(): while Gtk.events_pending(): Gtk.main_iteration() time.sleep(0.3) ''' if not os.path.exists(comun.CONFIG_FILE) and internet_on(): configuration = Configuration() configuration.reset() latitude, longitude = ipaddress.get_current_location() city = geocodeapi.get_inv_direction(latitude, longitude)['city'] if city is None: city = '' configuration.set('latitude', latitude) configuration.set('longitude', longitude) configuration.set('location', city) configuration.save() cm = preferences.CM() if cm.run() == Gtk.ResponseType.ACCEPT: cm.save_preferences() else: exit(0) cm.hide() cm.destroy() for i in range(INDICATORS): self.widgets[i] = None self.load_preferences()
def menu_exit_response(self, widget): configuration = Configuration() configuration.set('tasklist_id', self.tasklist_id) configuration.save() self.tasks.backup() exit(0)
def save_preferences(self): configuration = Configuration() configuration.set("frame", self.sample_time.get_value()) configuration.set("scale", self.scale.get_active()) configuration.set("modify-width", self.modify_width.get_active()) configuration.set("width", self.width.get_value()) configuration.set("modify-height", self.modify_height.get_active()) configuration.set("height", self.height.get_value()) configuration.save()
def save_preferences(self): configuration = Configuration() configuration.set('first-time', False) configuration.set('version', comun.VERSION) if self.radiobutton1.get_active() is True: configuration.set('theme', 'light') elif self.radiobutton2.get_active() is True: configuration.set('theme', 'dark') else: configuration.set('theme', 'normal') if self.on_start['none'].get_active() is True: configuration.set('on_start', 0) elif self.on_start['enable'].get_active() is True: configuration.set('on_start', 1) else: configuration.set('on_start', -1) if self.on_end['none'].get_active() is True: configuration.set('on_end', 0) elif self.on_end['enable'].get_active() is True: configuration.set('on_end', 1) else: configuration.set('on_end', -1) configuration.set('autostart', self.checkbutton1.get_active()) set_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged', self.checkbutton2.get_active()) configuration.set('start_hidden', self.checkbutton5.get_active()) configuration.set('show_notifications', self.checkbutton6.get_active()) configuration.set('disable_on_typing', self.checkbutton8.get_active()) configuration.set('interval', self.interval.get_value()) configuration.set('natural_scrolling', self.checkbutton46.get_active()) tp = Touchpad() if tp.is_there_touchpad(): tipo = tp.get_driver() if tipo == SYNAPTICS: configuration.set( 'two_finger_scrolling', self.two_finger_scrolling.get_active()) configuration.set( 'edge_scrolling', self.edge_scrolling.get_active()) configuration.set( 'cicular_scrolling', self.cicular_scrolling.get_active()) configuration.set( 'right-top-corner', get_selected_value_in_combo(self.right_top_corner)) configuration.set( 'right-bottom-corner', get_selected_value_in_combo(self.right_bottom_corner)) configuration.set( 'left-top-corner', get_selected_value_in_combo(self.left_top_corner)) configuration.set( 'left-bottom-corner', get_selected_value_in_combo(self.right_bottom_corner)) configuration.set( 'one-finger-tap', get_selected_value_in_combo(self.one_finger_tap)) if tp.get_capabilities()['two-finger-detection']: configuration.set( 'two-finger-tap', get_selected_value_in_combo(self.two_finger_tap)) if tp.get_capabilities()['three-finger-detection']: configuration.set( 'three-finger-tap', get_selected_value_in_combo(self.three_finger_tap)) elif tipo == LIBINPUT: if tp.can_two_finger_scrolling(): configuration.set( 'two_finger_scrolling', self.two_finger_scrolling.get_active()) if tp.can_edge_scrolling(): configuration.set( 'edge_scrolling', self.edge_scrolling.get_active()) if tp.has_tapping(): configuration.set('tapping', self.tapping.get_active()) configuration.set('speed', self.speed.get_value()) elif tipo == EVDEV: configuration.set('speed', self.speed.get_value()) import watchdog configuration.set('faulty-devices', list(watchdog.faulty_devices)) configuration.save() desktop_environment = get_desktop_environment() if desktop_environment in ['gnome', 'unity', 'cinnamon', 'mate']: self.ctrl.set_active(True) self.alt.set_active(True) print(desktop_environment) if desktop_environment in ['gnome', 'unity']: dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) if key not in shortcuts: shortcuts.append(key) dcm.set_value('custom-keybindings', shortcuts) dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.\ custom-keybindings.touchpad-indicator') dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value('command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') dcm = DConfManager('org.gnome.settings-daemon.plugins.\ media-keys') shortcuts = dcm.get_value('custom-keybindings') key = '/org/gnome/settings-daemon/plugins/media-keys/\ custom-keybindings/touchpad-indicator/' if key in shortcuts: shortcuts.pop(shortcuts.index(key)) dcm.set_value('custom-keybindings', shortcuts) elif desktop_environment == 'cinnamon': dcm = DConfManager('org.cinnamon.desktop.keybindings.\ custom-keybindings.touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', [key1]) dcm.set_value('command', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) if 'touchpad-indicator' not in shortcuts: shortcuts.append('touchpad-indicator') dcm.set_value('custom-list', shortcuts) else: dcm.set_value('binding', []) dcm = DConfManager('org.cinnamon.desktop.keybindings') shortcuts = dcm.get_value('custom-list') if 'touchpad-indicator' in shortcuts: shortcuts.pop(shortcuts.index('touchpad-indicator')) dcm.set_value('custom-list', shortcuts) elif desktop_environment == 'mate': dcm = DConfManager('org.mate.desktop.keybindings.\ touchpad-indicator') if self.checkbutton0.get_active() and\ len(self.entry11.get_text()) > 0: key1 = '' key2 = None if self.ctrl.get_active() is True: key1 += '<Control>' key2 = '<Primary>' if self.alt.get_active() is True: key1 += '<Alt>' if key2 is not None: key2 += '<Alt>' key1 += self.entry11.get_text().lower() if key2 is not None: key2 += self.entry11.get_text().lower() if key1 not in get_shortcuts() and key2 not in get_shortcuts(): dcm.set_value('name', 'Touchpad-Indicator') dcm.set_value('binding', key1) dcm.set_value('action', '/usr/bin/python3 \ /usr/share/touchpad-indicator/change_touchpad_state.py') else: dcm.set_value('binding', '') elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith( '/commands/custom/', '/usr/share/\ touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>', '<Control>') xfceconf.set_property( '/commands/custom/' + key, '/usr/share/\ touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() configuration.set('first-time',False) configuration.set('version',comun.VERSION) key='' if self.ctrl.get_active() == True: key+='<Primary>' if self.alt.get_active() == True: key+='<Alt>' key += self.entry11.get_text() if self.radiobutton1.get_active() == True: theme = 'light' elif self.radiobutton2.get_active() == True: theme = 'dark' configuration.set('shortcut_enabled',self.checkbutton0.get_active()) configuration.set('autostart',self.checkbutton1.get_active()) create_or_remove_autostart(self.checkbutton1.get_active()) configuration.set('on_mouse_plugged',self.checkbutton2.get_active()) configuration.set('natural_scrolling',self.checkbutton46.get_active()) configuration.set('enable_on_exit',self.checkbutton3.get_active()) configuration.set('disable_on_exit',self.checkbutton4.get_active()) configuration.set('start_hidden',self.checkbutton5.get_active()) configuration.set('show_notifications',self.checkbutton6.get_active()) configuration.set('disable_touchpad_on_start_indicator',self.checkbutton7.get_active()) configuration.set('disable_on_typing',self.checkbutton8.get_active()) configuration.set('seconds',self.seconds.get_value()) configuration.set('shortcut',key) configuration.set('theme',theme) configuration.save() aclient = Synclient() aclient.set('VertEdgeScroll',1 if self.checkbutton41.get_active() else 0) aclient.set('HorizEdgeScroll',1 if self.checkbutton42.get_active() else 0) aclient.set('CircularScrolling',1 if self.checkbutton43.get_active() else 0) aclient.set('VertTwoFingerScroll',1 if self.checkbutton44.get_active() else 0) aclient.set('HorizTwoFingerScroll',1 if self.checkbutton45.get_active() else 0) aclient.set('TapButton1',self.combobox47.get_active()) aclient.set('TapButton2',self.combobox48.get_active()) aclient.set('TapButton3',self.combobox49.get_active()) if self.checkbutton46.get_active(): aclient.set('VertScrollDelta',-abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',-abs(int(aclient.get('HorizScrollDelta')))) else: aclient.set('VertScrollDelta',abs(int(aclient.get('VertScrollDelta')))) aclient.set('HorizScrollDelta',abs(int(aclient.get('HorizScrollDelta')))) desktop_environment = get_desktop_environment() if desktop_environment == 'gnome': print('gnom3') dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys') values = dcm.get_value('custom-keybindings') if self.checkbutton0.get_active(): if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' not in values: values.append('/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/') dcm.set_value('custom-keybindings',values) dcm = DConfManager('org.gnome.settings-daemon.plugins.media-keys.custom-keybindings.touchpad-indicator') print(dcm.set_value('binding',key)) print(dcm.set_value('command','/usr/bin/python3 /opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py')) print(dcm.set_value('name','Touchpad-Indicator key binding')) else: if '/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/' in values: values.remove('/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/touchpad-indicator/') dcm.set_value('custom-keybindings',values) elif desktop_environment == 'xfce': if xfconfquery_exists(): xfceconf = XFCEConfiguration('xfce4-keyboard-shortcuts') keys = xfceconf.search_for_value_in_properties_startswith('/commands/custom/','/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py') if keys: for akey in keys: xfceconf.reset_property(akey['key']) if self.checkbutton0.get_active(): key = key.replace('<Primary>','<Control>') xfceconf.set_property('/commands/custom/'+key,'/opt/extras.ubuntu.com/touchpad-indicator/share/touchpad-indicator/change_touchpad_state.py')
def save_preferences(self): configuration = Configuration() tree_iter = self.entry2.get_active_iter() if tree_iter != None: model = self.entry2.get_model() tasklist_id = model[tree_iter][1] configuration.set('tasklist_id',tasklist_id) if self.switch5.get_active(): configuration.set('theme','light') else: configuration.set('theme','dark') if self.option_tlo['copy'].get_active()==True: configuration.set('local',0) elif self.option_tlo['delete'].get_active()==True: configuration.set('local',1) else: configuration.set('local',2) if self.option_teo['copy'].get_active()==True: configuration.set('external',0) elif self.option_teo['delete'].get_active()==True: configuration.set('external',1) else: configuration.set('external',2) # if self.option_tb['copy local'].get_active()==True: configuration.set('both',0) elif self.option_tb['copy external'].get_active()==True: configuration.set('both',1) else: configuration.set('both',2) # configuration.save() filestart = os.path.join(os.getenv("HOME"),".config/autostart/google-tasks-indicator-autostart.desktop") if self.switch4.get_active(): if not os.path.exists(filestart): if not os.path.exists(os.path.dirname(filestart)): os.makedirs(os.path.dirname(filestart)) shutil.copyfile('/usr/share/google-tasks-indicator/google-tasks-indicator-autostart.desktop',filestart) else: if os.path.exists(filestart): os.remove(filestart)
def save_config(self): configuration = Configuration() configuration.set('show-hdd', self.show_hdd) configuration.set('show-net', self.show_net) configuration.save() self.refresh()
class Indicator(object): def __init__(self, hook): self.hook = hook self.indicator = AppIndicator3.Indicator.new( 'tasker', 'tasker', AppIndicator3.IndicatorCategory.APPLICATION_STATUS) Keybinder.init() self.tracking = False self.load_preferences() self.indicator.set_menu(self.build_menu()) self.indicator.set_label('', '') self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE) self.set_icon() self.load_todos() Gtk.main() def set_icon(self): if self.tracking: if self.theme_light: icon = config.ICON_PAUSED_LIGHT else: icon = config.ICON_PAUSED_DARK else: if self.theme_light: icon = config.ICON_ACTIVED_LIGHT else: icon = config.ICON_ACTIVED_DARK self.indicator.set_icon(icon) def load_preferences(self): self.configuration = Configuration() preferences = self.configuration.get('preferences') self.theme_light = preferences['theme-light'] self.todos = preferences['todos'] 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.projects = preferences['projects'] contexts = preferences['contexts'] tags = preferences['tags'] self.hide_completed = preferences.get('hide-completed', False) self.filter_projects = preferences.get('filter-projects', False) self.last_filtered_projects = preferences.get('last-filtered-projects', []) list_of_todos = todotxtio.from_file(self.todo_file) pattern = r'^\d{4}-\d{2}-\d{2}$' for todo in list_of_todos: for aproject in todo.projects: if aproject not in self.projects: self.projects.append(aproject) for acontext in todo.contexts: if acontext not in contexts: contexts.append(acontext) for atag in todo.tags: if atag not in [tag['name'] for tag in tags]: if re.search(pattern, todo.tags[atag]): tags.append({'name': atag, 'type': 'date'}) elif todo.tags[atag].lower() in ['true', 'false']: tags.append({'name': atag, 'type': 'boolean'}) elif todo.tags[atag].lower() in [ 'true', 'false']: tags.append({'name': atag, 'type': 'boolean'}) else: tags.append({'name': atag, 'type': 'string'}) preferences['projects'] = self.projects preferences['contexts'] = contexts preferences['tags'] = tags self.new_task_keybind = '<Control><Super>t' self.show_tasks_keybind = '<Control><Super>a' keybindings = preferences.get('keybindings', []) if keybindings: self.new_task_keybind = list( filter(lambda obj: obj.get('name') == 'new_task', keybindings) )[0]['keybind'] self.show_tasks_keybind = list( filter(lambda obj: obj.get('name') == 'show_tasks', keybindings) )[0]['keybind'] Keybinder.bind(self.new_task_keybind, self.on_menu_add_todo_activate) Keybinder.bind(self.show_tasks_keybind, self.on_menu_list_todos_activate) preferences['keybindings'] = [ {'name': 'new_task', 'keybind': self.new_task_keybind}, {'name': 'show_tasks', 'keybind': self.show_tasks_keybind}, ] self.configuration.set('preferences', preferences) self.configuration.save() self.set_icon() def on_popped(self, widget, display): pass def get_project_showed(self, ): if not hasattr(self, 'menu_filter_projects'): return [] projects_menuitems_actives = \ list(filter(lambda item: item.get_active(), self.menu_filter_projects.get_submenu().get_children())) return [menu_item.get_label() for menu_item in projects_menuitems_actives] def set_filter_project_label(self): projects_items = self.menu_filter_projects.get_submenu().get_children() projects_items_actives = self.get_project_showed() projects_sel = _('All') if len(projects_items) != len(projects_items_actives): projects_sel = ', '.join(projects_items_actives) if projects_sel == '': projects_sel = _('Select one to show tasks') self.menu_filter_projects.set_label(projects_sel) def on_menu_filter_project_toggled(self, widget, i): self.set_filter_project_label() self.load_todos() preferences = self.configuration.get('preferences') preferences['last-filtered-projects'] = self.get_project_showed() self.configuration.set('preferences', preferences) self.configuration.save() def on_menu_todo_toggled(self, widget): list_of_todos = todotxtio.from_file(self.todo_file) list_of_todos[widget.file_index].completed = widget.get_active() if widget.get_active(): creation_date = datetime.datetime.now().strftime('%Y-%m-%d') list_of_todos[widget.file_index].completion_date = creation_date else: list_of_todos[widget.file_index].completion_date = None todotxtio.to_file(self.todo_file, list_of_todos) if self.hide_completed: widget.hide() def sort(self, todo): if todo.priority: order = '000' + str(ord(todo.priority.upper())) return order[-3:] + todo.text.lower() return '999' + todo.text.lower() def load_todos(self): list_of_todos = todotxtio.from_file(self.todo_file) list_of_todos.sort(reverse=False, key=self.sort) while self.todos > len(self.menu_todos): menuitem = Gtk.CheckMenuItem.new_with_label('') menuitem.remove(menuitem.get_child()) menuitem.add(Gtk.Label.new('')) menuitem.get_child().set_use_markup(True) self.menu_todos.append(menuitem) for i in range(0, min(len(list_of_todos), self.todos)): if list_of_todos[i].priority: text = '({}) {}'.format(list_of_todos[i].priority, list_of_todos[i].text) else: text = list_of_todos[i].text self.menu_todos[i].file_index = i self.menu_todos[i].set_label(text) self.menu_todos[i].set_active(list_of_todos[i].completed) self.menu_todos[i].connect('toggled', self.on_menu_todo_toggled) hide_by_project = False if self.filter_projects: if not set(list_of_todos[i].projects).isdisjoint(self.get_project_showed()) or \ not list_of_todos[i].projects: self.menu_todos[i].show() else: self.menu_todos[i].hide() hide_by_project = True if not hide_by_project: if self.hide_completed and list_of_todos[i].completed: self.menu_todos[i].hide() elif self.hide_completed and not list_of_todos[i].completed: self.menu_todos[i].show() if not self.filter_projects and not self.hide_completed: self.menu_todos[i].show() if len(list_of_todos) < self.todos: for i in range(len(list_of_todos), self.todos): self.menu_todos[i].hide() def build_menu(self): menu = Gtk.Menu() menu.connect('draw', self.on_popped) if self.filter_projects: self.menu_filter_projects = Gtk.CheckMenuItem.new_with_label('') self.menu_filter_projects.set_submenu( self.get_filter_project_menu()) self.set_filter_project_label() menu.append(self.menu_filter_projects) menu.append(Gtk.SeparatorMenuItem()) self.menu_todos = [] for i in range(0, self.todos): menuitem = Gtk.CheckMenuItem.new_with_label('') menuitem.remove(menuitem.get_child()) menuitem.add(Gtk.Label.new('')) menuitem.get_child().set_use_markup(True) self.menu_todos.append(menuitem) menu.append(self.menu_todos[i]) menu.append(Gtk.SeparatorMenuItem()) menu_add_todo = Gtk.MenuItem.new_with_label(_('Add task')) menu_add_todo.connect('activate', self.on_menu_add_todo_activate) menu.append(menu_add_todo) menu_list_todos = Gtk.MenuItem.new_with_label(_('Tasks')) menu_list_todos.connect('activate', self.on_menu_list_todos_activate) menu.append(menu_list_todos) menu.append(Gtk.SeparatorMenuItem()) inner_menu_statistics = Gtk.Menu() menu_show_statistics = Gtk.MenuItem.new_with_label(_('By project')) menu_show_statistics.connect('activate', self.show_statistics, True) inner_menu_statistics.append(menu_show_statistics) menu_show_statistics = Gtk.MenuItem.new_with_label(_('By context')) menu_show_statistics.connect('activate', self.show_statistics, False) inner_menu_statistics.append(menu_show_statistics) menu_statistics = Gtk.MenuItem.new_with_label(_('Statistics')) menu_statistics.set_submenu(inner_menu_statistics) menu.append(menu_statistics) hookmenu = self.hook.get_hook_menu() if hookmenu: menu.append(Gtk.SeparatorMenuItem()) for menuitem in hookmenu[0]: menu.append(menuitem) menu.append(Gtk.SeparatorMenuItem()) hookmenu = self.hook.get_hook_menu() if hookmenu: menu.append(Gtk.SeparatorMenuItem()) for menuitem in hookmenu[0]: menu.append(menuitem) menu.append(Gtk.SeparatorMenuItem()) menu.append(Gtk.SeparatorMenuItem()) menu_preferences = Gtk.MenuItem.new_with_label(_('Preferences')) menu_preferences.connect('activate', self.show_preferences) menu.append(menu_preferences) menus_help = Gtk.MenuItem.new_with_label(_('Help')) menus_help.set_submenu(self.get_help_menu()) menu.append(menus_help) menu.append(Gtk.SeparatorMenuItem()) menu_quit = Gtk.MenuItem. new_with_label(_('Quit')) menu_quit.connect('activate', self.quit) menu.append(menu_quit) menu.show_all() return menu def on_menu_list_todos_activate(self, widget): listTodos = ListTodos(plugin_manager.get_list_box_todo_plugin_manager().hook) listTodos.indicator = self if listTodos.run() == Gtk.ResponseType.ACCEPT: listTodos.save() self.load_todos() listTodos.destroy() def on_menu_add_todo_activate(self, widget): addTodoDialog = AddTodoDialog(_('Add task')) if addTodoDialog.run() == Gtk.ResponseType.ACCEPT: todo = addTodoDialog.get_task() list_of_todos = todotxtio.from_file(self.todo_file) finded = False for atodo in list_of_todos: if todo.text == atodo.text: finded = True if not finded: list_of_todos.append(todo) todotxtio.to_file(self.todo_file, list_of_todos) self.load_todos() addTodoDialog.destroy() def show_change(self, widget): change = Change() response = change.run() change.destroy() def show_preferences(self, widget): widget.set_sensitive(False) preferences = Preferences() Keybinder.unbind(self.new_task_keybind) Keybinder.unbind(self.show_tasks_keybind) response = preferences.run() if response == Gtk.ResponseType.ACCEPT: preferences.save() self.load_preferences() self.load_todos() self.set_icon() widget.set_sensitive(True) preferences.destroy() def show_statistics(self, widget, by_project): widget.set_sensitive(False) title = _('Timetracking tasker') graph = Graph(title, by_project) graph.run() graph.destroy() widget.set_sensitive(True) def get_filter_project_menu(self): filter_menu = Gtk.Menu() for i in range(0, len(self.projects)): project_item = Gtk.CheckMenuItem.new_with_label(self.projects[i]) project_item.set_active(1 if self.projects[i] in self.last_filtered_projects else 0) project_item.connect('toggled', self.on_menu_filter_project_toggled, i) filter_menu.append(project_item) return filter_menu def get_help_menu(self): help_menu = Gtk.Menu() homepage_item = Gtk.MenuItem.new_with_label(_('Homepage')) homepage_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(homepage_item) help_item = Gtk.MenuItem.new_with_label(_('Get help online...')) help_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(help_item) translate_item = Gtk.MenuItem.new_with_label(_( 'Translate this application...')) translate_item.connect( 'activate', lambda x: webbrowser.open( 'http://www.atareao.es/aplicacion/tasker/')) help_menu.append(translate_item) bug_item = Gtk.MenuItem.new_with_label(_('Report a bug...')) bug_item.connect( 'activate', lambda x: webbrowser.open('https://github.com/atareao\ /tasker/issues')) help_menu.append(bug_item) help_menu.append(Gtk.SeparatorMenuItem()) twitter_item = Gtk.MenuItem.new_with_label(_('Found me in Twitter')) twitter_item.connect( 'activate', lambda x: webbrowser.open('https://twitter.com/atareao')) help_menu.append(twitter_item) # github_item = Gtk.MenuItem.new_with_label(_('Found me in GitHub')) github_item.connect( 'activate', lambda x: webbrowser.open('https://github.com/atareao')) help_menu.append(github_item) mastodon_item = Gtk.MenuItem.new_with_label(_('Found me in Mastodon')) mastodon_item.connect( 'activate', lambda x: webbrowser.open('https://mastodon.social/@atareao')) help_menu.append(mastodon_item) about_item = Gtk.MenuItem.new_with_label(_('About')) about_item.connect('activate', self.menu_about_response) help_menu.append(Gtk.SeparatorMenuItem()) help_menu.append(about_item) return help_menu def menu_about_response(self, widget): widget.set_sensitive(False) ad = Gtk.AboutDialog() ad.set_name(config.APPNAME) ad.set_version(config.VERSION) ad.set_copyright('Copyrignt (c) 2020\nLorenzo Carbonell') ad.set_comments(_('Tasker')) ad.set_license(''' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''') ad.set_website('') ad.set_website_label('http://www.atareao.es') ad.set_authors(['Fernando <a.k.a. flachica>', 'Lorenzo Carbonell<a.k.a. atareao>']) ad.set_translator_credits('Lorenzo Carbonell Cerezo <a.k.a. atareao>') ad.set_documenters(['Lorenzo Carbonell Cerezo <a.k.a. atareao>']) ad.set_artists(['Freepik <https://www.flaticon.com/authors/freepik>']) ad.set_logo(GdkPixbuf.Pixbuf.new_from_file(config.ICON)) ad.set_icon(GdkPixbuf.Pixbuf.new_from_file(config.ICON)) ad.set_program_name(config.APPNAME) monitor = Gdk.Display.get_primary_monitor(Gdk.Display.get_default()) scale = monitor.get_scale_factor() monitor_width = monitor.get_geometry().width / scale monitor_height = monitor.get_geometry().height / scale width = ad.get_preferred_width()[0] height = ad.get_preferred_height()[0] ad.move((monitor_width - width)/2, (monitor_height - height)/2) ad.run() ad.destroy() widget.set_sensitive(True) def quit(self, menu_item): list_of_todos = todotxtio.from_file(self.todo_file) for atodo in list_of_todos: if 'started_at' in atodo.tags and atodo.tags['started_at']: started_at = float(atodo.tags.get('started_at', 0)) lbhook = plugin_manager.get_list_box_todo_plugin_manager().hook just_now = time.time() if started_at: total_time = float(atodo.tags.get('total_time', 0)) + time.time() - started_at atodo.tags['started_at'] = '0' atodo.tags['total_time'] = str(total_time) lbhook.after_track_time( todo=atodo, before_started_at=started_at, after_started_at=0, total_time=total_time, just_now=just_now ) elif not started_at and atodo.completed and started_at: atodo.tags['started_at'] = '0' lbhook.after_track_time( todo=atodo, before_started_at=started_at, after_started_at=0, total_time=None, just_now=just_now ) todotxtio.to_file(self.todo_file, list_of_todos) Gtk.main_quit() # If Gtk throws an error or just a warning, main_quit() might not # actually close the app sys.exit(0) def set_icon_tracktime(self, tracking=False): if tracking: self.indicator.set_icon('media-playback-pause') else: self.set_icon()
touchpad_indicator_service = bus.get_object("es.atareao.TouchpadIndicator", "/es/atareao/TouchpadIndicator") check_status = touchpad_indicator_service.get_dbus_method("check_status", "es.atareao.TouchpadIndicator") check_status() print("Touchpad-Indicator is working") except dbus.exceptions.DBusException as argument: print(argument) touchpad = Touchpad() configuration = Configuration() touchpad_enabled = configuration.get("touchpad_enabled") touchpad_indicator_working = configuration.get("is_working") status = touchpad.are_all_touchpad_enabled() if touchpad_indicator_working: print("Touchpad-Indicator is working") if touchpad_enabled != status: if touchpad_enabled: touchpad.enable_all_touchpads() else: touchpad.disable_all_touchpads() newstatus = touchpad.are_all_touchpad_enabled() if status != newstatus: configuration.set("touchpad_enabled", newstatus) configuration.save() status = newstatus else: print("Touchpad-Indicator is not working") if status: print("Touchpad is enabled") else: print("Touchpad is disabled") exit(0)
def load_preferences(self): if not os.path.exists(comun.CONFIG_FILE): if internet_on(): configuration = Configuration() configuration.reset() latitude, longitude = ipaddress.get_current_location() city = geocodeapi.get_inv_direction( latitude, longitude)['city'] if city is None: city = '' configuration.set('latitude', latitude) configuration.set('longitude', longitude) configuration.set('location', city) configuration.save() cm = preferences.CM() if cm.run() == Gtk.ResponseType.ACCEPT: cm.save_preferences() else: exit(0) cm.hide() cm.destroy() configuration = Configuration() self.first_time = configuration.get('first-time') self.refresh = configuration.get('refresh') self.version = configuration.get('version') # self.preferences[0] = {} self.preferences[0]['show'] = configuration.get('main-location') self.preferences[0]['autolocation'] = configuration.get('autolocation') self.preferences[0]['location'] = configuration.get('location') self.preferences[0]['latitude'] = configuration.get('latitude') self.preferences[0]['longitude'] = configuration.get('longitude') self.preferences[0]['show-temperature'] =\ configuration.get('show-temperature') self.preferences[0]['show-notifications'] =\ configuration.get('show-notifications') self.preferences[0]['widget'] = configuration.get('widget1') # self.preferences[1] = {} self.preferences[1]['show'] = configuration.get('second-location') self.preferences[1]['autolocation'] = False self.preferences[1]['location'] = configuration.get('location2') self.preferences[1]['latitude'] = configuration.get('latitude2') self.preferences[1]['longitude'] = configuration.get('longitude2') self.preferences[1]['show-temperature'] =\ configuration.get('show-temperature2') self.preferences[1]['show-notifications'] =\ configuration.get('show-notifications2') self.preferences[1]['widget'] = configuration.get('widget2') # temperature = configuration.get('temperature') pressure = configuration.get('pressure') visibility = configuration.get('visibility') wind = configuration.get('wind') snow = configuration.get('snow') rain = configuration.get('rain') ampm = not configuration.get('24h') self.units = weatherservice.Units(temperature=temperature, wind=wind, pressure=pressure, visibility=visibility, snow=snow, rain=rain, ampm=ampm) self.ws = configuration.get('weather-service') if self.ws == 'yahoo': self.key = '' for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] = wyahooapi.YahooWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units) self.menus[i]['evolution'].hide() elif self.ws == 'worldweatheronline': self.key = configuration.get('wwo-key') for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ worldweatheronlineapi.WorldWeatherOnlineService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units, key=self.key) self.menus[i]['evolution'].hide() elif self.ws == 'openweathermap': self.key = '' for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ wopenweathermapapi.OWMWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units) self.menus[i]['evolution'].show() elif self.ws == 'wunderground': self.key = configuration.get('wu-key') for i in range(INDICATORS): if self.preferences[i]['show']: self.weatherservices[i] =\ wundergroundapi.UndergroundWeatherService( longitude=self.preferences[i]['longitude'], latitude=self.preferences[i]['latitude'], units=self.units, key=self.key) self.menus[i]['evolution'].hide() # self.icon_light = configuration.get('icon-light') # utcnow = datetime.utcnow() for i in range(INDICATORS): if self.preferences[i]['show'] and\ self.preferences[i]['widget']: if self.widgets[i] is not None: self.widgets[i].hide() self.widgets[i].destroy() self.widgets[i] = None self.widgets[i] = WeatherWidget( self.indicators[i], i) self.widgets[i].set_datetime(utcnow) self.widgets[i].set_location(self.preferences[i]['location']) self.widgets[i].connect('pinit', self.on_pinit, i) elif self.widgets[i] is not None: self.widgets[i].hide() self.widgets[i].destroy() self.widgets[i] = None print(1) self.update_weather() self.start_looking_for_internet()