def main(): # This can be removed once pygobject-3.10 is a requirement. # https://bugzilla.gnome.org/show_bug.cgi?id=686914 GLib.threads_init() Gst.init(sys.argv) _migrate_gconf_to_gsettings() cleanup_temporary_files() _start_window_manager() setup_timezone() setup_fonts() setup_theme() setup_proxy() # this must be added early, so that it executes and unfreezes the screen # even when we initially get blocked on the intro screen GLib.idle_add(unfreeze_screen_cb) GLib.idle_add(setup_cursortracker_cb) sound.restore() keyboard.setup() brightness.get_instance() sys.path.append(config.ext_path) if not _check_profile(): _start_intro() elif not _check_group_label(): _start_intro(start_on_age_page=True) else: _begin_desktop_startup() try: Gtk.main() except KeyboardInterrupt: print 'Ctrl+C pressed, exiting...' _stop_window_manager()
def test_new_brightness(self): try: f = open("../testCases/change_brightness.txt", "r") brightness = "" for line in f.readlines(): if not line.startswith("#"): brightness = line.rstrip() monitor = bright.get_instance() monitor._save(int(brightness)) self.assertEquals(1, 1) except: self.fail("unable to change brightness")
def __init__(self, label): self._color = profile.get_color() self._label = label TrayIcon.__init__(self, icon_name='brightness-100', xo_color=self._color) self.set_palette_invoker(FrameWidgetInvoker(self)) self.palette_invoker.props.toggle_palette = True model = brightness.get_instance() if model.get_path(): self._model = model self._model.changed_signal.connect(self.__brightness_changed_cb) self._update_output_info()
def main(): Gst.init(sys.argv) cleanup_temporary_files() _start_window_manager() setup_timezone() setup_fonts() setup_theme() setup_proxy() # this must be added early, so that it executes and unfreezes the screen # even when we initially get blocked on the intro screen GLib.idle_add(unfreeze_screen_cb) GLib.idle_add(setup_cursortracker_cb) sound.restore() keyboard.setup() brightness.get_instance() sys.path.append(config.ext_path) if not _check_profile(): _start_intro() elif not _check_group_label(): _start_intro(start_on_age_page=True) else: _begin_desktop_startup() try: Gtk.main() except KeyboardInterrupt: print('Ctrl+C pressed, exiting...') _stop_window_manager()
def handle_key_press(key): model = brightness.get_instance() if not model.get_path(): return value = model.get_brightness() if key == 'XF86MonBrightnessUp': new_value = value + model.get_step_amount() if new_value > model.get_max_brightness(): new_value = model.get_max_brightness() else: new_value = value - model.get_step_amount() if new_value < 0: new_value = 0 # don't write to the device unnecessarily if new_value == value: return model.set_brightness(new_value)
def __init__(self): Palette.__init__(self, label=_('My Display')) self._screenshot = PaletteMenuItem(_('Take a screenshot')) icon = Icon(icon_name='camera-external', pixel_size=style.SMALL_ICON_SIZE) self._screenshot.set_image(icon) icon.show() self._screenshot.connect('activate', self.__screenshot_cb) self._screenshot.show() self._box = PaletteMenuBox() self._brightness_manager = None # only add this widget if device available if brightness.get_instance().get_path(): self._add_brightness_manager() self._box.append_item(self._screenshot, 0, 0) self._box.show() self.set_content(self._box) self.connect('popup', self.__popup_cb)
def __init__(self, text, icon_name): Gtk.VBox.__init__(self) self._progress_bar = None self._adjustment = None icon = Icon(pixel_size=style.SMALL_ICON_SIZE) icon.props.icon_name = icon_name icon.props.xo_color = XoColor( '%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_BUTTON_GREY.get_svg())) icon.show() label = Gtk.Label(text) label.show() grid = Gtk.Grid() grid.set_column_spacing(style.DEFAULT_SPACING) grid.attach(icon, 0, 0, 1, 1) grid.attach(label, 1, 0, 1, 1) grid.show() alignment = Gtk.Alignment() alignment.set(0.5, 0, 0, 0) alignment.add(grid) alignment.show() self.add(alignment) alignment = Gtk.Alignment() alignment.set(0.5, 0, 0, 0) alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._model = brightness.get_instance() self._model_changed_hid = \ self._model.changed_signal.connect(self.__brightness_changed_cb) # if sugar-backlight-helper finds the device if self._model.get_path(): adjustment = Gtk.Adjustment( value=self._model.get_brightness(), lower=0, upper=self._model.get_max_brightness() + 1, step_incr=self._model.get_step_amount(), page_incr=self._model.get_step_amount(), page_size=self._model.get_step_amount()) self._adjustment = adjustment self._adjustment_timeout_id = None self._adjustment_hid = \ self._adjustment.connect('value_changed', self.__adjusted_cb) hscale = Gtk.HScale() hscale.props.draw_value = False hscale.set_adjustment(adjustment) hscale.set_digits(0) hscale.set_size_request(style.GRID_CELL_SIZE * 4, -1) alignment.add(hscale) hscale.show() else: self._progress_bar = Gtk.ProgressBar() self._progress_bar.set_size_request( style.zoom(style.GRID_CELL_SIZE * 4), -1) alignment.props.top_padding = style.DEFAULT_PADDING alignment.add(self._progress_bar) self._progress_bar.show() alignment.show() self.add(alignment)
def __init__(self, text, icon_name): Gtk.VBox.__init__(self) self._progress_bar = None self._adjustment = None icon = Icon(pixel_size=style.SMALL_ICON_SIZE) icon.props.icon_name = icon_name icon.props.xo_color = XoColor('%s,%s' % (style.COLOR_WHITE.get_svg(), style.COLOR_BUTTON_GREY.get_svg())) icon.show() label = Gtk.Label(text) label.show() grid = Gtk.Grid() grid.set_column_spacing(style.DEFAULT_SPACING) grid.attach(icon, 0, 0, 1, 1) grid.attach(label, 1, 0, 1, 1) grid.show() alignment = Gtk.Alignment() alignment.set(0.5, 0, 0, 0) alignment.add(grid) alignment.show() self.add(alignment) alignment = Gtk.Alignment() alignment.set(0.5, 0, 0, 0) alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._model = brightness.get_instance() self._model_changed_hid = \ self._model.changed_signal.connect(self.__brightness_changed_cb) # if sugar-backlight-helper finds the device if self._model.get_path(): adjustment = Gtk.Adjustment( value=self._model.get_brightness(), lower=0, upper=self._model.get_max_brightness() + 1, step_incr=self._model.get_step_amount(), page_incr=self._model.get_step_amount(), page_size=self._model.get_step_amount()) self._adjustment = adjustment self._adjustment_timeout_id = None self._adjustment_hid = \ self._adjustment.connect('value_changed', self.__adjusted_cb) hscale = Gtk.HScale() hscale.props.draw_value = False hscale.set_adjustment(adjustment) hscale.set_digits(0) hscale.set_size_request(style.GRID_CELL_SIZE * 4, -1) alignment.add(hscale) hscale.show() else: self._progress_bar = Gtk.ProgressBar() self._progress_bar.set_size_request( style.zoom(style.GRID_CELL_SIZE * 4), -1) alignment.props.top_padding = style.DEFAULT_PADDING alignment.add(self._progress_bar) self._progress_bar.show() alignment.show() self.add(alignment)