def generate_widget(self, value): """Generate a special widget for font options""" self.widget = gtk.FontButton() self.set_value(value) if self.realtime: self.widget.connect("font-set", self.has_changed) return self.widget
def __init__(self): window = gtk.Window() window.connect('destroy', lambda w: gtk.main_quit()) vbox = gtk.VBox() window.add(vbox) hbox = gtk.HBox() vbox.pack_start(hbox, False) label = gtk.Label('Current Font:') hbox.pack_start(label, False) fontbutton = gtk.FontButton('Monospace Italic 14') fontbutton.set_use_font(True) fontbutton.set_title('Select a font') fontbutton.connect('font-set', self.font_set_cb) hbox.pack_start(fontbutton) self.fontbutton = fontbutton bbox = gtk.HButtonBox() vbox.pack_start(bbox, False) b = gtk.ToggleButton('use_font', False) b.connect('toggled', self.use_font_cb) b.set_active(True) bbox.pack_start(b) b = gtk.ToggleButton('use_size', False) b.connect('toggled', self.use_size_cb) b.set_active(False) bbox.pack_start(b) b = gtk.ToggleButton('show_style', False) b.connect('toggled', self.show_style_cb) b.set_active(True) bbox.pack_start(b) b = gtk.ToggleButton('show_size', False) b.connect('toggled', self.show_size_cb) b.set_active(True) bbox.pack_start(b) window.show_all() return
def _add_font_selection(self, table): # need to hardcode this, cannot register it as a preference table.add_inputs((('use_custom_font', 'bool', _('Use a custom font')), # T: option in preferences dialog )) table.preferences_sections['use_custom_font'] = 'GtkInterface' self.fontbutton = gtk.FontButton() self.fontbutton.set_use_font(True) # preview in button self.fontbutton.set_sensitive(False) text_style = self.ui.config.get_config_dict('<profile>/style.conf') try: font = text_style['TextView']['font'] if font: self.fontbutton.set_font_name(font) self.fontbutton.set_sensitive(True) table['use_custom_font'] = True except KeyError: pass table.widgets['use_custom_font'].connect( 'toggled', lambda o: self.fontbutton.set_sensitive(o.get_active())) self.fontbutton.set_size_request(100, -1) input_table_factory(((None, self.fontbutton), ), table)
def __init__(self, option): """ Constructor. @param cb: An instance of the application class. @type cb: pida.main.Application @param section: The configuration section that the widget is for. @type section: string @param key: The configuration key that the widget is for @type key: string """ widget = gtk.FontButton() registry_widget.__init__(self, widget, option)
def _create_custom_tab(self): # TODO: Improve this code (maybe a slave) box = gtk.VBox() table = gtk.Table() table.set_row_spacings(6) table.set_col_spacings(6) table.set_border_width(6) table.attach(gtk.Label(_('Font:')), 0, 1, 0, 1, yoptions=0, xoptions=0) settings = self.get_print_settings() font_name = settings.get('stoq-font-name') self.font_button = gtk.FontButton(font_name) table.attach(self.font_button, 1, 2, 0, 1, xoptions=0, yoptions=0) box.pack_start(table, False, False) box.show_all() return box
def __init__(self, sheriff_gtk, parent): # add command dialog gtk.Dialog.__init__( self, "Preferences", parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT, gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT), ) table = gtk.Table(4, 2) # console rate limit table.attach(gtk.Label("Console rate limit (kB/s)"), 0, 1, 0, 1, 0, 0) self.rate_limit_sb = gtk.SpinButton() self.rate_limit_sb.set_digits(0) self.rate_limit_sb.set_increments(1, 1000) self.rate_limit_sb.set_range(0, 999999) self.rate_limit_sb.set_value( sheriff_gtk.cmd_console.get_output_rate_limit()) table.attach(self.rate_limit_sb, 1, 2, 0, 1) # background color table.attach(gtk.Label("Console background color"), 0, 1, 1, 2, 0, 0) self.bg_color_bt = gtk.ColorButton( sheriff_gtk.cmd_console.get_background_color()) table.attach(self.bg_color_bt, 1, 2, 1, 2) # foreground color table.attach(gtk.Label("Console text color"), 0, 1, 2, 3, 0, 0) self.text_color_bt = gtk.ColorButton( sheriff_gtk.cmd_console.get_text_color()) table.attach(self.text_color_bt, 1, 2, 2, 3) # font table.attach(gtk.Label("Console font"), 0, 1, 3, 4, 0, 0) self.font_bt = gtk.FontButton(sheriff_gtk.cmd_console.get_font()) table.attach(self.font_bt, 1, 2, 3, 4) self.vbox.pack_start(table, False, False, 0) table.show_all()
def __init__(self, icon_name='font-preview', **kwargs): self._accelerator = None self._tooltip = None #self._palette_invoker = ToolInvoker() self._palette = None gobject.GObject.__init__(self, **kwargs) # The gtk.ToolButton has already added a normal button. # Replace it with a ColorButton font_button = gtk.FontButton() self.add(font_button) # The following is so that the behaviour on the toolbar is correct. font_button.set_relief(gtk.RELIEF_NONE) font_button.icon_size = gtk.ICON_SIZE_LARGE_TOOLBAR #self._palette_invoker.attach_tool(self) # This widget just proxies the following properties to the colorbutton font_button.connect('notify::font-name', self.__notify_change) font_button.connect('notify::show-style', self.__notify_change) font_button.connect('notify::show-size', self.__notify_change) font_button.connect('notify::icon-name', self.__notify_change) font_button.connect('notify::icon-size', self.__notify_change) font_button.connect('notify::title', self.__notify_change) font_button.connect('font-set', self.__font_set_cb) font_button.connect('can-activate-accel', self.__button_can_activate_accel_cb)
def __init__(self, box, conf, ind): self.conf = conf self.ind = ind for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] label = gtk.Label("Size / Font / Opacity :") label.set_alignment(0, 0.5) val = int(self.settings['width']) adjustment = gtk.Adjustment(value=val, lower=100, upper=2000, step_incr=10, page_incr=100, page_size=0) self.term_w = gtk.SpinButton(adjustment=adjustment, climb_rate=0.0, digits=0) val = int(self.settings['height']) adjustment = gtk.Adjustment(value=val, lower=100, upper=2000, step_incr=10, page_incr=100, page_size=0) self.term_h = gtk.SpinButton(adjustment=adjustment, climb_rate=0.0, digits=0) val = int(self.settings['opacity']) adjustment = gtk.Adjustment(value=val, lower=0, upper=100, step_incr=1, page_incr=10, page_size=0) self.term_opacity = gtk.SpinButton(adjustment=adjustment, climb_rate=0.0, digits=0) self.term_font = gtk.FontButton(self.settings['font']) hbox = gtk.HBox() hbox.set_spacing(10) hbox.pack_start(label, True) hbox.pack_start(self.term_w, False, False) hbox.pack_start(gtk.Label('x'), False, False) hbox.pack_start(self.term_h, False, False) hbox.pack_start(self.term_font, False, False) hbox.pack_end(self.term_opacity, False, False) box.pack_start(hbox, False, False) label = gtk.Label("Execute command :") label.set_alignment(0, 0.5) self.exec_cmd = gtk.Entry() self.exec_cmd.set_text(self.settings['exec_cmd']) hbox = gtk.HBox() hbox.set_spacing(10) hbox.pack_start(label, False, False) hbox.pack_end(self.exec_cmd, True) box.pack_start(hbox, False, False)
def initGUI(self, save_func=None): self.MainWin.set_modal(True) self.MainWin.props.allow_grow = False MainBox = gtk.VBox(spacing=5) MainBox.props.border_width = 5 self.MainWin.add(MainBox) GlobalConfFrame = gtk.Frame(label="Global Options") GlobalConfTable = gtk.Table(1, 2) GlobalConfTable.props.border_width = 5 GlobalConfTable.props.row_spacing = 5 GlobalConfTable.props.column_spacing = 5 GlobalConfFrame.add(GlobalConfTable) MainBox.pack_start(GlobalConfFrame) GlobalConfTable.attach(gtk.Label("Start Maximized:"), 1, 2, 1, 2, gtk.EXPAND) MaximizedConf = gtk.CheckButton() MaximizedConf.set_active(self.Config["start-maximized"]) MaximizedConf.connect("toggled", self.maximized_hook) GlobalConfTable.attach(MaximizedConf, 2, 3, 1, 2, gtk.EXPAND) TermConfFrame = gtk.Frame(label="Terminal Options") TermConfTable = gtk.Table(3, 2) TermConfTable.props.border_width = 5 TermConfTable.props.row_spacing = 5 TermConfTable.props.column_spacing = 5 TermConfFrame.add(TermConfTable) MainBox.pack_start(TermConfFrame) TermConfTable.attach(gtk.Label("Font:"), 1, 2, 1, 2, gtk.EXPAND) FontConf = gtk.FontButton(fontname=self.Config["font"]) FontConf.connect("font-set", self.font_hook) TermConfTable.attach(FontConf, 2, 3, 1, 2, gtk.EXPAND) SizeBox = gtk.HBox() SizeBox.props.spacing = 5 TermConfTable.attach(SizeBox, 1, 3, 2, 3) SizeBox.pack_start(gtk.Label("Min Width:"), fill=False, expand=False) WidthEntry = gtk.SpinButton( gtk.Adjustment(value=self.Config["min-width"], lower=1, upper=9999, step_incr=1)) WidthEntry.connect("value-changed", self.width_hook) SizeBox.pack_start(WidthEntry, fill=False, expand=False) SizeBox.pack_start(gtk.Label("Min Height:"), fill=False, expand=False) HeightEntry = gtk.SpinButton( gtk.Adjustment(value=self.Config["min-height"], lower=1, upper=9999, step_incr=1)) HeightEntry.connect("value-changed", self.height_hook) SizeBox.pack_start(HeightEntry, fill=False, expand=False) ConfirmBox = gtk.HBox(spacing=5) CancelButton = gtk.Button(stock=gtk.STOCK_CANCEL) ConfirmBox.pack_start(CancelButton, fill=False) SaveButton = gtk.Button(stock=gtk.STOCK_SAVE) ConfirmBox.pack_start(SaveButton, fill=False) MainBox.pack_start(ConfirmBox, fill=False, expand=False) # wire up behaviour CancelButton.connect("clicked", lambda discard: self.MainWin.destroy()) SaveButton.connect("clicked", self.save_hook, save_func) self.MainWin.show_all()
def __init__(self, application): gtk.ScrolledWindow.__init__(self) self.observer = Observer() self.objects = dict() from canvas import Canvas self.canvas = Canvas(application) self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) properties = gtk.VBox() self.add_with_viewport(properties) self.group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) #---START------------------------------------------------------- button = Button(_("General properties")) properties.pack_start(button, False, False) form = Form("general", self) button.add(form) form.add_section(_("Units")) entry = gtk.combo_box_new_text() entry.append_text(CENTIMETERS) entry.append_text(MILLIMETERS) entry.append_text(DOTS) entry.append_text(INCHES) entry.set_active(1) form.add_entry(_("Preferred linear unit"), entry, "linear-unit") entry = gtk.combo_box_new_text() entry.append_text(DEGREES) entry.append_text(RADIANS) entry.set_active(1) form.add_entry(_("Preferred angular unit"), entry, "angular-unit") #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Document properties")) properties.pack_start(button, False, False) form = Form("document", self) button.add(form) form.add_section(_("Size")) entry = LinearEntry() form.add_entry(_("Width"), entry, "width") entry = LinearEntry() form.add_entry(_("Height"), entry, "height") form.add_section(_("Margins")) entry = LinearEntry() form.add_entry(_("Top"), entry, "top-margin") entry = LinearEntry() form.add_entry(_("Bottom"), entry, "bottom-margin") entry = LinearEntry() form.add_entry(_("Left"), entry, "left-margin") entry = LinearEntry() form.add_entry(_("Right"), entry, "right-margin") form.add_section(_("Config")) entry = LinearEntry() form.add_entry(_("Grid size"), entry, "grid-size") entry = LinearEntry() form.add_entry(_("Guides size"), entry, "guides-size") entry = gtk.CheckButton(_("Show margins")) form.add_entry(None, entry, "margins-active") entry = gtk.CheckButton(_("Show guides")) form.add_entry(None, entry, "guides-active") entry = gtk.CheckButton(_("Show grid")) form.add_entry(None, entry, "grid-active") entry = gtk.CheckButton(_("Enable snap")) form.add_entry(None, entry, "snap") #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Line properties")) self.objects["Line"] = button properties.pack_start(button, False, False) form = SizedObjectForm("line", self) button.add(form) #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Box properties")) self.objects["Box"] = button properties.pack_start(button, False, False) form = ColorizedObjectForm("box", self) button.add(form) #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Rounded box properties")) self.objects["Rounded"] = button properties.pack_start(button, False, False) form = ColorizedObjectForm("rounded", self) button.add(form) form.add_section(_("Shape")) entry = LinearEntry() entry.set_value(0) form.add_entry(_("Radius"), entry, "radius") #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Text properties")) self.objects["Text"] = button properties.pack_start(button, False, False) form = ColorizedObjectForm("text", self) button.add(form) form.add_section(_("Format")) entry = gtk.FontButton() entry.connect("font-set", self.change_font) form.add_entry(_("Font"), entry, "font") entry = gtk.CheckButton(_("Preserve aspect")) entry.connect("toggled", self.preserve) form.add_entry(None, entry, "preserve") form.add_section(_("Text")) entry = TextPad(application) self.disconnect_handler = entry.buffer.connect("changed", self.changed) entry.connect("cursor-moved", self.cursor_moved) form.add_entry(None, entry, "text") #---END--------------------------------------------------------- #---START--------ARC properties----------------------------------------------- button = Button(_("Arc properties")) self.objects["Arc"] = button properties.pack_start(button, False, False) form = ColorizedObjectForm("arc", self) button.add(form) form.add_section(_("Angle")) self.angle_start = AngularEntry() form.add_entry(_("Start Angle"), self.angle_start, "start") self.angle_start.spin.connect("value-changed", self.change_angle_start) self.angle_stop = AngularEntry() form.add_entry(_("Stop Angle"), self.angle_stop, "stop") self.angle_stop.spin.connect("value-changed", self.change_angle_stop) form.add_section(_("Other")) self.closed_btn = gtk.CheckButton() form.add_entry(_("Closed Arc"), self.closed_btn, "closed") self.closed_btn.connect("toggled", self.close_arc) self.closed_at_centre_btn = gtk.CheckButton() self.closed_at_centre_btn.set_active(1) form.add_entry(_("Closed Arc at Centre"), self.closed_at_centre_btn, "closed-at-centre") self.closed_at_centre_btn.connect("toggled", self.close_at_centre_arc) #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Table properties")) self.objects["Table"] = button properties.pack_start(button, False, False) form = PositionedObjectForm("table", self) button.add(form) form.add_section(_("Spacing")) entry = LinearEntry() entry.set_value(0) form.add_entry(_("Vertical"), entry, "vertical-spacing") entry = LinearEntry() entry.set_value(0) form.add_entry(_("Horizontal"), entry, "horizontal-spacing") form.add_section(_("Size")) entry = LinearEntry() entry.set_value(1) entry.connect("value-changed", self.set_table_columns) form.add_entry(_("Columns"), entry, "columns") entry = LinearEntry() entry.set_value(5) entry.connect("value-changed", self.set_table_rows) form.add_entry(_("Rows"), entry, "rows") form.add_section(_("Color")) entry = gtk.ColorButton() form.add_entry(_("Stroke"), entry, "stroke") entry = gtk.ColorButton() form.add_entry(_("Fill"), entry, "fill") form.add_section(_("Format")) entry = gtk.FontButton() entry.connect("font-set", self.set_table_font) form.add_entry(_("Font"), entry, "font") form.add_section(_("Columns")) entry = ColumnsEditor() entry.add_column() entry.connect("width-edited", self.set_table_column_width) entry.connect("title-edited", self.set_table_column_title) form.add_entry(None, entry, "columns-editor") #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Barcode properties")) self.objects["BarCode"] = button properties.pack_start(button, False, False) form = ColorizedObjectForm("barcode", self) button.add(form) form.add_section(_("Barcode")) entry = gtk.combo_box_new_text() entry.connect("changed", self.changed_barcode_type) for type in sorted(barcodes, key=lambda type: barcodes[type]): entry.append_text(type) form.add_entry(_("Type"), entry, "type") entry = gtk.Entry() entry.connect("changed", self.changed_barcode_code) form.add_entry(_("Code"), entry, "code") #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Image properties")) self.objects["Image"] = button properties.pack_start(button, False, False) form = SizedObjectForm("image", self) button.add(form) form.add_section(_("Image")) def update_preview(dialog, preview): filename = dialog.get_preview_filename() try: pixbuf = gtk.gdk.pixbuf_new_from_file_at_size( filename, 128, 128) preview.set_from_pixbuf(pixbuf) have_preview = True except: have_preview = False dialog.set_preview_widget_active(have_preview) dialog = gtk.FileChooserDialog( title="Source image file", #parent = self, action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT), backend=None) preview = gtk.Image() dialog.set_preview_widget(preview) dialog.connect("update-preview", update_preview, preview) #dialog.set_transient_for(self) dialog.set_default_response(gtk.RESPONSE_OK) def add_filter(dialog, name, pattern, type=None): filter = gtk.FileFilter() filter.set_name(name) if type: filter.add_mime_type(type) filter.add_pattern(pattern) dialog.add_filter(filter) add_filter(dialog, "PNG files", "*.png", "image/png") add_filter(dialog, "JPG files", "*.jpg", "image/jpg") add_filter(dialog, "All files", "*") dialog.connect("file-activated", self.changed_image_file) entry = gtk.FileChooserButton(dialog) form.add_entry(_("Image file"), entry, "file", True) #---END--------------------------------------------------------- #---START------------------------------------------------------- button = Button(_("Chart properties")) self.objects["Chart"] = button properties.pack_start(button, False, False) form = SizedObjectForm("chart", self) button.add(form) form.add_section(_("Chart")) entry = gtk.combo_box_new_text() entry.connect("changed", self.changed_chart_type) for type in sorted(chart_types, key=lambda type: chart_types[type]): entry.append_text(type) form.add_entry(_("Type"), entry, "type") #---END--------------------------------------------------------- fill = gtk.Label("\n") properties.add(fill)
def show_configure(self): dialog = gtk.Dialog("Configure Python Console", geany.main_widgets.window, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT)) dialog.set_has_separator(True) content_area = dialog.get_content_area() content_area.set_border_width(6) vbox = gtk.VBox(spacing=6) vbox.set_border_width(6) lbl = gtk.Label() lbl.set_use_markup(True) lbl.set_markup("<b>General</b>") fra_general = gtk.Frame("") fra_general.set_shadow_type(gtk.SHADOW_NONE) fra_general.set_label_widget(lbl) al_general = gtk.Alignment(0.0, 0.0, 1.0, 1.0) al_general.set_padding(0, 0, 12, 0) fra_general.add(al_general) tbl = gtk.Table(3, 2, False) tbl.set_row_spacings(6) tbl.set_col_spacings(6) tbl.set_border_width(6) lbl = gtk.Label("Banner:") lbl.set_alignment(0.0, 0.0) tvw = gtk.TextView() tvw.get_buffer().set_text(self.banner) tvw.get_buffer().connect("changed", self.on_banner_changed) swin = gtk.ScrolledWindow() swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) swin.set_shadow_type(gtk.SHADOW_ETCHED_IN) swin.add(tvw) tbl.attach(lbl, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(swin, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0) lbl = gtk.Label("") lbl.set_alignment(0.0, 0.5) check = gtk.CheckButton("Use Readline") if self.use_rl_completer: check.set_active(True) check.connect("toggled", self.on_use_rl_completer_toggled) tbl.attach(lbl, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(check, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 0, 0) lbl = gtk.Label("") lbl.set_alignment(0.0, 0.5) lbl.set_use_markup(True) lbl.set_markup('<span size="small" style="italic">' + 'Note: General settings will be applied when console is reloaded.' + '</span>') tbl.attach(lbl, 0, 2, 2, 3, gtk.FILL, gtk.FILL, 0, 0) al_general.add(tbl) lbl = gtk.Label() lbl.set_use_markup(True) lbl.set_markup("<b>Appearances</b>") fra_appearances = gtk.Frame("") fra_appearances.set_shadow_type(gtk.SHADOW_NONE) fra_appearances.set_label_widget(lbl) al_appearances = gtk.Alignment(0.0, 0.0, 1.0, 1.0) al_appearances.set_padding(0, 0, 12, 0) fra_appearances.add(al_appearances) tbl = gtk.Table(3, 2, False) tbl.set_row_spacings(6) tbl.set_col_spacings(6) tbl.set_border_width(6) lbl = gtk.Label("Font:") lbl.set_alignment(0.0, 0.5) btn = gtk.FontButton(self.font) btn.connect("font-set", self.on_font_changed) tbl.attach(lbl, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) lbl = gtk.Label("FG Color:") lbl.set_alignment(0.0, 0.5) btn = gtk.ColorButton(gdk.color_parse(self.fg)) btn.connect("color-set", self.on_fg_color_changed) tbl.attach(lbl, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) lbl = gtk.Label("BG Color:") lbl.set_alignment(0.0, 0.5) btn = gtk.ColorButton(gdk.color_parse(self.bg)) btn.connect("color-set", self.on_bg_color_changed) tbl.attach(lbl, 0, 1, 2, 3, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) al_appearances.add(tbl) vbox.pack_start(fra_general, True, True, 0) vbox.pack_start(fra_appearances, False, True, 0) content_area.pack_start(vbox, True, True, 0) content_area.show_all() dialog.run() dialog.destroy()
def configure(self, dialog): vbox = gtk.VBox(spacing=6) vbox.set_border_width(6) lbl = gtk.Label() lbl.set_use_markup(True) lbl.set_markup("<b>General</b>") fra_general = gtk.Frame("") fra_general.set_shadow_type(gtk.SHADOW_NONE) fra_general.set_label_widget(lbl) al_general = gtk.Alignment(0.0, 0.0, 1.0, 1.0) al_general.set_padding(0, 0, 12, 0) fra_general.add(al_general) tbl = gtk.Table(3, 2, False) tbl.set_row_spacings(6) tbl.set_col_spacings(6) tbl.set_border_width(6) lbl = gtk.Label("Banner:") lbl.set_alignment(0.0, 0.0) tvw = gtk.TextView() tvw.get_buffer().set_text(self.banner) tvw.get_buffer().connect("changed", self.on_banner_changed) swin = gtk.ScrolledWindow() swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) swin.set_shadow_type(gtk.SHADOW_ETCHED_IN) swin.add(tvw) tbl.attach(lbl, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(swin, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL, 0, 0) lbl = gtk.Label("") lbl.set_alignment(0.0, 0.5) check = gtk.CheckButton("Use Readline") if self.use_rl_completer: check.set_active(True) check.connect("toggled", self.on_use_rl_completer_toggled) tbl.attach(lbl, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(check, 1, 2, 1, 2, gtk.FILL, gtk.FILL, 0, 0) lbl = gtk.Label("") lbl.set_alignment(0.0, 0.5) lbl.set_use_markup(True) lbl.set_markup( '<span size="small" style="italic">' + 'Note: General settings will be applied when console is reloaded.' + '</span>') tbl.attach(lbl, 0, 2, 2, 3, gtk.FILL, gtk.FILL, 0, 0) al_general.add(tbl) lbl = gtk.Label() lbl.set_use_markup(True) lbl.set_markup("<b>Appearances</b>") fra_appearances = gtk.Frame("") fra_appearances.set_shadow_type(gtk.SHADOW_NONE) fra_appearances.set_label_widget(lbl) al_appearances = gtk.Alignment(0.0, 0.0, 1.0, 1.0) al_appearances.set_padding(0, 0, 12, 0) fra_appearances.add(al_appearances) tbl = gtk.Table(3, 2, False) tbl.set_row_spacings(6) tbl.set_col_spacings(6) tbl.set_border_width(6) lbl = gtk.Label("Font:") lbl.set_alignment(0.0, 0.5) btn = gtk.FontButton(self.font) btn.connect("font-set", self.on_font_changed) tbl.attach(lbl, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 0, 1, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) lbl = gtk.Label("FG Color:") lbl.set_alignment(0.0, 0.5) btn = gtk.ColorButton(gdk.color_parse(self.fg)) btn.connect("color-set", self.on_fg_color_changed) tbl.attach(lbl, 0, 1, 1, 2, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 1, 2, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) lbl = gtk.Label("BG Color:") lbl.set_alignment(0.0, 0.5) btn = gtk.ColorButton(gdk.color_parse(self.bg)) btn.connect("color-set", self.on_bg_color_changed) tbl.attach(lbl, 0, 1, 2, 3, gtk.FILL, gtk.FILL, 0, 0) tbl.attach(btn, 1, 2, 2, 3, gtk.FILL | gtk.EXPAND, gtk.FILL, 0, 0) al_appearances.add(tbl) vbox.pack_start(fra_general, True, True, 0) vbox.pack_start(fra_appearances, False, True, 0) return vbox
def _addBasicSettingsPage(self): page = gtk.VBox(False, 5) self.pages["basicsettings"] = page page.set_border_width(5) page.show() self.append_page(page) self.set_page_title(page, "Select the basic button settings") self.set_page_type(page, gtk.ASSISTANT_PAGE_CONTENT) label = gtk.Label( "Please choose the basic layout settings of your buttons.") label.set_line_wrap(True) label.show() page.pack_start(label, True, True, 0) table = gtk.Table(rows=4, columns=2, homogeneous=False) table.show() # font label = gtk.Label("Button text font") label.show() table.attach(label, 0, 1, 0, 1) fontsel = gtk.FontButton() fontsel.set_show_size(True) if self.data["font"]: fontsel.set_font_name(self.data["font"]) else: self.data["font"] = fontsel.get_font_name() fontsel.show() fontsel.connect("font-set", self._cb_set_font) table.attach(fontsel, 1, 2, 0, 1) # strcolor label = gtk.Label("Button text color") label.show() table.attach(label, 0, 1, 1, 2) colorsel = gimpui.ColorSelector() if self.data["strcolor"]: colorsel.set_color(self.data["strcolor"]) else: self.data["strcolor"] = colorsel.get_color() colorsel.show() colorsel.connect("color-changed", self._cb_set_color, "strcolor", "basicsettings") table.attach(colorsel, 1, 2, 1, 2) # background toggle bgtoggle = gtk.CheckButton("Use a pattern for button") bgtoggle.set_active(self.data["usepattern"]) bgtoggle.show() table.attach(bgtoggle, 1, 2, 2, 3) # background color / pattern if self.data["usepattern"]: label = gtk.Label("Button pattern") else: label = gtk.Label("Button color") label.show() patternsel = gimpui.PatternSelectButton() if self.data["pattern"]: patternsel.set_pattern(self.data["pattern"]) patternsel.connect("pattern-set", self._cb_set_pattern) colorsel = gimpui.ColorSelector() if self.data["buttoncolor"]: colorsel.set_color(self.data["buttoncolor"]) else: self.data["buttoncolor"] = colorsel.get_color() colorsel.connect("color-changed", self._cb_set_color, "buttoncolor", "basicsettings") bgtoggle.connect("toggled", self._cb_bgtoggle_toggle, label, "Button pattern", patternsel, "Button color", colorsel) if self.data["usepattern"]: patternsel.show() else: colorsel.show() table.attach(label, 0, 1, 3, 4) table.attach(patternsel, 1, 2, 3, 4) table.attach(colorsel, 1, 2, 3, 4) page.pack_end(table)
def __init__(self, applet_name): DockXAppletDialog.__init__(self, applet_name) table = gtk.Table(2, 3) self.vbox.pack_start(table) self.font_button = gtk.FontButton() self.font_button.set_use_font(True) self.font_button.set_use_size(True) self.font_button.set_show_style(True) label = gtk.Label(_("Font:")) table.attach(label, 0, 1, 0, 1) self.font_button.set_title(_("Clock font")) self.font_button.connect("font_set", self.__set_font) table.attach(self.font_button, 1, 2, 0, 1) label = gtk.Label(_("Color:")) table.attach(label, 0, 1, 1, 2) self.color_button = gtk.ColorButton() self.color_button.set_title(_("Font color")) self.color_button.connect("color-set", self.__color_set) table.attach(self.color_button, 1, 2, 1, 2) self.date_cb = gtk.CheckButton(_("Show Date")) self.date_cb.connect("toggled", self.__cb_toggled, "show_date") table.attach(self.date_cb, 1, 2, 2, 3) frame = gtk.Frame() self.vbox.pack_start(frame) vbox = gtk.VBox() frame.add(vbox) self.custom_clock_cb = gtk.CheckButton(_("Use custom clock")) self.custom_clock_cb.connect("toggled", self.__cb_toggled, "use_custom_format") vbox.pack_start(self.custom_clock_cb) hbox = gtk.HBox() vbox.pack_start(hbox) self.cf_entry = gtk.Entry() self.cf_entry.set_tooltip_text( "The format is identical to gnome-panel clock's custom format. Google 'gnome-panel custom clock' for exampels." ) hbox.pack_start(self.cf_entry) self.cf_button = gtk.Button() image = gtk.image_new_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_SMALL_TOOLBAR) self.cf_button.add(image) self.cf_button.connect("clicked", self.__set_custom_format) hbox.pack_start(self.cf_button) hbox = gtk.HBox() self.vbox.pack_start(hbox) label = gtk.Label(_("Text direction: ")) hbox.pack_start(label) self.td_cbt = gtk.combo_box_new_text() self.td_cbt.append_text(_("default")) self.td_cbt.append_text(_("left-right")) self.td_cbt.append_text(_("top-down")) self.td_cbt.append_text(_("bottom-up")) self.td_cbt.connect("changed", self.__text_direction_changed) hbox.pack_start(self.td_cbt) self.show_all()
def __init__(self, parent, application): SettingsPage.__init__(self, parent, application, 'terminal', _('Terminal')) # create vte terminal options align_vte = gtk.Alignment(xscale=1) align_vte.set_padding(0, 10, 15, 15) self._vbox_vte = gtk.VBox(False, 0) self._radio_vte = gtk.RadioButton(label=_('VTE based terminal')) self._radio_vte.connect('toggled', self._parent.enable_save) # option for showing scrollbars self._checkbox_scrollbars_visible = gtk.CheckButton( _('Show scrollbars when needed')) self._checkbox_scrollbars_visible.connect('toggled', self._parent.enable_save) # option for custom font self._align_font = gtk.Alignment() self._align_font.set_padding(0, 0, 15, 15) hbox_font = gtk.HBox(False, 5) self._checkbox_system_font = gtk.CheckButton( _('Use the system fixed width font')) self._checkbox_system_font.connect('toggled', self.__toggled_system_font) label_font = gtk.Label(_('Font:')) label_font.set_alignment(0, 0.5) self._button_font = gtk.FontButton() self._button_font.connect('font-set', self._parent.enable_save) # option for cursor shape hbox_cursor_shape = gtk.HBox(False, 5) label_cursor_shape = gtk.Label(_('Cursor shape:')) label_cursor_shape.set_alignment(0, 0.5) list_cursor_shape = gtk.ListStore(str, int) list_cursor_shape.append((_('Block'), CursorShape.BLOCK)) list_cursor_shape.append((_('I-Beam'), CursorShape.IBEAM)) list_cursor_shape.append((_('Underline'), CursorShape.UNDERLINE)) cell_cursor_shape = gtk.CellRendererText() self._combobox_cursor_shape = gtk.ComboBox(list_cursor_shape) self._combobox_cursor_shape.connect('changed', self._parent.enable_save) self._combobox_cursor_shape.pack_start(cell_cursor_shape) self._combobox_cursor_shape.add_attribute(cell_cursor_shape, 'text', 0) # option for allowing bold text in terminal self._checkbox_allow_bold = gtk.CheckButton(_('Allow bold text')) self._checkbox_allow_bold.connect('toggled', self._parent.enable_save) # option for automatically hiding mouse when typing self._checkbox_autohide_mouse = gtk.CheckButton( _('Automatically hide mouse when typing')) self._checkbox_autohide_mouse.connect('toggled', self._parent.enable_save) # create external terminal options align_external = gtk.Alignment(xscale=1) align_external.set_padding(0, 0, 15, 15) self._vbox_external = gtk.VBox(False, 5) self._radio_external = gtk.RadioButton(group=self._radio_vte, label=_('External terminal')) vbox_command = gtk.VBox(False, 0) label_command = gtk.Label(_('Command line:')) label_command.set_alignment(0, 0.5) self._entry_command = gtk.Entry() self._entry_command.connect('changed', self._parent.enable_save) vbox_command2 = gtk.VBox(False, 0) label_command2 = gtk.Label( _('Command line for executing specific program:')) label_command2.set_alignment(0, 0.5) self._entry_command2 = gtk.Entry() self._entry_command2.connect('changed', self._parent.enable_save) label_note = gtk.Label( _('<small><i>Note:' '\n\tOmitting {0} will open new terminal application instead of tab.' '\n\t{0} will be replaced with socket/window id.' '\n\t{1} will be replaced with specified command and its parameters.' '\n\t{2} will be replaced with current working directory.' '</i></small>')) label_note.set_alignment(0, 0) label_note.set_use_markup(True) # pack interface hbox_font.pack_start(label_font, False, False, 0) hbox_font.pack_start(self._button_font, True, True, 0) self._align_font.add(hbox_font) hbox_cursor_shape.pack_start(label_cursor_shape, False, False, 0) hbox_cursor_shape.pack_start(self._combobox_cursor_shape, False, False, 0) vbox_command.pack_start(label_command, False, False, 0) vbox_command.pack_start(self._entry_command, False, False, 0) vbox_command2.pack_start(label_command2, False, False, 0) vbox_command2.pack_start(self._entry_command2, False, False, 0) self._vbox_vte.pack_start(self._checkbox_scrollbars_visible, False, False, 0) self._vbox_vte.pack_start(self._checkbox_system_font, False, False, 0) self._vbox_vte.pack_start(self._align_font, False, False, 0) self._vbox_vte.pack_start(hbox_cursor_shape, False, False, 5) self._vbox_vte.pack_start(self._checkbox_allow_bold, False, False, 0) self._vbox_vte.pack_start(self._checkbox_autohide_mouse, False, False, 0) self._vbox_external.pack_start(vbox_command, False, False, 0) self._vbox_external.pack_start(vbox_command2, False, False, 0) self._vbox_external.pack_start(label_note, False, False, 0) align_vte.add(self._vbox_vte) align_external.add(self._vbox_external) self.pack_start(self._radio_vte, False, False, 0) self.pack_start(align_vte, False, False, 0) self.pack_start(self._radio_external, False, False, 0) self.pack_start(align_external, False, False, 0)
def __init__(self, box, conf, ind): self.conf = conf self.ind = ind for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] table = gtk.Table(4, 2, False) label = gtk.Label("Line 1 :") label.set_alignment(0, 0.5) self.line1_format = gtk.Entry() self.line1_format.set_width_chars(10) self.line1_format.set_text(self.settings['line1']) map = label.get_colormap() colour = map.alloc_color(self.settings['line1_color']) self.line1_color = gtk.ColorButton(colour) self.line1_font = gtk.FontButton(self.settings['line1_font']) table.attach(label, 0, 1, 0, 1) table.attach(self.line1_format, 1, 2, 0, 1) table.attach(self.line1_color, 2, 3, 0, 1) table.attach(self.line1_font, 3, 4, 0, 1) label = gtk.Label("Line 2 :") label.set_alignment(0, 0.5) self.line2_format = gtk.Entry() self.line2_format.set_width_chars(10) self.line2_format.set_text(self.settings['line2']) colour = map.alloc_color(self.settings['line2_color']) self.line2_color = gtk.ColorButton(colour) self.line2_font = gtk.FontButton(self.settings['line2_font']) table.attach(label, 0, 1, 1, 2) table.attach(self.line2_format, 1, 2, 1, 2) table.attach(self.line2_color, 2, 3, 1, 2) table.attach(self.line2_font, 3, 4, 1, 2) label = gtk.Label(_("Tooltip :")) label.set_alignment(0, 0.5) self.tooltip_format = gtk.Entry() self.tooltip_format.set_width_chars(10) self.tooltip_format.set_text(self.settings['tooltip']) table.attach(label, 0, 1, 2, 3) table.attach(self.tooltip_format, 1, 2, 2, 3) box.pack_start(table, True) text_line1format = gtk.TextView() text_line1format.set_wrap_mode(gtk.WRAP_WORD) text_line1format.set_border_width(2) txt_buffer = text_line1format.get_buffer() txt_buffer.set_text(INFO) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(text_line1format) expander = gtk.expander_new_with_mnemonic("_Info") expander.add(sw) box.pack_start(table, False, False) box.pack_start(expander, True, True)
def __init__(self, box, conf, ind): self.conf = conf self.ind = ind self.settings = conf.launcher[ind] for key in settings: if not key in self.settings: self.settings[key] = settings[key] ### Active color - Padding hhbox = gtk.HBox(False, 0) hhbox.set_spacing(10) hbox = gtk.HBox(False, 0) hbox.set_spacing(10) label = gtk.Label('Active window color') map = label.get_colormap() colour = map.alloc_color(self.settings['active_color']) self.active_color = gtk.ColorButton(colour) self.active_color.set_use_alpha(True) self.active_color.set_alpha(self.settings['opacity']) hbox.pack_start(label, False) hbox.pack_start(self.active_color, False) hhbox.pack_start(hbox, False) hbox = gtk.HBox(False, 0) hbox.set_spacing(10) label = gtk.Label('Padding') adjustment = gtk.Adjustment(value=self.settings['padding'], lower=1, upper=25, step_incr=1, page_incr=10, page_size=0) self.padding = gtk.SpinButton(adjustment=adjustment, climb_rate=0.0, digits=0) hbox.pack_start(label, False) hbox.pack_start(self.padding, False) hhbox.pack_start(hbox, False) box.pack_start(hhbox, False) ### Show all windows - desktop position/name self.show_all_win_checkbox = gtk.CheckButton('Show all windows') self.show_all_win_checkbox.set_active( int(self.settings['show_all_win'])) box.pack_start(self.show_all_win_checkbox, False) ### Show desktop position/name showdesktopbox = gtk.HBox() self.show_desk_pos_checkbox = gtk.CheckButton('Show desktop position') self.show_desk_pos_checkbox.set_active( int(self.settings['show_desk_pos'])) showdesktopbox.pack_start(self.show_desk_pos_checkbox, True) self.show_desk_name_checkbox = gtk.CheckButton('Show desktop name') self.show_desk_name_checkbox.set_active( int(self.settings['show_desk_name'])) colour = map.alloc_color(self.settings['desktop_color']) self.desk_color = gtk.ColorButton(colour) self.desk_font = gtk.FontButton(self.settings['desktop_font']) showdesktopbox.pack_start(self.desk_font, True) showdesktopbox.pack_start(self.desk_color, False) box.pack_start(showdesktopbox, False) showdesknamebox = gtk.HBox(False, 0) showdesknamebox.set_border_width(0) showdesknamebox.set_spacing(10) label = gtk.Label(' ') showdesknamebox.pack_start(label, False) showdesknamebox.pack_start(self.show_desk_name_checkbox, False) box.pack_start(showdesknamebox, False) ### expand self.expand_checkbox = gtk.CheckButton( 'Fills space on the bar in fixed mode') self.expand_checkbox.set_active(int(self.settings['expand'])) box.pack_start(self.expand_checkbox, False)
class config(): def __init__(self, box, conf, ind): self.conf = conf self.ind = ind framebox = gtk.VBox(False, 0) framebox.set_border_width(5) framebox.set_spacing(10) box.pack_start(framebox) for key in settings: if not key in conf.launcher[ind]: conf.launcher[ind][key] = settings[key] self.settings = conf.launcher[ind] # make new array from string # because when you save the array, it looks like a string: [{'text':'\xd0\xa3\xd0\xa0\xd0\x90'}] # but when the load value, adeskbar takes it as a string type alarmlist_dict = {} alarmlist_str = self.settings['alarmlist'] settings['alarmlist'] = [] if str(alarmlist_str) != '[]': q = [] try: q = alarmlist_str[2:-2].split("}, {") except Exception, e: q.append(alarmlist_str[2:-2]) for a in q: paras = a[1:-1].split("', '") for line in paras: k, v = line.split("': '") alarmlist_dict[k] = v settings['alarmlist'].append(alarmlist_dict) alarmlist_dict = {} table = gtk.Table(4, 2, False) label = gtk.Label(_("Time :")) label.set_alignment(0, 0.5) self.time_format = gtk.Entry() self.time_format.set_width_chars(10) self.time_format.set_text(self.settings['time']) map = label.get_colormap() colour = map.alloc_color(self.settings['time_color']) self.time_color = gtk.ColorButton(colour) self.time_font = gtk.FontButton(self.settings['time_font']) table.attach(label, 0, 1, 0, 1) table.attach(self.time_format, 1, 2, 0, 1) table.attach(self.time_color, 2, 3, 0, 1) table.attach(self.time_font, 3, 4, 0, 1) label = gtk.Label(_("Date :")) label.set_alignment(0, 0.5) self.date_format = gtk.Entry() self.date_format.set_width_chars(10) self.date_format.set_text(self.settings['date']) colour = map.alloc_color(self.settings['date_color']) self.date_color = gtk.ColorButton(colour) self.date_font = gtk.FontButton(self.settings['date_font']) table.attach(label, 0, 1, 1, 2) table.attach(self.date_format, 1, 2, 1, 2) table.attach(self.date_color, 2, 3, 1, 2) table.attach(self.date_font, 3, 4, 1, 2) label = gtk.Label(_("Tooltip :")) label.set_alignment(0, 0.5) self.tooltip_format = gtk.Entry() self.tooltip_format.set_width_chars(10) self.tooltip_format.set_text(self.settings['tooltip']) table.attach(label, 0, 1, 2, 3) table.attach(self.tooltip_format, 1, 2, 2, 3) framebox.pack_start(table, True) text_timeformat = gtk.TextView() text_timeformat.set_wrap_mode(gtk.WRAP_WORD) text_timeformat.set_border_width(2) buffer = text_timeformat.get_buffer() buffer.set_text(INFO) sw = gtk.ScrolledWindow() sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) sw.add(text_timeformat) expander = gtk.expander_new_with_mnemonic(_("_Info")) expander.add(sw) framebox.pack_start(expander, True) self.mouseover_checkbox = gtk.CheckButton(_('Show on mouseover')) self.mouseover_checkbox.set_active(int( conf.launcher[ind]['mouseover'])) framebox.pack_end(self.mouseover_checkbox, False, False) bBox = gtk.VBox(False, 0) bBox.set_spacing(10) bBox.set_border_width(4) BoxListControls = gtk.HBox(False, 0) # ListStore self.view = View(self) self.view.connect("row-activated", self.edit_item) index = 0 if settings['alarmlist'] != []: for alarm in settings['alarmlist']: date_d = alarm['date_d'] date_m = alarm['date_m'] date_y = alarm['date_y'] time_h = alarm['time_h'] time_m = alarm['time_m'] day1 = alarm['day1'] day2 = alarm['day2'] day3 = alarm['day3'] day4 = alarm['day4'] day5 = alarm['day5'] day6 = alarm['day6'] day7 = alarm['day7'] soundfile = alarm['soundfile'] cmd = alarm['cmd'] text = alarm['text'] notify = alarm['notify'] remind = alarm['remind'] index = alarm['index'] self.view.add_launcher(date_d, date_m, date_y, time_h, time_m, day1, day2, day3, day4, day5, day6, day7, soundfile, cmd, text, notify, remind, index) self.view.model.connect("row-deleted", self.view.row_deleted) scrolled = gtk.ScrolledWindow() scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolled.add(self.view) scrolled.set_size_request(550, 100) frame = gtk.Frame() frame.add(scrolled) ## Control buttons for list # Add Launcher button = core.image_button(_('add new task'), './images/conf/add_custom.png', 24) button.connect("clicked", self.new_item_custom) BoxListControls.pack_start(button, False, False) # Remove button = core.image_button(_('remove'), './images/conf/remove.png', 24) button.connect("clicked", self.remove_item) BoxListControls.pack_start(button, False, False) bBox.pack_start(BoxListControls, False, False) bBox.pack_start(frame, False, False) framebox.pack_start(bBox, False, False)
def make_preferences_dialog(self): # TODO: switch to something declarative or at least clean-up the following mess self.prefs = prefs = gtk.Dialog(APP_NAME, None, gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)) prefs.connect("response", self.on_preferences_changed) prefs.connect("delete-event", self.on_preferences_changed) def on_sb_time_changed(widget, data=None): self.options.timeout = widget.get_value() self.logger.debug("Timeout value changed: %f." % self.options.timeout) def on_cbox_sizes_changed(widget, data=None): index = widget.get_active() self.options.font_size = FONT_SIZES.keys()[index] self.update_geometry() self.logger.debug("Window size changed: %s." % self.options.font_size) def on_cbox_modes_changed(widget, data=None): index = widget.get_active() self.options.key_mode = KEY_MODES.keys()[index] self.on_change_mode() self.logger.debug("Key mode changed: %s." % self.options.key_mode) def on_cbox_bak_changed(widget, data=None): index = widget.get_active() self.options.bak_mode = BAK_MODES.keys()[index] self.on_change_mode() self.logger.debug("Bak mode changed: %s." % self.options.bak_mode) def on_cbox_mods_changed(widget, data=None): index = widget.get_active() self.options.mods_mode = MODS_MODES.keys()[index] self.on_change_mode() self.logger.debug("Mods mode changed: %s." % self.options.mods_mode) def on_cbox_modsonly_changed(widget, data=None): self.options.mods_only = widget.get_active() self.on_change_mode() self.logger.debug("Modifiers only changed: %s." % self.options.mods_only) def on_cbox_visshift_changed(widget, data=None): self.options.vis_shift = widget.get_active() self.on_change_mode() self.logger.debug("Visible Shift changed: %s." % self.options.vis_shift) def on_cbox_visspace_changed(widget, data=None): self.options.vis_space = widget.get_active() self.on_change_mode() self.logger.debug("Show Whitespace changed: %s." % self.options.vis_space) def on_cbox_position_changed(widget, data=None): index = widget.get_active() new_position = POSITIONS.keys()[index] if new_position == 'fixed': new_geom = on_btn_sel_geom(widget) if not new_geom: self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) return elif self.options.position == 'fixed': # automatically clear geometry self.options.geometry = None self.options.position = new_position self.update_geometry() self.logger.debug("Window position changed: %s." % self.options.position) def on_cbox_screen_changed(widget, data=None): self.options.screen = widget.get_active() self.set_active_monitor(self.options.screen) self.logger.debug("Screen changed: %d." % self.options.screen) def on_cbox_persist_changed(widget, data=None): self.options.persist = widget.get_active() if not self.get_property('visible'): self.show() else: self.on_label_change(self.label.get_text()) self.logger.debug("Persistent changed: %s." % self.options.persist) def on_sb_compr_changed(widget, data=None): self.options.compr_cnt = widget.get_value_as_int() self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_cbox_compr_changed(widget, data=None): compr_enabled = widget.get_active() self.sb_compr.set_sensitive(compr_enabled) self.options.compr_cnt = self.sb_compr.get_value_as_int( ) if compr_enabled else 0 self.on_change_mode() self.logger.debug("Compress repeats value changed: %d." % self.options.compr_cnt) def on_btn_sel_geom(widget, data=None): try: ret = subprocess.check_output(['slop', '-f', '%x %y %w %h']) except subprocess.CalledProcessError: return False except OSError: msg = gtk.MessageDialog( parent=self, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK, message_format="Error running \"slop\"") msg.format_secondary_markup( "\"slop\" is required for interactive selection. " "See <a href=\"https://github.com/naelstrof/slop\">" "https://github.com/naelstrof/slop</a>") msg.run() msg.destroy() return False self.options.geometry = map(int, ret.split(' ')) self.update_geometry() self.btn_reset_geom.set_sensitive(True) return True def on_btn_reset_geom(widget, data=None): self.options.geometry = None if self.options.position == 'fixed': self.options.position = 'bottom' self.cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) self.update_geometry() widget.set_sensitive(False) def on_adj_opacity_changed(widget, data=None): self.options.opacity = widget.get_value() self.update_colors() def on_font_color_changed(widget, data=None): self.options.font_color = widget.get_color().to_string() self.update_colors() def on_bg_color_changed(widget, data=None): self.options.bg_color = widget.get_color().to_string() self.update_colors() def on_btn_font(widget, data=None): self.options.font_desc = widget.get_font_name() self.font = pango.FontDescription(self.options.font_desc) self.update_label() frm_main = gtk.Frame(_("Preferences")) frm_main.set_border_width(6) frm_time = gtk.Frame("<b>%s</b>" % _("Time")) frm_time.set_border_width(4) frm_time.get_label_widget().set_use_markup(True) frm_time.set_shadow_type(gtk.SHADOW_NONE) vbox_time = gtk.VBox(spacing=6) hbox_time = gtk.HBox() lbl_time1 = gtk.Label(_("Display for")) lbl_time2 = gtk.Label(_("seconds")) sb_time = gtk.SpinButton(digits=1) sb_time.set_increments(0.5, 1.0) sb_time.set_range(0.5, 10.0) sb_time.set_numeric(True) sb_time.set_update_policy(gtk.UPDATE_IF_VALID) sb_time.set_value(self.options.timeout) sb_time.connect("value-changed", on_sb_time_changed) hbox_time.pack_start(lbl_time1, expand=False, fill=False, padding=6) hbox_time.pack_start(sb_time, expand=False, fill=False, padding=4) hbox_time.pack_start(lbl_time2, expand=False, fill=False, padding=4) vbox_time.pack_start(hbox_time) chk_persist = gtk.CheckButton(_("Persistent window")) chk_persist.connect("toggled", on_cbox_persist_changed) chk_persist.set_active(self.options.persist) vbox_time.pack_start(chk_persist) frm_time.add(vbox_time) frm_time.show_all() frm_position = gtk.Frame("<b>%s</b>" % _("Position")) frm_position.set_border_width(4) frm_position.get_label_widget().set_use_markup(True) frm_position.set_shadow_type(gtk.SHADOW_NONE) vbox_position = gtk.VBox(spacing=6) lbl_screen = gtk.Label(_("Screen")) cbox_screen = gtk.combo_box_new_text() scr = self.get_screen() for n in range(scr.get_n_monitors()): cbox_screen.insert_text( n, '%d: %s' % (n, scr.get_monitor_plug_name(n))) cbox_screen.set_active(self.monitor) cbox_screen.connect("changed", on_cbox_screen_changed) hbox0_position = gtk.HBox() hbox0_position.pack_start(lbl_screen, expand=False, fill=False, padding=6) hbox0_position.pack_start(cbox_screen, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox0_position) lbl_positions = gtk.Label(_("Position")) self.cbox_positions = cbox_positions = gtk.combo_box_new_text() cbox_positions.set_name('position') for key, value in enumerate(POSITIONS): cbox_positions.insert_text(key, value) cbox_positions.set_active(POSITIONS.keys().index( self.options.position)) cbox_positions.connect("changed", on_cbox_position_changed) self.btn_reset_geom = btn_reset_geom = gtk.Button(_("Reset")) btn_reset_geom.connect("clicked", on_btn_reset_geom) btn_reset_geom.set_sensitive(self.options.geometry is not None) hbox1_position = gtk.HBox() hbox1_position.pack_start(lbl_positions, expand=False, fill=False, padding=6) hbox1_position.pack_start(cbox_positions, expand=False, fill=False, padding=4) hbox1_position.pack_start(btn_reset_geom, expand=False, fill=False, padding=4) vbox_position.pack_start(hbox1_position) btn_sel_geom = gtk.Button(_("Select window/region")) btn_sel_geom.connect("clicked", on_btn_sel_geom) vbox_position.pack_start(btn_sel_geom) frm_aspect = gtk.Frame("<b>%s</b>" % _("Aspect")) frm_aspect.set_border_width(4) frm_aspect.get_label_widget().set_use_markup(True) frm_aspect.set_shadow_type(gtk.SHADOW_NONE) vbox_aspect = gtk.VBox(spacing=6) frm_position.add(vbox_position) hbox0_font = gtk.HBox() lbl_font = gtk.Label(_("Font")) btn_font = gtk.FontButton(self.options.font_desc) btn_font.set_use_size(False) btn_font.set_show_size(False) btn_font.connect("font-set", on_btn_font) hbox0_font.pack_start(lbl_font, expand=False, fill=False, padding=6) hbox0_font.pack_start(btn_font, expand=False, fill=False, padding=4) hbox2_aspect = gtk.HBox() lbl_sizes = gtk.Label(_("Size")) cbox_sizes = gtk.combo_box_new_text() cbox_sizes.set_name('size') for key, value in enumerate(FONT_SIZES): cbox_sizes.insert_text(key, value) cbox_sizes.set_active(FONT_SIZES.keys().index(self.options.font_size)) cbox_sizes.connect("changed", on_cbox_sizes_changed) hbox2_aspect.pack_start(lbl_sizes, expand=False, fill=False, padding=6) hbox2_aspect.pack_start(cbox_sizes, expand=False, fill=False, padding=4) hbox3_font_color = gtk.HBox() lbl_font_color = gtk.Label(_("Font color")) btn_font_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.font_color)) btn_font_color.connect("color-set", on_font_color_changed) btn_bg_color = gtk.ColorButton( color=gtk.gdk.color_parse(self.options.bg_color)) btn_bg_color.connect("color-set", on_bg_color_changed) hbox3_font_color.pack_start(lbl_font_color, expand=False, fill=False, padding=6) hbox3_font_color.pack_start(btn_font_color, expand=False, fill=False, padding=4) hbox3_font_color.pack_start(btn_bg_color, expand=False, fill=False, padding=4) hbox4_aspect = gtk.HBox() lbl_opacity = gtk.Label(_("Opacity")) adj_opacity = gtk.Adjustment(self.options.opacity, 0.1, 1.0, 0.1, 0, 0) adj_opacity.connect("value-changed", on_adj_opacity_changed) adj_scale = gtk.HScale(adj_opacity) hbox4_aspect.pack_start(lbl_opacity, expand=False, fill=False, padding=6) hbox4_aspect.pack_start(adj_scale, expand=True, fill=True, padding=4) vbox_aspect.pack_start(hbox0_font) vbox_aspect.pack_start(hbox2_aspect) vbox_aspect.pack_start(hbox3_font_color) vbox_aspect.pack_start(hbox4_aspect) frm_aspect.add(vbox_aspect) frm_kbd = gtk.Frame("<b>%s</b>" % _("Keys")) frm_kbd.set_border_width(4) frm_kbd.get_label_widget().set_use_markup(True) frm_kbd.set_shadow_type(gtk.SHADOW_NONE) vbox_kbd = gtk.VBox(spacing=6) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Keyboard mode")) cbox_modes = gtk.combo_box_new_text() cbox_modes.set_name('mode') for key, value in enumerate(KEY_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(KEY_MODES.keys().index(self.options.key_mode)) cbox_modes.connect("changed", on_cbox_modes_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Backspace mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(BAK_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(BAK_MODES.keys().index(self.options.bak_mode)) cbox_modes.connect("changed", on_cbox_bak_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) hbox_kbd = gtk.HBox() lbl_kbd = gtk.Label(_("Modifiers mode")) cbox_modes = gtk.combo_box_new_text() for key, value in enumerate(MODS_MODES): cbox_modes.insert_text(key, value) cbox_modes.set_active(MODS_MODES.keys().index(self.options.mods_mode)) cbox_modes.connect("changed", on_cbox_mods_changed) hbox_kbd.pack_start(lbl_kbd, expand=False, fill=False, padding=6) hbox_kbd.pack_start(cbox_modes, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_kbd) chk_kbd = gtk.CheckButton(_("Show Modifier sequences only")) chk_kbd.connect("toggled", on_cbox_modsonly_changed) chk_kbd.set_active(self.options.mods_only) vbox_kbd.pack_start(chk_kbd) chk_kbd = gtk.CheckButton(_("Always show Shift")) chk_kbd.connect("toggled", on_cbox_visshift_changed) chk_kbd.set_active(self.options.vis_shift) vbox_kbd.pack_start(chk_kbd) chk_vspace = gtk.CheckButton(_("Show Whitespace characters")) chk_vspace.set_active(self.options.vis_space) chk_vspace.connect("toggled", on_cbox_visspace_changed) vbox_kbd.pack_start(chk_vspace) hbox_compr = gtk.HBox() chk_compr = gtk.CheckButton(_("Compress repeats after")) chk_compr.set_active(self.options.compr_cnt > 0) chk_compr.connect("toggled", on_cbox_compr_changed) self.sb_compr = sb_compr = gtk.SpinButton(digits=0) sb_compr.set_increments(1, 1) sb_compr.set_range(1, 100) sb_compr.set_numeric(True) sb_compr.set_update_policy(gtk.UPDATE_IF_VALID) sb_compr.set_value(self.options.compr_cnt or 3) sb_compr.connect("value-changed", on_sb_compr_changed) hbox_compr.pack_start(chk_compr, expand=False, fill=False) hbox_compr.pack_start(sb_compr, expand=False, fill=False, padding=4) vbox_kbd.pack_start(hbox_compr) frm_kbd.add(vbox_kbd) hbox_main = gtk.HBox() vbox_main = gtk.VBox() vbox_main.pack_start(frm_time, False, False, 6) vbox_main.pack_start(frm_position, False, False, 6) vbox_main.pack_start(frm_aspect, False, False, 6) hbox_main.pack_start(vbox_main) vbox_main = gtk.VBox() vbox_main.pack_start(frm_kbd, False, False, 6) hbox_main.pack_start(vbox_main) frm_main.add(hbox_main) prefs.vbox.pack_start(frm_main) prefs.set_destroy_with_parent(True) prefs.set_resizable(False) prefs.set_has_separator(False) prefs.set_default_response(gtk.RESPONSE_CLOSE) prefs.vbox.show_all()
alignment.add(entry) table.attach(label, 0, 1, 4, 5, gtk.FILL, 0) table.attach(alignment, 1, 2, 4, 5, gtk.EXPAND | gtk.FILL, 0) label = gtk.Label(_("Fill color:")) label.set_alignment(0.0, 0.5) alignment = gtk.Alignment(0.0, 0.5) entry = gtk.ColorButton() alignment.add(entry) table.attach(label, 0, 1, 5, 6, gtk.FILL, 0) table.attach(alignment, 1, 2, 5, 6, gtk.EXPAND | gtk.FILL, 0) label = gtk.Label(_("Text:")) label.set_alignment(0.0, 0.5) alignment = gtk.Alignment(0.0, 0.5) entry = gtk.Entry() alignment.add(entry) table.attach(label, 0, 1, 6, 7, gtk.FILL, 0) table.attach(alignment, 1, 2, 6, 7, gtk.EXPAND | gtk.FILL, 0) label = gtk.Label(_("Font:")) label.set_alignment(0.0, 0.5) alignment = gtk.Alignment(0.0, 0.5) entry = gtk.FontButton() alignment.add(entry) table.attach(label, 0, 1, 7, 8, gtk.FILL, 0) table.attach(alignment, 1, 2, 7, 8, gtk.EXPAND | gtk.FILL, 0) window.show_all() gtk.main()