def setup_preferences(self, prefs): def change_timeout(value): if hasattr(self, "timer"): self.timer.change_interval(value * 60) # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/mail-read.svg")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/mail-read.png")) themes = filter(filter_theme, os.listdir(theme_dir)) themes = [system_theme_name] + sorted(themes) + sorted( os.listdir(mail_theme_dir)) combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for theme in themes: combobox_theme.append_text(theme) if self.awn.settings["theme"] not in themes: self.awn.settings["theme"] = system_theme_name binder = self.awn.settings.get_binder(prefs) binder.bind("theme", "combobox-theme", key_callback=self.awn.theme.theme) binder.bind("email-client", "entry-client") binder.bind("show-network-errors", "checkbutton-alert-errors") binder.bind("timeout", "spinbutton-timeout", key_callback=change_timeout) self.awn.settings.load_bindings(binder)
def setup_preferences(self, prefs): def change_timeout(value): if hasattr(self, "timer"): self.timer.change_interval(value * 60) # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/mail-read.svg")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/mail-read.png")) themes = filter(filter_theme, os.listdir(theme_dir)) themes = [system_theme_name] + sorted(themes) + sorted(os.listdir(mail_theme_dir)) combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for theme in themes: combobox_theme.append_text(theme) if self.awn.settings["theme"] not in themes: self.awn.settings["theme"] = system_theme_name binder = self.awn.settings.get_binder(prefs) binder.bind("theme", "combobox-theme", key_callback=self.awn.theme.theme) binder.bind("email-client", "entry-client") binder.bind("show-network-errors", "checkbutton-alert-errors") binder.bind("timeout", "spinbutton-timeout", key_callback=change_timeout) self.awn.settings.load_bindings(binder)
def setup_general_preferences(self, prefs): container = gtk.VBox() prefs.get_object("vbox-general").reparent(container) self.preferences_notebook.append_page(container, gtk.Label(_("General"))) refresh_title = lambda v: self.__clock_updater.update_title() refresh_clock = lambda v: self.__clock_updater.draw_clock_cb() init_clock = lambda v: self.initialize_clock() self.themes = os.listdir(default_themes_dir) if os.path.isdir(cairo_clock_themes_dir): self.themes.extend(os.listdir(cairo_clock_themes_dir)) # Remove duplicates and sort the list self.themes = sorted(list(set(self.themes))) combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for i in self.themes: combobox_theme.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = default_theme self.binder.bind("time-24-format", "radio-24-format", key_callback=refresh_title) self.binder.bind("time-date", "check-time-date", key_callback=refresh_title) self.binder.bind("time-seconds", "check-time-seconds", key_callback=refresh_title) self.binder.bind("show-seconds-hand", "check-second-hand", key_callback=refresh_clock) self.binder.bind("theme", "combobox-theme", key_callback=init_clock)
def __init__(self, prefs, binder, weather_overlay): self.__prefs = prefs self.__weather_overlay = weather_overlay add_cell_renderer_text(prefs.get_object("combobox-temperature-unit")) add_cell_renderer_text(prefs.get_object("combobox-wind-speed-unit")) binder.bind("temperature-unit", "combobox-temperature-unit") binder.bind("wind-speed-unit", "combobox-wind-speed-unit") binder.bind("show-weather", "check-show-weather", key_callback=self.show_weather_toggled_cb)
def load_device_pref(self, prefs): device_labels = self.backend.get_device_labels() if self.applet.settings["device"] not in device_labels: self.applet.settings["device"] = self.backend.get_default_device_label() self.combobox_device = prefs.get_object("combobox-device") awnlib.add_cell_renderer_text(self.combobox_device) for i in device_labels: self.combobox_device.append_text(i) self.backend.set_device(self.applet.settings["device"])
def load_device_pref(self, prefs): device_labels = self.backend.get_device_labels() if self.applet.settings["device"] not in device_labels: self.applet.settings[ "device"] = self.backend.get_default_device_label() self.combobox_device = prefs.get_object("combobox-device") awnlib.add_cell_renderer_text(self.combobox_device) for i in device_labels: self.combobox_device.append_text(i) self.backend.set_device(self.applet.settings["device"])
def load_theme_pref(self, prefs): # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/audio-volume-high.svg")) themes = filter(filter_theme, os.listdir(theme_dir)) self.themes = [system_theme_name] + sorted(themes) + sorted(os.listdir(moonbeam_theme_dir)) combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for i in self.themes: combobox_theme.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = system_theme_name self.setup_icons()
def load_theme_pref(self, prefs): # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile( os.path.join(theme_dir, theme, "scalable/status/audio-volume-high.svg")) themes = filter(filter_theme, os.listdir(theme_dir)) self.themes = [system_theme_name] + sorted(themes) + sorted( os.listdir(moonbeam_theme_dir)) combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for i in self.themes: combobox_theme.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = system_theme_name self.setup_icons()
def setup_context_menu(self): number_of_cpus = ( SysFSBackend.get_number_of_cpus() ) # called only once: assumes that every backend returns the same number prefs = gtk.Builder() prefs.add_from_file(ui_file) combobox = prefs.get_object("combobox-cpu") awnlib.add_cell_renderer_text(combobox) for i in range(0, number_of_cpus): combobox.append_text(str(i)) binder = self.applet.settings.get_binder(prefs) binder.bind("cpu_number", "combobox-cpu", key_callback=self.initialize_backend) self.applet.settings.load_bindings(binder) self.initialize_backend(self.applet.settings["cpu_number"]) if number_of_cpus > 1: prefs.get_object("preferences-vbox").reparent(self.applet.dialog.new("preferences").vbox)
def setup_general_preferences(self, prefs): """Setup the main settings window.""" # Unit combobox unit_combobox = prefs.get_object("combobox_unit") awnlib.add_cell_renderer_text(unit_combobox) for i in units.UNIT_STR_LONG[:3]: unit_combobox.append_text(i) # Theme combobox theme_combobox = prefs.get_object("combobox_theme") awnlib.add_cell_renderer_text(theme_combobox) for theme in self.__themes: # Add filename with '_' replaced width space theme_combobox.append_text(theme) # If the set theme is not available, revert to default if self.applet.settings["theme"] not in self.__themes: self.__icon = None self.applet.settings["theme"] = self.__themes[0] # Font size combobox font_combobox = prefs.get_object("combobox_font_size") awnlib.add_cell_renderer_text(font_combobox) for font_size in font_size_names: font_combobox.append_text(font_size) # Font size combobox should be grayed out when value overlay is # disabled show_checkbutton = prefs.get_object("checkbutton_show_value_overlay") fontsize_hbox = prefs.get_object("hbox_font_size") fontsize_hbox.set_sensitive(show_checkbutton.get_active()) show_checkbutton.connect("toggled", lambda w: fontsize_hbox.set_sensitive(w.get_active()))
def setup_general_preferences(self, prefs): """Setup the main settings window.""" # Unit combobox unit_combobox = prefs.get_object("combobox_unit") awnlib.add_cell_renderer_text(unit_combobox) for i in units.UNIT_STR_LONG[:3]: unit_combobox.append_text(i) # Theme combobox theme_combobox = prefs.get_object("combobox_theme") awnlib.add_cell_renderer_text(theme_combobox) for theme in self.__themes: # Add filename with '_' replaced width space theme_combobox.append_text(theme) # If the set theme is not available, revert to default if self.applet.settings["theme"] not in self.__themes: self.__icon = None self.applet.settings["theme"] = self.__themes[0] # Font size combobox font_combobox = prefs.get_object("combobox_font_size") awnlib.add_cell_renderer_text(font_combobox) for font_size in font_size_names: font_combobox.append_text(font_size) # Font size combobox should be grayed out when value overlay is # disabled show_checkbutton = prefs.get_object("checkbutton_show_value_overlay") fontsize_hbox = prefs.get_object("hbox_font_size") fontsize_hbox.set_sensitive(show_checkbutton.get_active()) show_checkbutton.connect( "toggled", lambda w: fontsize_hbox.set_sensitive(w.get_active()))
def setup_context_menu(self): number_of_cpus = SysFSBackend.get_number_of_cpus( ) # called only once: assumes that every backend returns the same number prefs = gtk.Builder() prefs.add_from_file(ui_file) combobox = prefs.get_object("combobox-cpu") awnlib.add_cell_renderer_text(combobox) for i in range(0, number_of_cpus): combobox.append_text(str(i)) binder = self.applet.settings.get_binder(prefs) binder.bind("cpu_number", "combobox-cpu", key_callback=self.initialize_backend) self.applet.settings.load_bindings(binder) self.initialize_backend(self.applet.settings["cpu_number"]) if number_of_cpus > 1: prefs.get_object("preferences-vbox").reparent( self.applet.dialog.new("preferences").vbox)
def setup_preferences(self, prefs): refresh_dialog = lambda v: self.refresh_icon_and_forecast() def refresh_curved_dialog(value): self.forecaster.setup_forecast_dialog() refresh_dialog(None) # dummy value refresh_map = lambda v: self.set_map_pixbuf(self.map_pixbuf) # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/weather-clear.svg")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.png")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.svg")) themes = sorted(filter(filter_theme, os.listdir(theme_dir))) self.themes = [system_theme_name] + themes + ["moonbeam"] def refresh_theme_and_dialog(value): self.setup_theme() refresh_dialog(None) self.setup_theme() """ General preferences """ self.search_window = prefs.get_object("locations-search-dialog") def response_event_cb(widget, response): if response < 0: self.search_window.hide() self.search_window.connect("response", response_event_cb) self.search_window.connect("delete_event", lambda w, e: True) def location_button_clicked_cb(widget): self.init_search_window() self.search_list.append([_("No records found"), None]) self.search_window.show_all() prefs.get_object("button-location").connect( "clicked", location_button_clicked_cb) unit_combobox = prefs.get_object("combobox-temperature-unit") awnlib.add_cell_renderer_text(unit_combobox) for i in temperature_units: unit_combobox.append_text(i) theme_combobox = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(theme_combobox) for i in self.themes: theme_combobox.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = self.themes[0] tempicon_checkbutton = prefs.get_object("checkbutton-temperature-icon") fontsize_hbox = prefs.get_object("hbox-font-size") fontsize_hbox.set_sensitive(tempicon_checkbutton.get_active()) tempicon_checkbutton.connect( "toggled", lambda w: fontsize_hbox.set_sensitive(w.get_active())) self.location_label = prefs.get_object("locationLabel") self.location_label.set_markup("<b>%s</b>" % self.applet.settings["location"]) binder = self.applet.settings.get_binder(prefs) binder.bind("show-temperature-icon", "checkbutton-temperature-icon", key_callback=self.refresh_icon) binder.bind("temperature-font-size", "combobox-font-size", key_callback=self.refresh_icon) binder.bind("temperature-unit", "combobox-temperature-unit", key_callback=refresh_dialog) binder.bind("theme", "combobox-theme", key_callback=refresh_theme_and_dialog) binder.bind("curved_dialog", "curvedCheckbutton", key_callback=refresh_curved_dialog) binder.bind("map_maxwidth", "mapWidthSpinbutton", key_callback=refresh_map) self.applet.settings.load_bindings(binder) """ Location search window """ self.search_list = gtk.ListStore(str, str) self.treeview = prefs.get_object("location-treeview") self.treeview.set_model(self.search_list) self.treeview.append_column( gtk.TreeViewColumn("Location", gtk.CellRendererText(), text=0)) self.ok_button = prefs.get_object("location-ok-button") self.ok_button.connect("clicked", self.ok_button_clicked_cb) self.treeview.connect("cursor-changed", lambda w: self.ok_button.set_sensitive(True)) self.treeview.connect("row-activated", lambda v, p, c: self.ok_button_clicked_cb()) find_button = prefs.get_object("location-find-button") self.location_entry = prefs.get_object("location-entry") def location_entry_changed_cb(widget): find_button.set_sensitive(len(self.location_entry.get_text()) > 0) self.location_entry.connect("changed", location_entry_changed_cb) self.location_entry.connect("activate", self.search_locations_cb) find_button.connect("clicked", self.search_locations_cb)
def setup_preferences(self, prefs): refresh_dialog = lambda v: self.refresh_icon_and_forecast() def refresh_curved_dialog(value): self.forecaster.setup_forecast_dialog() refresh_dialog(None) # dummy value refresh_map = lambda v: self.set_map_pixbuf(self.map_pixbuf) # Only use themes that are likely to provide all the files def filter_theme(theme): return os.path.isfile(os.path.join(theme_dir, theme, "scalable/status/weather-clear.svg")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.png")) \ or os.path.isfile(os.path.join(theme_dir, theme, "48x48/status/weather-clear.svg")) themes = sorted(filter(filter_theme, os.listdir(theme_dir))) self.themes = [system_theme_name] + themes + ["moonbeam"] def refresh_theme_and_dialog(value): self.setup_theme() refresh_dialog(None) self.setup_theme() """ General preferences """ self.search_window = prefs.get_object("locations-search-dialog") def response_event_cb(widget, response): if response < 0: self.search_window.hide() self.search_window.connect("response", response_event_cb) self.search_window.connect("delete_event", lambda w, e: True) def location_button_clicked_cb(widget): self.init_search_window() self.search_list.append([_("No records found"), None]) self.search_window.show_all() prefs.get_object("button-location").connect("clicked", location_button_clicked_cb) unit_combobox = prefs.get_object("combobox-temperature-unit") awnlib.add_cell_renderer_text(unit_combobox) for i in temperature_units: unit_combobox.append_text(i) theme_combobox = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(theme_combobox) for i in self.themes: theme_combobox.append_text(i) if self.applet.settings["theme"] not in self.themes: self.applet.settings["theme"] = self.themes[0] tempicon_checkbutton = prefs.get_object("checkbutton-temperature-icon") fontsize_hbox = prefs.get_object("hbox-font-size") fontsize_hbox.set_sensitive(tempicon_checkbutton.get_active()) tempicon_checkbutton.connect("toggled", lambda w: fontsize_hbox.set_sensitive(w.get_active())) self.location_label = prefs.get_object("locationLabel") self.location_label.set_markup("<b>%s</b>" % self.applet.settings["location"]) binder = self.applet.settings.get_binder(prefs) binder.bind("show-temperature-icon", "checkbutton-temperature-icon", key_callback=self.refresh_icon) binder.bind("temperature-font-size", "combobox-font-size", key_callback=self.refresh_icon) binder.bind("temperature-unit", "combobox-temperature-unit", key_callback=refresh_dialog) binder.bind("theme", "combobox-theme", key_callback=refresh_theme_and_dialog) binder.bind("curved_dialog", "curvedCheckbutton", key_callback=refresh_curved_dialog) binder.bind("map_maxwidth", "mapWidthSpinbutton", key_callback=refresh_map) self.applet.settings.load_bindings(binder) """ Location search window """ self.search_list = gtk.ListStore(str, str) self.treeview = prefs.get_object("location-treeview") self.treeview.set_model(self.search_list) self.treeview.append_column(gtk.TreeViewColumn("Location", gtk.CellRendererText(), text=0)) self.ok_button = prefs.get_object("location-ok-button") self.ok_button.connect("clicked", self.ok_button_clicked_cb) self.treeview.connect("cursor-changed", lambda w: self.ok_button.set_sensitive(True)) self.treeview.connect("row-activated", lambda v, p, c: self.ok_button_clicked_cb()) find_button = prefs.get_object("location-find-button") self.location_entry = prefs.get_object("location-entry") def location_entry_changed_cb(widget): find_button.set_sensitive(len(self.location_entry.get_text()) > 0) self.location_entry.connect("changed", location_entry_changed_cb) self.location_entry.connect("activate", self.search_locations_cb) find_button.connect("clicked", self.search_locations_cb)
def load_track_pref(self, prefs): self.combobox_track = prefs.get_object("combobox-mixer-track") awnlib.add_cell_renderer_text(self.combobox_track) self.reload_tracks()
def setup_context_menu(self): prefs = gtk.Builder() prefs.add_from_file(ui_file) prefs.get_object("vbox-preferences").reparent( self.applet.dialog.new("preferences").vbox) """ Battery """ if self.backend is not None: batteries = self.backend.get_batteries() self.combobox_battery = prefs.get_object("combobox-battery") awnlib.add_cell_renderer_text(self.combobox_battery) for model in batteries.values(): self.combobox_battery.append_text(model) if self.applet.settings["battery-udi"] not in batteries: self.applet.settings["battery-udi"] = batteries.keys()[0] if len(self.applet.settings["low-level-unit"]) == 0: self.applet.settings["low-level-unit"] = _("Percent") battery_getter = lambda key_value: batteries[key_value] battery_setter = lambda widget_value: batteries.keys()[ batteries.values().index(widget_value)] else: frame = prefs.get_object("frame-battery") frame.hide_all() frame.set_no_show_all(True) battery_getter = lambda v: v battery_setter = lambda v: v """ Display """ # Only use themes that are likely to provide all the files self.themes = os.listdir(themes_dir) self.themes.sort() combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for i in self.themes: combobox_theme.append_text(i) self.theme = self.applet.settings["theme"] if self.theme not in self.themes: self.applet.settings["theme"] = self.theme = default_theme """ Notifications """ if self.backend is not None: self.hbox_low_level = prefs.get_object("hbox-low-level") self.hbox_low_level.set_sensitive( self.applet.settings["warn-low-level"]) self.hbox_high_level = prefs.get_object("hbox-high-level") self.hbox_high_level.set_sensitive( self.applet.settings["notify-high-level"]) else: frame = prefs.get_object("frame-notifications") frame.hide_all() frame.set_no_show_all(True) refresh_message = lambda v: self.__message_handler.evaluate() binder = self.applet.settings.get_binder(prefs) binder.bind("theme", "combobox-theme", key_callback=self.combobox_theme_changed_cb) binder.bind("battery-udi", "combobox-battery", getter_transform=battery_getter, setter_transform=battery_setter, key_callback=self.combobox_battery_changed_cb) binder.bind("warn-low-level", "checkbutton-warn-low-level", key_callback=self.toggled_warn_low_level_cb) binder.bind("notify-high-level", "checkbutton-notify-high-level", key_callback=self.toggled_notify_high_level_cb) binder.bind("level-warn-low", "spinbutton-low-level", key_callback=refresh_message) binder.bind("level-notify-high", "spinbutton-high-level", key_callback=refresh_message) binder.bind("low-level-unit", "combobox-low-level", key_callback=self.combobox_low_level_unit_changed_cb) self.applet.settings.load_bindings(binder)
def setup_context_menu(self): prefs = gtk.Builder() prefs.add_from_file(ui_file) prefs.get_object("vbox-preferences").reparent(self.applet.dialog.new("preferences").vbox) """ Battery """ if self.backend is not None: batteries = self.backend.get_batteries() self.combobox_battery = prefs.get_object("combobox-battery") awnlib.add_cell_renderer_text(self.combobox_battery) for model in batteries.values(): self.combobox_battery.append_text(model) if self.applet.settings["battery-udi"] not in batteries: self.applet.settings["battery-udi"] = batteries.keys()[0] if len(self.applet.settings["low-level-unit"]) == 0: self.applet.settings["low-level-unit"] = _("Percent") battery_getter = lambda key_value: batteries[key_value] battery_setter = lambda widget_value: batteries.keys()[batteries.values().index(widget_value)] else: frame = prefs.get_object("frame-battery") frame.hide_all() frame.set_no_show_all(True) battery_getter = lambda v: v battery_setter = lambda v: v """ Display """ # Only use themes that are likely to provide all the files self.themes = os.listdir(themes_dir) self.themes.sort() combobox_theme = prefs.get_object("combobox-theme") awnlib.add_cell_renderer_text(combobox_theme) for i in self.themes: combobox_theme.append_text(i) self.theme = self.applet.settings["theme"] if self.theme not in self.themes: self.applet.settings["theme"] = self.theme = default_theme """ Notifications """ if self.backend is not None: self.hbox_low_level = prefs.get_object("hbox-low-level") self.hbox_low_level.set_sensitive(self.applet.settings["warn-low-level"]) self.hbox_high_level = prefs.get_object("hbox-high-level") self.hbox_high_level.set_sensitive(self.applet.settings["notify-high-level"]) else: frame = prefs.get_object("frame-notifications") frame.hide_all() frame.set_no_show_all(True) refresh_message = lambda v: self.__message_handler.evaluate() binder = self.applet.settings.get_binder(prefs) binder.bind("theme", "combobox-theme", key_callback=self.combobox_theme_changed_cb) binder.bind("battery-udi", "combobox-battery", getter_transform=battery_getter, setter_transform=battery_setter, key_callback=self.combobox_battery_changed_cb) binder.bind("warn-low-level", "checkbutton-warn-low-level", key_callback=self.toggled_warn_low_level_cb) binder.bind("notify-high-level", "checkbutton-notify-high-level", key_callback=self.toggled_notify_high_level_cb) binder.bind("level-warn-low", "spinbutton-low-level", key_callback=refresh_message) binder.bind("level-notify-high", "spinbutton-high-level", key_callback=refresh_message) binder.bind("low-level-unit", "combobox-low-level", key_callback=self.combobox_low_level_unit_changed_cb) self.applet.settings.load_bindings(binder)