Merge branch 'master' into overlay-design02

Conflicts:
	js/ui/appDisplay.js
This commit is contained in:
Colin Walters 2009-06-18 13:12:21 -04:00
commit 75da772d05
6 changed files with 58 additions and 39 deletions

View File

@ -104,7 +104,7 @@ function getAppInfo(appId) {
// //
// Return value: the list of #AppInfo // Return value: the list of #AppInfo
function getMostUsedApps(count) { function getMostUsedApps(count) {
let appMonitor = new Shell.AppMonitor(); let appMonitor = Shell.AppMonitor.get_default();
// Ask for more apps than we need, since the list of recently used // Ask for more apps than we need, since the list of recently used
// apps might contain an app we don't have a desktop file for // apps might contain an app we don't have a desktop file for

View File

@ -18,32 +18,6 @@ ENTERED_MENU_COLOR.from_pixel(0x00ff0022);
const MENU_ICON_SIZE = 24; const MENU_ICON_SIZE = 24;
const MENU_SPACING = 15; const MENU_SPACING = 15;
// TODO - move this into GConf once we're not a plugin anymore
// but have taken over metacity
// This list is taken from GNOME Online popular applications
// http://online.gnome.org/applications
// but with nautilus removed (since it should already be running)
// and evince, totem, and gnome-file-roller removed (since they're
// usually started by opening documents, not by opening the app
// directly)
const DEFAULT_APPLICATIONS = [
'mozilla-firefox.desktop',
'gnome-terminal.desktop',
'evolution.desktop',
'gedit.desktop',
'mozilla-thunderbird.desktop',
'rhythmbox.desktop',
'epiphany.desktop',
'xchat.desktop',
'openoffice.org-1.9-writer.desktop',
'emacs.desktop',
'gnome-system-monitor.desktop',
'openoffice.org-1.9-calc.desktop',
'eclipse.desktop',
'openoffice.org-1.9-impress.desktop',
'vncviewer.desktop'
];
const MAX_ITEMS = 30; const MAX_ITEMS = 30;
/* This class represents a single display item containing information about an application. /* This class represents a single display item containing information about an application.
@ -196,8 +170,8 @@ AppDisplay.prototype = {
// map<itemId, array of category names> // map<itemId, array of category names>
this._appCategories = {}; this._appCategories = {};
this._appMonitor = new Shell.AppMonitor(); this._appMonitor = Shell.AppMonitor.get_default();
this._appSystem = new Shell.AppSystem(); this._appSystem = Shell.AppSystem.get_default();
this._appsStale = true; this._appsStale = true;
this._appSystem.connect('changed', Lang.bind(this, function(appSys) { this._appSystem.connect('changed', Lang.bind(this, function(appSys) {
this._appsStale = true; this._appsStale = true;
@ -208,6 +182,7 @@ AppDisplay.prototype = {
this._redisplayMenus(); this._redisplayMenus();
})); }));
this._appMonitor.connect('changed', Lang.bind(this, function(monitor) { this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
this._appsStale = true;
this._redisplay(false); this._redisplay(false);
})); }));
@ -316,19 +291,22 @@ AppDisplay.prototype = {
} }
}, },
_addApp: function(appId) { _addAppForId: function(appId) {
let appInfo = AppInfo.getAppInfo(appId); let appInfo = AppInfo.getAppInfo(appId);
if (appInfo != null) { if (appInfo != null) {
this._allItems[appId] = appInfo; this._addApp(appInfo);
// [] is returned if we could not get the categories or the list of categories was empty
let categories = Shell.get_categories_for_desktop_file(appId);
this._appCategories[appId] = categories;
} else { } else {
log("appInfo for " + appId + " was not found."); log("appInfo for " + appId + " was not found.");
} }
}, },
//// Protected method overrides //// _addApp: function(appInfo) {
let appId = appInfo.id;
this._allItems[appId] = appInfo;
// [] is returned if we could not get the categories or the list of categories was empty
let categories = Shell.get_categories_for_desktop_file(appId);
this._appCategories[appId] = categories;
},
// Gets information about all applications by calling Gio.app_info_get_all(). // Gets information about all applications by calling Gio.app_info_get_all().
_refreshCache : function() { _refreshCache : function() {
@ -347,7 +325,7 @@ AppDisplay.prototype = {
let menuApps = this._appSystem.get_applications_for_menu(menu.id); let menuApps = this._appSystem.get_applications_for_menu(menu.id);
for (let j = 0; j < menuApps.length; j++) { for (let j = 0; j < menuApps.length; j++) {
let appId = menuApps[j]; let appId = menuApps[j];
this._addApp(appId); this._addAppForId(appId);
} }
} }
@ -356,7 +334,16 @@ AppDisplay.prototype = {
let settings = this._appSystem.get_all_settings(); let settings = this._appSystem.get_all_settings();
for (let i = 0; i < settings.length; i++) { for (let i = 0; i < settings.length; i++) {
let appId = settings[i]; let appId = settings[i];
this._addApp(appId); this._addAppForId(appId);
}
// Some applications, such as Evince, might not be in the menus,
// but might be returned by the applications monitor as most used
// applications, in which case we include them.
let mostUsedAppInfos = AppInfo.getMostUsedApps(MAX_ITEMS);
for (let i = 0; i < mostUsedAppInfos.length; i++) {
let appInfo = mostUsedAppInfos[i];
this._addApp(appInfo);
} }
this._appsStale = false; this._appsStale = false;

View File

@ -912,3 +912,19 @@ on_enable_monitoring_key_changed (GConfClient *client,
{ {
update_enable_monitoring ((ShellAppMonitor *) monitor); update_enable_monitoring ((ShellAppMonitor *) monitor);
} }
/**
* shell_app_monitor_get_default:
*
* Return Value: (transfer none): The global #ShellAppMonitor instance
*/
ShellAppMonitor *
shell_app_monitor_get_default ()
{
static ShellAppMonitor *instance;
if (instance == NULL)
instance = g_object_new (SHELL_TYPE_APP_MONITOR, NULL);
return instance;
}

View File

@ -33,7 +33,7 @@ struct _ShellAppMonitorClass
GType shell_app_monitor_get_type (void) G_GNUC_CONST; GType shell_app_monitor_get_type (void) G_GNUC_CONST;
ShellAppMonitor* shell_app_monitor_new(void); ShellAppMonitor* shell_app_monitor_get_default(void);
/* Get the most popular applications for a given activity */ /* Get the most popular applications for a given activity */
GSList *shell_app_monitor_get_most_used_apps (ShellAppMonitor *monitor, GSList *shell_app_monitor_get_most_used_apps (ShellAppMonitor *monitor,

View File

@ -299,3 +299,19 @@ shell_app_system_get_all_settings (ShellAppSystem *monitor)
{ {
return monitor->priv->cached_setting_ids; return monitor->priv->cached_setting_ids;
} }
/**
* shell_app_system_get_default:
*
* Return Value: (transfer none): The global #ShellAppSystem singleton
*/
ShellAppSystem *
shell_app_system_get_default ()
{
static ShellAppSystem *instance = NULL;
if (instance == NULL)
instance = g_object_new (SHELL_TYPE_APP_SYSTEM, NULL);
return instance;
}

View File

@ -29,7 +29,7 @@ struct _ShellAppSystemClass
}; };
GType shell_app_system_get_type (void) G_GNUC_CONST; GType shell_app_system_get_type (void) G_GNUC_CONST;
ShellAppSystem* shell_app_system_new(void); ShellAppSystem* shell_app_system_get_default(void);
GSList *shell_app_system_get_applications_for_menu (ShellAppSystem *system, const char *menu); GSList *shell_app_system_get_applications_for_menu (ShellAppSystem *system, const char *menu);