r6847 - bigboard/trunk/bigboard/stocks/apps
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r6847 - bigboard/trunk/bigboard/stocks/apps
- Date: Fri, 26 Oct 2007 17:27:16 -0500 (CDT)
Author: marinaz
Date: 2007-10-26 17:27:12 -0500 (Fri, 26 Oct 2007)
New Revision: 6847
Modified:
bigboard/trunk/bigboard/stocks/apps/AppsStock.py
bigboard/trunk/bigboard/stocks/apps/apps.py
Log:
Offer a hardcoded list of popular local applications for someone who is
not logged in to Mugshot and is not connected to the network.
Modified: bigboard/trunk/bigboard/stocks/apps/AppsStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-10-26 21:58:42 UTC (rev 6846)
+++ bigboard/trunk/bigboard/stocks/apps/AppsStock.py 2007-10-26 22:27:12 UTC (rev 6847)
@@ -22,7 +22,12 @@
_logger = logging.getLogger("bigboard.stocks.AppsStock")
GCONF_KEY_APP_SIZE = '/apps/bigboard/application_list_size'
-
+
+# TODO: with some applications, the name of the file is less predictable, while the official name of the application is more predictable,
+# for example on my system Evolution is redhat-evolution-mail and Open Office Writer is openoffice.org-1.9-writer,
+# so we might try to do this selection using the names, such as "Firefox Web Browser", "Terminal", "File Browser", "Email", "Text Editor", etc.
+POPULAR_APPS = ["mozilla-firefox", "gnome-terminal", "gnome-nautilus", "evolution", "gnome-gedit", "evince", "mozilla-thunderbird", "rhythmbox", "totem", "gnome-eog", "gnome-file-roller", "epiphany", "openoffice.org-write", "liferia", "xchat", "synaptic", "pup", "gnome-volume-control", "openoffice.org-clac", "gnome-gcalctool", "gnome-system-monitor", "amarok", "gimp", "xchat-gnome", "gnome-bug-buddy", "gnu-emacs", "eclipse", "gaim", "openoffice.org-impress", "vncviewer"]
+
class AppDisplayLauncher(apps_widgets.AppDisplay):
def __init__(self):
super(AppDisplayLauncher, self).__init__()
@@ -166,18 +171,28 @@
usage = self.__repo.get_app_usage_enabled()
pinned_apps = self.__repo.get_pinned_apps()
global_top_apps = self.__repo.get_global_top_apps()
+ local_apps = self.__repo.get_local_apps()
static_size = gconf.client_get_default().get_int(GCONF_KEY_APP_SIZE) or 7
self.__set_subtitle(None)
apps_in_set = []
+ using_local_apps = False
if usage:
apps_in_set = pinned_apps
- if len(apps_in_set) == 0 and len(global_top_apps) > 0:
- apps_in_set = global_top_apps
- self.__set_subtitle("Popular Applications")
+ if len(apps_in_set) == 0:
+ if len(global_top_apps) > 0:
+ apps_in_set = global_top_apps
+ self.__set_subtitle("Popular Applications")
+ elif len(local_apps) > 0:
+ apps_in_set = local_apps
+ using_local_apps = True
- ## note the "-" in front of the cmp to sort descending
- apps_in_set.sort(lambda a, b: - cmp(a.get_usage_count(), b.get_usage_count()))
+ if using_local_apps:
+ apps_in_set = filter(lambda a: POPULAR_APPS.count(a.get_app_name_from_file_name()) > 0, apps_in_set)
+ apps_in_set.sort(lambda a, b: cmp(POPULAR_APPS.index(a.get_app_name_from_file_name()), POPULAR_APPS.index(b.get_app_name_from_file_name())))
+ else:
+ ## note the "-" in front of the cmp to sort descending
+ apps_in_set.sort(lambda a, b: - cmp(a.get_usage_count(), b.get_usage_count()))
for i, app in enumerate(apps_in_set):
if i >= static_size:
Modified: bigboard/trunk/bigboard/stocks/apps/apps.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps.py 2007-10-26 21:58:42 UTC (rev 6846)
+++ bigboard/trunk/bigboard/stocks/apps/apps.py 2007-10-26 22:27:12 UTC (rev 6847)
@@ -30,8 +30,22 @@
self.__pinned = False
def get_id(self):
- return self.__resource.id
+ return self.__resource and self.__resource.id or self.__menu_entry.get_desktop_file_path()
+ def get_app_name_from_file_name(self):
+ # this is intended for local apps
+ if not self.__menu_entry:
+ return ""
+
+ file_path = self.__menu_entry.get_desktop_file_path()
+ app_name_start = file_path.rfind("/") + 1
+ app_name_end = file_path.rfind(".")
+ #_logger.debug("name %s file path %s start %s end %s", self.get_name(), file_path, app_name_start, app_name_end)
+ if app_name_start < 0 or app_name_end < 0:
+ return ""
+ else:
+ return file_path[app_name_start:app_name_end]
+
def is_local(self):
return self.__resource is None
@@ -421,7 +435,7 @@
for id,app in self.__ddm_apps.iteritems():
app.recheck_installed()
- self.emit("local-apps-changed", self.get_local_apps())
+ self.emit("local-apps-changed", self.__local_apps.itervalues())
def get_app_for_resource(self, app_resource):
if not self.__ddm_apps.has_key(app_resource.id):
@@ -482,7 +496,7 @@
return self.__ddm_apps.itervalues()
def get_local_apps(self):
- return self.__local_apps.itervalues()
+ return self.__local_apps.values()
def get_pinned_apps(self):
return self.__my_pinned_apps
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]