def select_font(cls, style, callback): '''select font and if available size and style, receives a e3.Message.Style object with the current style the callback receives a new style object with the new selection ''' def select_font_cb(button, window, callback, response, color_sel, color): '''callback called on button selection''' if response == stock.ACCEPT: window.hide() fdesc = pango.FontDescription(font_sel.get_font_name()) style = utils.pango_font_description_to_style(fdesc) style.color.red = color.red style.color.green = color.green style.color.blue = color.blue style.color.alpha = color.alpha callback(style) window.hide() window = cls.new_window('Select font') font_sel = gtk.FontSelection() font_sel.set_preview_text('OMG PONNIES! I\'m a preview text!') fdesc = utils.style_to_pango_font_description(style) window.hbox.pack_start(font_sel, True, True) font_sel.set_font_name(fdesc.to_string()) cls.add_button(window, gtk.STOCK_CANCEL, stock.CANCEL, callback, select_font_cb, font_sel, style.color) cls.add_button(window, gtk.STOCK_OK, stock.ACCEPT, callback, select_font_cb, font_sel, style.color) window.show_all()
def __init__(self, parent=None): debug.mainthreadTest() self.dialog = gtklogger.Dialog(title="OOF2 Font Selector", parent=parent) gtklogger.newTopLevelWidget(self.dialog, "FontSelector") self.dialog.add_button(gtk.STOCK_OK, self.OK) self.dialog.add_button(gtk.STOCK_CANCEL, self.CANCEL) self.fontselector = gtk.FontSelection() self.dialog.vbox.pack_start(self.fontselector, expand=1, fill=1)