def __get_layout(self, widget): context = widget.get_pango_context() layout = pango.Layout(context) fdesc = gtk.widget_get_default_style().font_desc layout.set_font_description(fdesc) layout.set_markup(self.get_property("content")) return layout
def notify(): if hasattr(self, 'popup_default_fg'): fgcol = self.popup_default_fg else: fgcol = gtk.widget_get_default_style().fg for s in [gtk.STATE_ACTIVE, gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED]: self.popupbutton.child.modify_fg(s, fgcol[s])
def _setup_font(self, font): ''' This should be set even for non-text columns. ::param font:: is None or a pango.FontDescription ''' default_font = gtk.widget_get_default_style().font_desc if font is None: font = default_font def_font_sz = float(default_font.get_size()) try: self.cellrenderer.set_property('font-desc', font) except TypeError: pass # how much has the font deviated from normal? self._font_ratio = font.get_size()/def_font_sz try: # adjust the display size of the column ratio = self._font_ratio # small fonts can be problematic.. # -> TODO: perhaps default widths could be specified # in character widths instead? then we could # calculate it instead of using arbitrary widths if ratio < 1: ratio = ratio * 1.25 self.size = max(int(self.size*ratio),1) except AttributeError: pass
def notify(): if hasattr(self, 'popup_default_fg'): fgcol = self.popup_default_fg else: fgcol = gtk.widget_get_default_style().fg for s in [ gtk.STATE_ACTIVE, gtk.STATE_NORMAL, gtk.STATE_PRELIGHT, gtk.STATE_SELECTED ]: self.popupbutton.child.modify_fg(s, fgcol[s])
def set_valid(self): """Changes the validation state to valid, which will remove icons and reset the background color """ log.debug('Setting state for %s to VALID' % self.model_attribute) self._set_valid_state(True) self._fade.stop() self._set_pixbuf(None) style = gtk.widget_get_default_style() self.update_background(style.base[gtk.STATE_NORMAL])
def set_valid(self): """Changes the validation state to valid, which will remove icons and reset the background color """ log.debug("Setting state for %s to VALID" % self.model_attribute) self._set_valid_state(True) self._fade.stop() self._set_pixbuf(None) style = gtk.widget_get_default_style() self.update_background(style.base[gtk.STATE_NORMAL])
def build_palette(self, gtksettings): style = gtk.rc_get_style_by_paths(gtksettings, 'GtkWindow', 'GtkWindow', gtk.Window) style = style or gtk.widget_get_default_style() # build pathbar color palette self.fg = PathBarColorArray(style.fg) self.bg = PathBarColorArray(style.bg) self.text = PathBarColorArray(style.text) self.base = PathBarColorArray(style.base) self.light = PathBarColorArray(style.base) self.mid = PathBarColorArray(style.base) self.dark = PathBarColorArray(style.base) return
def __init__(self, image_path): super(SelectableBoxesArea, self).__init__() self.image = goocanvas.Image() self.frame = [] self.setBackgroundImage(image_path) self.grab_focus(self.image) style = gtk.widget_get_default_style() self.set_property('background-color', style.bg[gtk.STATE_NORMAL].to_string()) self.get_root_item().add_child(self.image, -1) self.area_fill_rgba = (94, 156, 235, 150) self.area_stroke_rgba = (94, 156, 235, 250) self.area_selected_stroke_rgba = (255, 255, 0, 255) self.image.connect('button_press_event', self.startSelectionArea) self.image.connect('button_release_event', self.endSelectionArea) self.image.connect('motion_notify_event', self.updateSelectionArea) self.image.connect('key_press_event', self.pressedKeyOnImage) self.connect('scroll-event', self.scrollEventCb) self.selected_areas = [] self.currently_created_area = None
def get_layout(self, *args): if len(args) == 1: treeview, text = args[0], "" else: treeview, text = args context = treeview.get_pango_context() layout = pango.Layout(context) fdesc = gtk.widget_get_default_style().font_desc layout.set_font_description(fdesc) if text: layout.set_text(text) else: try: text = self.get_property("text") except AttributeError: text = "" layout.set_text(text) return layout
def __init__(self, app, gui): SidePanel.__init__(self) self.app = app ss = self.app.prefm.get_pref('sidepanel_switchonclick') self.switchsignal = 'clicked' if ss else 'enter' tc = gtk.widget_get_default_style().text[gtk.STATE_NORMAL] textcolor = "".join(map(chr, [tc.red, tc.green, tc.blue])) self.structbrowser = treestruct.StructBrowser() self.add_expander('struct', _("Structure"), self.structbrowser) for s in ['changetab', 'open', 'save', 'close']: gui.connect(s, self.update_structbrowser) self.structbrowser.activated_cb = self.ev_struct_activate self.syms = self.load_symbols_from_files() for categ in sorted(self.syms.keys()): pal = palette.Palette() for t in sorted(self.syms[categ].keys()): try: tool = self.syms[categ][t] pixb = gtk.gdk.pixbuf_new_from_file(tool['Img']) if self.app.prefm.get_pref('sidepanel_symcolorfromtheme'): datapix = pixb.get_pixels() datapix2 = "" for i in xrange(len(datapix)/4): datapix2 += textcolor + datapix[4*i+3] pixb = gtk.gdk.pixbuf_new_from_data(datapix2, pixb.get_colorspace(), pixb.get_has_alpha(), pixb.get_bits_per_sample(), pixb.get_width(), pixb.get_height(), pixb.get_rowstride()) tooltip = glib.markup_escape_text(tool['Insert']) pal.add_tool([t, tooltip, pixb]) except StandardError: msg = "sidepanel > can't load symbol '%s/%s'" % (categ,t) log(msg, 'warning') pal.set_item_activated_callback(self.insert_symbol, categ) name = self.get_local_name(tool) self.add_expander(categ, name, pal)
def _get_system_default_font(): return gtk.widget_get_default_style().font_desc.to_string()
def set_color(self, color=None): if color: self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) else: self.modify_bg(gtk.STATE_NORMAL, gtk.widget_get_default_style().bg_gc[gtk.STATE_NORMAL])