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