From: "Ludovic Courtès" <ludo@gnu.org>
To: 36376@debbugs.gnu.org
Cc: Leo Prikler <leo.prikler@student.tugraz.at>,
Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: bug#36376: Application menu of desktop environment not automatically updated
Date: Tue, 03 Nov 2020 23:46:13 +0100 [thread overview]
Message-ID: <87o8keawju.fsf@gnu.org> (raw)
In-Reply-To: <871rzhn483.fsf@gnu.org> ("Ludovic Courtès"'s message of "Tue, 25 Jun 2019 16:12:44 +0200")
[-- Attachment #1: Type: text/plain, Size: 1560 bytes --]
Ludovic Courtès <ludo@gnu.org> skribis:
> This is not news to us, but as
> <https://distrowatch.com/weekly.php?issue=20190624#guixsd> notes, the
> application menu of desktop environments is not automatically updated
> when a package is installed or removed. It’d be great if we could
> somehow notify the desktop environment.
We’ve investigated today on IRC with Maxim and Leo P. and here’s the
summary of our findings:
• GNOME Shell, in ‘appDisplay.js’, “listens” to the
‘installed-changed’ GLib signals and uses that to rebuild its
application menu.
• In ‘shell-app-system.c’, ‘installed-changed’ is emitted when the
GAppInfoMonitor emits ‘changed’:
monitor = g_app_info_monitor_get ();
g_signal_connect (monitor, "changed", G_CALLBACK (installed_changed), self);
installed_changed (monitor, self);
• GLib emits the ‘changed’ signal when ‘g_app_info_monitor_fire’ is
called from ‘desktop_file_dir_changed’, itself called when one of
the directories in $XDG_DATA_DIRS (among others) changes. It uses
‘GFileMonitor’ under the hood, which is essentially inotify.
The GLib patch below is an attempt to monitor ~/.guix-profile and to
treat changes to that symlink as if they were changes to
~/.guix-profile/share/applications (which contains ‘.desktop’ files.)
It actually builds but I haven’t tested it yet. :-)
WDYT?
If we take that route, we could add a ‘replacement’ for GLib.
Thanks,
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 2821 bytes --]
diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c
index f1e2fdd..96dcc32 100644
--- a/gio/gdesktopappinfo.c
+++ b/gio/gdesktopappinfo.c
@@ -161,6 +161,7 @@ static DesktopFileDir *desktop_file_dir_user_config = NULL; /* (owned) */
static DesktopFileDir *desktop_file_dir_user_data = NULL; /* (owned) */
static GMutex desktop_file_dir_lock;
static const gchar *gio_launch_desktop_path = NULL;
+static GFileMonitor *guix_profile_monitor = NULL;
/* Monitor 'changed' signal handler {{{2 */
static void desktop_file_dir_reset (DesktopFileDir *dir);
@@ -230,6 +231,22 @@ desktop_file_dir_get_alternative_dir (DesktopFileDir *dir)
return parent;
}
+static void
+guix_profile_changed (GFileMonitor *monitor,
+ GFile *file,
+ GFile *other_file,
+ GFileMonitorEvent event_type,
+ gpointer user_data)
+{
+ DesktopFileDir *dir = user_data;
+
+ desktop_file_dir_reset (dir);
+
+ /* When ~/.guix-profile changes, emit the 'changed' signal so everyone
+ knows. */
+ g_app_info_monitor_fire ();
+}
+
static void
desktop_file_dir_changed (GFileMonitor *monitor,
GFile *file,
@@ -1531,6 +1548,7 @@ desktop_file_dirs_lock (void)
if (desktop_file_dirs == NULL || desktop_file_dirs->len == 0)
{
+ const gchar *home;
const char * const *dirs;
gint i;
@@ -1555,6 +1573,27 @@ desktop_file_dirs_lock (void)
for (i = 0; dirs[i]; i++)
g_ptr_array_add (desktop_file_dirs, desktop_file_dir_new (dirs[i]));
+ home = g_get_home_dir ();
+ if (guix_profile_monitor == NULL && home != NULL)
+ {
+ DesktopFileDir *dir;
+ const gchar *profile, *data_dir;
+ profile = g_build_filename (home, ".guix-profile", NULL);
+ data_dir = g_build_filename (profile, "share", NULL);
+ dir = desktop_file_dir_new (data_dir);
+
+ /* Monitor ~/.guix-profile and treat modifications to
+ ~/.guix-profile as if they were modifications to
+ ~/.guix-profile/share. */
+ guix_profile_monitor =
+ g_local_file_monitor_new_in_worker (profile, FALSE, G_FILE_MONITOR_NONE,
+ guix_profile_changed,
+ desktop_file_dir_ref (dir),
+ closure_notify_cb, NULL);
+
+ g_ptr_array_add (desktop_file_dirs, desktop_file_dir_ref (dir));
+ }
+
/* The list of directories will never change after this, unless
* g_get_user_config_dir() changes due to %G_TEST_OPTION_ISOLATE_DIRS. */
desktop_file_dirs_config_dir = user_config_dir;
next prev parent reply other threads:[~2020-11-03 22:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-25 14:12 bug#36376: Application menu of desktop environment not automatically updated Ludovic Courtès
2020-11-03 22:46 ` Ludovic Courtès [this message]
2020-11-03 23:28 ` Leo Prikler
2020-11-04 21:41 ` bug#35594: " Maxim Cournoyer
2020-11-04 22:15 ` Ludovic Courtès
2020-11-05 6:38 ` Maxim Cournoyer
2020-11-06 16:02 ` Ludovic Courtès
2020-11-06 18:56 ` Maxim Cournoyer
2020-11-10 15:23 ` Ludovic Courtès
2020-11-10 17:48 ` bug#35594: " zimoun
2020-11-10 21:23 ` Ludovic Courtès
2020-11-12 15:56 ` bug#35594: " Ludovic Courtès
2020-11-13 20:38 ` bug#36376: " Ludovic Courtès
2020-11-17 4:57 ` Maxim Cournoyer
2020-11-17 9:08 ` Ludovic Courtès
2020-11-18 4:34 ` Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o8keawju.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=36376@debbugs.gnu.org \
--cc=leo.prikler@student.tugraz.at \
--cc=maxim.cournoyer@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.