[kupfer: 28/41] Use kupfer-execute, kupfer-catalog, kupfer-launch by default
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 28/41] Use kupfer-execute, kupfer-catalog, kupfer-launch by default
- Date: Tue, 26 Apr 2011 17:15:09 +0000 (UTC)
commit 401a5d4bdf29ace94178ab418245178128f627df
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Tue Apr 26 18:45:47 2011 +0200
Use kupfer-execute, kupfer-catalog, kupfer-launch by default
Prefer these themable basic icons, also don't load kupfer-object etc
icons if the icon theme already defines them.
kupfer/icons.py | 16 ++++++++++++++++
kupfer/obj/base.py | 2 +-
kupfer/obj/fileactions.py | 3 ---
kupfer/obj/objects.py | 4 ++--
kupfer/obj/sources.py | 4 +---
kupfer/ui/browser.py | 2 +-
6 files changed, 21 insertions(+), 10 deletions(-)
---
diff --git a/kupfer/icons.py b/kupfer/icons.py
index 151f5b8..beb2ce1 100644
--- a/kupfer/icons.py
+++ b/kupfer/icons.py
@@ -23,6 +23,14 @@ SMALL_SZ = 24
gtk.icon_size_register("kupfer-large", LARGE_SZ, LARGE_SZ)
gtk.icon_size_register("kupfer-small", SMALL_SZ, SMALL_SZ)
+## default fallbacks for our themable icons
+kupfer_icon_fallbacks = {
+ 'kupfer-execute': 'gtk-execute',
+ 'kupfer-object': 'gtk-file',
+ 'kupfer-object-multiple': 'gtk-file',
+ 'kupfer-catalog': 'folder-saved-search',
+}
+
def _icon_theme_changed(theme):
pretty.print_info(__name__, "Icon theme changed, clearing cache")
global icon_cache
@@ -47,6 +55,9 @@ def load_kupfer_icons(scheduler):
if not icon_path:
pretty.print_info(__name__, "Icon", basename,icon_path,"not found")
continue
+ if _default_theme.has_icon(icon_name):
+ pretty.print_debug(__name__, "Skipping already existing", icon_name)
+ continue
pixbuf = pixbuf_new_from_file_at_size(icon_path, size,size)
gtk.icon_theme_add_builtin_icon(icon_name, size, pixbuf)
pretty.print_debug(__name__, "Loading icon", icon_name, "at", size,
@@ -304,6 +315,11 @@ def get_icon_for_name(icon_name, icon_size, icon_names=[]):
icon = _IconRenderer.pixbuf_for_name(load_name, icon_size)
if icon:
break
+ elif icon_name in kupfer_icon_fallbacks:
+ fallback_name = kupfer_icon_fallbacks[icon_name]
+ icon = _IconRenderer.pixbuf_for_name(fallback_name, icon_size)
+ if icon:
+ break
except Exception:
pretty.print_exc(__name__)
icon = None
diff --git a/kupfer/obj/base.py b/kupfer/obj/base.py
index 4c23bf9..712e70b 100644
--- a/kupfer/obj/base.py
+++ b/kupfer/obj/base.py
@@ -224,7 +224,7 @@ class Action (KupferObject):
"""
return True
'''
- fallback_icon_name = "gtk-execute"
+ fallback_icon_name = "kupfer-execute"
def __hash__(self):
return hash(repr(self))
diff --git a/kupfer/obj/fileactions.py b/kupfer/obj/fileactions.py
index 218db76..2b99f60 100644
--- a/kupfer/obj/fileactions.py
+++ b/kupfer/obj/fileactions.py
@@ -70,9 +70,6 @@ class Open (Action):
def get_description(self):
return _("Open with default application")
- def get_icon_name(self):
- return "gtk-execute"
-
class RevealFile (Action):
def __init__(self, name=_("Reveal")):
super(RevealFile, self).__init__(name)
diff --git a/kupfer/obj/objects.py b/kupfer/obj/objects.py
index fe78033..8d475bc 100644
--- a/kupfer/obj/objects.py
+++ b/kupfer/obj/objects.py
@@ -315,7 +315,7 @@ class Launch (Action):
def get_icon_name(self):
if self.is_running:
return "go-jump"
- return Action.get_icon_name(self)
+ return "kupfer-launch"
class LaunchAgain (Launch):
rank_adjust = 0
@@ -380,7 +380,7 @@ class RunnableLeaf (Leaf):
iname = self.get_icon_name()
if iname:
return icons.get_gicon_with_fallbacks(None, (iname, ))
- return icons.ComposedIcon("kupfer-object", "gtk-execute")
+ return icons.ComposedIcon("kupfer-object", "kupfer-execute")
def get_icon_name(self):
return ""
diff --git a/kupfer/obj/sources.py b/kupfer/obj/sources.py
index 34ec81b..7c4d3af 100644
--- a/kupfer/obj/sources.py
+++ b/kupfer/obj/sources.py
@@ -146,6 +146,7 @@ class MultiSource (Source):
A source whose items are the combined items
of all @sources
"""
+ fallback_icon_name = "kupfer-catalog"
def __init__(self, sources):
super(MultiSource, self).__init__(_("Catalog"))
self.sources = sources
@@ -169,6 +170,3 @@ class MultiSource (Source):
def get_description(self):
return _("Root catalog")
- def get_icon_name(self):
- return "folder-saved-search"
-
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index b7f324a..9625721 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -921,7 +921,7 @@ class ActionSearch (Search):
# don't look up icons too early
if not self._initialized:
return ("", None)
- return _("No action"), icons.get_icon_for_name("gtk-execute",
+ return _("No action"), icons.get_icon_for_name("kupfer-execute",
self.icon_size)
def setup_empty(self):
self.handle_no_matches()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]