def _load_configuration(self): self.joy_mode = self.conf_client.get_string( "/apps/gnome15/%s/joymode" % self.device.uid) self.digital_calibration = g15gconf.get_int_or_default( self.conf_client, "/apps/gnome15/%s/digital_offset" % self.device.uid, 63) self.analogue_calibration = g15gconf.get_int_or_default( self.conf_client, "/apps/gnome15/%s/analogue_offset" % self.device.uid, 20)
def _set_offset_depending_on_mode(self, widget): mode = self.gconf_client.get_string("/apps/gnome15/%s/joymode" % self.device.uid) offset_model = self.offset_widget.get_adjustment() if mode in [ g15uinput.JOYSTICK, g15uinput.MOUSE]: val = g15gconf.get_int_or_default(self.gconf_client, "/apps/gnome15/%s/analogue_offset" % self.device.uid, ANALOGUE_OFFSET) else: val = g15gconf.get_int_or_default(self.gconf_client, "/apps/gnome15/%s/digital_offset" % self.device.uid, DIGITAL_OFFSET) offset_model.set_value(val)
def __init__(self, parent, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key self._visible_options = None self._widget_tree = gtk.Builder() self._widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "weather.ui")) dialog = self._widget_tree.get_object("WeatherDialog") dialog.set_transient_for(parent) self._source = self._widget_tree.get_object("Source") self._source.connect("changed", self._load_options_for_source) self._sources_model = self._widget_tree.get_object("SourcesModel") for b in get_available_backends(): l = [b, get_backend(b).backend_name ] self._sources_model.append(l) g15uigconf.configure_combo_from_gconf(gconf_client, "%s/source" % gconf_key, "Source", self._sources_model[0][0] if len(self._sources_model) > 0 else None, self._widget_tree) self._load_options_for_source() update = self._widget_tree.get_object("UpdateAdjustment") update.set_value(g15gconf.get_int_or_default(gconf_client, gconf_key + "/update", DEFAULT_UPDATE_INTERVAL)) update.connect("value-changed", self._value_changed, update, gconf_key + "/update") unit = self._widget_tree.get_object("UnitCombo") unit.set_active(gconf_client.get_int(gconf_key + "/units")) unit.connect("changed", self._unit_changed, unit, gconf_key + "/units") g15uigconf.configure_checkbox_from_gconf(gconf_client, "%s/use_theme_icons" % gconf_key, "UseThemeIcons", True, self._widget_tree) g15uigconf.configure_checkbox_from_gconf(gconf_client, "%s/twenty_four_hour_times" % gconf_key, "TwentyFourHourTimes", True, self._widget_tree) dialog.run() dialog.hide()
def __init__(self, parent, driver, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key widget_tree = gtk.Builder() widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "tails.ui")) # Feeds self.file_model = widget_tree.get_object("FileModel") self.reload_model() self.file_list = widget_tree.get_object("FileList") self.file_renderer = widget_tree.get_object("FileRenderer") # Lines self.lines_adjustment = widget_tree.get_object("LinesAdjustment") self.lines_adjustment.set_value(g15gconf.get_int_or_default(self._gconf_client, "%s/lines" % self._gconf_key, 10)) # Connect to events self.lines_adjustment.connect("value-changed", self.lines_changed) self.file_renderer.connect("edited", self.file_edited) widget_tree.get_object("NewFile").connect("clicked", self.new_file) widget_tree.get_object("RemoveFile").connect("clicked", self.remove_file) # Show dialog self.dialog = widget_tree.get_object("TailsDialog") self.dialog.set_transient_for(parent) ah = gconf_client.notify_add(gconf_key + "/files", self.files_changed); self.dialog.run() self.dialog.hide() gconf_client.notify_remove(ah);
def __init__(self, parent, driver, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key widget_tree = gtk.Builder() widget_tree.add_from_file( os.path.join(os.path.dirname(__file__), "tails.ui")) # Feeds self.file_model = widget_tree.get_object("FileModel") self.reload_model() self.file_list = widget_tree.get_object("FileList") self.file_renderer = widget_tree.get_object("FileRenderer") # Lines self.lines_adjustment = widget_tree.get_object("LinesAdjustment") self.lines_adjustment.set_value( g15gconf.get_int_or_default(self._gconf_client, "%s/lines" % self._gconf_key, 10)) # Connect to events self.lines_adjustment.connect("value-changed", self.lines_changed) self.file_renderer.connect("edited", self.file_edited) widget_tree.get_object("NewFile").connect("clicked", self.new_file) widget_tree.get_object("RemoveFile").connect("clicked", self.remove_file) # Show dialog self.dialog = widget_tree.get_object("TailsDialog") self.dialog.set_transient_for(parent) ah = gconf_client.notify_add(gconf_key + "/files", self.files_changed) self.dialog.run() self.dialog.hide() gconf_client.notify_remove(ah)
def __init__(self, parent, driver, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key widget_tree = gtk.Builder() widget_tree.add_from_file(os.path.join(os.path.dirname(__file__), "rss.ui")) # Feeds self.feed_model = widget_tree.get_object("FeedModel") self.reload_model() self.feed_list = widget_tree.get_object("FeedList") self.url_renderer = widget_tree.get_object("URLRenderer") # Optins self.update_adjustment = widget_tree.get_object("UpdateAdjustment") self.update_adjustment.set_value(g15gconf.get_int_or_default(self._gconf_client, "%s/update_time" % self._gconf_key, 60)) g15uigconf.configure_checkbox_from_gconf(gconf_client, "%s/twenty_four_hour_times" % gconf_key, "TwentyFourHourTimes", True, widget_tree) # Connect to events self.update_adjustment.connect("value-changed", self.update_time_changed) self.url_renderer.connect("edited", self.url_edited) widget_tree.get_object("NewURL").connect("clicked", self.new_url) widget_tree.get_object("RemoveURL").connect("clicked", self.remove_url) # Display # Show dialog dialog = widget_tree.get_object("RSSDialog") dialog.set_transient_for(parent) ah = gconf_client.notify_add(gconf_key + "/urls", self.urls_changed); dialog.run() dialog.hide() gconf_client.notify_remove(ah);
def _load_configuration(self): self.respect_timeout = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/respect_timeout", False) self.allow_actions = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/allow_actions", False) self.allow_cancel = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/allow_cancel", True) self.on_keyboard_screen = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/on_keyboard_screen", True) self.on_desktop = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/on_desktop", True) self.blink_keyboard_backlight = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/blink_keyboard_backlight", True) self.blink_memory_bank = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/blink_memory_bank", True) self.change_keyboard_backlight_color = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/change_keyboard_backlight_color", False) self.enable_sounds = g15gconf.get_bool_or_default( self._gconf_client, self._gconf_key + "/enable_sounds", True) self.blink_delay = g15gconf.get_int_or_default( self._gconf_client, self._gconf_key + "/blink_delay", 500) self.keyboard_backlight_color = g15gconf.get_rgb_or_default( self._gconf_client, self._gconf_key + "/keyboard_backlight_color", (128, 128, 128))
def _load_files(self): self.lines = g15gconf.get_int_or_default(self._gconf_client, "%s/lines" % self._gconf_key, 10) file_list = self._gconf_client.get_list(self._gconf_key + "/files", gconf.VALUE_STRING) def init(): # Add new pages for file_path in file_list: if not file_path in self._pages: pg = G15TailPage(self, file_path) self._pages[file_path] = pg else: self._pages[file_path]._reload() # Remove pages that no longer exist to_remove = [] for file_path in self._pages: page = self._pages[file_path] if not page.file_path in file_list: self._screen.del_page(page) to_remove.append(file_path) for page in to_remove: del self._pages[page] g15screen.run_on_redraw(init)
def grab_keyboard(self, callback): self.callback = callback self.last_keys = None self.last_ext_keys = None self.thread = pylibg15.grab_keyboard(self._handle_key_event, \ g15gconf.get_int_or_default(self.conf_client, "/apps/gnome15/usb_key_read_timeout", 100), self._on_error) self.thread.on_unplug = self._keyboard_unplugged
def _start_recording(self): self._record_fps = g15gconf.get_int_or_default(self._gconf_client, "%s/fps" % self._gconf_key, 10) path = self._find_next_free_filename("avi", _("Gnome15_Video")) g15notify.notify(_("LCD Screenshot"), _("Started recording video"), "dialog-info") g15os.mkdir_p("%s.tmp" % path) self._frame_no = 1 self._recording = True self._record_to = path self._frame()
def _start_recording(self): self._record_fps = g15gconf.get_int_or_default( self._gconf_client, "%s/fps" % self._gconf_key, 10) path = self._find_next_free_filename("avi", _("Gnome15_Video")) g15notify.notify(_("LCD Screenshot"), _("Started recording video"), "dialog-info") g15os.mkdir_p("%s.tmp" % path) self._frame_no = 1 self._recording = True self._record_to = path self._frame()
def _load_configuration(self): self.respect_timeout = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/respect_timeout", False) self.allow_actions = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/allow_actions", False) self.allow_cancel = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/allow_cancel", True) self.on_keyboard_screen = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/on_keyboard_screen", True) self.on_desktop = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/on_desktop", True) self.blink_keyboard_backlight = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/blink_keyboard_backlight", True) self.blink_memory_bank = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/blink_memory_bank", True) self.change_keyboard_backlight_color = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/change_keyboard_backlight_color", False) self.enable_sounds = g15gconf.get_bool_or_default(self._gconf_client, self._gconf_key + "/enable_sounds", True) self.blink_delay = g15gconf.get_int_or_default(self._gconf_client, self._gconf_key + "/blink_delay", 500) self.keyboard_backlight_color = g15gconf.get_rgb_or_default(self._gconf_client, self._gconf_key + "/keyboard_backlight_color", ( 128, 128, 128 ))
def _load_configuration(self): work_duration_conf_key = self._get_configuration_key("work_duration") self.pommodoro_timer.work_duration = g15gconf.get_int_or_default(self.gconf_client, work_duration_conf_key, DEFAULT_WORK_DURATION) shortbreak_conf_key = self._get_configuration_key("shortbreak_duration") self.pommodoro_timer.shortbreak_duration = \ g15gconf.get_int_or_default(self.gconf_client, shortbreak_conf_key, DEFAULT_SHORTBREAK_DURATION) longbreak_conf_key = self._get_configuration_key("longbreak_duration") self.pommodoro_timer.longbreak_duration = \ g15gconf.get_int_or_default(self.gconf_client, longbreak_conf_key, DEFAULT_LONGBREAK_DURATION) pommodoro_count_conf_key = self._get_configuration_key("pommodoro_count") self.pommodoro_timer.init_count_at(g15gconf.get_int_or_default(self.gconf_client, pommodoro_count_conf_key, 0)) self.pommodoro_timer.recalculate()
def _load_configuration(self): work_duration_conf_key = self._get_configuration_key("work_duration") self.pommodoro_timer.work_duration = g15gconf.get_int_or_default( self.gconf_client, work_duration_conf_key, DEFAULT_WORK_DURATION) shortbreak_conf_key = self._get_configuration_key( "shortbreak_duration") self.pommodoro_timer.shortbreak_duration = \ g15gconf.get_int_or_default(self.gconf_client, shortbreak_conf_key, DEFAULT_SHORTBREAK_DURATION) longbreak_conf_key = self._get_configuration_key("longbreak_duration") self.pommodoro_timer.longbreak_duration = \ g15gconf.get_int_or_default(self.gconf_client, longbreak_conf_key, DEFAULT_LONGBREAK_DURATION) pommodoro_count_conf_key = self._get_configuration_key( "pommodoro_count") self.pommodoro_timer.init_count_at( g15gconf.get_int_or_default(self.gconf_client, pommodoro_count_conf_key, 0)) self.pommodoro_timer.recalculate()
def __init__(self, parent, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key self._visible_options = None self._widget_tree = Gtk.Builder() self._widget_tree.add_from_file( os.path.join(os.path.dirname(__file__), "weather.ui")) dialog = self._widget_tree.get_object("WeatherDialog") dialog.set_transient_for(parent) self._source = self._widget_tree.get_object("Source") self._source.connect("changed", self._load_options_for_source) self._sources_model = self._widget_tree.get_object("SourcesModel") for b in get_available_backends(): l = [b, get_backend(b).backend_name] self._sources_model.append(l) g15uigconf.configure_combo_from_gconf( gconf_client, "%s/source" % gconf_key, "Source", self._sources_model[0][0] if len(self._sources_model) > 0 else None, self._widget_tree) self._load_options_for_source() update = self._widget_tree.get_object("UpdateAdjustment") update.set_value( g15gconf.get_int_or_default(gconf_client, gconf_key + "/update", DEFAULT_UPDATE_INTERVAL)) update.connect("value-changed", self._value_changed, update, gconf_key + "/update") unit = self._widget_tree.get_object("UnitCombo") unit.set_active(gconf_client.get_int(gconf_key + "/units")) unit.connect("changed", self._unit_changed, unit, gconf_key + "/units") g15uigconf.configure_checkbox_from_gconf( gconf_client, "%s/use_theme_icons" % gconf_key, "UseThemeIcons", True, self._widget_tree) g15uigconf.configure_checkbox_from_gconf( gconf_client, "%s/twenty_four_hour_times" % gconf_key, "TwentyFourHourTimes", True, self._widget_tree) dialog.run() dialog.hide()
def __init__(self, parent, driver, gconf_client, gconf_key): self._gconf_client = gconf_client self._gconf_key = gconf_key widget_tree = gtk.Builder() widget_tree.add_from_file( os.path.join(os.path.dirname(__file__), "rss.ui")) # Feeds self.feed_model = widget_tree.get_object("FeedModel") self.reload_model() self.feed_list = widget_tree.get_object("FeedList") self.url_renderer = widget_tree.get_object("URLRenderer") # Optins self.update_adjustment = widget_tree.get_object("UpdateAdjustment") self.update_adjustment.set_value( g15gconf.get_int_or_default(self._gconf_client, "%s/update_time" % self._gconf_key, 60)) g15uigconf.configure_checkbox_from_gconf( gconf_client, "%s/twenty_four_hour_times" % gconf_key, "TwentyFourHourTimes", True, widget_tree) # Connect to events self.update_adjustment.connect("value-changed", self.update_time_changed) self.url_renderer.connect("edited", self.url_edited) widget_tree.get_object("NewURL").connect("clicked", self.new_url) widget_tree.get_object("RemoveURL").connect("clicked", self.remove_url) # Display # Show dialog dialog = widget_tree.get_object("RSSDialog") dialog.set_transient_for(parent) ah = gconf_client.notify_add(gconf_key + "/urls", self.urls_changed) dialog.run() dialog.hide() gconf_client.notify_remove(ah)
def _load_config(self): val = g15gconf.get_int_or_default(self.gconf_client, self.gconf_key + "/update", DEFAULT_UPDATE_INTERVAL) self.refresh_interval = val * 60.0
def _load_configuration(self): self.joy_mode = self.conf_client.get_string("/apps/gnome15/%s/joymode" % self.device.uid) self.digital_calibration = g15gconf.get_int_or_default(self.conf_client, "/apps/gnome15/%s/digital_offset" % self.device.uid, 63) self.analogue_calibration = g15gconf.get_int_or_default(self.conf_client, "/apps/gnome15/%s/analogue_offset" % self.device.uid, 20)
def __init__(self, parent, gconf_client, gconf_key, file_path, item_name, default_refresh=60): """ Constructor Keyword arguments: parent -- parent GTK component (for modality) gconf_client -- gconf client gconf_key -- gconf key prefix for this plugin file_path -- location of accounts file item_name -- name of item in XML files """ self.gconf_client = gconf_client self.gconf_key = gconf_key self.visible_options = None self._save_timer = None self._adjusting = False self.account_mgr = G15AccountManager(file_path, item_name) self.widget_tree = Gtk.Builder() self.widget_tree.add_from_file( os.path.join(g15globals.ui_dir, "accounts.ui")) # Models self.type_model = self.widget_tree.get_object("TypeModel") self.account_model = self.widget_tree.get_object("AccountModel") self.type_model.clear() for t in self.get_account_types(): self.type_model.append([t, self.get_account_type_name(t)]) # Widgets self.account_type = self.widget_tree.get_object("TypeCombo") self.account_list = self.widget_tree.get_object("AccountList") self.url_renderer = self.widget_tree.get_object("URLRenderer") # Updates self.update_adjustment = self.widget_tree.get_object( "UpdateAdjustment") self.update_adjustment.set_value( g15gconf.get_int_or_default(gconf_client, gconf_key + "/update_time", default_refresh)) # Connect to events self.account_list.connect("cursor-changed", self._select_account) self.account_type.connect("changed", self._type_changed) self.update_adjustment.connect("value-changed", self._update_time_changed) self.url_renderer.connect("edited", self._url_edited) self.widget_tree.get_object("NewAccount").connect( "clicked", self._new_url) self.widget_tree.get_object("RemoveAccount").connect( "clicked", self._remove_url) # Configure widgets self._reload_model() self._select_account() # Hide non-relevant stuff self.widget_tree.get_object("TypeContainer").set_visible( len(self.get_account_types()) > 1) # Additional options place_holder = self.widget_tree.get_object("OptionsContainer") opts = self.create_general_options() if opts: opts.reparent(place_holder) # Show dialog dialog = self.widget_tree.get_object("AccountDialog") dialog.set_transient_for(parent) ah = gconf_client.notify_add(gconf_key + "/urls", self._urls_changed) dialog.run() dialog.hide() gconf_client.notify_remove(ah)
def _schedule_refresh(self): schedule_seconds = g15gconf.get_int_or_default(self._gconf_client, "%s/update_time" % self._gconf_key, 60) * 60.0 self._refresh_timer = g15scheduler.schedule("FeedRefreshTimer", schedule_seconds, self._refresh)
def _schedule_refresh(self): schedule_seconds = g15gconf.get_int_or_default( self._gconf_client, "%s/update_time" % self._gconf_key, 60) * 60.0 self._refresh_timer = g15scheduler.schedule("FeedRefreshTimer", schedule_seconds, self._refresh)
def get_int_or_default(gconf_client, key, default=None): return g15gconf.get_int_or_default(gconf_client, key, default)