def __interface(self): self.set_position(Gtk.WindowPosition.CENTER) self.set_size_request(800, 600) master_box = Gtk.Box() master_box.set_spacing(5) self.add(master_box) left_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) left_box.set_size_request(200, -1) master_box.pack_start(left_box, False, True, 0) separator = Gtk.VSeparator() master_box.pack_start(separator, False, False, 0) center_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) master_box.pack_start(center_box, True, True, 0) separator = Gtk.VSeparator() master_box.pack_start(separator, False, False, 0) right_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) right_box.set_size_request(200, -1) master_box.pack_start(right_box, False, True, 0) pict = GdkPixbuf.Pixbuf.new_from_file_at_scale( filename=os.path.join(os.path.dirname(os.path.abspath(__file__)), "Avatar.png"), width=150, height=150, preserve_aspect_ratio=True) avatar = Gtk.Image.new_from_pixbuf(pict) # avatar = Gtk.Image() # avatar.set_from_file( # os.path.join( # os.path.dirname(os.path.abspath(__file__)), # "avatar.jpg" # ) # ) # avatar.set_size_request(50,50) left_box.pack_start(avatar, False, True, 5) separator = Gtk.HSeparator() left_box.pack_start(separator, False, True, 5) user_label = Gtk.Label(label="User name") left_box.pack_start(user_label, False, True, 0) separator = Gtk.HSeparator() left_box.pack_start(separator, False, True, 5) l_space = Gtk.Alignment() left_box.pack_start(l_space, True, True, 5) separator = Gtk.HSeparator() left_box.pack_start(separator, False, True, 5) b_box = Gtk.ButtonBox() b_box.set_spacing(5) left_box.pack_start(b_box, False, False, 5) separator = Gtk.HSeparator() left_box.pack_start(separator, False, False, 5) close_button = Gtk.Button(label="Close") close_button.connect("clicked", Gtk.main_quit) b_box.pack_start(close_button, True, True, 5) scroll_box = Gtk.ScrolledWindow() scroll_box.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) center_box.pack_start(scroll_box, True, True, 5) self.chat_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) scroll_box.add(self.chat_box) separator = Gtk.HSeparator() center_box.pack_start(separator, False, False, 5) # output_message = Gtk.Frame() send_box = Gtk.Box() send_box.set_spacing(5) center_box.pack_start(send_box, False, True, 5) separator = Gtk.HSeparator() center_box.pack_start(separator, False, False, 5) smile_button = Gtk.Button(label=":-)") send_box.pack_start(smile_button, False, False, 0) message_entry = Gtk.Entry() send_box.pack_start(message_entry, True, True, 0) send_button = Gtk.Button(label="send") send_box.pack_start(send_button, False, False, 0) favorite_label = Gtk.Label(label="Favorites") right_box.pack_start(favorite_label, False, False, 0)
def __init__ (self, gamemodel): GObject.GObject.__init__(self) self.gamemodel = gamemodel self.cids = {} self.closed = False tabcontent, white_label, black_label, game_info_label = self.initTabcontents() boardvbox, board, infobar, clock = self.initBoardAndClock(gamemodel) statusbar, stat_hbox = self.initStatusbar(board) self.tabcontent = tabcontent self.player_name_labels = (white_label, black_label) self.game_info_label = game_info_label self.board = board self.statusbar = statusbar self.infobar = infobar infobar.connect("hide", self.infobar_hidden) self.game_ended_message = None self.clock = clock self.notebookKey = Gtk.Alignment() self.boardvbox = boardvbox self.stat_hbox = stat_hbox self.menuitems = MenuItemsDict(self) gamemodel.connect("game_started", self.game_started) gamemodel.connect("game_ended", self.game_ended) gamemodel.connect("game_changed", self.game_changed) gamemodel.connect("game_paused", self.game_paused) gamemodel.connect("game_resumed", self.game_resumed) gamemodel.connect("moves_undone", self.moves_undone) gamemodel.connect("game_unended", self.game_unended) gamemodel.connect("game_saved", self.game_saved) gamemodel.connect("players_changed", self.players_changed) gamemodel.connect("analyzer_added", self.analyzer_added) gamemodel.connect("analyzer_removed", self.analyzer_removed) gamemodel.connect("analyzer_resumed", self.analyzer_resumed) gamemodel.connect("analyzer_paused", self.analyzer_paused) self.players_changed(gamemodel) if self.gamemodel.display_text: self.game_info_label.set_text(" " + self.gamemodel.display_text) if gamemodel.timed: gamemodel.timemodel.connect("zero_reached", self.zero_reached) if isinstance(gamemodel, ICGameModel): gamemodel.connection.bm.connect("player_lagged", self.player_lagged) gamemodel.connection.bm.connect("opp_not_out_of_time", self.opp_not_out_of_time) board.view.connect("shown_changed", self.shown_changed) fromGtkThread = currentThread().getName() == "MainThread" if not fromGtkThread: condition = Condition() def do(): self.panels = [panel.Sidepanel().load(self) for panel in sidePanels] if not fromGtkThread: condition.acquire() condition.notify() condition.release() if not fromGtkThread: GLib.idle_add(do) condition.acquire() condition.wait() else: do()
def __init__(self, win): Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL) self.win = win self.win.set_main_widget(self) self.win.top_bar.enable_prev() self.win.change_prev_callback(self.win.go_to_home) image = Gtk.Image.new_from_file(media + "/Graphics/about-screen.png") version_number, os_name = get_current_version() os_variant = read_file_contents('/etc/kanux_version_variant') version_align = self.create_align( "Kano OS: {name} v{version}".format(name=os_name, version=version_number), 'about_version' ) if os_variant: variant_align = self.create_align( "{variant}".format(variant=os_variant), 'about_version' ) space_align = self.create_align( _("Disk space used: {used}B / {total}B").format(**get_space_available()) ) try: celsius = u"{:.1f}\N{DEGREE SIGN}C".format(get_temperature()) except ValueError: celsius = "?" temperature_align = self.create_align( _(u"Temperature: {celsius}").format(celsius=celsius) ) model_align = self.create_align( _("Model: {model}").format(model=get_model_name()) ) terms_and_conditions = OrangeButton(_("Terms and conditions")) terms_and_conditions.connect( 'button_release_event', self.show_terms_and_conditions ) credits_button = OrangeButton(_("Meet the team")) credits_button.connect( 'button_release_event', self.show_credits ) self.kano_button = KanoButton(_("BACK")) self.kano_button.pack_and_align() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) hbox.pack_start(terms_and_conditions, False, False, 4) hbox.pack_start(credits_button, False, False, 4) hbutton_container = Gtk.Alignment( xalign=0.5, xscale=0, yalign=0, yscale=0 ) hbutton_container.add(hbox) image.set_margin_top(10) self.pack_start(image, False, False, 10) self.pack_start(version_align, False, False, 2) if os_variant: self.pack_start(variant_align, False, False, 2) self.pack_start(space_align, False, False, 1) self.pack_start(temperature_align, False, False, 1) self.pack_start(model_align, False, False, 1) self.pack_start(hbutton_container, False, False, 3) self.pack_start(self.kano_button.align, False, False, 10) self.kano_button.connect('button-release-event', self.win.go_to_home) self.kano_button.connect('key-release-event', self.win.go_to_home) # Refresh window self.win.show_all()
def __init__(self, model, alerts=None): SectionView.__init__(self) self._model = model self._images_loaded = False self._append_to_store_sid = None self.connect('realize', self.__realize_cb) self.connect('unrealize', self.__unrealize_cb) self.set_border_width(style.DEFAULT_SPACING * 2) self.set_spacing(style.DEFAULT_SPACING) label_box = Gtk.Box() label_bg = Gtk.Label(label=_('Select a background:')) label_bg.modify_fg(Gtk.StateType.NORMAL, style.COLOR_SELECTION_GREY.get_gdk_color()) label_bg.show() label_box.pack_start(label_bg, False, True, 0) label_box.show() self.pack_start(label_box, False, True, 1) clear_button = Gtk.Button() clear_button.set_label(_('Clear background')) clear_button.connect('clicked', self._clear_clicked_cb) clear_button.show() self.pack_end(clear_button, False, True, 0) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_shadow_type(Gtk.ShadowType.ETCHED_IN) scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.pack_start(scrolled_window, True, True, 0) scrolled_window.show() self._store = Gtk.ListStore(GdkPixbuf.Pixbuf, str) self._icon_view = Gtk.IconView.new_with_model(self._store) self._icon_view.set_selection_mode(Gtk.SelectionMode.SINGLE) self._icon_view.connect('selection-changed', self._background_selected) self._icon_view.set_pixbuf_column(0) self._icon_view.grab_focus() scrolled_window.add(self._icon_view) self._icon_view.show() alpha = self._model.get_background_alpha_level() alpha_box = Gtk.HBox() alpha_buttons = [] alpha_icons = [ [1.0, 'network-wireless-000'], [0.8, 'network-wireless-020'], [0.6, 'network-wireless-040'], [0.4, 'network-wireless-060'], [0.2, 'network-wireless-080']] for value, icon_name in alpha_icons: if len(alpha_buttons) > 0: button = RadioToolButton(group=alpha_buttons[0]) else: button = RadioToolButton(group=None) button.set_icon_name(icon_name) button.value = value button.props.active = value == alpha button.show() alpha_box.pack_start(button, False, True, 0) alpha_buttons.append(button) for button in alpha_buttons: button.connect('toggled', self._set_alpha_cb) alpha_alignment = Gtk.Alignment() alpha_alignment.set(0.5, 0, 0, 0) alpha_alignment.add(alpha_box) alpha_box.show() self.pack_start(alpha_alignment, False, False, 0) alpha_alignment.show() self._paths_list = [] file_paths = [] for directory in self._model.BACKGROUNDS_DIRS: if directory is not None and os.path.exists(directory): for root, dirs, files in os.walk(directory): for file_ in files: file_paths.append(os.path.join(root, file_)) self._append_to_store(file_paths) self.setup()
def __init__(self, args): metadata = json.load( io.open(os.path.join(APPLET_DIR, 'metadata.json'), 'r', encoding='utf8')) self.settings = AppletSettings(metadata['uuid'], args.instance_id) Gtk.Window.__init__(self, title=metadata['name']) self.set_size_request(400, 300) self.set_position(Gtk.WindowPosition.CENTER) self.connect('delete-event', self._exit_application) self.connect('destroy', self._exit_application) frame = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, border_width=10, spacing=10) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, border_width=0, spacing=10) scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) self.liststore_worldclocks = Gtk.ListStore(str, str) for item in self.settings.get('worldclocks'): self.liststore_worldclocks.append(item.split('|')) self.treeview = Gtk.TreeView(model=self.liststore_worldclocks) # Labels column cellrenderertext = Gtk.CellRendererText() cellrenderertext.set_property('editable', True) cellrenderertext.connect('edited', self._on_label_edited) col = Gtk.TreeViewColumn('Display Name', cellrenderertext, text=0) col.set_property('resizable', True) col.set_expand(True) self.treeview.append_column(col) # Timezones column timezones = self._get_timezones() cellrendererautocomplete = CellRendererAutoComplete( timezones, match_anywhere=True, force_match=True) cellrendererautocomplete.set_property('editable', True) cellrendererautocomplete.connect('edited', self._on_tz_edited) col = Gtk.TreeViewColumn('Timezone', cellrendererautocomplete, text=1) col.set_expand(True) self.treeview.append_column(col) # Allow enable drag and drop of rows including row move self.treeview.set_reorderable(True) scrolled_window.add(self.treeview) self.treeview.show() # right-hand buttons hbox.pack_start(scrolled_window, True, True, 0) align = Gtk.Alignment() align.set(0.5, 0.5, 0, 0) vbox = Gtk.VBox() buttons = ( ('top', Gtk.STOCK_GOTO_TOP), ('up', Gtk.STOCK_GO_UP), ('down', Gtk.STOCK_GO_DOWN), ('bottom', Gtk.STOCK_GOTO_BOTTOM), ) for button in buttons: img = Gtk.Image() img.set_from_stock(button[1], Gtk.IconSize.BUTTON) btn = Gtk.Button(image=img) btn.connect('clicked', self._reorder, button[0]) vbox.pack_start(btn, False, False, 0) align.add(vbox) hbox.pack_end(align, False, False, 0) frame.pack_start(hbox, True, True, 0) # time format for World Clocks time_format = self.settings.get('worldclocks-timeformat') hbox = Gtk.HBox() label = Gtk.Label(_('Time format for World Clocks')) self.entry_timeformat = Gtk.Entry() hbox.pack_start(label, False, False, 5) hbox.add(self.entry_timeformat) self.entry_timeformat.set_text(time_format) frame.pack_start(hbox, False, False, 0) link_button = Gtk.LinkButton( 'http://timezonedb.com/time-zones', _('Browse valid timezone values by country (online)')) frame.pack_start(link_button, False, False, 0) # bottom buttons box_buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, border_width=0, spacing=10) btn_add = Gtk.Button(stock=Gtk.STOCK_ADD) btn_add.connect('clicked', self._add_entry) box_buttons.pack_start(btn_add, False, False, 0) btn_remove = Gtk.Button(stock=Gtk.STOCK_REMOVE) btn_remove.connect('clicked', self._remove_entry) box_buttons.pack_start(btn_remove, False, False, 0) btn_close = Gtk.Button(stock=Gtk.STOCK_CLOSE) btn_close.connect('clicked', self._exit_application) box_buttons.pack_end(btn_close, False, False, 0) btn_clear = Gtk.Button(stock=Gtk.STOCK_CLEAR) btn_clear.connect('clicked', self._clear_entries) box_buttons.pack_end(btn_clear, False, False, 0) frame.pack_end(box_buttons, False, False, 0) frame.show_all() self.add(frame) self.show_all()
def __init__(self): # Fake windows to avoid warning about Dialog without transient self._window = Gtk.Window() self.dialog = Gtk.Dialog(title="Tryton - " + _('Login'), modal=True) self.dialog.set_transient_for(self._window) self.dialog.set_icon(TRYTON_ICON) self.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS) self.dialog.set_resizable(False) tooltips = common.Tooltips() button_cancel = Gtk.Button(label=_('_Cancel'), use_underline=True) tooltips.set_tip(button_cancel, _('Cancel connection to the Tryton server')) self.dialog.add_action_widget(button_cancel, Gtk.ResponseType.CANCEL) self.button_connect = Gtk.Button(label=_('C_onnect'), use_underline=True) self.button_connect.get_style_context().add_class( Gtk.STYLE_CLASS_SUGGESTED_ACTION) self.button_connect.set_can_default(True) tooltips.set_tip(self.button_connect, _('Connect the Tryton server')) self.dialog.add_action_widget(self.button_connect, Gtk.ResponseType.OK) self.dialog.set_default_response(Gtk.ResponseType.OK) alignment = Gtk.Alignment(yalign=0, yscale=0, xscale=1) grid = Gtk.Grid(column_spacing=3, row_spacing=3) alignment.add(grid) self.dialog.vbox.pack_start(alignment, expand=True, fill=True, padding=0) image = Gtk.Image() image.set_from_file(os.path.join(PIXMAPS_DIR, 'tryton.png')) image.set_valign(Gtk.Align.START) overlay = Gtk.Overlay() overlay.add(image) label = Gtk.Label(label='<span color="white">%s</span>' % __version__, use_markup=True) label.props.halign = Gtk.Align.END label.props.valign = Gtk.Align.START label.props.margin_right = 10 label.props.margin_top = 5 overlay.add_overlay(label) grid.attach(overlay, 0, 0, 3, 1) self.profile_store = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_BOOLEAN) self.combo_profile = Gtk.ComboBox(hexpand=True) cell = Gtk.CellRendererText() self.combo_profile.pack_start(cell, expand=True) self.combo_profile.add_attribute(cell, 'text', 0) self.combo_profile.add_attribute(cell, 'sensitive', 1) self.combo_profile.set_model(self.profile_store) self.combo_profile.connect('changed', self.profile_changed) self.profile_label = Gtk.Label(label=set_underline(_('Profile:')), use_underline=True, halign=Gtk.Align.END) self.profile_label.set_mnemonic_widget(self.combo_profile) self.profile_button = Gtk.Button(label=set_underline(_('Manage...')), use_underline=True) self.profile_button.connect('clicked', self.profile_manage) grid.attach(self.profile_label, 0, 1, 1, 1) grid.attach(self.combo_profile, 1, 1, 1, 1) grid.attach(self.profile_button, 2, 1, 1, 1) self.expander = Gtk.Expander() self.expander.set_label(_('Host / Database information')) self.expander.connect('notify::expanded', self.expand_hostspec) grid.attach(self.expander, 0, 2, 3, 1) self.label_host = Gtk.Label(label=set_underline(_('Host:')), use_underline=True, halign=Gtk.Align.END) self.entry_host = Gtk.Entry(hexpand=True) self.entry_host.connect_after('focus-out-event', self.clear_profile_combo) self.entry_host.set_activates_default(True) self.label_host.set_mnemonic_widget(self.entry_host) grid.attach(self.label_host, 0, 3, 1, 1) grid.attach(self.entry_host, 1, 3, 2, 1) self.label_database = Gtk.Label(label=set_underline(_('Database:')), use_underline=True, halign=Gtk.Align.END) self.entry_database = Gtk.Entry(hexpand=True) self.entry_database.connect_after('focus-out-event', self.clear_profile_combo) self.entry_database.set_activates_default(True) self.label_database.set_mnemonic_widget(self.entry_database) grid.attach(self.label_database, 0, 4, 1, 1) grid.attach(self.entry_database, 1, 4, 2, 1) self.entry_login = Gtk.Entry(hexpand=True) self.entry_login.set_activates_default(True) grid.attach(self.entry_login, 1, 5, 2, 1) label_username = Gtk.Label(label=set_underline(_("User name:")), use_underline=True, halign=Gtk.Align.END, margin=3) label_username.set_mnemonic_widget(self.entry_login) grid.attach(label_username, 0, 5, 1, 1) # Profile information self.profile_cfg = os.path.join(get_config_dir(), 'profiles.cfg') self.profiles = configparser.ConfigParser() if not os.path.exists(self.profile_cfg): short_version = '.'.join(__version__.split('.', 2)[:2]) name = 'demo%s.tryton.org' % short_version self.profiles.add_section(name) self.profiles.set(name, 'host', name) self.profiles.set(name, 'database', 'demo%s' % short_version) self.profiles.set(name, 'username', 'demo') else: try: self.profiles.read(self.profile_cfg) except configparser.ParsingError: logger.error("Fail to parse profiles.cfg", exc_info=True) for section in self.profiles.sections(): active = all( self.profiles.has_option(section, option) for option in ('host', 'database')) self.profile_store.append([section, active])
def on_module_selected(self): if not self.loaded: print("Loading Accessibility module") self.iface_settings = Gio.Settings(schema_id="org.cinnamon.desktop.interface") self.wm_settings = Gio.Settings(schema_id="org.cinnamon.desktop.wm.preferences"); self.mag_settings = Gio.Settings(schema_id="org.cinnamon.desktop.a11y.magnifier"); self.sidePage.stack = SettingsStack() self.sidePage.add_widget(self.sidePage.stack) #### Visual page = SettingsPage() self.sidePage.stack.add_titled(page, "visual", _("Visual")) # Visual Aids settings = page.add_section(_("Visual Aids")) switch = Switch(_("High contrast")) self.iface_settings.bind_with_mapping(KEY_GTK_THEME, switch.content_widget, "active", Gio.SettingsBindFlags.DEFAULT, self.hi_con_get_mapping, self.hi_con_set_mapping) settings.add_row(switch) switch = Switch(_("Large text")) self.iface_settings.bind_with_mapping(KEY_TEXT_SCALING_FACTOR, switch.content_widget, "active", Gio.SettingsBindFlags.DEFAULT, self.lg_text_get_mapping, self.lg_text_set_mapping) settings.add_row(switch) switch = GSettingsDependencySwitch(_("Screen reader"), "org.cinnamon.desktop.a11y.applications", "screen-reader-enabled", None, ["orca"], ["gnome-orca"]) settings.add_row(switch) # Desktop Zoom settings = page.add_section(_("Desktop Zoom")) switch = GSettingsSwitch(_("Enable zoom"), "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") settings.add_row(switch) spin = GSettingsSpinButton(_("Magnification"), "org.cinnamon.desktop.a11y.magnifier", "mag-factor", None, 1.0, 15.0, step=0.5) settings.add_reveal_row(spin, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") zoom_key_options = [["", _("Disabled")], ["<Alt>", "<Alt>"],["<Super>", "<Super>"],["<Control>", "<Control>"], ["<Shift>", "<Shift>"]] widget = GSettingsComboBox(_("Mouse wheel modifier"), "org.cinnamon.desktop.wm.preferences", "mouse-button-zoom-modifier", zoom_key_options) widget.set_tooltip_text(_("While this modifier is pressed, mouse scrolling will increase or decrease zoom.")) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") switch = GSettingsSwitch(_("Scroll at screen edges"), "org.cinnamon.desktop.a11y.magnifier", "scroll-at-edges") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") mouse_track_options = [["centered", _("Keep cursor centered")], ["proportional", _("Cursor moves with contents")], ["push", _("Cursor pushes contents around")]] widget = GSettingsComboBox(_("Mouse tracking mode"), "org.cinnamon.desktop.a11y.magnifier", "mouse-tracking", mouse_track_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") switch = GSettingsSwitch(_("Lens mode"), "org.cinnamon.desktop.a11y.magnifier", "lens-mode") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") self.zoom_stack = SettingsStack() self.zoom_stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE) lens_shape_options = [["square", _("Square")], ["horizontal", _("Horizontal strip")], ["vertical", _("Vertical strip")]] widget = GSettingsComboBox(_("Lens shape"), "org.cinnamon.desktop.a11y.magnifier", "lens-shape", lens_shape_options) self.zoom_stack.add_named(widget, "shape") screen_pos_options = [["full-screen", _("Full screen")], ["top-half", _("Top half")], ["bottom-half", _("Bottom half")], ["left-half", _("Left half")], ["right-half", _("Right half")]] widget = GSettingsComboBox(_("Screen position"), "org.cinnamon.desktop.a11y.magnifier", "screen-position", screen_pos_options) self.zoom_stack.add_named(widget, "screen") settings.add_reveal_row(self.zoom_stack, "org.cinnamon.desktop.a11y.applications", "screen-magnifier-enabled") self.mag_settings.bind_with_mapping("lens-mode", self.zoom_stack, "visible-child-name", Gio.SettingsBindFlags.GET, self.zoom_stack_get, None) if (self.mag_settings.get_boolean("lens-mode")): self.zoom_stack.set_visible_child_name("shape") else: self.zoom_stack.set_visible_child_name("screen") #### Keyboard page = SettingsPage() self.sidePage.stack.add_titled(page, "keyboard", _("Keyboard")) # Virtual keyboard settings = page.add_section(_("Virtual keyboard")) switch = GSettingsSwitch(_("Enable the on-screen keyboard"), "org.cinnamon.desktop.a11y.applications", "screen-keyboard-enabled", None) settings.add_row(switch) keyboard_type_options = [["tablet", _("Tablet")], ["touch", _("Touch")], ["fullscale", _("Full scale")], ["scan", _("Scanning")]] widget = GSettingsComboBox(_("Keyboard layout"), "org.cinnamon.keyboard", "keyboard-type", keyboard_type_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-keyboard-enabled") keyboard_position_options = [["bottom", _("At the bottom of the screen")], ["top", _("At the top of the screen")]] widget = GSettingsComboBox(_("Keyboard position"), "org.cinnamon.keyboard", "keyboard-position", keyboard_position_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-keyboard-enabled") keyboard_size_options = [[4, _("A quarter of the screen")], [3, _("A third of the screen")], [2, _("Half of the screen")]] widget = GSettingsComboBox(_("Keyboard size"), "org.cinnamon.keyboard", "keyboard-size", keyboard_size_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-keyboard-enabled") activation_mode_options = [["accessible", _("Show the keyboard any time something expects input")], ["on-demand", _("Show keyboard only when the user activates it")]]; widget = GSettingsComboBox(_("Activation mode"), "org.cinnamon.keyboard", "activation-mode", activation_mode_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.a11y.applications", "screen-keyboard-enabled") # Keyboard indicators settings = page.add_section(_("Keyboard indicators")) switch = GSettingsSwitch(_("Use visual indicator on Caps and Num Lock"), "org.cinnamon.desktop.a11y.keyboard", "togglekeys-enable-osd") settings.add_row(switch) switch = GSettingsSwitch(_("Use audio indicator on Caps and Num Lock"), "org.cinnamon.desktop.a11y.keyboard", "togglekeys-enable-beep") settings.add_row(switch) sound_picker = GSettingsSoundFileChooser(_("Sound to use Caps or Num Lock on"), "org.cinnamon.desktop.a11y.keyboard", "togglekeys-sound-on") settings.add_reveal_row(sound_picker, "org.cinnamon.desktop.a11y.keyboard", "togglekeys-enable-beep") sound_picker = GSettingsSoundFileChooser(_("Sound to use Caps or Num Lock off"), "org.cinnamon.desktop.a11y.keyboard", "togglekeys-sound-off") settings.add_reveal_row(sound_picker, "org.cinnamon.desktop.a11y.keyboard", "togglekeys-enable-beep") settings = page.add_section(_("Event feedback (required for typing assistance alerts)")) switch = GSettingsSwitch(_("Enable visual alerts"), "org.cinnamon.desktop.wm.preferences", "visual-bell") settings.add_row(switch) visual_bell_options = [["fullscreen-flash", _("Flash the entire monitor")], ["frame-flash", _("Flash the active window")]] widget = GSettingsComboBox(_("Visual style"), "org.cinnamon.desktop.wm.preferences", "visual-bell-type", visual_bell_options) settings.add_reveal_row(widget, "org.cinnamon.desktop.wm.preferences", "visual-bell") switch = GSettingsSwitch(_("Enable audio alerts"), "org.cinnamon.desktop.wm.preferences", "audible-bell") settings.add_row(switch) sound_picker = GSettingsSoundFileChooser(_("Sound to use for window alerts"), "org.cinnamon.desktop.wm.preferences", "bell-sound") settings.add_reveal_row(sound_picker, "org.cinnamon.desktop.wm.preferences", "audible-bell") #### Typing Assistance page = SettingsPage() self.sidePage.stack.add_titled(page, "typing", _("Typing assistance")) # Stickykeys settings = page.add_section(_("Sticky keys")) switch = GSettingsSwitch(_("Treat a sequence of modifier keys as a combination"), "org.cinnamon.desktop.a11y.keyboard", "stickykeys-enable", None) settings.add_row(switch) switch = GSettingsSwitch(_("Disable if two modifiers are pressed together"), "org.cinnamon.desktop.a11y.keyboard", "stickykeys-two-key-off", None) settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "stickykeys-enable") switch = GSettingsSwitch(_("Alert when a modifier key is pressed"), "org.cinnamon.desktop.a11y.keyboard", "stickykeys-modifier-beep", "org.cinnamon.desktop.sound/event-sounds") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "stickykeys-enable") # Slowkeys settings = page.add_section(_("Slow keys")) switch = GSettingsSwitch(_("Put a delay between when a key is pressed and when it is accepted"), "org.cinnamon.desktop.a11y.keyboard", "slowkeys-enable", None) settings.add_row(switch) switch = GSettingsSwitch(_("Alert when a key is pressed"), "org.cinnamon.desktop.a11y.keyboard", "slowkeys-beep-press", "org.cinnamon.desktop.sound/event-sounds") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "slowkeys-enable") switch = GSettingsSwitch(_("Alert when a key is accepted"), "org.cinnamon.desktop.a11y.keyboard", "slowkeys-beep-accept", "org.cinnamon.desktop.sound/event-sounds") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "slowkeys-enable") switch = GSettingsSwitch(_("Alert when a key is rejected"), "org.cinnamon.desktop.a11y.keyboard", "slowkeys-beep-reject", "org.cinnamon.desktop.sound/event-sounds") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "slowkeys-enable") slider = GSettingsRange(_("Acceptance delay"), "org.cinnamon.desktop.a11y.keyboard", "slowkeys-delay", _("Short"), _("Long"), 0, 500, 10, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.keyboard", "slowkeys-enable") # Bouncekeys settings = page.add_section(_("Bounce keys")) switch = GSettingsSwitch(_("Ignore fast duplicate keypresses"), "org.cinnamon.desktop.a11y.keyboard", "bouncekeys-enable", None) settings.add_row(switch) switch = GSettingsSwitch(_("Alert when a key is rejected"), "org.cinnamon.desktop.a11y.keyboard", "bouncekeys-beep-reject", "org.cinnamon.desktop.sound/event-sounds") settings.add_reveal_row(switch, "org.cinnamon.desktop.a11y.keyboard", "bouncekeys-enable") slider = GSettingsRange(_("Acceptance delay"), "org.cinnamon.desktop.a11y.keyboard", "bouncekeys-delay", _("Short"), _("Long"), 0, 900, 10, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.keyboard", "bouncekeys-enable") #### Pointing and Clicking page = SettingsPage() self.sidePage.stack.add_titled(page, "mouse", _("Mouse")) # Mousekeys settings = page.add_section(_("Mouse keys")) switch = GSettingsSwitch(_("Control the pointer using the keypad"), "org.cinnamon.desktop.a11y.keyboard", "mousekeys-enable", None) settings.add_row(switch) slider = GSettingsRange(_("Initial delay"), "org.cinnamon.desktop.a11y.keyboard", "mousekeys-init-delay", _("Shorter"), _("Longer"), 10, 2000, 10, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.keyboard", "mousekeys-enable") slider = GSettingsRange(_("Acceleration time"), "org.cinnamon.desktop.a11y.keyboard", "mousekeys-accel-time", _("Shorter"), _("Longer"), 10, 2000, 10, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.keyboard", "mousekeys-enable") slider = GSettingsRange(_("Maximum speed"), "org.cinnamon.desktop.a11y.keyboard", "mousekeys-max-speed", _("Slower"), _("Faster"), 1, 500, 1, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.keyboard", "mousekeys-enable") # Dependency Checker settings = page.add_reveal_section(_("Simulated secondary click and hover click")) self.dc_section = settings install_widget = SettingsWidget() self.dep_button = DependencyCheckInstallButton(_("Checking dependencies"), _("Please install: %s") % ("mousetweaks"), ["mousetweaks"], Gtk.Alignment(), self.on_dep_satisfied) install_widget.pack_start(self.dep_button, True, False, 0) settings.add_row(install_widget) self.dc_section._revealer.set_reveal_child(True) # Secondary click settings = page.add_reveal_section(_("Simulated secondary click")) self.ssc_section = settings switch = GSettingsSwitch(_("Trigger a secondary click by holding down the primary button"), "org.cinnamon.desktop.a11y.mouse", "secondary-click-enabled", None) settings.add_row(switch) slider = GSettingsRange(_("Acceptance delay"), "org.cinnamon.desktop.a11y.mouse", "secondary-click-time", _("Shorter"), _("Longer"), 0.5, 3.0, 0.1, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.mouse", "secondary-click-enabled") # Hover Click settings = page.add_reveal_section(_("Hover click")) self.hc_section = settings switch = GSettingsSwitch(_("Trigger a click when the pointer hovers"), "org.cinnamon.desktop.a11y.mouse", "dwell-click-enabled", None) settings.add_row(switch) slider = GSettingsRange(_("Delay"), "org.cinnamon.desktop.a11y.mouse", "dwell-time", _("Short"), _("Long"), 0.2, 3.0, 0.1, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.mouse", "dwell-click-enabled") slider = GSettingsRange(_("Motion threshold"), "org.cinnamon.desktop.a11y.mouse", "dwell-threshold", _("Small"), _("Large"), 1, 30, 1, show_value=False) settings.add_reveal_row(slider, "org.cinnamon.desktop.a11y.mouse", "dwell-click-enabled")
def __init__(self, text, icon_name, device): Gtk.VBox.__init__(self) self._device = device self._ok_icon = Icon(icon_name='dialog-ok') self._cancel_icon = Icon(icon_name='dialog-cancel') 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) adjustment = Gtk.Adjustment(value=device.props.level, lower=0, upper=100 + sound.VOLUME_STEP, step_incr=sound.VOLUME_STEP, page_incr=sound.VOLUME_STEP, page_size=sound.VOLUME_STEP) self._adjustment = adjustment 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) hscale.show() button = Gtk.Button() button.props.relief = Gtk.ReliefStyle.NONE button.props.focus_on_click = False button.connect('clicked', self.__muted_clicked_cb) button.show() self._button = button grid = Gtk.Grid() grid.set_column_spacing(style.DEFAULT_SPACING) grid.attach(hscale, 0, 0, 1, 1) grid.attach(button, 1, 0, 1, 1) grid.show() alignment = Gtk.Alignment() alignment.set(0.5, 0, 0, 0) alignment.set_padding(0, 0, style.DEFAULT_SPACING, style.DEFAULT_SPACING) alignment.add(grid) alignment.show() self.add(alignment) self._adjustment_hid = \ self._adjustment.connect('value_changed', self.__level_adjusted_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): self.pixbuf_loader = None self.image_stream = None self.window = Gtk.Window(title="Images") self.window.connect('destroy', self.cleanup_cb) self.window.set_border_width(8) vbox = Gtk.VBox(spacing=8) vbox.set_border_width(8) self.window.add(vbox) label = Gtk.Label() label.set_markup('<u>Image loaded from file</u>') vbox.pack_start(label, False, False, 0) frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) # The alignment keeps the frame from growing when users resize # the window align = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) align.add(frame) vbox.pack_start(align, False, False, 0) self.base_path = os.path.abspath(os.path.dirname(__file__)) self.base_path = os.path.join(self.base_path, 'data') filename = os.path.join(self.base_path, 'gtk-logo-rgb.gif') pixbuf = GdkPixbuf.Pixbuf.new_from_file(filename) transparent = pixbuf.add_alpha(True, 0xff, 0xff, 0xff) image = Gtk.Image.new_from_pixbuf(transparent) frame.add(image) # Animation label = Gtk.Label() label.set_markup('<u>Animation loaded from file</u>') vbox.pack_start(label, False, False, 0) frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) # The alignment keeps the frame from growing when users resize # the window align = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) align.add(frame) vbox.pack_start(align, False, False, 0) img_path = path.join(self.base_path, 'floppybuddy.gif') image = Gtk.Image.new_from_file(img_path) frame.add(image) # Symbolic icon label = Gtk.Label() label.set_markup('<u>Symbolic themed icon</u>') vbox.pack_start(label, False, False, 0) frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) # The alignment keeps the frame from growing when users resize # the window align = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) align.add(frame) vbox.pack_start(align, False, False, 0) gicon = Gio.ThemedIcon.new_with_default_fallbacks( 'battery-caution-charging-symbolic') image = Gtk.Image.new_from_gicon(gicon, Gtk.IconSize.DIALOG) frame.add(image) # progressive label = Gtk.Label() label.set_markup('<u>Progressive image loading</u>') vbox.pack_start(label, False, False, 0) frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) # The alignment keeps the frame from growing when users resize # the window align = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) align.add(frame) vbox.pack_start(align, False, False, 0) image = Gtk.Image.new_from_pixbuf(None) frame.add(image) self.start_progressive_loading(image) # Sensistivity control button = Gtk.ToggleButton.new_with_mnemonic('_Insensitive') button.connect('toggled', self.toggle_sensitivity_cb, vbox) vbox.pack_start(button, False, False, 0) self.window.show_all()
def __build_window(self): """Build up the widget""" # toplevel widget self.top_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(self.top_vbox) # header line: icon, grid with name and "hide in wv" # FIXME self.hdr_align = Gtk.Alignment() self.top_vbox.pack_start(self.hdr_align, False, True, 0) self.hdr_align.set_padding(0, 5, 0, 0) self.hdr_box = Gtk.Box() self.clear_box = Gtk.Box() self.hdr_align.add(self.hdr_box) self.hdr_box.set_spacing(10) # Button to tag icon selector self.ti_bt = Gtk.Button() self.ti_bt_label = Gtk.Label() self.ti_bt.add(self.ti_bt_label) self.hidden_entry = Gtk.Entry() self.hidden_entry.set_width_chars(1) self.ti_bt_label.get_style_context().add_class('icon') self.hidden_entry.get_style_context().add_class('hidden') self.hdr_box.pack_start(self.ti_bt, False, False, 0) self.hdr_box.pack_start(self.hidden_entry, False, False, 0) self.ti_bt.set_size_request(64, 64) self.hidden_entry.set_size_request(0, 0) self.ti_bt.set_relief(Gtk.ReliefStyle.HALF) self.ti_bt_clear = Gtk.Button() self.ti_bt_clear.set_label(_('Remove icon')) self.clear_box.add(self.ti_bt_clear) # vbox for tag name and hid in WV self.tp_grid = Gtk.Grid() self.hdr_box.pack_start(self.tp_grid, False, True, 0) self.tp_grid.set_column_spacing(5) self.tn_entry_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.add(self.tn_entry_lbl_align) self.tn_entry_lbl = Gtk.Label() self.tn_entry_lbl.set_markup("<span weight='bold'>%s</span>" % _("Name : ")) self.tn_entry_lbl_align.add(self.tn_entry_lbl) self.tn_entry = Gtk.Entry() self.tn_entry.set_width_chars(20) self.tp_grid.attach(self.tn_entry, 1, 0, 1, 1) self.tn_cb_lbl_align = Gtk.Alignment.new(0, 0.5, 0, 0) self.tp_grid.attach(self.tn_cb_lbl_align, 0, 1, 1, 1) self.tn_cb_lbl = Gtk.Label(label=_('Show Tag in "Actionable" view:')) self.tn_cb_lbl_align.add(self.tn_cb_lbl) self.tn_cb = Gtk.CheckButton() self.tp_grid.attach(self.tn_cb, 1, 1, 1, 1) # Tag color self.tc_vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.top_vbox.pack_start(self.clear_box, False, False, 0) self.top_vbox.pack_start(self.tc_vbox, False, True, 0) self.tc_label_align = Gtk.Alignment() self.tc_vbox.pack_start(self.tc_label_align, False, True, 0) self.tc_label_align.set_padding(25, 0, 0, 0) self.tc_label = Gtk.Label() self.tc_label_align.add(self.tc_label) self.tc_label.set_markup( "<span weight='bold'>%s</span>" % _("Select Tag Color:")) self.tc_label.set_alignment(0, 0.5) # Tag color chooser self.tc_cc_align = Gtk.Alignment.new(0.5, 0.5, 0, 0) self.tc_vbox.pack_start(self.tc_cc_align, False, False, 0) self.tc_cc_align.set_padding(25, 15, 10, 10) self.tc_cc_colsel = SimpleColorSelector() # self.tc_cc_colsel = Gtk.ColorChooserWidget() self.tc_cc_align.add(self.tc_cc_colsel)
def __init__(self, options, title="Xpra Session Browser"): super().__init__() self.exit_code = 0 self.set_title(title) self.set_border_width(20) self.set_resizable(True) self.set_default_size(800, 220) self.set_decorated(True) self.set_size_request(800, 220) self.set_position(Gtk.WindowPosition.CENTER) self.set_wmclass("xpra-sessions-gui", "Xpra-Sessions-GUI") add_close_accel(self, self.quit) self.connect("delete_event", self.quit) icon = get_icon_pixbuf("browse.png") if icon: self.set_icon(icon) hb = Gtk.HeaderBar() hb.set_show_close_button(True) hb.props.title = "Xpra" button = Gtk.Button() icon = Gio.ThemedIcon(name="help-about") image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON) button.add(image) button.set_tooltip_text("About") button.connect("clicked", self.show_about) hb.add(button) hb.show_all() self.set_titlebar(hb) self.clients = {} self.clients_disconnecting = set() self.child_reaper = getChildReaper() self.vbox = Gtk.VBox(False, 20) self.add(self.vbox) title_label = Gtk.Label(title) title_label.modify_font(Pango.FontDescription("sans 14")) title_label.show() self.vbox.add(title_label) self.warning = Gtk.Label(" ") red = color_parse("red") self.warning.modify_fg(Gtk.StateType.NORMAL, red) self.warning.show() self.vbox.add(self.warning) self.password_box = Gtk.HBox(False, 10) self.password_label = Gtk.Label("Password:"******"" #log.info("options=%s (%s)", options, type(options)) self.local_info_cache = {} self.dotxpra = DotXpra(options.socket_dir, options.socket_dirs, username) self.poll_local_sessions() self.populate() GLib.timeout_add(5 * 1000, self.update) self.vbox.show() self.show()
def build_gui(self): self.win = win = Gtk.Window(title='Gnomecast v%s' % __version__) win.set_border_width(0) win.set_icon(self.get_logo_pixbuf(color='#000000')) self.cast_store = cast_store = Gtk.ListStore(object, str) vbox_outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0) vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=16) self.thumbnail_image = Gtk.Image() self.thumbnail_image.set_from_pixbuf(self.get_logo_pixbuf()) vbox_outer.pack_start(self.thumbnail_image, True, False, 0) alignment = Gtk.Alignment(xscale=1, yscale=1) alignment.add(vbox) alignment.set_padding(16, 20, 16, 16) vbox_outer.pack_start(alignment, False, False, 0) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=8) vbox.pack_start(hbox, False, False, 0) self.cast_combo = cast_combo = Gtk.ComboBox.new_with_model(cast_store) cast_combo.set_entry_text_column(1) renderer_text = Gtk.CellRendererText() cast_combo.pack_start(renderer_text, True) cast_combo.add_attribute(renderer_text, "text", 1) hbox.pack_start(cast_combo, True, True, 0) refresh_button = Gtk.Button(None, image=Gtk.Image(stock=Gtk.STOCK_REFRESH)) refresh_button.connect("clicked", self.init_casts) hbox.pack_start(refresh_button, False, False, 0) win.add(vbox_outer) self.file_button = button1 = Gtk.Button( "Choose an audio or video file...") button1.connect("clicked", self.on_file_clicked) vbox.pack_start(button1, False, False, 0) self.subtitle_store = subtitle_store = Gtk.ListStore(str, int, str) subtitle_store.append(["No subtitles.", -1, None]) subtitle_store.append(["Add subtitle file...", -2, None]) self.subtitle_combo = Gtk.ComboBox.new_with_model(subtitle_store) self.subtitle_combo.connect("changed", self.on_subtitle_combo_changed) self.subtitle_combo.set_entry_text_column(0) renderer_text = Gtk.CellRendererText() self.subtitle_combo.pack_start(renderer_text, True) self.subtitle_combo.add_attribute(renderer_text, "text", 0) self.subtitle_combo.set_active(0) vbox.pack_start(self.subtitle_combo, False, False, 0) self.scrubber_adj = Gtk.Adjustment(0, 0, 100, 15, 60, 0) self.scrubber = Gtk.Scale(orientation=Gtk.Orientation.HORIZONTAL, adjustment=self.scrubber_adj) self.scrubber.set_digits(0) def f(scale, s): notes = [self.humanize_seconds(s)] if self.cast and self.cast.media_controller.status.player_state == 'BUFFERING': notes.append('...') return ''.join(notes) self.scrubber.connect("format-value", f) self.scrubber.connect("change-value", self.scrubber_move_started) self.scrubber.connect("change-value", self.scrubber_moved) self.scrubber.set_sensitive(False) vbox.pack_start(self.scrubber, False, False, 0) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=16) self.rewind_button = Gtk.Button( None, image=Gtk.Image(stock=Gtk.STOCK_MEDIA_REWIND)) self.rewind_button.connect("clicked", self.rewind_clicked) self.rewind_button.set_sensitive(False) hbox.pack_start(self.rewind_button, True, False, 0) self.play_button = Gtk.Button( None, image=Gtk.Image(stock=Gtk.STOCK_MEDIA_PLAY)) self.play_button.connect("clicked", self.play_clicked) self.play_button.set_sensitive(False) hbox.pack_start(self.play_button, True, False, 0) self.forward_button = Gtk.Button( None, image=Gtk.Image(stock=Gtk.STOCK_MEDIA_FORWARD)) self.forward_button.connect("clicked", self.forward_clicked) self.forward_button.set_sensitive(False) hbox.pack_start(self.forward_button, True, False, 0) self.stop_button = Gtk.Button( None, image=Gtk.Image(stock=Gtk.STOCK_MEDIA_STOP)) self.stop_button.connect("clicked", self.stop_clicked) self.stop_button.set_sensitive(False) hbox.pack_start(self.stop_button, True, False, 0) vbox.pack_start(hbox, False, False, 0) cast_combo.connect("changed", self.on_cast_combo_changed) win.connect("delete-event", self.quit) win.connect("key_press_event", self.on_key_press) win.show_all() GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self.quit)
def __init__(self, app, actions, config_name): """Initialize. :param app: the main Application object. :param iterable actions: keyboard action names to pass through. :param str config_name: config prefix for saving window size. Use a simple "lowercase_with_underscores" name for the configuration key prefix. See also: `gui.keyboard.KeyboardManager.add_window()`. """ # Superclass Gtk.Window.__init__(self, type=Gtk.WindowType.POPUP) self.set_modal(True) # Internal state self.app = app self._size = None # last recorded size from any show() self._motion_handler_id = None self._prefs_size_key = "%s.window_size" % (config_name,) self._resize_info = None # state during an edge resize self._outside_grab_active = False self._outside_cursor = Gdk.Cursor(Gdk.CursorType.LEFT_PTR) self._popup_info = None # Initial positioning self._initial_move_pos = None # used when forcing a specific position self._corrected_pos = None # used when keeping the widget on-screen # Resize cursors self._edge_cursors = {} for edge, cursor in self.EDGE_CURSORS.iteritems(): if cursor is not None: cursor = Gdk.Cursor(cursor) self._edge_cursors[edge] = cursor # Default size self.set_gravity(Gdk.Gravity.NORTH_WEST) default_size = (self.MIN_WIDTH, self.MIN_HEIGHT) w, h = app.preferences.get(self._prefs_size_key, default_size) w = clamp(int(w), self.MIN_WIDTH, self.MAX_WIDTH) h = clamp(int(h), self.MIN_HEIGHT, self.MAX_HEIGHT) default_size = (w, h) self.set_transient_for(app.drawWindow) self.set_default_size(*default_size) self.set_position(Gtk.WindowPosition.MOUSE) # Register with the keyboard manager, but only let certain actions be # driven from the keyboard. app.kbm.add_window(self, actions) # Event handlers self.connect("realize", self._realize_cb) self.connect("configure-event", self._configure_cb) self.connect("enter-notify-event", self._crossing_cb) self.connect("leave-notify-event", self._crossing_cb) self.connect("show", self._show_cb) self.connect("hide", self._hide_cb) self.connect("button-press-event", self._button_press_cb) self.connect("button-release-event", self._button_release_cb) self.add_events( Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK ) # Appearance self._frame = Gtk.Frame() self._frame.set_shadow_type(Gtk.ShadowType.OUT) self._align = Gtk.Alignment(0.5, 0.5, 1.0, 1.0) self._align.set_padding( self.EDGE_SIZE, self.EDGE_SIZE, self.EDGE_SIZE, self.EDGE_SIZE ) self._frame.add(self._align) Gtk.Window.add(self, self._frame)
def __init__(self): super().__init__(title="Mega Chat | Login") event.Event(name="login") self.is_login = False self.is_password = False self.set_border_width(50) #self.set_resizable(False) box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.add(box) top_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) box.pack_start(top_box, True, True, 0) login_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) password_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) label_login = Gtk.Label(label="Login") self.login = Gtk.Entry() self.login.connect("changed", self.on_change_login) login_box.pack_start(label_login, True, True, 0) login_box.pack_start(self.login, expand=False, fill=False, padding=5) top_box.pack_start(login_box, expand=False, fill=False, padding=5) label_password = Gtk.Label(label="Password") self.password = Gtk.Entry() self.password.connect("changed", self.on_change_password) password_box.pack_start(label_password, True, True, 0) password_box.pack_start(self.password, expand=False, fill=False, padding=5) top_box.pack_start(password_box, expand=False, fill=False, padding=5) separator = Gtk.HSeparator() box.pack_start(separator, True, False, 5) # l_box = Gtk.Box() # p_box = Gtk.Box() # login_frame = Gtk.Frame(label="Login") # login_frame.add(login) # password_frame = Gtk.Frame(label="Password") # password_frame.add(password) # l_box.pack_strart(login, True, False, 5) # p_box.pack_strart(password, True, False, 5) # top_box.pack_start(login_frame, False, False, 0) # top_box.pack_start(password_frame, False, False, 0) bottom_box = Gtk.Box() box.pack_start(bottom_box, True, True, 0) b_box = Gtk.ButtonBox(orientation=Gtk.Orientation.VERTICAL) bottom_box.pack_start(b_box, False, True, 0) registration = Gtk.Button(label="Registration") registration.set_sensitive(False) registration.connect("clicked", self.on_registration) b_box.pack_start(registration, True, False, 0) b_space = Gtk.Alignment() b_box.pack_start(b_space, True, True, 0) c_box = Gtk.ButtonBox(orientation=Gtk.Orientation.VERTICAL) c_box.set_spacing(10) self.sign_in = Gtk.Button(label="Sign In") self.sign_in.connect("clicked", self.on_sign_in) self.sign_in.set_sensitive(False) c_box.pack_start(self.sign_in, True, True, 0) bottom_box.pack_start(c_box, True, True, 0) button_close = Gtk.Button(label="Close") button_close.connect("clicked", Gtk.main_quit) c_box.pack_end(button_close, True, True, 0)
def __init__(self, simulator, viewer_config, num_frames, ekf_enabled=True, use_slam_evaluation=True): """ Initializes a Viewer object :param simulator: The underlying simulator :param viewer_config: The configuration of the Viewer :param num_frames: Number of frame of the GUI, determined by which algorithms are activated :param ekf_enabled: Boolean value specifying if EKF is enabled :param use_slam_evaluation: Boolean value specifying if the slam evaluation is enabled """ # bind the simulator self.simulator = simulator self.cfg = viewer_config self.ekf_enabled = ekf_enabled self.use_slam_evaluation = use_slam_evaluation # initialize camera parameters self.num_frames = num_frames self.view_width_pixels = viewer_config["pixels_width"] self.view_height_pixels = viewer_config["pixels_height"] self.pixels_per_meter = viewer_config["zoom"] # initialize frames self.current_frames = [Frame() for _ in range(self.num_frames)] # initialize the window self.window = gtk.Window() self.window.set_title('Sobot Rimulator') self.window.set_resizable(False) self.window.connect('delete_event', self.on_delete) # Define labels of the drawing areas if self.ekf_enabled: label_strings = ["World", "EKF SLAM", "FastSLAM"][:self.num_frames] else: label_strings = ["World", "FastSLAM"][:self.num_frames] self.labels = [] for label_string in label_strings: label = gtk.Label() label.set_text(label_string) self.labels.append(label) # initialize the drawing_areas self.drawing_areas = [] # This list contains the drawing functions for the frames. The list has same length as number of frames. on_expose_functions = [self.on_expose1, self.on_expose2, self.on_expose3][:self.num_frames] for on_expose in on_expose_functions: drawing_area = gtk.DrawingArea() drawing_area.set_size_request(self.view_width_pixels, self.view_height_pixels) drawing_area.connect('draw', on_expose) self.drawing_areas.append(drawing_area) # initialize the painter self.painter = Painter(self.pixels_per_meter) # == initialize the buttons # build the play button self.button_play = gtk.Button('Play') play_image = gtk.Image() play_image.set_from_stock(gtk.STOCK_MEDIA_PLAY, gtk.IconSize.BUTTON) self.button_play.set_image(play_image) self.button_play.set_image_position(gtk.PositionType.LEFT) self.button_play.connect('clicked', self.on_play) # build the stop button self.button_stop = gtk.Button('Stop') stop_image = gtk.Image() stop_image.set_from_stock(gtk.STOCK_MEDIA_STOP, gtk.IconSize.BUTTON) self.button_stop.set_image(stop_image) self.button_stop.set_image_position(gtk.PositionType.LEFT) self.button_stop.connect('clicked', self.on_stop) # build the step button self.button_step = gtk.Button('Step') step_image = gtk.Image() step_image.set_from_stock(gtk.STOCK_MEDIA_NEXT, gtk.IconSize.BUTTON) self.button_step.set_image(step_image) self.button_step.set_image_position(gtk.PositionType.LEFT) self.button_step.connect('clicked', self.on_step) # build the reset button self.button_reset = gtk.Button('Reset') reset_image = gtk.Image() reset_image.set_from_stock(gtk.STOCK_MEDIA_REWIND, gtk.IconSize.BUTTON) self.button_reset.set_image(reset_image) self.button_reset.set_image_position(gtk.PositionType.LEFT) self.button_reset.connect('clicked', self.on_reset) # build the save map button self.button_save_map = gtk.Button('Save Map') save_map_image = gtk.Image() save_map_image.set_from_stock(gtk.STOCK_SAVE, gtk.IconSize.BUTTON) self.button_save_map.set_image(save_map_image) self.button_save_map.set_image_position(gtk.PositionType.LEFT) self.button_save_map.connect('clicked', self.on_save_map) # build the load map button self.button_load_map = gtk.Button('Load Map') load_map_image = gtk.Image() load_map_image.set_from_stock(gtk.STOCK_OPEN, gtk.IconSize.BUTTON) self.button_load_map.set_image(load_map_image) self.button_load_map.set_image_position(gtk.PositionType.LEFT) self.button_load_map.connect('clicked', self.on_load_map) # build the random map buttons self.button_random_map = gtk.Button('Random Map') random_map_image = gtk.Image() random_map_image.set_from_stock(gtk.STOCK_REFRESH, gtk.IconSize.BUTTON) self.button_random_map.set_image(random_map_image) self.button_random_map.set_image_position(gtk.PositionType.LEFT) self.button_random_map.connect('clicked', self.on_random_map) # build the draw-invisibles toggle button self.draw_invisibles = False # controls whether invisible world elements are displayed self.button_draw_invisibles = gtk.Button() self._decorate_draw_invisibles_button_inactive() self.button_draw_invisibles.set_image_position(gtk.PositionType.LEFT) self.button_draw_invisibles.connect('clicked', self.on_draw_invisibles) # build the plot slam evaluation button self.button_slam_evaluation = gtk.Button("Plot Slam Evaluation") self.button_slam_evaluation.set_image_position(gtk.PositionType.LEFT) self.button_slam_evaluation.connect('clicked', self.on_slam_evaluation) # build the plot-covariance-matrix button self.button_plot_covariances = gtk.Button("Plot Covariance Matrix") self.button_plot_covariances.set_image_position(gtk.PositionType.LEFT) self.button_plot_covariances.connect('clicked', self.on_plot_covariances) # == lay out the window labels_box = gtk.HBox(spacing=self.view_width_pixels - 52) # Subtract number of pixels that the text of the labels roughly need for label in self.labels: labels_box.pack_start(label, False, False, 0) labels_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) labels_alignment.add(labels_box) plots_box = gtk.HBox(spacing=5) for drawing_area in self.drawing_areas: plots_box.pack_start(drawing_area, False, False, 0) plots_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) plots_alignment.add(plots_box) # pack the simulation control buttons sim_controls_box = gtk.HBox(spacing=5) sim_controls_box.pack_start(self.button_play, False, False, 0) sim_controls_box.pack_start(self.button_stop, False, False, 0) sim_controls_box.pack_start(self.button_step, False, False, 0) sim_controls_box.pack_start(self.button_reset, False, False, 0) # pack the map control buttons map_controls_box = gtk.HBox(spacing=5) map_controls_box.pack_start(self.button_save_map, False, False, 0) map_controls_box.pack_start(self.button_load_map, False, False, 0) map_controls_box.pack_start(self.button_random_map, False, False, 0) # pack the information buttons information_box = gtk.HBox() information_box.pack_start(self.button_draw_invisibles, False, False, 0) if self.ekf_enabled: information_box.pack_start(self.button_plot_covariances, False, False, 0) if num_frames > 1 and self.use_slam_evaluation: information_box.pack_start(self.button_slam_evaluation, False, False, 0) # align the controls sim_controls_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) map_controls_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) invisibles_button_alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) sim_controls_alignment.add(sim_controls_box) map_controls_alignment.add(map_controls_box) invisibles_button_alignment.add(information_box) # create the alert box self.alert_box = gtk.Label() # lay out the simulation view and all of the controls layout_box = gtk.VBox() layout_box.pack_start(labels_alignment, False, False, 5) layout_box.pack_start(plots_alignment, False, False, 0) layout_box.pack_start(self.alert_box, False, False, 5) layout_box.pack_start(sim_controls_alignment, False, False, 5) layout_box.pack_start(map_controls_alignment, False, False, 5) layout_box.pack_start(invisibles_button_alignment, False, False, 5) # apply the layout self.window.add(layout_box) # show the simulator window self.window.show_all()
def __init__(self, songs): super(AlbumArtWindow, self).__init__() self.image_cache = [] self.image_cache_size = 10 self.search_lock = False self.set_title(_('Album Art Downloader')) self.set_icon_name(Icons.EDIT_FIND) self.set_default_size(800, 550) image = CoverArea(self, songs[0]) self.liststore = Gtk.ListStore(object, object) self.treeview = treeview = AllTreeView(model=self.liststore) self.treeview.set_headers_visible(False) self.treeview.set_rules_hint(True) targets = [("text/uri-list", 0, 0)] targets = [Gtk.TargetEntry.new(*t) for t in targets] treeview.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, targets, Gdk.DragAction.COPY) treeselection = self.treeview.get_selection() treeselection.set_mode(Gtk.SelectionMode.SINGLE) treeselection.connect('changed', self.__select_callback, image) self.treeview.connect("drag-data-get", self.__drag_data_get, treeselection) rend_pix = Gtk.CellRendererPixbuf() img_col = Gtk.TreeViewColumn('Thumb') img_col.pack_start(rend_pix, False) def cell_data_pb(column, cell, model, iter_, *args): surface = model[iter_][0] cell.set_property("surface", surface) img_col.set_cell_data_func(rend_pix, cell_data_pb, None) treeview.append_column(img_col) rend_pix.set_property('xpad', 2) rend_pix.set_property('ypad', 2) border_width = self.get_scale_factor() * 2 rend_pix.set_property('width', self.THUMB_SIZE + 4 + border_width) rend_pix.set_property('height', self.THUMB_SIZE + 4 + border_width) def escape_data(data): for rep in ('\n', '\t', '\r', '\v'): data = data.replace(rep, ' ') return util.escape(' '.join(data.split())) def cell_data(column, cell, model, iter, data): cover = model[iter][1] esc = escape_data txt = '<b><i>%s</i></b>' % esc(cover['name']) txt += "\n<small>%s</small>" % ( _('from %(source)s') % { "source": util.italic(esc(cover['source'])) }) if 'resolution' in cover: txt += "\n" + _('Resolution: %s') % util.italic( esc(cover['resolution'])) if 'size' in cover: txt += "\n" + _('Size: %s') % util.italic(esc(cover['size'])) cell.markup = txt cell.set_property('markup', cell.markup) rend = Gtk.CellRendererText() rend.set_property('ellipsize', Pango.EllipsizeMode.END) info_col = Gtk.TreeViewColumn('Info', rend) info_col.set_cell_data_func(rend, cell_data) treeview.append_column(info_col) sw_list = Gtk.ScrolledWindow() sw_list.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) sw_list.set_shadow_type(Gtk.ShadowType.IN) sw_list.add(treeview) search_labelraw = Gtk.Label('raw') search_labelraw.set_alignment(xalign=1.0, yalign=0.5) self.search_fieldraw = Gtk.Entry() self.search_fieldraw.connect('activate', self.start_search) self.search_fieldraw.connect('changed', self.__searchfieldchanged) search_labelclean = Gtk.Label('clean') search_labelclean.set_alignment(xalign=1.0, yalign=0.5) self.search_fieldclean = Gtk.Label() self.search_fieldclean.set_can_focus(False) self.search_fieldclean.set_alignment(xalign=0.0, yalign=0.5) self.search_radioraw = Gtk.RadioButton(group=None, label=None) self.search_radioraw.connect("toggled", self.__searchtypetoggled, "raw") self.search_radioclean = Gtk.RadioButton(group=self.search_radioraw, label=None) self.search_radioclean.connect("toggled", self.__searchtypetoggled, "clean") #note: set_active(False) appears to have no effect #self.search_radioraw.set_active( # self.config_get_bool('searchraw', False)) if self.config_get_bool('searchraw', False): self.search_radioraw.set_active(True) else: self.search_radioclean.set_active(True) search_labelresultsmax = Gtk.Label('limit') search_labelresultsmax.set_alignment(xalign=1.0, yalign=0.5) search_labelresultsmax.set_tooltip_text( _("Per engine 'at best' results limit")) search_adjresultsmax = Gtk.Adjustment(value=int( self.config_get("resultsmax", 3)), lower=1, upper=REQUEST_LIMIT_MAX, step_incr=1, page_incr=0, page_size=0) self.search_spinresultsmax = Gtk.SpinButton( adjustment=search_adjresultsmax, climb_rate=0.2, digits=0) self.search_spinresultsmax.set_alignment(xalign=0.5) self.search_spinresultsmax.set_can_focus(False) self.search_button = Button(_("_Search"), Icons.EDIT_FIND) self.search_button.connect('clicked', self.start_search) search_button_box = Gtk.Alignment() search_button_box.set(1, 0, 0, 0) search_button_box.add(self.search_button) search_table = Gtk.Table(rows=3, columns=4, homogeneous=False) search_table.attach(search_labelraw, 0, 1, 0, 1, xoptions=Gtk.AttachOptions.FILL, xpadding=6) search_table.attach(self.search_radioraw, 1, 2, 0, 1, xoptions=0, xpadding=0) search_table.attach(self.search_fieldraw, 2, 4, 0, 1) search_table.attach(search_labelclean, 0, 1, 1, 2, xoptions=Gtk.AttachOptions.FILL, xpadding=6) search_table.attach(self.search_radioclean, 1, 2, 1, 2, xoptions=0, xpadding=0) search_table.attach(self.search_fieldclean, 2, 4, 1, 2, xpadding=4) search_table.attach(search_labelresultsmax, 0, 2, 2, 3, xoptions=Gtk.AttachOptions.FILL, xpadding=6) search_table.attach(self.search_spinresultsmax, 2, 3, 2, 3, xoptions=Gtk.AttachOptions.FILL, xpadding=0) search_table.attach(search_button_box, 3, 4, 2, 3) widget_space = 5 self.progress = Gtk.ProgressBar() left_vbox = Gtk.VBox(spacing=widget_space) left_vbox.pack_start(search_table, False, True, 0) left_vbox.pack_start(sw_list, True, True, 0) hpaned = Paned() hpaned.set_border_width(widget_space) hpaned.pack1(left_vbox, shrink=False) hpaned.pack2(image, shrink=False) hpaned.set_position(275) self.add(hpaned) self.show_all() left_vbox.pack_start(self.progress, False, True, 0) self.connect('destroy', self.__save_config) song = songs[0] text = SEARCH_PATTERN.format(song) self.set_text(text) self.start_search()
def _init_widgets(self): # Icon preview and edit TDW self._tdw = tileddrawwidget.TiledDrawWidget() self._tdw.set_model(self._model) self._tdw.set_size_request(brushmanager.PREVIEW_W * self._SCALE, brushmanager.PREVIEW_H * self._SCALE) self._tdw.scale = float(self._SCALE) self._tdw.scroll_on_allocate = False self._tdw.pixelize_threshold = 0 tdw_align = Gtk.Alignment(xalign=0.5, yalign=0.0, xscale=0.0, yscale=0.0) tdw_align.add(self._tdw) self.attach(tdw_align, 0, 0, 1, 1) ctrlr = CanvasController(self._tdw) ctrlr.init_pointer_events() ctrlr.modes.default_mode_class = FreehandMode # Brush name label lbl = Gtk.Label() lbl.set_alignment(0.5, 0.0) lbl.set_justify(Gtk.Justification.CENTER) lbl_tmpl = self._ICON_PREVIEWING_TMPL lbl.set_markup(lbl_tmpl % (lib.xml.escape(self._NO_BRUSH_NAME), )) self.attach(lbl, 0, 1, 1, 1) self.brush_name_label = lbl # Action buttons button_box = Gtk.VButtonBox() button_box.set_homogeneous(False) button_box.set_layout(Gtk.ButtonBoxStyle.START) button_box.set_spacing(4) # TRANSLATORS: begin editing a brush's preview icon b = self._make_image_button(_('Edit'), "mypaint-freehand-symbolic", self._edit_cb) b.set_tooltip_text(_("Begin editing this preview icon")) button_box.pack_start(b, False, True, 0) self._edit_button = b # TRANSLATORS: revert edits to a brush icon b = self._make_image_button(_('Revert'), "mypaint-document-revert-symbolic", self._revert_cb) b.set_tooltip_text(_("Discard changes, and cancel editing")) button_box.pack_start(b, False, True, 0) button_box.set_child_secondary(b, False) self._revert_button = b # TRANSLATORS: clear the brush preview icon being edited b = self._make_image_button(_('Clear'), "mypaint-clear-all-symbolic", self._clear_cb) b.set_tooltip_text(_("Clear the preview icon")) button_box.pack_start(b, False, True, 0) self._clear_button = b # TRANSLATORS: set the brush icon to a built-in default b = self._make_image_button(_('Auto'), "mypaint-document-new-symbolic", self._default_cb) b.set_tooltip_text(_("Use the default icon")) button_box.pack_start(b, False, True, 0) self._default_button = b # TRANSLATORS: save edits to a brush icon b = self._make_image_button(_('Save'), "mypaint-document-save-symbolic", self._save_cb) b.set_tooltip_text(_("Save this preview icon, and finish editing")) button_box.pack_start(b, False, True, 0) button_box.set_child_secondary(b, True) self._save_button = b self.attach(button_box, 1, 0, 1, 2) self.connect_after("show", self._show_cb) mb = self._bm.selected_brush preview = mb.preview self._set_preview_pixbuf(preview) name = mb.name if name is None: name = self._NO_BRUSH_NAME self.brush_name_label.set_markup(lbl_tmpl % (lib.xml.escape(name), ))
def __init__(self, handle): activity.Activity.__init__(self, handle) self.set_title('FotoToon') self._max_participants = 1 self.page = None toolbar_box = ToolbarBox() activity_button = ActivityToolbarButton(self) activity_toolbar = activity_button.page toolbar_box.toolbar.insert(activity_button, 0) edit_toolbar_btn = ToolbarButton() edit_toolbar = Gtk.Toolbar() edit_toolbar_btn.props.page = edit_toolbar edit_toolbar_btn.props.icon_name = 'toolbar-edit' edit_toolbar_btn.label = _('Edit') toolbar_box.toolbar.insert(edit_toolbar_btn, -1) view_toolbar_btn = ToolbarButton() view_toolbar = Gtk.Toolbar() view_toolbar_btn.props.page = view_toolbar view_toolbar_btn.props.icon_name = 'toolbar-view' view_toolbar_btn.label = _('View') toolbar_box.toolbar.insert(view_toolbar_btn, -1) slideview_btn = ToggleToolButton('slideshow') slideview_btn.set_tooltip(_('Slideshow')) slideview_btn.set_active(False) slideview_btn.connect('clicked', self._switch_view_mode, False) view_toolbar.insert(slideview_btn, -1) slideview_btn.show() slideview_timings_btn = ToggleToolButton('slideshow-stopwatch') slideview_timings_btn.set_tooltip(_('Slideshow with Timings')) slideview_timings_btn.set_active(False) slideview_timings_btn.connect('clicked', self._switch_view_mode, True) view_toolbar.insert(slideview_timings_btn, -1) slideview_timings_btn.show() time_button = ToolButton('stopwatch') time_button.set_tooltip(_('Set Image Duration in Slideshow (Seconds)')) view_toolbar.insert(time_button, -1) time_button.show() self._time_spin = Gtk.SpinButton.new_with_range(MIN_TIME, MAX_TIME, 1) self._time_spin.connect('value-changed', self.__time_spin_changed_cb) self._time_spin.props.value = DEFAULT_TIME self._time_spin.props.update_policy = \ Gtk.SpinButtonUpdatePolicy.IF_VALID palette = time_button.get_palette() palette.connect('popup', self.__time_button_popup_cb) time_button.connect( 'clicked', lambda *args: palette.popup(immediate=True, state=Palette.SECONDARY)) alignment = Gtk.Alignment() alignment.set_padding(style.DEFAULT_PADDING, style.DEFAULT_PADDING, style.DEFAULT_PADDING, style.DEFAULT_PADDING) alignment.add(self._time_spin) self._time_spin.show() palette.set_content(alignment) alignment.show() fullscreen_btn = ToolButton('view-fullscreen') fullscreen_btn.set_tooltip(_('Fullscreen')) fullscreen_btn.props.accelerator = '<Alt>Return' fullscreen_btn.connect('clicked', lambda w: self.fullscreen()) view_toolbar.insert(fullscreen_btn, -1) fullscreen_btn.show() self.set_toolbar_box(toolbar_box) toolbar = toolbar_box.toolbar self.page = Page() self.globes_manager = GlobesManager(toolbar, edit_toolbar, self) # fonts self._text_button = ToolbarButton() self._text_button.props.page = TextToolbar(self.page) self._text_button.props.icon_name = 'format-text-size' self._text_button.props.label = _('Text') self._toolbar_box.toolbar.insert(self._text_button, -1) reorder_img_btn = ToolButton('thumbs-view') reorder_img_btn.set_icon_name('thumbs-view') reorder_img_btn.set_tooltip(_('Change image order')) reorder_img_btn.connect('clicked', self.__image_order_cb) edit_toolbar.insert(reorder_img_btn, -1) reorder_img_btn.show() bgchange = ToolButton(icon_name='contract-coordinates') bgchange.set_tooltip(_('Edit background image')) bgchange.connect('clicked', self.__bgchange_clicked_cb) edit_toolbar.insert(bgchange, -1) bgchange.show() separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar_box.toolbar.insert(separator, -1) stop = StopButton(self) toolbar_box.toolbar.insert(stop, -1) toolbar_box.show_all() # add export button separator_2 = Gtk.SeparatorToolItem() separator_2.show() activity_toolbar.insert(separator_2, -1) self.bt_save_as_image = ToolButton() self.bt_save_as_image.props.icon_name = 'save-as-image' self.bt_save_as_image.connect('clicked', self.write_image) self.bt_save_as_image.set_tooltip(_('Save as Image')) activity_toolbar.insert(self.bt_save_as_image, -1) self.bt_save_as_image.show() save_as_pdf = ToolButton() save_as_pdf.props.icon_name = 'save-as-pdf' save_as_pdf.connect('clicked', self._save_as_pdf) save_as_pdf.set_tooltip(_('Save as a Book (PDF)')) activity_toolbar.insert(save_as_pdf, -1) save_as_pdf.show() save_as_ogg = ToolButton() save_as_ogg.props.icon_name = 'save-as-ogg' save_as_ogg.connect('clicked', self.__save_as_ogg_cb) save_as_ogg.set_tooltip(_('Save as a Movie (OGG)')) activity_toolbar.insert(save_as_ogg, -1) save_as_ogg.show() activity_button.page.title.connect("focus-in-event", self.on_title) scrolled = Gtk.ScrolledWindow() # scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS) scrolled.add_with_viewport(self.page) scrolled.set_kinetic_scrolling(False) scrolled.show_all() self._slideview = SlideView(self) self._slideview.show_all() self._notebook = Gtk.Notebook() self._notebook.set_show_tabs(False) self._notebook.append_page(scrolled, None) self._notebook.append_page(self._slideview, None) self._notebook.show_all() if self._jobject.file_path is None or self._jobject.file_path == '': empty_widget = EmptyWidget() empty_widget.connect('choose-image', self.__add_image) self.set_canvas(empty_widget) else: self.set_canvas(self._notebook) self.show() self.metadata['mime_type'] = 'application/x-fototoon-activity' self.page.empty_page = handle.object_id is None self._key_press_signal_id = None
def __init__(self): Gtk.Grid.__init__(self) self.set_row_spacing(6) self.set_column_spacing(6) from application import get_app self.app = get_app() prefs = self.app.preferences row = 0 label = Gtk.Label() label.set_markup(_("Tolerance:")) label.set_tooltip_text( _("How much pixel colors are allowed to vary from the start\n" "before Flood Fill will refuse to fill them")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) value = prefs.get(self.TOLERANCE_PREF, self.DEFAULT_TOLERANCE) value = float(value) adj = Gtk.Adjustment(value=value, lower=0.0, upper=1.0, step_increment=0.05, page_increment=0.05, page_size=0) adj.connect("value-changed", self._tolerance_changed_cb) self._tolerance_adj = adj scale = Gtk.Scale() scale.set_hexpand(True) scale.set_adjustment(adj) scale.set_draw_value(False) self.attach(scale, 1, row, 1, 1) row += 1 label = Gtk.Label() label.set_markup(_("Source:")) label.set_tooltip_text(_("Which visible layers should be filled")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) text = _("Sample Merged") checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( _("When considering which area to fill, use a\n" "temporary merge of all the visible layers\n" "underneath the current layer")) self.attach(checkbut, 1, row, 1, 1) active = bool( prefs.get(self.SAMPLE_MERGED_PREF, self.DEFAULT_SAMPLE_MERGED)) checkbut.set_active(active) checkbut.connect("toggled", self._sample_merged_toggled_cb) self._sample_merged_toggle = checkbut row += 1 label = Gtk.Label() label.set_markup(_("Target:")) label.set_tooltip_text(_("Where the output should go")) label.set_alignment(1.0, 0.5) label.set_hexpand(False) self.attach(label, 0, row, 1, 1) text = _("New Layer (once)") checkbut = Gtk.CheckButton.new_with_label(text) checkbut.set_tooltip_text( _("Create a new layer with the results of the fill.\n" "This is turned off automatically after use.")) self.attach(checkbut, 1, row, 1, 1) active = self.DEFAULT_MAKE_NEW_LAYER checkbut.set_active(active) self._make_new_layer_toggle = checkbut row += 1 align = Gtk.Alignment(0.5, 1.0, 1.0, 0.0) align.set_vexpand(True) button = Gtk.Button(label=_("Reset")) button.connect("clicked", self._reset_clicked_cb) button.set_tooltip_text(_("Reset options to their defaults")) align.add(button) self.attach(align, 0, row, 2, 1)
def _init_ui(self): self.set_property("orientation", Gtk.Orientation.HORIZONTAL) # create Right Toolbar """ self.side_toolbar_right = self._create_right_toolbar() self.side_toolbar_right.set_property("border-width", 40) self.pack_end(self.side_toolbar_right, False, False, 10) """ # create Left Toolbar self.side_toolbar_left = self._create_left_toolbar() self.side_toolbar_left.set_property("border-width", 40) self.pack_start(self.side_toolbar_left, False, False, 10) # Create Central Area self.vbox = Gtk.VBox() self.pack_start(self.vbox, True, True, 10) """ self.heading = PageHeading("Let's Edit Font:" + globals.FONT.info.familyName, fontSize='20000') self.vbox.pack_start(self.heading, False, False, 30) self.vbox.pack_start(Gtk.HSeparator(), False, False, 0) self.characterMap = CharacterMap(10, 1, 'BUTTON') self.vbox.pack_start(self.characterMap, False, False, 30) self.vbox.pack_start(Gtk.HSeparator(), False, False, 0) """ # Create Drawing Area self.editor_alignment = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) self.editor_area = GlyphBox() self.editor_alignment.add(self.editor_area) self.vbox.pack_start(self.editor_alignment, True, True, 0) # Add the Drawing Area inside a scrolling window """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_border_width(10) scrolled_window.add_with_viewport(self.editor_alignment) self.vbox.pack_start(scrolled_window, True, True, 0) """ self.show_all()
def __init__(self, label=None, accel_path=None, text_maxlen=style.MENU_WIDTH_CHARS, **kwargs): # DEPRECATED: label is passed with the primary-text property, # accel_path is set via the invoker property self._primary_text = None self._secondary_text = None self._icon = None self._icon_visible = True self._primary_event_box = Gtk.EventBox() self._primary_event_box.show() self._primary_box = Gtk.HBox() self._primary_event_box.add(self._primary_box) self._primary_box.show() self._icon_box = Gtk.HBox() self._icon_box.set_size_request(style.GRID_CELL_SIZE, -1) self._primary_box.pack_start(self._icon_box, False, True, 0) labels_box = Gtk.VBox() self._label_alignment = Gtk.Alignment(xalign=0, yalign=0.5, xscale=1, yscale=0.33) self._label_alignment.set_padding( style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING, style.DEFAULT_SPACING) self._label_alignment.add(labels_box) self._label_alignment.show() self._primary_box.pack_start(self._label_alignment, True, True, 0) labels_box.show() self._label = Gtk.AccelLabel(label='') self._label.set_alignment(0, 0.5) if text_maxlen > 0: self._label.set_max_width_chars(text_maxlen) self._label.set_ellipsize(style.ELLIPSIZE_MODE_DEFAULT) labels_box.pack_start(self._label, True, True, 0) self._primary_event_box.connect('button-release-event', self.__button_release_event_cb) self._primary_event_box.set_events(Gdk.EventMask.BUTTON_RELEASE_MASK) self._secondary_label = Gtk.Label() self._secondary_label.set_alignment(0, 0.5) labels_box.pack_start(self._secondary_label, True, True, 0) self._secondary_box = Gtk.VBox() self._separator = Gtk.HSeparator() self._secondary_box.pack_start(self._separator, True, True, 0) self._secondary_box.show() # we init after initializing all of our containers PaletteWindow.__init__(self, **kwargs) self._full_request = [0, 0] self._content = None # we set these for backward compatibility if label is not None: self.props.primary_text = label self._add_content() self.action_bar = PaletteActionBar() self._secondary_box.pack_start(self.action_bar, True, True, 0) self.action_bar.show() self.connect('notify::invoker', self.__notify_invoker_cb) # Default to a normal window palette self._content_widget = None self.set_content(None)
def _init_ui(self): heading = PageHeading("Let's Create a new Font", fontSize='20000') self.pack_start(heading, False, False, 10) # a container box for the form, unused # form_container = Gtk.HBox() scrolled_window = Gtk.ScrolledWindow() scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) scrolled_window.set_border_width(10) alignment_box = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0, yscale=0) scrolled_window.add_with_viewport(alignment_box) self.pack_start(scrolled_window, True, True, 0) # a vbox to store the form fields form_box = Gtk.VBox() alignment_box.add(form_box) # Adding the form fields # Family Name # Type: Text # TODO: Text Formatting: Capitalised self.family_name = InlineTextInputBox("Family Name", "Enter the name of your font", "", "*") form_box.pack_start(self.family_name, False, False, 10) # Style Name # Type: Dropdown # Only have "Regular" for now vbox = Gtk.VBox() hbox = Gtk.HBox() name = Gtk.Label("Style Name") name.set_tooltip_text('Enter the style of your font') msg = Gtk.Label("") hbox.pack_start(name, False, False, 5) hbox.pack_start(msg, False, False, 5) vbox.pack_start(hbox, False, False, 10) self.style_name_combo = Gtk.ComboBoxText.new() self.style_name_combo.append('regular', 'Regular') self.style_name_combo.set_active(0) vbox.pack_start(self.style_name_combo, False, False, 0) form_box.pack_start(vbox, False, False, 10) # Version # Default Value: 1.000 # Type: Text self.version = InlineTextInputBox("Version", "Enter the version of your font", "1.000") form_box.pack_start(self.version, False, False, 10) # Year # Default Value: 2016 # Type: Number self.year = InlineNumberInputBox( "Year", "The year in which the font was " "created", "2016", "") form_box.pack_start(self.year, False, False, 10) # Trademark # Default Value: Blank # Type: Text self.trademark = InlineTextInputBox( "Trademark", "Enter the trademark of your font") form_box.pack_start(self.version, False, False, 10) # Author Info # Default Value: Blank # Type: Text self.author_info = InlineTextInputBox( "Author Info", "Enter the Name of all the " "Authors separated a by \',\'", "", "*") form_box.pack_start(self.author_info, False, False, 10) # Copyright # Default Value: year The familyname Authors # Type: Text self.copyright = InlineTextInputBox( "Copyright", "Enter the Copyright Info", "2016 The " + self.family_name.get_text() + " " + self.author_info.get_text()) form_box.pack_start(self.copyright, False, False, 10) # License, # Default Value: This Font Software is licensed under the SIL Open # Font License, Version 1.1. This license is available with a FAQ # at: http://scripts.sil.org/OFL # Type: Text self.license = InlineTextInputBox( "License", "Enter the license for your font", "This Font Software is licensed " "under the SIL Open Font License, " "Version 1.1.", "") form_box.pack_start(self.license, False, False, 10) # License URL # Default Value: http://scripts.sil.org/OFL # Type: Text self.license_url = InlineTextInputBox( "License URL", "Enter a url of the above " "mentioned license", "http://scripts.sil.org/OFL", "") form_box.pack_start(self.license_url, False, False, 10) # Cap Height # Default Value: 800 # Type: Number self.cap_height = InlineNumberInputBox( "Cap Height", "The height of the capital " "letters of the font", "800", "") form_box.pack_start(self.cap_height, False, False, 10) # x-height # Default Value: 500 # Type: Number self.x_height = InlineNumberInputBox( "x Height", "The height of the small letters " "of the font", "500", "") form_box.pack_start(self.x_height, False, False, 10) # Ascender # Default Value: 800 # Type: Number self.ascender = InlineNumberInputBox("Ascender", "", "800", "") form_box.pack_start(self.ascender, False, False, 10) # Descender # Default Value: -200 # Type: Number self.descender = InlineNumberInputBox("Descender", "", "-200", "") form_box.pack_start(self.descender, False, False, 10) # Units per em # Def globals.ault Value: 1000 # Type: Number self.unit_per_em = InlineNumberInputBox("Units per em", "", "1000", "") form_box.pack_start(self.unit_per_em, False, False, 10) submit_button = ImageButton(icon_name='dialog-ok-active', fill_color='#32B232') submit_button.connect("clicked", self._submit_form) form_box.pack_start(submit_button, False, False, 10) self.show_all()
def xal(widget, xalign=1): al = Gtk.Alignment(xalign=xalign, yalign=0.5, xscale=0, yscale=0) al.add(widget) return al
def setup_window(self): self.window = Gtk.Window() self.window.set_border_width(20) self.window.connect("delete-event", self.close) self.window.set_default_size(400, 300) self.window.set_title("Xpra Bug Report") icon_pixbuf = get_icon_pixbuf("bugs.png") if icon_pixbuf: self.window.set_icon(icon_pixbuf) self.window.set_position(Gtk.WindowPosition.CENTER) vbox = Gtk.VBox(False, 0) vbox.set_spacing(15) # Title hbox = Gtk.HBox(False, 0) icon_pixbuf = get_icon_pixbuf("xpra.png") if icon_pixbuf and self.show_about: from xpra.gtk_common.about import about logo_button = Gtk.Button("") settings = logo_button.get_settings() settings.set_property('gtk-button-images', True) logo_button.connect("clicked", about) logo_button.set_tooltip_text("About") image = Gtk.Image() image.set_from_pixbuf(icon_pixbuf) logo_button.set_image(image) hbox.pack_start(logo_button, expand=False, fill=False) #the box containing all the input: ibox = Gtk.VBox(False, 0) ibox.set_spacing(3) vbox.pack_start(ibox) # Description al = Gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0) al.add(Gtk.Label("Please describe the problem:")) ibox.pack_start(al) #self.description = Gtk.Entry(max=128) #self.description.set_width_chars(40) self.description = Gtk.TextView() self.description.set_accepts_tab(True) self.description.set_justification(Gtk.Justification.LEFT) self.description.set_border_width(2) self.description.set_size_request(300, 80) #self.description.modify_bg(Gtk.StateType.NORMAL, Gdk.Color(red=32768, green=32768, blue=32768)) ibox.pack_start(self.description, expand=False, fill=False) # Toggles: al = Gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0) al.add(Gtk.Label("Include:")) ibox.pack_start(al) #generic toggles: from xpra.gtk_common.keymap import get_gtk_keymap from xpra.codecs.loader import codec_versions, load_codecs load_codecs() try: from xpra.sound.wrapper import query_sound def get_sound_info(): return query_sound() except ImportError: get_sound_info = None def get_gl_info(): if self.opengl_info: return self.opengl_info from xpra.net.net_util import get_info as get_net_info from xpra.platform.paths import get_info as get_path_info from xpra.platform.gui import get_info as get_gui_info from xpra.version_util import get_version_info, get_platform_info, get_host_info def get_sys_info(): from xpra.platform.info import get_user_info from xpra.scripts.config import read_xpra_defaults return { "argv": sys.argv, "path": sys.path, "exec_prefix": sys.exec_prefix, "executable": sys.executable, "version": get_version_info(), "platform": get_platform_info(), "host": get_host_info(OBFUSCATE), "paths": get_path_info(), "gtk": get_gtk_version_info(), "gui": get_gui_info(), "display": get_display_info(), "user": get_user_info(), "env": os.environ, "config": read_xpra_defaults(), } get_screenshot, take_screenshot_fn = None, None #screenshot: may have OS-specific code try: from xpra.platform.gui import take_screenshot take_screenshot_fn = take_screenshot except ImportError: log("failed to load platfrom specific screenshot code", exc_info=True) if not take_screenshot_fn: #try with Pillow: try: from PIL import ImageGrab #@UnresolvedImport from io import BytesIO def pillow_imagegrab_screenshot(): img = ImageGrab.grab() out = BytesIO() img.save(out, format="PNG") v = out.getvalue() out.close() return (img.width, img.height, "png", img.width * 3, v) take_screenshot_fn = pillow_imagegrab_screenshot except Exception as e: log("cannot use Pillow's ImageGrab: %s", e) if not take_screenshot_fn: #default: gtk screen capture try: from xpra.server.shadow.gtk_root_window_model import GTKImageCapture rwm = GTKImageCapture(get_default_root_window()) take_screenshot_fn = rwm.take_screenshot except Exception: log.warn("Warning: failed to load gtk screenshot code", exc_info=True) log("take_screenshot_fn=%s", take_screenshot_fn) if take_screenshot_fn: def _get_screenshot(): #take_screenshot() returns: w, h, "png", rowstride, data return take_screenshot_fn()[4] get_screenshot = _get_screenshot def get_server_log(): return self.server_log self.toggles = ( ("system", "txt", "System", get_sys_info, True, "Xpra version, platform and host information - including hostname and account information" ), ("server-log", "txt", "Server Log", get_server_log, bool(self.server_log), "Xpra version, platform and host information - including hostname and account information" ), ("network", "txt", "Network", get_net_info, True, "Compression, packet encoding and encryption"), ("encoding", "txt", "Encodings", codec_versions, bool(codec_versions), "Picture encodings supported"), ("opengl", "txt", "OpenGL", get_gl_info, bool(self.opengl_info), "OpenGL driver and features"), ("sound", "txt", "Sound", get_sound_info, bool(get_sound_info), "Sound codecs and GStreamer version information"), ("keyboard", "txt", "Keyboard Mapping", get_gtk_keymap, True, "Keyboard layout and key mapping"), ("xpra-info", "txt", "Server Info", self.get_server_info, bool(self.get_server_info), "Full server information from 'xpra info'"), ("screenshot", "png", "Screenshot", get_screenshot, bool(get_screenshot), ""), ) self.checkboxes = {} for name, _, title, value_cb, sensitive, tooltip in self.toggles: cb = Gtk.CheckButton(title + [" (not available)", ""][bool(value_cb)]) cb.set_active(self.includes.get(name, True)) cb.set_sensitive(sensitive) cb.set_tooltip_text(tooltip) ibox.pack_start(cb) self.checkboxes[name] = cb # Buttons: hbox = Gtk.HBox(False, 20) vbox.pack_start(hbox) def btn(label, tooltip, callback, icon_name=None): btn = Gtk.Button(label) btn.set_tooltip_text(tooltip) btn.connect("clicked", callback) if icon_name: icon = get_icon_pixbuf(icon_name) if icon: btn.set_image(scaled_image(icon, 24)) hbox.pack_start(btn) return btn btn("Copy to clipboard", "Copy all data to clipboard", self.copy_clicked, "clipboard.png") btn("Save", "Save Bug Report", self.save_clicked, "download.png") btn("Cancel", "", self.close, "quit.png") def accel_close(*_args): self.close() add_close_accel(self.window, accel_close) vbox.show_all() self.window.vbox = vbox self.window.add(vbox)
def __init__(self, gamemodel): GObject.GObject.__init__(self) self.gamemodel = gamemodel self.cids = {} self.closed = False tabcontent, white_label, black_label, game_info_label = self.initTabcontents( ) boardvbox, board, infobar, clock = self.initBoardAndClock(gamemodel) statusbar, stat_hbox = self.initStatusbar(board) self.tabcontent = tabcontent self.player_name_labels = (white_label, black_label) self.game_info_label = game_info_label self.board = board self.statusbar = statusbar self.infobar = infobar infobar.connect("hide", self.infobar_hidden) self.game_ended_message = None self.clock = clock self.notebookKey = Gtk.Alignment() self.boardvbox = boardvbox self.stat_hbox = stat_hbox self.menuitems = MenuItemsDict(self) gamemodel.connect_after("game_started", self.game_started) gamemodel.connect_after("game_ended", self.game_ended) gamemodel.connect_after("game_changed", self.game_changed) gamemodel.connect("game_paused", self.game_paused) gamemodel.connect("game_resumed", self.game_resumed) gamemodel.connect("moves_undone", self.moves_undone) gamemodel.connect("game_unended", self.game_unended) gamemodel.connect("game_saved", self.game_saved) gamemodel.connect("players_changed", self.players_changed) gamemodel.connect("analyzer_added", self.analyzer_added) gamemodel.connect("analyzer_removed", self.analyzer_removed) gamemodel.connect("analyzer_resumed", self.analyzer_resumed) gamemodel.connect("analyzer_paused", self.analyzer_paused) gamemodel.connect("message_received", self.message_received) self.players_changed(gamemodel) if self.gamemodel.display_text: if isinstance(gamemodel, ICGameModel): self.game_info_label.set_text("%s [%s]" % ( self.display_text, self.gamemodel.ficsgame.gameno)) else: self.game_info_label.set_text(self.display_text) if gamemodel.timed: gamemodel.timemodel.connect("zero_reached", self.zero_reached) if isinstance(gamemodel, ICGameModel): gamemodel.connection.bm.connect("player_lagged", self.player_lagged) gamemodel.connection.bm.connect("opp_not_out_of_time", self.opp_not_out_of_time) board.view.connect("shownChanged", self.shownChanged) def do_load_panels(event): self.panels = [panel.Sidepanel().load(self) for panel in sidePanels] if event is not None: event.set() thread = currentThread() if thread.name == "MainThread": do_load_panels(None) else: event = threading.Event() GLib.idle_add(do_load_panels, event) event.wait() if isinstance(gamemodel, ICGameModel): gamemodel.gmwidg_ready.set()
def __init__(self, gamemodel, perspective): GObject.GObject.__init__(self) self.gamemodel = gamemodel self.perspective = perspective self.cids = {} self.closed = False # InfoBarMessage with rematch, undo or observe buttons self.game_ended_message = None self.tabcontent, white_label, black_label, self.game_info_label = self.initTabcontents( ) self.boardvbox, self.board, self.infobar, self.clock = self.initBoardAndClock( self.gamemodel) self.stat_hbox = self.initButtons(self.board) self.player_name_labels = (white_label, black_label) self.infobar.connect("hide", self.infobar_hidden) self.notebookKey = Gtk.Alignment() self.menuitems = MenuItemsDict() self.gamemodel_cids = [ self.gamemodel.connect_after("game_started", self.game_started), self.gamemodel.connect_after("game_ended", self.game_ended), self.gamemodel.connect_after("game_changed", self.game_changed), self.gamemodel.connect("game_paused", self.game_paused), self.gamemodel.connect("game_resumed", self.game_resumed), self.gamemodel.connect("moves_undone", self.moves_undone), self.gamemodel.connect("game_unended", self.game_unended), self.gamemodel.connect("game_saved", self.game_saved), self.gamemodel.connect("players_changed", self.players_changed), self.gamemodel.connect("analyzer_added", self.analyzer_added), self.gamemodel.connect("analyzer_removed", self.analyzer_removed), self.gamemodel.connect("message_received", self.message_received), ] self.players_changed(self.gamemodel) self.notify_cids = [ conf.notify_add("showFICSgameno", self.on_show_fics_gameno), ] if self.gamemodel.display_text: if isinstance(self.gamemodel, ICGameModel) and conf.get("showFICSgameno"): self.game_info_label.set_text( "%s [%s]" % (self.display_text, self.gamemodel.ficsgame.gameno)) else: self.game_info_label.set_text(self.display_text) if self.gamemodel.timed: self.cids[ self.gamemodel.timemodel] = self.gamemodel.timemodel.connect( "zero_reached", self.zero_reached) self.connections = defaultdict(list) if isinstance(self.gamemodel, ICGameModel): self.connections[self.gamemodel.connection.bm].append( self.gamemodel.connection.bm.connect("player_lagged", self.player_lagged)) self.connections[self.gamemodel.connection.bm].append( self.gamemodel.connection.bm.connect("opp_not_out_of_time", self.opp_not_out_of_time)) self.cids[self.board.view] = self.board.view.connect( "shownChanged", self.shownChanged) if isinstance(self.gamemodel, ICGameModel): self.gamemodel.gmwidg_ready.set()
def do_create_window(self): self.window = Gtk.Window() self.window.set_border_width(20) self.window.connect("delete-event", self.destroy) self.window.set_default_size(400, 260) self.window.set_title("Xpra Launcher") self.window.set_position(Gtk.WindowPosition.CENTER) self.window.set_wmclass("xpra-launcher-gui", "Xpra-Launcher-GUI") add_close_accel(self.window, self.destroy) icon = get_icon_pixbuf("connect.png") if icon: self.window.set_icon(icon) hb = Gtk.HeaderBar() hb.set_show_close_button(True) hb.props.title = "Session Launcher" self.window.set_titlebar(hb) hb.add(self.button("About", "help-about", about)) self.bug_tool = None def bug(*_args): if self.bug_tool is None: from xpra.client.gtk_base.bug_report import BugReport self.bug_tool = BugReport() self.bug_tool.init(show_about=False) self.bug_tool.show() hb.add(self.button("Bug Report", "bugs", bug)) if has_mdns(): self.mdns_gui = None def mdns(*_args): if self.mdns_gui is None: from xpra.client.gtk_base.mdns_gui import mdns_sessions self.mdns_gui = mdns_sessions(self.config) def close_mdns(): self.mdns_gui.destroy() self.mdns_gui = None self.mdns_gui.do_quit = close_mdns else: self.mdns_gui.present() hb.add(self.button("Browse Sessions", "mdns", mdns)) hb.show_all() vbox = Gtk.VBox(False, 0) vbox.set_spacing(15) # Title label = Gtk.Label("Connect to xpra server") label.modify_font(Pango.FontDescription("sans 14")) vbox.pack_start(label) # Mode: hbox = Gtk.HBox(False, 5) self.mode_combo = Gtk.ComboBoxText() for x in self.get_connection_modes(): self.mode_combo.append_text(x.upper()) self.mode_combo.connect("changed", self.mode_changed) hbox.pack_start(Gtk.Label("Mode: "), False, False) hbox.pack_start(self.mode_combo, False, False) align_hbox = Gtk.Alignment(xalign = .5) align_hbox.add(hbox) vbox.pack_start(align_hbox) # Username@Host:Port (ssh -> ssh, proxy) vbox_proxy = Gtk.VBox(False, 15) hbox = Gtk.HBox(False, 5) self.proxy_vbox = vbox_proxy self.proxy_username_entry = Gtk.Entry() self.proxy_username_entry.set_max_length(128) self.proxy_username_entry.set_width_chars(16) self.proxy_username_entry.connect("changed", self.validate) self.proxy_username_entry.connect("activate", self.connect_clicked) self.proxy_username_entry.set_tooltip_text("username") self.proxy_host_entry = Gtk.Entry() self.proxy_host_entry.set_max_length(128) self.proxy_host_entry.set_width_chars(24) self.proxy_host_entry.connect("changed", self.validate) self.proxy_host_entry.connect("activate", self.connect_clicked) self.proxy_host_entry.set_tooltip_text("hostname") self.proxy_port_entry = Gtk.Entry() self.proxy_port_entry.set_max_length(5) self.proxy_port_entry.set_width_chars(5) self.proxy_port_entry.connect("changed", self.validate) self.proxy_port_entry.connect("activate", self.connect_clicked) self.proxy_port_entry.set_tooltip_text("SSH port") hbox.pack_start(Gtk.Label("Proxy: "), False, False) hbox.pack_start(self.proxy_username_entry, True, True) hbox.pack_start(Gtk.Label("@"), False, False) hbox.pack_start(self.proxy_host_entry, True, True) hbox.pack_start(self.proxy_port_entry, False, False) vbox_proxy.pack_start(hbox) # Password hbox = Gtk.HBox(False, 5) self.proxy_password_hbox = hbox self.proxy_password_entry = Gtk.Entry() self.proxy_password_entry.set_max_length(128) self.proxy_password_entry.set_width_chars(30) self.proxy_password_entry.set_text("") self.proxy_password_entry.set_visibility(False) self.proxy_password_entry.connect("changed", self.password_ok) self.proxy_password_entry.connect("changed", self.validate) self.proxy_password_entry.connect("activate", self.connect_clicked) hbox.pack_start(Gtk.Label("Proxy Password"), False, False) hbox.pack_start(self.proxy_password_entry, True, True) vbox_proxy.pack_start(hbox) # Private key hbox = Gtk.HBox(False, 5) self.pkey_hbox = hbox self.proxy_key_label = Gtk.Label("Proxy private key path (PPK):") self.proxy_key_entry = Gtk.Entry() self.proxy_key_browse = Gtk.Button("Browse") self.proxy_key_browse.connect("clicked", self.proxy_key_browse_clicked) hbox.pack_start(self.proxy_key_label, False, False) hbox.pack_start(self.proxy_key_entry, True, True) hbox.pack_start(self.proxy_key_browse, False, False) vbox_proxy.pack_start(hbox) # Check boxes hbox = Gtk.HBox(False, 5) self.check_boxes_hbox = hbox self.password_scb = Gtk.CheckButton("Server password same as proxy") self.password_scb.set_mode(True) self.password_scb.set_active(True) self.password_scb.connect("toggled", self.validate) align_password_scb = Gtk.Alignment(xalign = 1.0) align_password_scb.add(self.password_scb) self.username_scb = Gtk.CheckButton("Server username same as proxy") self.username_scb.set_mode(True) self.username_scb.set_active(True) self.username_scb.connect("toggled", self.validate) align_username_scb = Gtk.Alignment(xalign = 0.0) align_username_scb.add(self.username_scb) hbox.pack_start(align_username_scb, True, True) hbox.pack_start(align_password_scb, True, True) vbox_proxy.pack_start(hbox) # condiditonal stuff that goes away for "normal" ssh vbox.pack_start(vbox_proxy) # Username@Host:Port (main) hbox = Gtk.HBox(False, 5) self.username_entry = Gtk.Entry() self.username_entry.set_max_length(128) self.username_entry.set_width_chars(16) self.username_entry.connect("changed", self.validate) self.username_entry.connect("activate", self.connect_clicked) self.username_entry.set_tooltip_text("username") self.host_entry = Gtk.Entry() self.host_entry.set_max_length(128) self.host_entry.set_width_chars(24) self.host_entry.connect("changed", self.validate) self.host_entry.connect("activate", self.connect_clicked) self.host_entry.set_tooltip_text("hostname") self.ssh_port_entry = Gtk.Entry() self.ssh_port_entry.set_max_length(5) self.ssh_port_entry.set_width_chars(5) self.ssh_port_entry.connect("changed", self.validate) self.ssh_port_entry.connect("activate", self.connect_clicked) self.ssh_port_entry.set_tooltip_text("SSH port") self.port_entry = Gtk.Entry() self.port_entry.set_max_length(5) self.port_entry.set_width_chars(5) self.port_entry.connect("changed", self.validate) self.port_entry.connect("activate", self.connect_clicked) self.port_entry.set_tooltip_text("port/display") hbox.pack_start(Gtk.Label("Server:"), False, False) hbox.pack_start(self.username_entry, True, True) hbox.pack_start(Gtk.Label("@"), False, False) hbox.pack_start(self.host_entry, True, True) hbox.pack_start(self.ssh_port_entry, False, False) hbox.pack_start(Gtk.Label(":"), False, False) hbox.pack_start(self.port_entry, False, False) vbox.pack_start(hbox) # Password hbox = Gtk.HBox(False, 5) self.password_hbox = hbox self.password_entry = Gtk.Entry() self.password_entry.set_max_length(128) self.password_entry.set_width_chars(30) self.password_entry.set_text("") self.password_entry.set_visibility(False) self.password_entry.connect("changed", self.password_ok) self.password_entry.connect("changed", self.validate) self.password_entry.connect("activate", self.connect_clicked) hbox.pack_start(Gtk.Label("Server Password:"******"Disable Strict Host Key Check") self.nostrict_host_check.set_active(False) al = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0) al.add(self.nostrict_host_check) hbox.pack_start(al) vbox.pack_start(hbox) # Info Label self.info = Gtk.Label() self.info.set_line_wrap(True) self.info.set_size_request(360, -1) self.info.modify_fg(Gtk.StateType.NORMAL, red) vbox.pack_start(self.info) hbox = Gtk.HBox(False, 0) hbox.set_spacing(20) self.advanced_options_check = Gtk.CheckButton("Advanced Options") self.advanced_options_check.connect("toggled", self.advanced_options_toggled) self.advanced_options_check.set_active(False) al = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0) al.add(self.advanced_options_check) hbox.pack_start(al) vbox.pack_start(hbox) self.advanced_box = Gtk.VBox() vbox.pack_start(self.advanced_box) # Encoding: hbox = Gtk.HBox(False, 20) hbox.set_spacing(20) hbox.pack_start(Gtk.Label("Encoding: ")) self.encoding_combo = Gtk.MenuButton() encodings = ["auto"]+[x for x in PREFERRED_ENCODING_ORDER] server_encodings = encodings es = make_encodingsmenu(self.get_current_encoding, self.set_new_encoding, encodings, server_encodings) self.encoding_combo.set_popup(es) hbox.pack_start(self.encoding_combo) self.advanced_box.pack_start(hbox) self.set_new_encoding(self.config.encoding) # Sharing: self.sharing = Gtk.CheckButton("Sharing") self.sharing.set_active(bool(self.config.sharing)) self.sharing.set_tooltip_text("allow multiple concurrent users to connect") al = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.0, yscale=0) al.add(self.sharing) self.advanced_box.pack_start(al) # Buttons: hbox = Gtk.HBox(False, 20) vbox.pack_start(hbox) #Save: self.save_btn = Gtk.Button("Save") self.save_btn.set_tooltip_text("Save settings to a session file") self.save_btn.connect("clicked", self.save_clicked) hbox.pack_start(self.save_btn) #Load: self.load_btn = Gtk.Button("Load") self.load_btn.set_tooltip_text("Load settings from a session file") self.load_btn.connect("clicked", self.load_clicked) hbox.pack_start(self.load_btn) # Connect button: self.connect_btn = Gtk.Button("Connect") self.connect_btn.connect("clicked", self.connect_clicked) connect_icon = get_icon_pixbuf("retry.png") if connect_icon: self.connect_btn.set_image(scaled_image(connect_icon, 24)) hbox.pack_start(self.connect_btn) vbox.show_all() self.advanced_options_toggled() self.window.vbox = vbox self.window.add(vbox)
def __init__(self, text_label=None, icon_name=None, text_maxlen=60, xo_color=None, file_name=None, accelerator=None): Gtk.EventBox.__init__(self) self.set_above_child(True) self.icon = None self._hbox = Gtk.HBox() vbox = Gtk.VBox() self.add(vbox) vbox.show() hbox = Gtk.HBox() vbox.pack_start(hbox, True, True, style.DEFAULT_PADDING) hbox.show() hbox.pack_start(self._hbox, True, True, style.DEFAULT_PADDING) if icon_name is not None: self.icon = Icon(icon_name=icon_name, pixel_size=style.SMALL_ICON_SIZE) if xo_color is not None: self.icon.props.xo_color = xo_color self._hbox.pack_start(self.icon, expand=False, fill=False, padding=style.DEFAULT_PADDING) elif file_name is not None: self.icon = Icon(file=file_name, pixel_size=style.SMALL_ICON_SIZE) if xo_color is not None: self.icon.props.xo_color = xo_color self._hbox.pack_start(self.icon, expand=False, fill=False, padding=style.DEFAULT_PADDING) align = Gtk.Alignment(xalign=0.0, yalign=0.5, xscale=0.0, yscale=0.0) self.label = Gtk.Label(text_label) if text_maxlen > 0: self.label.set_max_width_chars(text_maxlen) self.label.set_ellipsize(style.ELLIPSIZE_MODE_DEFAULT) align.add(self.label) self._hbox.pack_start(align, expand=True, fill=True, padding=style.DEFAULT_PADDING) self._accelerator_label = Gtk.AccelLabel('') if accelerator is not None: self._accelerator_label.set_text(accelerator) self._hbox.pack_start(self._accelerator_label, expand=False, fill=False, padding=style.DEFAULT_PADDING) self.id_bt_release_cb = self.connect('button-release-event', self.__button_release_cb) self.id_enter_notify_cb = self.connect('enter-notify-event', self.__enter_notify_cb) self.id_leave_notify_cb = self.connect('leave-notify-event', self.__leave_notify_cb) self.show_all()
def make_window(): window = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) window.set_title("Window Focus") window.set_size_request(640, 200) window.set_position(Gtk.WindowPosition.CENTER) window.connect("delete_event", Gtk.main_quit) icon = get_icon_pixbuf("windows.png") if icon: window.set_icon(icon) vbox = Gtk.VBox() hbox = Gtk.HBox() def add_btn(label, cb): b = Gtk.Button(label=label) def bcb(*_args): cb() b.connect('clicked', bcb) hbox.add(b) def restack_above(): window.get_window().restack(None, True) add_btn("Restack Above", restack_above) def restack_below(): window.get_window().restack(None, False) add_btn("Restack Below", restack_below) def _raise(): window.get_window().raise_() add_btn("Raise", _raise) def _lower(): window.get_window().lower() add_btn("Lower", _lower) vbox.add(hbox) N = 8 labels = [] font = Pango.FontDescription("sans 12") for _ in range(N): l = Gtk.Label() l.modify_font(font) labels.append(l) for l in labels: al = Gtk.Alignment(xalign=0, yalign=0.5, xscale=0.0, yscale=0) al.add(l) vbox.add(al) window.add(vbox) window.show_all() text = deque(maxlen=N) def update(s): text.append("%s: %s" % (datetime.now(), s)) for i, t in enumerate(text): labels[i].set_text(t) #self.selectX11FocusChange(self) def focus_in(_window, _event): update("focus-in-event") def focus_out(_window, _event): update("focus-out-event") def has_toplevel_focus(window, _event): update("has-toplevel-focus: %s" % window.has_toplevel_focus()) window.connect("focus-in-event", focus_in) window.connect("focus-out-event", focus_out) window.connect("notify::has-toplevel-focus", has_toplevel_focus) if POSIX and not OSX: from xpra.gtk_common.error import xlog from xpra.x11.gtk_x11.gdk_display_source import init_gdk_display_source from xpra.x11.gtk_x11.gdk_bindings import init_x11_filter from xpra.x11.bindings.window_bindings import X11WindowBindings #pylint: disable=no-name-in-module from xpra.os_util import is_Wayland if not is_Wayland(): #x11 focus events: gdk_win = window.get_window() xid = gdk_win.get_xid() init_gdk_display_source() os.environ["XPRA_X11_DEBUG_EVENTS"] = "FocusIn,FocusOut" init_x11_filter() with xlog: X11WindowBindings().selectFocusChange(xid) return window