2008-11-20 19:53:11 -05:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2009-11-24 09:07:40 -05:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
#include "shell-app-system.h"
|
2011-10-05 10:44:50 -04:00
|
|
|
#include "shell-app-usage.h"
|
2009-06-25 17:43:54 -04:00
|
|
|
#include <string.h>
|
2008-11-20 19:53:11 -05:00
|
|
|
|
|
|
|
#include <gio/gio.h>
|
2010-11-05 12:47:50 -04:00
|
|
|
#include <glib/gi18n.h>
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-10-15 19:28:29 -04:00
|
|
|
#include "shell-app-private.h"
|
2010-12-20 21:06:03 -05:00
|
|
|
#include "shell-window-tracker-private.h"
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
#include "shell-app-system-private.h"
|
2009-07-07 16:08:41 -04:00
|
|
|
#include "shell-global.h"
|
2011-08-10 12:58:40 -04:00
|
|
|
#include "shell-util.h"
|
2009-07-07 16:08:41 -04:00
|
|
|
|
2009-08-21 14:48:14 -04:00
|
|
|
/* Vendor prefixes are something that can be preprended to a .desktop
|
|
|
|
* file name. Undo this.
|
|
|
|
*/
|
2011-03-17 18:44:41 -04:00
|
|
|
static const char*const vendor_prefixes[] = { "gnome-",
|
|
|
|
"fedora-",
|
|
|
|
"mozilla-",
|
2011-12-05 21:24:47 -05:00
|
|
|
"debian-",
|
2011-03-17 18:44:41 -04:00
|
|
|
NULL };
|
2009-08-21 14:48:14 -04:00
|
|
|
|
2008-11-20 19:53:11 -05:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
APP_STATE_CHANGED,
|
2009-06-25 17:43:54 -04:00
|
|
|
INSTALLED_CHANGED,
|
2008-11-20 19:53:11 -05:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
struct _ShellAppSystemPrivate {
|
2009-05-14 14:14:18 -04:00
|
|
|
GMenuTree *apps_tree;
|
|
|
|
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
GHashTable *running_apps;
|
2012-06-19 11:35:05 -04:00
|
|
|
GHashTable *visible_id_to_app;
|
2011-09-19 12:49:05 -04:00
|
|
|
GHashTable *id_to_app;
|
2013-10-02 18:16:45 -04:00
|
|
|
GHashTable *startup_wm_class_to_id;
|
2008-11-20 19:53:11 -05:00
|
|
|
};
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
static void shell_app_system_finalize (GObject *object);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
static void on_apps_tree_changed_cb (GMenuTree *tree, gpointer user_data);
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
G_DEFINE_TYPE(ShellAppSystem, shell_app_system, G_TYPE_OBJECT);
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
static void shell_app_system_class_init(ShellAppSystemClass *klass)
|
2008-11-20 19:53:11 -05:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = (GObjectClass *)klass;
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
gobject_class->finalize = shell_app_system_finalize;
|
2008-11-20 19:53:11 -05:00
|
|
|
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
signals[APP_STATE_CHANGED] = g_signal_new ("app-state-changed",
|
|
|
|
SHELL_TYPE_APP_SYSTEM,
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
SHELL_TYPE_APP);
|
2009-06-25 17:43:54 -04:00
|
|
|
signals[INSTALLED_CHANGED] =
|
|
|
|
g_signal_new ("installed-changed",
|
2009-04-22 15:21:35 -04:00
|
|
|
SHELL_TYPE_APP_SYSTEM,
|
2008-11-20 19:53:11 -05:00
|
|
|
G_SIGNAL_RUN_LAST,
|
2009-06-25 17:43:54 -04:00
|
|
|
G_STRUCT_OFFSET (ShellAppSystemClass, installed_changed),
|
2011-10-18 18:19:32 -04:00
|
|
|
NULL, NULL, NULL,
|
2008-11-20 19:53:11 -05:00
|
|
|
G_TYPE_NONE, 0);
|
|
|
|
|
2009-04-22 15:21:35 -04:00
|
|
|
g_type_class_add_private (gobject_class, sizeof (ShellAppSystemPrivate));
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-04-22 15:21:35 -04:00
|
|
|
shell_app_system_init (ShellAppSystem *self)
|
2008-11-20 19:53:11 -05:00
|
|
|
{
|
2009-04-22 15:21:35 -04:00
|
|
|
ShellAppSystemPrivate *priv;
|
2009-06-25 17:43:54 -04:00
|
|
|
|
2009-04-01 15:51:17 -04:00
|
|
|
self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
2009-04-22 15:21:35 -04:00
|
|
|
SHELL_TYPE_APP_SYSTEM,
|
|
|
|
ShellAppSystemPrivate);
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2011-09-19 12:49:05 -04:00
|
|
|
priv->running_apps = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL);
|
|
|
|
priv->id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
NULL,
|
|
|
|
(GDestroyNotify)g_object_unref);
|
2012-06-19 11:35:05 -04:00
|
|
|
|
|
|
|
/* All the objects in this hash table are owned by id_to_app */
|
|
|
|
priv->visible_id_to_app = g_hash_table_new (g_str_hash, g_str_equal);
|
|
|
|
|
2013-10-02 18:16:45 -04:00
|
|
|
priv->startup_wm_class_to_id = g_hash_table_new (g_str_hash, g_str_equal);
|
2012-04-06 14:02:04 -04:00
|
|
|
|
2012-06-19 11:35:05 -04:00
|
|
|
/* We want to track NoDisplay apps, so we add INCLUDE_NODISPLAY. We'll
|
|
|
|
* filter NoDisplay apps out when showing them to the user. */
|
2011-04-18 16:05:47 -04:00
|
|
|
priv->apps_tree = gmenu_tree_new ("applications.menu", GMENU_TREE_FLAGS_INCLUDE_NODISPLAY);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
g_signal_connect (priv->apps_tree, "changed", G_CALLBACK (on_apps_tree_changed_cb), self);
|
2009-09-02 17:35:09 -04:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
on_apps_tree_changed_cb (priv->apps_tree, self);
|
2008-11-20 19:53:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-04-22 15:21:35 -04:00
|
|
|
shell_app_system_finalize (GObject *object)
|
2008-11-20 19:53:11 -05:00
|
|
|
{
|
2009-04-22 15:21:35 -04:00
|
|
|
ShellAppSystem *self = SHELL_APP_SYSTEM (object);
|
|
|
|
ShellAppSystemPrivate *priv = self->priv;
|
2008-11-20 19:53:11 -05:00
|
|
|
|
2011-04-18 16:05:47 -04:00
|
|
|
g_object_unref (priv->apps_tree);
|
2009-05-14 14:14:18 -04:00
|
|
|
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
g_hash_table_destroy (priv->running_apps);
|
2011-09-19 12:49:05 -04:00
|
|
|
g_hash_table_destroy (priv->id_to_app);
|
2012-06-19 11:35:05 -04:00
|
|
|
g_hash_table_destroy (priv->visible_id_to_app);
|
2013-10-02 18:16:45 -04:00
|
|
|
g_hash_table_destroy (priv->startup_wm_class_to_id);
|
2011-03-17 18:44:41 -04:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
G_OBJECT_CLASS (shell_app_system_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-09-19 11:33:31 -04:00
|
|
|
get_flattened_entries_recurse (GMenuTreeDirectory *dir,
|
|
|
|
GHashTable *entry_set)
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
{
|
2011-09-19 11:33:31 -04:00
|
|
|
GMenuTreeIter *iter = gmenu_tree_directory_iter (dir);
|
2011-04-18 16:05:47 -04:00
|
|
|
GMenuTreeItemType next_type;
|
2009-04-01 15:51:17 -04:00
|
|
|
|
2011-04-18 16:05:47 -04:00
|
|
|
while ((next_type = gmenu_tree_iter_next (iter)) != GMENU_TREE_ITEM_INVALID)
|
2009-04-01 15:51:17 -04:00
|
|
|
{
|
2011-04-18 16:05:47 -04:00
|
|
|
gpointer item = NULL;
|
|
|
|
|
|
|
|
switch (next_type)
|
2009-04-01 15:51:17 -04:00
|
|
|
{
|
2011-04-18 16:05:47 -04:00
|
|
|
case GMENU_TREE_ITEM_ENTRY:
|
|
|
|
{
|
2011-09-19 11:33:31 -04:00
|
|
|
GMenuTreeEntry *entry;
|
|
|
|
item = entry = gmenu_tree_iter_get_entry (iter);
|
|
|
|
/* Key is owned by entry */
|
|
|
|
g_hash_table_replace (entry_set,
|
|
|
|
(char*)gmenu_tree_entry_get_desktop_file_id (entry),
|
|
|
|
gmenu_tree_item_ref (entry));
|
2011-04-18 16:05:47 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GMENU_TREE_ITEM_DIRECTORY:
|
|
|
|
{
|
|
|
|
item = gmenu_tree_iter_get_directory (iter);
|
2011-09-19 11:33:31 -04:00
|
|
|
get_flattened_entries_recurse ((GMenuTreeDirectory*)item, entry_set);
|
2011-04-18 16:05:47 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (item != NULL)
|
|
|
|
gmenu_tree_item_unref (item);
|
2009-04-01 15:51:17 -04:00
|
|
|
}
|
2009-05-14 13:03:18 -04:00
|
|
|
|
2011-04-18 16:05:47 -04:00
|
|
|
gmenu_tree_iter_unref (iter);
|
2009-05-14 13:03:18 -04:00
|
|
|
}
|
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
static GHashTable *
|
|
|
|
get_flattened_entries_from_tree (GMenuTree *tree)
|
2009-05-14 14:14:18 -04:00
|
|
|
{
|
2011-09-19 11:33:31 -04:00
|
|
|
GHashTable *table;
|
|
|
|
GMenuTreeDirectory *root;
|
2009-07-07 16:08:41 -04:00
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
table = g_hash_table_new_full (g_str_hash, g_str_equal,
|
|
|
|
(GDestroyNotify) NULL,
|
|
|
|
(GDestroyNotify) gmenu_tree_item_unref);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
root = gmenu_tree_get_root_directory (tree);
|
|
|
|
|
|
|
|
if (root != NULL)
|
|
|
|
get_flattened_entries_recurse (root, table);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
gmenu_tree_item_unref (root);
|
|
|
|
|
|
|
|
return table;
|
2009-07-07 16:08:41 -04:00
|
|
|
}
|
|
|
|
|
2009-05-14 14:14:18 -04:00
|
|
|
static void
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
on_apps_tree_changed_cb (GMenuTree *tree,
|
|
|
|
gpointer user_data)
|
2009-05-14 14:14:18 -04:00
|
|
|
{
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
ShellAppSystem *self = SHELL_APP_SYSTEM (user_data);
|
2011-04-18 16:05:47 -04:00
|
|
|
GError *error = NULL;
|
2011-09-19 11:33:31 -04:00
|
|
|
GHashTable *new_apps;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
2011-04-18 16:05:47 -04:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
g_assert (tree == self->priv->apps_tree);
|
2009-07-07 16:08:41 -04:00
|
|
|
|
2012-06-19 11:35:05 -04:00
|
|
|
g_hash_table_remove_all (self->priv->visible_id_to_app);
|
2011-03-17 18:44:41 -04:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
if (!gmenu_tree_load_sync (self->priv->apps_tree, &error))
|
|
|
|
{
|
2012-02-20 02:33:49 -05:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_warning ("Failed to load apps: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_warning ("Failed to load apps");
|
|
|
|
}
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
return;
|
|
|
|
}
|
2009-05-14 14:14:18 -04:00
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
new_apps = get_flattened_entries_from_tree (self->priv->apps_tree);
|
|
|
|
g_hash_table_iter_init (&iter, new_apps);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
{
|
2011-09-19 12:49:05 -04:00
|
|
|
const char *id = key;
|
2011-09-19 11:33:31 -04:00
|
|
|
GMenuTreeEntry *entry = value;
|
|
|
|
ShellApp *app;
|
2012-04-06 14:02:04 -04:00
|
|
|
GDesktopAppInfo *info;
|
|
|
|
const char *startup_wm_class;
|
|
|
|
|
2013-10-02 18:22:07 -04:00
|
|
|
info = g_desktop_app_info_new (gmenu_tree_entry_get_desktop_file_id (entry));
|
2013-02-08 22:52:25 -05:00
|
|
|
|
2011-09-19 12:49:05 -04:00
|
|
|
app = g_hash_table_lookup (self->priv->id_to_app, id);
|
2011-09-19 11:33:31 -04:00
|
|
|
if (app != NULL)
|
2012-04-06 14:02:04 -04:00
|
|
|
{
|
|
|
|
GDesktopAppInfo *old_info;
|
|
|
|
const gchar *old_startup_wm_class;
|
|
|
|
|
2013-02-08 22:52:25 -05:00
|
|
|
old_info = shell_app_get_app_info (app);
|
2012-04-06 14:02:04 -04:00
|
|
|
old_startup_wm_class = g_desktop_app_info_get_startup_wm_class (old_info);
|
|
|
|
|
|
|
|
if (old_startup_wm_class)
|
2013-10-02 18:16:45 -04:00
|
|
|
g_hash_table_remove (self->priv->startup_wm_class_to_id, old_startup_wm_class);
|
2013-02-08 22:52:25 -05:00
|
|
|
|
|
|
|
_shell_app_set_app_info (app, info);
|
|
|
|
g_object_ref (app); /* Extra ref, removed in _replace below */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
app = _shell_app_new (info);
|
2012-04-06 14:02:04 -04:00
|
|
|
}
|
|
|
|
|
2013-10-02 18:22:07 -04:00
|
|
|
g_object_unref (info);
|
|
|
|
|
2013-02-08 22:52:25 -05:00
|
|
|
g_hash_table_replace (self->priv->id_to_app, (char*)id, app);
|
|
|
|
if (!gmenu_tree_entry_get_is_nodisplay_recurse (entry))
|
|
|
|
g_hash_table_replace (self->priv->visible_id_to_app, (char*)id, app);
|
|
|
|
|
2012-04-06 14:02:04 -04:00
|
|
|
startup_wm_class = g_desktop_app_info_get_startup_wm_class (info);
|
|
|
|
if (startup_wm_class)
|
2013-10-02 18:16:45 -04:00
|
|
|
g_hash_table_replace (self->priv->startup_wm_class_to_id,
|
|
|
|
(char*)startup_wm_class, (char*)id);
|
2011-09-19 12:49:05 -04:00
|
|
|
}
|
|
|
|
/* Now iterate over the apps again; we need to unreference any apps
|
|
|
|
* which have been removed. The JS code may still be holding a
|
|
|
|
* reference; that's fine.
|
|
|
|
*/
|
|
|
|
g_hash_table_iter_init (&iter, self->priv->id_to_app);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
|
|
{
|
|
|
|
const char *id = key;
|
2011-09-19 11:33:31 -04:00
|
|
|
|
2011-09-19 12:49:05 -04:00
|
|
|
if (!g_hash_table_lookup (new_apps, id))
|
2013-03-16 16:50:16 -04:00
|
|
|
g_hash_table_iter_remove (&iter);
|
2011-09-19 12:49:05 -04:00
|
|
|
}
|
2013-03-16 16:50:16 -04:00
|
|
|
|
2011-09-19 11:33:31 -04:00
|
|
|
g_hash_table_destroy (new_apps);
|
2009-10-02 19:02:14 -04:00
|
|
|
|
|
|
|
g_signal_emit (self, signals[INSTALLED_CHANGED], 0);
|
2009-09-02 17:35:09 -04:00
|
|
|
}
|
|
|
|
|
2009-06-18 12:27:19 -04:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
2009-06-25 17:43:54 -04:00
|
|
|
|
2009-10-15 19:28:29 -04:00
|
|
|
/**
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
* shell_app_system_lookup_app:
|
2009-10-15 19:28:29 -04:00
|
|
|
*
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
* Find a #ShellApp corresponding to an id.
|
2009-10-15 19:28:29 -04:00
|
|
|
*
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
* Return value: (transfer none): The #ShellApp for id, or %NULL if none
|
2009-10-15 19:28:29 -04:00
|
|
|
*/
|
|
|
|
ShellApp *
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
shell_app_system_lookup_app (ShellAppSystem *self,
|
|
|
|
const char *id)
|
2009-06-25 17:43:54 -04:00
|
|
|
{
|
2011-09-19 12:49:05 -04:00
|
|
|
return g_hash_table_lookup (self->priv->id_to_app, id);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
}
|
2009-06-25 17:43:54 -04:00
|
|
|
|
2009-07-07 16:08:41 -04:00
|
|
|
/**
|
|
|
|
* shell_app_system_lookup_heuristic_basename:
|
2010-09-14 20:56:34 -04:00
|
|
|
* @system: a #ShellAppSystem
|
|
|
|
* @id: Probable application identifier
|
2009-07-07 16:08:41 -04:00
|
|
|
*
|
|
|
|
* Find a valid application corresponding to a given
|
|
|
|
* heuristically determined application identifier
|
|
|
|
* string, or %NULL if none.
|
|
|
|
*
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
* Returns: (transfer none): A #ShellApp for @name
|
2009-07-07 16:08:41 -04:00
|
|
|
*/
|
2009-10-15 19:28:29 -04:00
|
|
|
ShellApp *
|
2009-07-07 16:08:41 -04:00
|
|
|
shell_app_system_lookup_heuristic_basename (ShellAppSystem *system,
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
const char *name)
|
2009-07-07 16:08:41 -04:00
|
|
|
{
|
2009-10-15 19:28:29 -04:00
|
|
|
ShellApp *result;
|
2013-04-20 17:15:10 -04:00
|
|
|
const char *const *prefix;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
|
|
|
|
result = shell_app_system_lookup_app (system, name);
|
2009-07-07 16:08:41 -04:00
|
|
|
if (result != NULL)
|
|
|
|
return result;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
|
2013-04-20 17:15:10 -04:00
|
|
|
for (prefix = vendor_prefixes; *prefix != NULL; prefix++)
|
2009-08-21 14:48:14 -04:00
|
|
|
{
|
2013-04-20 17:15:10 -04:00
|
|
|
char *tmpid = g_strconcat (*prefix, name, NULL);
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
result = shell_app_system_lookup_app (system, tmpid);
|
2009-08-21 14:48:14 -04:00
|
|
|
g_free (tmpid);
|
|
|
|
if (result != NULL)
|
|
|
|
return result;
|
|
|
|
}
|
2009-07-07 16:08:41 -04:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-08 21:39:59 -04:00
|
|
|
/**
|
2012-04-06 14:02:04 -04:00
|
|
|
* shell_app_system_lookup_desktop_wmclass:
|
2012-04-08 21:39:59 -04:00
|
|
|
* @system: a #ShellAppSystem
|
2013-08-08 04:40:01 -04:00
|
|
|
* @wmclass: (allow-none): A WM_CLASS value
|
2012-04-08 21:39:59 -04:00
|
|
|
*
|
2012-04-06 14:02:04 -04:00
|
|
|
* Find a valid application whose .desktop file, without the extension
|
|
|
|
* and properly canonicalized, matches @wmclass.
|
2012-04-08 21:39:59 -04:00
|
|
|
*
|
|
|
|
* Returns: (transfer none): A #ShellApp for @wmclass
|
|
|
|
*/
|
|
|
|
ShellApp *
|
2012-04-06 14:02:04 -04:00
|
|
|
shell_app_system_lookup_desktop_wmclass (ShellAppSystem *system,
|
|
|
|
const char *wmclass)
|
2012-04-08 21:39:59 -04:00
|
|
|
{
|
|
|
|
char *canonicalized;
|
|
|
|
char *desktop_file;
|
|
|
|
ShellApp *app;
|
|
|
|
|
|
|
|
if (wmclass == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2013-08-18 12:26:37 -04:00
|
|
|
/* First try without changing the case (this handles
|
|
|
|
org.example.Foo.Bar.desktop applications)
|
|
|
|
|
|
|
|
Note that is slightly wrong in that Gtk+ would set
|
|
|
|
the WM_CLASS to Org.example.Foo.Bar, but it also
|
|
|
|
sets the instance part to org.example.Foo.Bar, so we're ok
|
|
|
|
*/
|
|
|
|
desktop_file = g_strconcat (wmclass, ".desktop", NULL);
|
|
|
|
app = shell_app_system_lookup_heuristic_basename (system, desktop_file);
|
|
|
|
g_free (desktop_file);
|
|
|
|
|
|
|
|
if (app)
|
|
|
|
return app;
|
|
|
|
|
2012-04-08 21:39:59 -04:00
|
|
|
canonicalized = g_ascii_strdown (wmclass, -1);
|
|
|
|
|
|
|
|
/* This handles "Fedora Eclipse", probably others.
|
|
|
|
* Note g_strdelimit is modify-in-place. */
|
|
|
|
g_strdelimit (canonicalized, " ", '-');
|
|
|
|
|
|
|
|
desktop_file = g_strconcat (canonicalized, ".desktop", NULL);
|
|
|
|
|
|
|
|
app = shell_app_system_lookup_heuristic_basename (system, desktop_file);
|
|
|
|
|
|
|
|
g_free (canonicalized);
|
|
|
|
g_free (desktop_file);
|
|
|
|
|
|
|
|
return app;
|
|
|
|
}
|
|
|
|
|
2012-04-06 14:02:04 -04:00
|
|
|
/**
|
|
|
|
* shell_app_system_lookup_startup_wmclass:
|
|
|
|
* @system: a #ShellAppSystem
|
2013-08-08 04:40:01 -04:00
|
|
|
* @wmclass: (allow-none): A WM_CLASS value
|
2012-04-06 14:02:04 -04:00
|
|
|
*
|
|
|
|
* Find a valid application whose .desktop file contains a
|
|
|
|
* StartupWMClass entry matching @wmclass.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none): A #ShellApp for @wmclass
|
|
|
|
*/
|
|
|
|
ShellApp *
|
|
|
|
shell_app_system_lookup_startup_wmclass (ShellAppSystem *system,
|
|
|
|
const char *wmclass)
|
|
|
|
{
|
2013-10-02 18:16:45 -04:00
|
|
|
const char *id;
|
|
|
|
|
2013-08-08 04:40:01 -04:00
|
|
|
if (wmclass == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2013-10-02 18:16:45 -04:00
|
|
|
id = g_hash_table_lookup (system->priv->startup_wm_class_to_id, wmclass);
|
|
|
|
if (id == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return shell_app_system_lookup_app (system, id);
|
2012-04-06 14:02:04 -04:00
|
|
|
}
|
|
|
|
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
void
|
|
|
|
_shell_app_system_notify_app_state_changed (ShellAppSystem *self,
|
|
|
|
ShellApp *app)
|
|
|
|
{
|
|
|
|
ShellAppState state = shell_app_get_state (app);
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case SHELL_APP_STATE_RUNNING:
|
2013-04-20 15:51:04 -04:00
|
|
|
case SHELL_APP_STATE_BUSY:
|
2011-09-19 12:49:05 -04:00
|
|
|
g_hash_table_insert (self->priv->running_apps, g_object_ref (app), NULL);
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
break;
|
|
|
|
case SHELL_APP_STATE_STARTING:
|
|
|
|
break;
|
|
|
|
case SHELL_APP_STATE_STOPPED:
|
2011-09-19 12:49:05 -04:00
|
|
|
g_hash_table_remove (self->priv->running_apps, app);
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_signal_emit (self, signals[APP_STATE_CHANGED], 0, app);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_app_system_get_running:
|
|
|
|
* @self: A #ShellAppSystem
|
|
|
|
*
|
|
|
|
* Returns the set of applications which currently have at least one
|
|
|
|
* open window in the given context. The returned list will be sorted
|
|
|
|
* by shell_app_compare().
|
|
|
|
*
|
|
|
|
* Returns: (element-type ShellApp) (transfer container): Active applications
|
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
shell_app_system_get_running (ShellAppSystem *self)
|
|
|
|
{
|
|
|
|
gpointer key, value;
|
|
|
|
GSList *ret;
|
|
|
|
GHashTableIter iter;
|
|
|
|
|
|
|
|
g_hash_table_iter_init (&iter, self->priv->running_apps);
|
|
|
|
|
|
|
|
ret = NULL;
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
|
|
{
|
2011-09-19 12:49:05 -04:00
|
|
|
ShellApp *app = key;
|
apps: Ensure running apps override new .desktop file data
This patch fixes the "apps vanish from alt-TAB bug".
If a "package system" rips away and possibly replaces .desktop files
at some random time, we have historically used inotify to detect this
and reread state (in a racy way, but...). In GNOME 2, this was
generally not too problematic because the menu widget was totally
separate from the list of windows - and the data they operate on was
disjoint as well.
In GNOME 3 we unify these, and this creates architectural problems
because the windows are tied to the app.
What this patch tries to do is, when rereading the application state,
if we have a running application, we keep that app around instead of
making a new instance. This ensures we preserve any state such as the
set of open windows.
This requires moving the running state into ShellAppSystem. Adjust
callers as necessary, and while we're at it drop the unused "contexts"
stuff.
This is just a somewhat quick band-aid; a REAL fix would require us
having low-level control over application installation. As long as
we're on top of random broken tar+wget wrappers, it will be gross.
A slight future improvement to this patch would add an explicit
"merge" between the old and new data. I think probably we always keep
around the ShellApp corresponding to a given ID, but replace its
GMenuTreeEntry.
https://bugzilla.gnome.org/show_bug.cgi?id=657990
2011-09-03 10:32:06 -04:00
|
|
|
|
|
|
|
ret = g_slist_prepend (ret, app);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = g_slist_sort (ret, (GCompareFunc)shell_app_compare);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-29 17:45:30 -05:00
|
|
|
static gint
|
2011-10-05 10:44:50 -04:00
|
|
|
compare_apps_by_usage (gconstpointer a,
|
|
|
|
gconstpointer b,
|
|
|
|
gpointer data)
|
2009-11-29 17:45:30 -05:00
|
|
|
{
|
2011-10-05 10:44:50 -04:00
|
|
|
ShellAppUsage *usage = shell_app_usage_get_default ();
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
ShellApp *app_a = (ShellApp*)a;
|
|
|
|
ShellApp *app_b = (ShellApp*)b;
|
|
|
|
|
2011-10-05 10:44:50 -04:00
|
|
|
return shell_app_usage_compare (usage, "", app_a, app_b);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *
|
|
|
|
sort_and_concat_results (ShellAppSystem *system,
|
|
|
|
GSList *prefix_matches,
|
|
|
|
GSList *substring_matches)
|
|
|
|
{
|
2013-02-08 22:08:13 -05:00
|
|
|
GSList *matches = NULL;
|
|
|
|
GSList *l;
|
|
|
|
|
2010-06-06 19:09:15 -04:00
|
|
|
prefix_matches = g_slist_sort_with_data (prefix_matches,
|
2011-10-05 10:44:50 -04:00
|
|
|
compare_apps_by_usage,
|
2010-06-06 19:09:15 -04:00
|
|
|
system);
|
|
|
|
substring_matches = g_slist_sort_with_data (substring_matches,
|
2011-10-05 10:44:50 -04:00
|
|
|
compare_apps_by_usage,
|
2010-06-06 19:09:15 -04:00
|
|
|
system);
|
2013-02-08 22:08:13 -05:00
|
|
|
|
|
|
|
for (l = substring_matches; l != NULL; l = l->next)
|
|
|
|
matches = g_slist_prepend (matches, (char *) shell_app_get_id (SHELL_APP (l->data)));
|
|
|
|
for (l = prefix_matches; l != NULL; l = l->next)
|
|
|
|
matches = g_slist_prepend (matches, (char *) shell_app_get_id (SHELL_APP (l->data)));
|
|
|
|
|
|
|
|
return g_slist_reverse (matches);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* normalize_terms:
|
|
|
|
* @terms: (element-type utf8): Input search terms
|
|
|
|
*
|
|
|
|
* Returns: (element-type utf8) (transfer full): Unicode-normalized and lowercased terms
|
|
|
|
*/
|
|
|
|
static GSList *
|
|
|
|
normalize_terms (GSList *terms)
|
|
|
|
{
|
|
|
|
GSList *normalized_terms = NULL;
|
|
|
|
GSList *iter;
|
|
|
|
for (iter = terms; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
const char *term = iter->data;
|
2012-12-12 11:04:27 -05:00
|
|
|
normalized_terms = g_slist_prepend (normalized_terms,
|
|
|
|
shell_util_normalize_casefold_and_unaccent (term));
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
return normalized_terms;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
search_tree (ShellAppSystem *self,
|
|
|
|
GSList *terms,
|
|
|
|
GHashTable *apps)
|
2009-11-29 17:45:30 -05:00
|
|
|
{
|
|
|
|
GSList *prefix_results = NULL;
|
|
|
|
GSList *substring_results = NULL;
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
GSList *normalized_terms;
|
|
|
|
GHashTableIter iter;
|
|
|
|
gpointer key, value;
|
2009-11-29 17:45:30 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
normalized_terms = normalize_terms (terms);
|
2009-11-29 17:45:30 -05:00
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
g_hash_table_iter_init (&iter, apps);
|
|
|
|
while (g_hash_table_iter_next (&iter, &key, &value))
|
|
|
|
{
|
|
|
|
ShellApp *app = value;
|
|
|
|
_shell_app_do_match (app, normalized_terms,
|
2011-10-05 19:07:29 -04:00
|
|
|
&prefix_results,
|
|
|
|
&substring_results);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
2012-06-18 06:22:29 -04:00
|
|
|
g_slist_free_full (normalized_terms, g_free);
|
2009-11-29 17:45:30 -05:00
|
|
|
|
2011-10-05 19:07:29 -04:00
|
|
|
return sort_and_concat_results (self, prefix_results, substring_results);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_app_system_initial_search:
|
2010-09-14 20:56:34 -04:00
|
|
|
* @system: A #ShellAppSystem
|
2010-06-06 19:09:15 -04:00
|
|
|
* @terms: (element-type utf8): List of terms, logical AND
|
2009-11-29 17:45:30 -05:00
|
|
|
*
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
* Search through applications for the given search terms.
|
2009-11-29 17:45:30 -05:00
|
|
|
*
|
2013-02-08 22:08:13 -05:00
|
|
|
* Returns: (transfer container) (element-type utf8): List of applications
|
2009-11-29 17:45:30 -05:00
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
shell_app_system_initial_search (ShellAppSystem *self,
|
|
|
|
GSList *terms)
|
|
|
|
{
|
2012-06-19 11:35:05 -04:00
|
|
|
return search_tree (self, terms, self->priv->visible_id_to_app);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* shell_app_system_subsearch:
|
2010-09-14 20:56:34 -04:00
|
|
|
* @system: A #ShellAppSystem
|
2013-02-08 22:08:13 -05:00
|
|
|
* @previous_results: (element-type utf8): List of previous results
|
2010-06-06 19:09:15 -04:00
|
|
|
* @terms: (element-type utf8): List of terms, logical AND
|
2009-11-29 17:45:30 -05:00
|
|
|
*
|
|
|
|
* Search through a previous result set; for more information, see
|
2013-10-12 11:07:41 -04:00
|
|
|
* js/ui/search.js. Note that returned strings are only valid until
|
|
|
|
* a return to the main loop.
|
2009-11-29 17:45:30 -05:00
|
|
|
*
|
2013-02-08 22:08:13 -05:00
|
|
|
* Returns: (transfer container) (element-type utf8): List of application identifiers
|
2009-11-29 17:45:30 -05:00
|
|
|
*/
|
|
|
|
GSList *
|
|
|
|
shell_app_system_subsearch (ShellAppSystem *system,
|
|
|
|
GSList *previous_results,
|
|
|
|
GSList *terms)
|
|
|
|
{
|
|
|
|
GSList *iter;
|
|
|
|
GSList *prefix_results = NULL;
|
|
|
|
GSList *substring_results = NULL;
|
|
|
|
GSList *normalized_terms = normalize_terms (terms);
|
|
|
|
|
2013-02-15 23:17:44 -05:00
|
|
|
previous_results = g_slist_reverse (previous_results);
|
|
|
|
|
2009-11-29 17:45:30 -05:00
|
|
|
for (iter = previous_results; iter; iter = iter->next)
|
|
|
|
{
|
2013-02-08 22:08:13 -05:00
|
|
|
ShellApp *app = shell_app_system_lookup_app (system, iter->data);
|
|
|
|
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
_shell_app_do_match (app, normalized_terms,
|
2011-10-05 19:07:29 -04:00
|
|
|
&prefix_results,
|
|
|
|
&substring_results);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
2012-06-18 06:22:29 -04:00
|
|
|
g_slist_free_full (normalized_terms, g_free);
|
2009-11-29 17:45:30 -05:00
|
|
|
|
|
|
|
/* Note that a shorter term might have matched as a prefix, but
|
|
|
|
when extended only as a substring, so we have to redo the
|
|
|
|
sort rather than reusing the existing ordering */
|
2011-10-05 19:07:29 -04:00
|
|
|
return sort_and_concat_results (system, prefix_results, substring_results);
|
2009-11-29 17:45:30 -05:00
|
|
|
}
|
|
|
|
|