[pessulus] [pessulus] Use icon-name attribute for gtk.CellRendererPixbuf
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Subject: [pessulus] [pessulus] Use icon-name attribute for gtk.CellRendererPixbuf
- Date: Tue, 28 Jul 2009 22:09:46 +0000 (UTC)
commit 1dc42df2d8800c600300e69bf8bf0860ff3af1bb
Author: Vincent Untz <vuntz gnome org>
Date: Tue Jul 28 23:20:33 2009 +0200
[pessulus] Use icon-name attribute for gtk.CellRendererPixbuf
The code was still using pixbufs. This lets us remove quite some code,
especially to load icons.
Note that we don't support icons that are specified with an absolute
path anymore, but this wasn't used anyway.
Pessulus/disabledapplets.py | 29 ++++----------------------
Pessulus/icons.py | 47 ++----------------------------------------
Pessulus/maindialog.py | 12 +++-------
3 files changed, 12 insertions(+), 76 deletions(-)
---
diff --git a/Pessulus/disabledapplets.py b/Pessulus/disabledapplets.py
index a294ef4..1e5fa47 100644
--- a/Pessulus/disabledapplets.py
+++ b/Pessulus/disabledapplets.py
@@ -114,33 +114,26 @@ class PessulusDisabledApplets:
COLUMN_IID,
COLUMN_NAME,
COLUMN_ICON_NAME,
- COLUMN_ICON,
COLUMN_DISABLED
- ) = range (5)
+ ) = range (4)
def __init__ (self, treeview, lockdownbutton):
self.notify_id = None
self.key = "/apps/panel/global/disabled_applets"
self.disabled_applets = None
- self.liststore = gtk.ListStore (str, str, str, gtk.gdk.Pixbuf, bool)
+ self.liststore = gtk.ListStore (str, str, str, bool)
self.liststore.set_sort_column_id (self.COLUMN_NAME, gtk.SORT_ASCENDING)
self.treeview = treeview
self.treeview.get_selection ().set_mode (gtk.SELECTION_SINGLE)
self.treeview.set_model (self.liststore)
- self.treeview.connect ("screen-changed", self.__on_screen_changed)
self.treeview.connect ("destroy", self.__on_destroyed)
self.lockdownbutton = lockdownbutton
self.lockdownbutton.connect ("toggled",
self.__on_lockdownbutton_toggled)
- screen = self.treeview.get_screen ()
- self.icon_theme = gtk.icon_theme_get_for_screen (screen)
-
- self.icon_theme.connect ("changed", self.__on_icontheme_changed)
-
self.__fill_liststore ()
self.__create_columns ()
@@ -152,17 +145,6 @@ class PessulusDisabledApplets:
self.notify_id = globalvar.applier.notify_add (self.key,
self.__on_notified)
- def __on_screen_changed (self, widget, screen):
- self.icon_theme = gtk.icon_theme_get_for_screen (screen)
- self.__on_icontheme_changed (self.icon_theme)
-
- def __on_icontheme_changed (self, icontheme):
- def update_icon (model, path, iter, data):
- if model[iter][self.COLUMN_ICON_NAME] != "":
- model[iter][self.COLUMN_ICON] = icons.load_icon (self.icon_theme, model[iter][self.COLUMN_ICON_NAME])
-
- self.liststore.foreach (update_icon, self)
-
def __fill_liststore (self):
applets = bonobo.activation.query ("has_all (repo_ids, ['IDL:Bonobo/Control:1.0', 'IDL:GNOME/Vertigo/PanelAppletShell:1.0'])")
@@ -181,7 +163,7 @@ class PessulusDisabledApplets:
elif prop.name == "name" and bestname == -1:
name = prop.v.value_string
elif prop.name == "panel:icon":
- icon = prop.v.value_string
+ icon = icons.fix_icon_name(prop.v.value_string)
if name == None:
name = applet.iid
@@ -193,8 +175,7 @@ class PessulusDisabledApplets:
self.liststore.set (iter,
self.COLUMN_IID, applet.iid,
self.COLUMN_NAME, name,
- self.COLUMN_ICON_NAME, icon,
- self.COLUMN_ICON, icons.load_icon (self.icon_theme, icon))
+ self.COLUMN_ICON_NAME, icon)
def __create_columns (self):
column = gtk.TreeViewColumn ()
@@ -211,7 +192,7 @@ class PessulusDisabledApplets:
cell = gtk.CellRendererPixbuf ()
column.pack_start (cell, False)
- column.set_attributes (cell, pixbuf = self.COLUMN_ICON)
+ column.set_attributes (cell, icon_name = self.COLUMN_ICON_NAME)
cell = gtk.CellRendererText ()
column.pack_start (cell, True)
diff --git a/Pessulus/icons.py b/Pessulus/icons.py
index de491ef..80630c1 100644
--- a/Pessulus/icons.py
+++ b/Pessulus/icons.py
@@ -20,48 +20,10 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
#
-import os
-import gtk
-
-def load_icon_from_path (icon_path):
- if os.path.isfile (icon_path):
- try:
- return gtk.gdk.pixbuf_new_from_file_at_size (icon_path, 24, 24)
- except:
- pass
- return None
-
-def load_icon_from_data_dirs (icon_value):
- data_dirs = None
- if os.environ.has_key ("XDG_DATA_DIRS"):
- data_dirs = os.environ["XDG_DATA_DIRS"]
- if not data_dirs:
- data_dirs = "/usr/local/share/:/usr/share/"
-
- for data_dir in data_dirs.split (":"):
- retval = load_icon_from_path (os.path.join (data_dir, "pixmaps",
- icon_value))
- if retval:
- return retval
- retval = load_icon_from_path (os.path.join (data_dir, "icons",
- icon_value))
- if retval:
- return retval
-
- return None
-
-def load_icon (icon_theme, icon_value):
- if not icon_value:
+def fix_icon_name (icon_name):
+ if not icon_name:
return None
- if os.path.isabs (icon_value):
- icon = load_icon_from_path (icon_value)
- if icon:
- return icon
- icon_name = os.path.basename (icon_value)
- else:
- icon_name = icon_value
-
if icon_name.endswith (".png"):
icon_name = icon_name[:-len (".png")]
elif icon_name.endswith (".xpm"):
@@ -69,7 +31,4 @@ def load_icon (icon_theme, icon_value):
elif icon_name.endswith (".svg"):
icon_name = icon_name[:-len (".svg")]
- try:
- return icon_theme.load_icon (icon_name, 24, 0)
- except:
- return load_icon_from_data_dirs (icon_value)
+ return icon_name
diff --git a/Pessulus/maindialog.py b/Pessulus/maindialog.py
index 92fb929..8013436 100644
--- a/Pessulus/maindialog.py
+++ b/Pessulus/maindialog.py
@@ -30,7 +30,6 @@ from xml.sax.saxutils import escape as escape_pango
from config import *
import disabledapplets
-import icons
import lockdownbutton
import lockdowncheckbutton
import globalvar
@@ -147,14 +146,11 @@ class PessulusMainDialog:
self.__on_unsafeprotocols_toggled (checkbutton, hbox)
def __init_pageselector (self):
- #FIXME: need to update icons on icon theme change/screen change
- icon_theme = gtk.icon_theme_get_for_screen (self.window.get_screen ())
-
use_tree = False
if use_tree:
- store = gtk.TreeStore (str, gtk.gdk.Pixbuf, int)
+ store = gtk.TreeStore (str, str, int)
else:
- store = gtk.ListStore (str, gtk.gdk.Pixbuf, int)
+ store = gtk.ListStore (str, str, int)
notebook = self.xml.get_widget ("notebook2")
children = notebook.get_children ()
@@ -177,7 +173,7 @@ class PessulusMainDialog:
iter = store.append ()
store.set (iter,
- self.COLUMN_ICON, icons.load_icon (icon_theme, icon),
+ self.COLUMN_ICON, icon,
self.COLUMN_NAME, name,
self.COLUMN_PAGENUMBER, i)
@@ -189,7 +185,7 @@ class PessulusMainDialog:
cell = gtk.CellRendererPixbuf ()
col.pack_start (cell, True)
- col.add_attribute (cell, 'pixbuf', self.COLUMN_ICON)
+ col.add_attribute (cell, 'icon_name', self.COLUMN_ICON)
cell = gtk.CellRendererText ()
col.pack_start (cell, True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]