ibus/ibus-xx-gtk-legacy-icon.patch

134 lines
5.2 KiB
Diff

From e2b07deb05182355f7bdecdd69a731a566ad832c Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 17 Feb 2011 15:16:21 +0900
Subject: [PATCH] Use gtk_icon_factory_lookup_default for GTK stock
gtk_icon_theme_load_icon doesn't load GTK legacy stock ids because
The stock legacy symlinks are removed in the latst GTK.
---
ui/gtk/engineabout.py | 13 ++++++++++---
ui/gtk/icon.py | 40 ++++++++++++++++++++++++++++++++++++----
ui/gtk/panel.py | 4 ++--
3 files changed, 48 insertions(+), 9 deletions(-)
diff --git a/ui/gtk/engineabout.py b/ui/gtk/engineabout.py
index a34e930..1af806c 100644
--- a/ui/gtk/engineabout.py
+++ b/ui/gtk/engineabout.py
@@ -24,6 +24,7 @@ import gtk
from gtk import gdk
import pango
import ibus
+import icon as _icon
from i18n import _, N_
@@ -35,7 +36,9 @@ class EngineAbout(gtk.Dialog):
self.__init_ui()
def __init_ui(self):
- self.set_icon_name("gtk-about")
+ # Gtk stock symlink is legacy.
+ pixbufs = _icon.icon_set_get_pixbufs_default(None, gtk.STOCK_ABOUT)
+ self.set_icon_list(*pixbufs)
sw = gtk.ScrolledWindow()
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
@@ -96,6 +99,10 @@ class EngineAbout(gtk.Dialog):
theme = gtk.icon_theme_get_default()
icon = theme.lookup_icon("ibus-engine", 48, 0)
if icon == None:
- icon = theme.lookup_icon("gtk-missing-image", 48, 0)
- pixbuf = icon.load_icon()
+ # Gtk stock symlink is legacy.
+ pixbuf = _icon.icon_set_get_pixbuf_default(None,
+ gtk.STOCK_MISSING_IMAGE,
+ 48)
+ else:
+ pixbuf = icon.load_icon()
return pixbuf
diff --git a/ui/gtk/icon.py b/ui/gtk/icon.py
index 5b5f97f..d91fe4a 100644
--- a/ui/gtk/icon.py
+++ b/ui/gtk/icon.py
@@ -22,6 +22,32 @@
import gtk
import gtk.gdk as gdk
+import sys
+
+def icon_set_get_pixbuf_default(icon_set, stock_id, size, state=gtk.STATE_NORMAL):
+ if icon_set == None:
+ icon_set = gtk.icon_factory_lookup_default(stock_id)
+ if icon_set == None:
+ return None
+ return icon_set.render_icon(gtk.widget_get_default_style(),
+ gtk.widget_get_default_direction(),
+ state,
+ size,
+ None, None)
+
+def icon_set_get_pixbufs_default(icon_set, stock_id, state=gtk.STATE_NORMAL):
+ if icon_set == None:
+ icon_set = gtk.icon_factory_lookup_default(stock_id)
+ pixbufs = []
+ if icon_set == None:
+ return []
+ for size in icon_set.get_sizes():
+ pixbufs.append(icon_set.render_icon(gtk.widget_get_default_style(),
+ gtk.widget_get_default_direction(),
+ state,
+ size,
+ None, None))
+ return pixbufs
class IconWidget(gtk.Image):
def __init__(self, icon, size):
@@ -31,11 +57,17 @@ class IconWidget(gtk.Image):
if icon.startswith("/"):
pixbuf = gdk.pixbuf_new_from_file(icon)
else:
- theme = gtk.icon_theme_get_default()
- pixbuf = theme.load_icon(icon, size, 0)
+ # Gtk stock symlink is legacy.
+ icon_set = gtk.icon_factory_lookup_default(icon)
+ if icon_set != None:
+ pixbuf = icon_set_get_pixbuf_default(icon_set, icon, size)
+ else:
+ theme = gtk.icon_theme_get_default()
+ pixbuf = theme.load_icon(icon, size, 0)
except:
- theme = gtk.icon_theme_get_default()
- pixbuf = theme.load_icon(gtk.STOCK_MISSING_IMAGE, size, 0)
+ print >> sys.stderr, "Not Found Icon", icon, size
+ # Gtk stock symlink is legacy.
+ pixbuf = icon_set_get_pixbuf_default(None, gtk.STOCK_MISSING_IMAGE, size)
width = pixbuf.get_width()
height = pixbuf.get_height()
diff --git a/ui/gtk/panel.py b/ui/gtk/panel.py
index 07b0fa2..2244455 100644
--- a/ui/gtk/panel.py
+++ b/ui/gtk/panel.py
@@ -412,7 +412,7 @@ class Panel(ibus.PanelBase):
menu.add(item)
item = gtk.ImageMenuItem(_("Turn off input method"))
- item.set_image(_icon.IconWidget("gtk-close", size[0]))
+ item.set_image(_icon.IconWidget(gtk.STOCK_CLOSE, size[0]))
item.connect("activate", self.__im_menu_item_activate_cb, None)
if self.__focus_ic == None or not self.__focus_ic.is_enabled():
item.set_sensitive(False)
@@ -452,7 +452,7 @@ class Panel(ibus.PanelBase):
menu = gtk.Menu()
item = gtk.ImageMenuItem(_("No input window"))
size = gtk.icon_size_lookup(gtk.ICON_SIZE_MENU)
- item.set_image(_icon.IconWidget("gtk-info", size[0]))
+ item.set_image(_icon.IconWidget(gtk.STOCK_INFO, size[0]))
menu.add(item)
menu.show_all()
else:
--
1.7.4