Make combobox icons bigger when there is no text

This commit is contained in:
Marco Pesenti Gritti 2007-07-23 13:15:02 +02:00
parent 4da2bafa84
commit aee3330be4
2 changed files with 10 additions and 4 deletions

1
NEWS
View File

@ -1,3 +1,4 @@
* #2323 Make combobox icons bigger when there is no text. (marco)
* Add option to GlibURLDownloader to download to specified file instead * Add option to GlibURLDownloader to download to specified file instead
of tempfile (dcbw) of tempfile (dcbw)

View File

@ -53,9 +53,9 @@ class ComboBox(gtk.ComboBox):
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): 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(gtk.ICON_SIZE_MENU) width, height = gtk.icon_size_lookup(size)
info = icon_theme.lookup_icon(name, width, height) info = icon_theme.lookup_icon(name, width, height)
if not info: if not info:
raise ValueError("Icon '" + name + "' not found.") raise ValueError("Icon '" + name + "' not found.")
@ -76,9 +76,14 @@ class ComboBox(gtk.ComboBox):
self.add_attribute(self._text_renderer, 'text', 1) self.add_attribute(self._text_renderer, 'text', 1)
if icon_name: if icon_name:
width, height = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU) if text:
size = gtk.ICON_SIZE_MENU
else:
size = gtk.ICON_SIZE_LARGE_TOOLBAR
width, height = gtk.icon_size_lookup(size)
if icon_name[0:6] == "theme:": if icon_name[0:6] == "theme:":
icon_name = self._get_real_name_from_theme(icon_name[6:]) icon_name = self._get_real_name_from_theme(icon_name[6:], size)
pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_name, width, height) pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon_name, width, height)
else: else:
pixbuf = None pixbuf = None