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
This commit is contained in:
parent
e00bfcc2cf
commit
546ae00854
@ -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));
|
||||
@ -457,12 +458,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());
|
||||
}
|
||||
@ -476,7 +482,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
|
||||
|
@ -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:
|
||||
|
@ -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)
|
||||
@ -1577,6 +1585,19 @@ shell_app_class_init(ShellAppClass *klass)
|
||||
SHELL_APP_STATE_STOPPED,
|
||||
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:
|
||||
*
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user