[gnome-shell/wip/sass] Add busy property to ShellApp
- From: Jakub Steiner <jimmac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/sass] Add busy property to ShellApp
- Date: Thu, 8 Jan 2015 10:05:43 +0000 (UTC)
commit c296b56c0e325b6d50c816446361cf1ed26eb22b
Author: Phillip Wood <phillip wood dunelm org uk>
Date: Tue Sep 16 11:08:19 2014 +0100
Add busy property to ShellApp
Using a separate property to show when the application is busy rather
than cramming it into the state property makes the code clearer. In most
places we only care if an app is running or not, not whether it is
actually busy.
https://bugzilla.gnome.org/show_bug.cgi?id=736492
js/ui/panel.js | 8 +++++++-
src/shell-app-system.c | 1 -
src/shell-app.c | 39 ++++++++++++++++++++++++++++++---------
src/shell-app.h | 5 +++--
4 files changed, 40 insertions(+), 13 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index d182cdb..335af18 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -181,6 +181,7 @@ const AppMenuButton = new Lang.Class({
this._targetApp = null;
this._appMenuNotifyId = 0;
this._actionGroupNotifyId = 0;
+ this._busyNotifyId = 0;
let bin = new St.Bin({ name: 'appMenu' });
bin.connect('style-changed', Lang.bind(this, this._onStyleChanged));
@@ -393,12 +394,17 @@ const AppMenuButton = new Lang.Class({
this._targetApp.disconnect(this._actionGroupNotifyId);
this._actionGroupNotifyId = 0;
}
+ if (this._busyNotifyId) {
+ this._targetApp.disconnect(this._busyNotifyId);
+ this._busyNotifyId = 0;
+ }
this._targetApp = targetApp;
if (this._targetApp) {
this._appMenuNotifyId = this._targetApp.connect('notify::menu', Lang.bind(this, this._sync));
this._actionGroupNotifyId = this._targetApp.connect('notify::action-group', Lang.bind(this,
this._sync));
+ this._busyNotifyId = this._targetApp.connect('notify::busy', Lang.bind(this, this._sync));
this._label.setText(this._targetApp.get_name());
this.actor.set_accessible_name(this._targetApp.get_name());
}
@@ -412,7 +418,7 @@ const AppMenuButton = new Lang.Class({
let isBusy = (this._targetApp != null &&
(this._targetApp.get_state() == Shell.AppState.STARTING ||
- this._targetApp.get_state() == Shell.AppState.BUSY));
+ this._targetApp.get_busy()));
if (isBusy)
this.startAnimation();
else
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index d330975..ff838f9 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -335,7 +335,6 @@ _shell_app_system_notify_app_state_changed (ShellAppSystem *self,
switch (state)
{
case SHELL_APP_STATE_RUNNING:
- case SHELL_APP_STATE_BUSY:
g_hash_table_insert (self->priv->running_apps, g_object_ref (app), NULL);
break;
case SHELL_APP_STATE_STARTING:
diff --git a/src/shell-app.c b/src/shell-app.c
index 2e12621..a16ef5c 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -92,6 +92,7 @@ struct _ShellApp
enum {
PROP_0,
PROP_STATE,
+ PROP_BUSY,
PROP_ID,
PROP_DBUS_ID,
PROP_ACTION_GROUP,
@@ -123,6 +124,9 @@ shell_app_get_property (GObject *gobject,
case PROP_STATE:
g_value_set_enum (value, app->state);
break;
+ case PROP_BUSY:
+ g_value_set_boolean (value, shell_app_get_busy (app));
+ break;
case PROP_ID:
g_value_set_string (value, shell_app_get_id (app));
break;
@@ -678,7 +682,6 @@ shell_app_activate_full (ShellApp *app,
case SHELL_APP_STATE_STARTING:
break;
case SHELL_APP_STATE_RUNNING:
- case SHELL_APP_STATE_BUSY:
shell_app_activate_window (app, NULL, timestamp);
break;
}
@@ -1060,22 +1063,27 @@ shell_app_on_ws_switch (MetaScreen *screen,
g_signal_emit (app, shell_app_signals[WINDOWS_CHANGED], 0);
}
+gboolean
+shell_app_get_busy (ShellApp *app)
+{
+ if (app->running_state != NULL &&
+ app->running_state->application_proxy != NULL &&
+ shell_org_gtk_application_get_busy (app->running_state->application_proxy))
+ return TRUE;
+
+ return FALSE;
+}
+
static void
busy_changed_cb (GObject *object,
GParamSpec *pspec,
gpointer user_data)
{
- ShellOrgGtkApplication *proxy;
ShellApp *app = user_data;
- g_assert (SHELL_IS_ORG_GTK_APPLICATION (object));
g_assert (SHELL_IS_APP (app));
- proxy = SHELL_ORG_GTK_APPLICATION (object);
- if (shell_org_gtk_application_get_busy (proxy))
- shell_app_state_transition (app, SHELL_APP_STATE_BUSY);
- else
- shell_app_state_transition (app, SHELL_APP_STATE_RUNNING);
+ g_object_notify (G_OBJECT (app), "busy");
}
static void
@@ -1097,7 +1105,7 @@ get_application_proxy (GObject *source,
G_CALLBACK (busy_changed_cb),
app);
if (shell_org_gtk_application_get_busy (proxy))
- shell_app_state_transition (app, SHELL_APP_STATE_BUSY);
+ g_object_notify (G_OBJECT (app), "busy");
}
if (app->running_state != NULL)
@@ -1578,6 +1586,19 @@ shell_app_class_init(ShellAppClass *klass)
G_PARAM_READABLE));
/**
+ * ShellApp:busy:
+ *
+ * Whether the application has marked itself as busy.
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_BUSY,
+ g_param_spec_boolean ("busy",
+ "Busy",
+ "Busy state",
+ FALSE,
+ G_PARAM_READABLE));
+
+ /**
* ShellApp:id:
*
* The id of this application (a desktop filename, or a special string
diff --git a/src/shell-app.h b/src/shell-app.h
index 4cf7572..2916331 100644
--- a/src/shell-app.h
+++ b/src/shell-app.h
@@ -30,8 +30,7 @@ struct _ShellAppClass
typedef enum {
SHELL_APP_STATE_STOPPED,
SHELL_APP_STATE_STARTING,
- SHELL_APP_STATE_RUNNING,
- SHELL_APP_STATE_BUSY
+ SHELL_APP_STATE_RUNNING
} ShellAppState;
GType shell_app_get_type (void) G_GNUC_CONST;
@@ -87,6 +86,8 @@ int shell_app_compare (ShellApp *app, ShellApp *other);
void shell_app_update_window_actions (ShellApp *app, MetaWindow *window);
void shell_app_update_app_menu (ShellApp *app, MetaWindow *window);
+gboolean shell_app_get_busy (ShellApp *app);
+
G_END_DECLS
#endif /* __SHELL_APP_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]