pylint combobox, iconentry and radiotoolbutton
This commit is contained in:
parent
97d9d21311
commit
8783d1113d
@ -14,9 +14,6 @@
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
import sys
|
||||
import os
|
||||
import logging
|
||||
|
||||
import gobject
|
||||
import gtk
|
||||
@ -54,7 +51,7 @@ class ComboBox(gtk.ComboBox):
|
||||
def _get_real_name_from_theme(self, name, size):
|
||||
icon_theme = gtk.icon_theme_get_default()
|
||||
width, height = gtk.icon_size_lookup(size)
|
||||
info = icon_theme.lookup_icon(name, width, 0)
|
||||
info = icon_theme.lookup_icon(name, max(width, height), 0)
|
||||
if not info:
|
||||
raise ValueError("Icon '" + name + "' not found.")
|
||||
fname = info.get_filename()
|
||||
@ -66,8 +63,9 @@ class ComboBox(gtk.ComboBox):
|
||||
self._icon_renderer = gtk.CellRendererPixbuf()
|
||||
|
||||
settings = self.get_settings()
|
||||
w, h = gtk.icon_size_lookup_for_settings(settings, gtk.ICON_SIZE_MENU)
|
||||
self._icon_renderer.props.stock_size = w
|
||||
w, h = gtk.icon_size_lookup_for_settings(
|
||||
settings, gtk.ICON_SIZE_MENU)
|
||||
self._icon_renderer.props.stock_size = max(w, h)
|
||||
|
||||
self.pack_start(self._icon_renderer, False)
|
||||
self.add_attribute(self._icon_renderer, 'pixbuf', 2)
|
||||
@ -87,7 +85,8 @@ class ComboBox(gtk.ComboBox):
|
||||
if icon_name:
|
||||
file_name = self._get_real_name_from_theme(icon_name, size)
|
||||
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(file_name, width, height)
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(
|
||||
file_name, width, height)
|
||||
else:
|
||||
pixbuf = None
|
||||
|
||||
@ -110,5 +109,4 @@ class ComboBox(gtk.ComboBox):
|
||||
self._model.clear()
|
||||
|
||||
def _is_separator(self, model, row):
|
||||
action_id, text, icon_name, is_separator = model[row]
|
||||
return is_separator
|
||||
return model[row][3]
|
||||
|
@ -21,7 +21,6 @@ from sugar import _sugarext
|
||||
|
||||
from sugar.graphics import style
|
||||
from sugar.graphics.icon import _SVGLoader
|
||||
import sugar.profile
|
||||
|
||||
ICON_ENTRY_PRIMARY = _sugarext.ICON_ENTRY_PRIMARY
|
||||
ICON_ENTRY_SECONDARY = _sugarext.ICON_ENTRY_SECONDARY
|
||||
@ -44,7 +43,6 @@ class IconEntry(_sugarext.IconEntry):
|
||||
|
||||
if icon_info.get_filename().endswith('.svg'):
|
||||
loader = _SVGLoader()
|
||||
color = sugar.profile.get_color()
|
||||
entities = {'fill_color': style.COLOR_TOOLBAR_GREY.get_svg(),
|
||||
'stroke_color': style.COLOR_TOOLBAR_GREY.get_svg()}
|
||||
handle = loader.load(icon_info.get_filename(), entities, None)
|
||||
|
@ -16,8 +16,6 @@
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
import logging
|
||||
|
||||
import gtk
|
||||
import gobject
|
||||
|
||||
@ -85,20 +83,22 @@ class RadioToolButton(gtk.RadioToolButton):
|
||||
self._palette = palette
|
||||
self._palette.props.invoker = ToolInvoker(self)
|
||||
|
||||
palette = gobject.property(type=object, setter=set_palette, getter=get_palette)
|
||||
palette = gobject.property(
|
||||
type=object, setter=set_palette, getter=get_palette)
|
||||
|
||||
def do_expose_event(self, event):
|
||||
child = self.get_child()
|
||||
allocation = self.get_allocation()
|
||||
|
||||
if self._palette and self._palette.is_up():
|
||||
invoker = self._palette.props.invoker
|
||||
invoker.draw_rectangle(event, self._palette)
|
||||
elif self.child.state == gtk.STATE_PRELIGHT:
|
||||
self.child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
elif child.state == gtk.STATE_PRELIGHT:
|
||||
child.style.paint_box(event.window, gtk.STATE_PRELIGHT,
|
||||
gtk.SHADOW_NONE, event.area,
|
||||
self.child, "toolbutton-prelight",
|
||||
self.allocation.x,
|
||||
self.allocation.y,
|
||||
self.allocation.width,
|
||||
self.allocation.height)
|
||||
child, "toolbutton-prelight",
|
||||
allocation.x, allocation.y,
|
||||
allocation.width, allocation.height)
|
||||
|
||||
gtk.RadioToolButton.do_expose_event(self, event)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user