[gnome-shell] Make ShellAppMonitor and ShellAppSystem singletons, remove unused code in appDisplay
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-shell] Make ShellAppMonitor and ShellAppSystem singletons, remove unused code in appDisplay
- Date: Thu, 18 Jun 2009 12:37:44 -0400 (EDT)
commit e7771b4eb096fb61aaf5e3520c6b58be66adb234
Author: Colin Walters <walters verbum org>
Date: Thu Jun 18 12:27:19 2009 -0400
Make ShellAppMonitor and ShellAppSystem singletons, remove unused code in appDisplay
We shouldn't create multiple instances of either. Also remove a bit
of unused code in appDisplay.
js/misc/appInfo.js | 2 +-
js/ui/appDisplay.js | 30 ++----------------------------
src/shell-app-monitor.c | 16 ++++++++++++++++
src/shell-app-monitor.h | 2 +-
src/shell-app-system.c | 16 ++++++++++++++++
src/shell-app-system.h | 2 +-
6 files changed, 37 insertions(+), 31 deletions(-)
---
diff --git a/js/misc/appInfo.js b/js/misc/appInfo.js
index d77b147..32f9bd0 100644
--- a/js/misc/appInfo.js
+++ b/js/misc/appInfo.js
@@ -104,7 +104,7 @@ function getAppInfo(appId) {
//
// Return value: the list of #AppInfo
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
// apps might contain an app we don't have a desktop file for
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 3eefc50..889fa53 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -18,32 +18,6 @@ ENTERED_MENU_COLOR.from_pixel(0x00ff0022);
const MENU_ICON_SIZE = 24;
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;
/* This class represents a single display item containing information about an application.
@@ -196,8 +170,8 @@ AppDisplay.prototype = {
// map<itemId, array of category names>
this._appCategories = {};
- this._appMonitor = new Shell.AppMonitor();
- this._appSystem = new Shell.AppSystem();
+ this._appMonitor = Shell.AppMonitor.get_default();
+ this._appSystem = Shell.AppSystem.get_default();
this._appsStale = true;
this._appSystem.connect('changed', Lang.bind(this, function(appSys) {
this._appsStale = true;
diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c
index 7a7cd58..34afc3c 100644
--- a/src/shell-app-monitor.c
+++ b/src/shell-app-monitor.c
@@ -912,3 +912,19 @@ on_enable_monitoring_key_changed (GConfClient *client,
{
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;
+}
diff --git a/src/shell-app-monitor.h b/src/shell-app-monitor.h
index 7a808f1..f0cf891 100644
--- a/src/shell-app-monitor.h
+++ b/src/shell-app-monitor.h
@@ -33,7 +33,7 @@ struct _ShellAppMonitorClass
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 */
GSList *shell_app_monitor_get_most_used_apps (ShellAppMonitor *monitor,
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 739d7dc..1d8aa11 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -299,3 +299,19 @@ shell_app_system_get_all_settings (ShellAppSystem *monitor)
{
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;
+}
diff --git a/src/shell-app-system.h b/src/shell-app-system.h
index cbd2d2e..2bdd597 100644
--- a/src/shell-app-system.h
+++ b/src/shell-app-system.h
@@ -29,7 +29,7 @@ struct _ShellAppSystemClass
};
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]