[gnome-shell] Add finer-grained signals to ShellAppMonitor, update appDisplay
- From: Dan Winship <danw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add finer-grained signals to ShellAppMonitor, update appDisplay
- Date: Wed, 12 Aug 2009 21:08:44 +0000 (UTC)
commit 15a3f39f65e9cecadd2444cc515ff45f864a1b3a
Author: Dan Winship <danw gnome org>
Date: Wed Aug 12 16:05:25 2009 -0400
Add finer-grained signals to ShellAppMonitor, update appDisplay
js/ui/appDisplay.js | 10 ++++++-
src/shell-app-monitor.c | 61 +++++++++++++++++++++++++++++++++++++---------
src/shell-app-monitor.h | 2 -
src/shell-marshal.list | 2 +
4 files changed, 59 insertions(+), 16 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 7d28fba..57d3608 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -193,7 +193,10 @@ AppDisplay.prototype = {
this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) {
this._redisplay(false);
}));
- this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
+ this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) {
+ this._redisplay(false);
+ }));
+ this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) {
this._redisplay(false);
}));
@@ -761,7 +764,10 @@ AppWell.prototype = {
this._appSystem.connect('favorites-changed', Lang.bind(this, function(appSys) {
this._redisplay();
}));
- this._appMonitor.connect('changed', Lang.bind(this, function(monitor) {
+ this._appMonitor.connect('app-added', Lang.bind(this, function(monitor) {
+ this._redisplay();
+ }));
+ this._appMonitor.connect('app-removed', Lang.bind(this, function(monitor) {
this._redisplay();
}));
diff --git a/src/shell-app-monitor.c b/src/shell-app-monitor.c
index 0a9e80f..ebeba0e 100644
--- a/src/shell-app-monitor.c
+++ b/src/shell-app-monitor.c
@@ -18,6 +18,7 @@
#include "shell-app-monitor.h"
#include "shell-app-system.h"
#include "shell-global.h"
+#include "shell-marshal.h"
#include "display.h"
#include "window.h"
@@ -154,7 +155,10 @@ struct AppUsage
};
enum {
- CHANGED,
+ APP_ADDED,
+ APP_REMOVED,
+ WINDOW_ADDED,
+ WINDOW_REMOVED,
STARTUP_SEQUENCE_CHANGED,
LAST_SIGNAL
@@ -196,13 +200,41 @@ static void shell_app_monitor_class_init(ShellAppMonitorClass *klass)
gobject_class->finalize = shell_app_monitor_finalize;
- signals[CHANGED] = g_signal_new ("changed",
- SHELL_TYPE_APP_MONITOR,
- G_SIGNAL_RUN_LAST,
- 0,
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ signals[APP_ADDED] = g_signal_new ("app-added",
+ SHELL_TYPE_APP_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _shell_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ SHELL_TYPE_APP_INFO);
+ signals[APP_REMOVED] = g_signal_new ("app-removed",
+ SHELL_TYPE_APP_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _shell_marshal_VOID__BOXED,
+ G_TYPE_NONE, 1,
+ SHELL_TYPE_APP_INFO);
+
+ signals[WINDOW_ADDED] = g_signal_new ("window-added",
+ SHELL_TYPE_APP_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _shell_marshal_VOID__BOXED_OBJECT,
+ G_TYPE_NONE, 2,
+ SHELL_TYPE_APP_INFO,
+ META_TYPE_WINDOW);
+ signals[WINDOW_REMOVED] = g_signal_new ("window-removed",
+ SHELL_TYPE_APP_MONITOR,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ _shell_marshal_VOID__BOXED_OBJECT,
+ G_TYPE_NONE, 2,
+ SHELL_TYPE_APP_INFO,
+ META_TYPE_WINDOW);
signals[STARTUP_SEQUENCE_CHANGED] = g_signal_new ("startup-sequence-changed",
SHELL_TYPE_APP_MONITOR,
@@ -526,15 +558,18 @@ track_window (ShellAppMonitor *self,
usage = get_app_usage_from_window (self, window);
- /* Ephemerally keep track of the number of windows open for this app,
- * when it switches between 0 and 1 we emit a changed signal.
+ /* Keep track of the number of windows open for this app, when it
+ * switches between 0 and 1 we emit an app-added signal.
*/
usage->window_count++;
if (usage->initially_seen_sequence == 0)
usage->initially_seen_sequence = ++self->initially_seen_sequence;
usage->last_seen = get_time ();
if (usage->window_count == 1)
- g_signal_emit (self, signals[CHANGED], 0);
+ g_signal_emit (self, signals[APP_ADDED], 0, app);
+
+ /* Emit window-added after app-added */
+ g_signal_emit (self, signals[WINDOW_ADDED], 0, app, window);
}
static void
@@ -569,10 +604,12 @@ shell_app_monitor_on_window_removed (MetaWorkspace *workspace,
/* Remove before emitting */
g_hash_table_remove (self->window_to_app, window);
+ g_signal_emit (self, signals[WINDOW_REMOVED], 0, app, window);
+
if (usage->window_count == 0)
{
usage->initially_seen_sequence = 0;
- g_signal_emit (self, signals[CHANGED], 0);
+ g_signal_emit (self, signals[APP_REMOVED], 0);
}
}
diff --git a/src/shell-app-monitor.h b/src/shell-app-monitor.h
index 491f860..7858d0a 100644
--- a/src/shell-app-monitor.h
+++ b/src/shell-app-monitor.h
@@ -30,8 +30,6 @@ struct _ShellAppMonitorClass
{
GObjectClass parent_class;
- void (*apps_changed)(ShellAppMonitor *menuwrapper,
- gpointer data);
};
GType shell_app_monitor_get_type (void) G_GNUC_CONST;
diff --git a/src/shell-marshal.list b/src/shell-marshal.list
index a86d7fd..329f8b3 100644
--- a/src/shell-marshal.list
+++ b/src/shell-marshal.list
@@ -1,2 +1,4 @@
VOID:INT,INT,INT
VOID:OBJECT,INT,INT,INT,INT
+VOID:BOXED
+VOID:BOXED,OBJECT
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]