[gnome-shell/overlay-design02] Make ShellAppMonitor and ShellAppSystem singletons



commit d7dcfe6a06ca6cef73dc76b5f7936bdd7f17decb
Author: Colin Walters <walters verbum org>
Date:   Tue Jun 2 17:21:50 2009 -0400

    Make ShellAppMonitor and ShellAppSystem singletons
---
 src/shell-app-monitor.c |   16 ++++++++++++++++
 src/shell-app-monitor.h |    2 +-
 src/shell-app-system.c  |   16 ++++++++++++++++
 src/shell-app-system.h  |    2 +-
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c
index 2a5f439..9573cde 100644
--- a/src/shell-app-monitor.c
+++ b/src/shell-app-monitor.c
@@ -261,6 +261,22 @@ shell_app_monitor_finalize (GObject *object)
 }
 
 /**
+ * shell_app_monitor_get_default:
+ *
+ * Return Value: (transfer none): The global #ShellAppMonitor singleton
+ */
+ShellAppMonitor *
+shell_app_monitor_get_default ()
+{
+  static ShellAppMonitor *instance = NULL;
+
+  if (instance == NULL)
+    instance = g_object_new (SHELL_TYPE_APP_Monitor, NULL);
+
+  return instance;
+}
+
+/**
  * shell_app_monitor_get_most_used_apps:
  *
  * Get a list of desktop identifiers representing the most popular applications
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 8829389..6ba92fb 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -115,6 +115,22 @@ shell_app_system_finalize (GObject *object)
   G_OBJECT_CLASS (shell_app_system_parent_class)->finalize(object);
 }
 
+/**
+ * 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;
+}
+
 static void
 reread_directories (ShellAppSystem *self, GSList **cache, GMenuTree *tree)
 {
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]