New patch attached, and I've also updated the corresponding patch for GTK+:
https://bugzilla.gnome.org/show_bug.cgi?id=611118
From 11bb52f7b89764cd672b89c1409b48d025b8c338 Mon Sep 17 00:00:00 2001 From: Colin Walters <[email protected]> Date: Thu, 25 Feb 2010 15:33:54 -0500 Subject: [PATCH] Support APPLICATION_ID and COMPLETED_BY keys For moving GNOME to an application-based system, it's useful if launcher systems say which .desktop file they're launching in the APPLICATION_ID key. This allows us to provide correct immediate feedback. The intent of the COMPLETED_BY key is to strongly associate the window which is completing the startup notification with the APPLICATION_ID known from the launch. --- doc/startup-notification.txt | 13 ++++++++++ libsn/sn-launcher.c | 19 ++++++++++++++ libsn/sn-launcher.h | 2 + libsn/sn-monitor.c | 55 +++++++++++++++++++++++++++++++++++++++++- libsn/sn-monitor.h | 2 + 5 files changed, 90 insertions(+), 1 deletions(-) diff --git a/doc/startup-notification.txt b/doc/startup-notification.txt index cf5b250..36444d7 100644 --- a/doc/startup-notification.txt +++ b/doc/startup-notification.txt @@ -299,6 +299,19 @@ The following keys may be provided optionally in either a "new" or a nor their WMClass is known, but which should preferably have their window mapped on the desktop specified by the value of DESKTOP. + + APPLICATION_ID + + When launching an application using a .desktop file, this + should be the full path to that file. For example, + "/usr/share/applications/foo.desktop". + +The following keys may be provided optionally in a "remove" message: + + COMPLETED_BY + + identification of the top-level window in which the launch + was completed. The value is the X window ID of the window. Some details of the startup sequence: diff --git a/libsn/sn-launcher.c b/libsn/sn-launcher.c index 21344cd..82718e3 100644 --- a/libsn/sn-launcher.c +++ b/libsn/sn-launcher.c @@ -44,6 +44,7 @@ struct SnLauncherContext char *wmclass; char *binary_name; char *icon_name; + char *application_id; struct timeval initiation_time; unsigned int completed : 1; unsigned int canceled : 1; @@ -121,6 +122,7 @@ sn_launcher_context_unref (SnLauncherContext *context) sn_free (context->wmclass); sn_free (context->binary_name); sn_free (context->icon_name); + sn_free (context->application_id); sn_display_unref (context->display); sn_free (context); @@ -266,6 +268,13 @@ sn_launcher_context_initiate (SnLauncherContext *context, values[i] = context->icon_name; ++i; } + + if (context->application_id != NULL) + { + names[i] = "APPLICATION_ID"; + values[i] = context->application_id; + ++i; + } assert (i < MAX_PROPS); @@ -433,6 +442,16 @@ sn_launcher_context_set_icon_name (SnLauncherContext *context, } void +sn_launcher_set_application_id (SnLauncherContext *context, + const char *desktop_file) +{ + WARN_ALREADY_INITIATED (context); + + sn_free (context->application_id); + context->application_id = sn_internal_strdup (desktop_file); +} + +void sn_launcher_context_set_extra_property (SnLauncherContext *context, const char *name, const char *value) diff --git a/libsn/sn-launcher.h b/libsn/sn-launcher.h index f88f11c..9cd34fd 100644 --- a/libsn/sn-launcher.h +++ b/libsn/sn-launcher.h @@ -61,6 +61,8 @@ void sn_launcher_context_set_binary_name (SnLauncherContext *context, const char *name); void sn_launcher_context_set_icon_name (SnLauncherContext *context, const char *name); +void sn_launcher_context_set_application_id (SnLauncherContext *context, + const char *desktop_file); void sn_launcher_context_set_extra_property (SnLauncherContext *context, const char *name, diff --git a/libsn/sn-monitor.c b/libsn/sn-monitor.c index 223473a..cb25e50 100644 --- a/libsn/sn-monitor.c +++ b/libsn/sn-monitor.c @@ -66,7 +66,9 @@ struct SnStartupSequence Time timestamp; char *binary_name; - char *icon_name; + char *icon_name; + char *application_id; + char *completed_by; unsigned int completed : 1; unsigned int canceled : 1; @@ -269,6 +271,8 @@ sn_startup_sequence_unref (SnStartupSequence *sequence) sn_free (sequence->wmclass); sn_free (sequence->binary_name); sn_free (sequence->icon_name); + sn_free (sequence->application_id); + sn_free (sequence->completed_by); sn_display_unref (sequence->display); sn_free (sequence); @@ -337,6 +341,18 @@ sn_startup_sequence_get_icon_name (SnStartupSequence *sequence) return sequence->icon_name; } +const char* +sn_startup_sequence_get_application_id (SnStartupSequence *sequence) +{ + return sequence->application_id; +} + +const char* +sn_startup_sequence_get_completed_by (SnStartupSequence *sequence) +{ + return sequence->completed_by; +} + int sn_startup_sequence_get_screen (SnStartupSequence *sequence) { @@ -805,6 +821,14 @@ xmessage_func (SnDisplay *display, changed = TRUE; } } + else if (strcmp (names[i], "APPLICATION_ID") == 0) + { + if (sequence->application_id == NULL) + { + sequence->application_id = sn_internal_strdup (values[i]); + changed = TRUE; + } + } else if (strcmp (names[i], "DESKTOP") == 0) { int workspace; @@ -884,7 +908,36 @@ xmessage_func (SnDisplay *display, else if (strcmp (prefix, "remove") == 0) { SnMonitorEvent *event; + sn_bool_t changed = FALSE; + i = 0; + while (names[i]) + { + if (strcmp (names[i], "COMPLETED_BY") == 0) + { + if (sequence->completed_by == NULL) + { + sequence->completed_by = sn_internal_strdup (values[i]); + changed = TRUE; + } + } + + i++; + } + + if (changed) + { + event = sn_new (SnMonitorEvent, 1); + + event->refcount = 1; + event->type = SN_MONITOR_EVENT_CHANGED; + event->context = NULL; + event->sequence = sequence; + sn_startup_sequence_ref (sequence); + + sn_list_append (events, event); + } + event = sn_new (SnMonitorEvent, 1); event->refcount = 1; diff --git a/libsn/sn-monitor.h b/libsn/sn-monitor.h index 15a38d7..6ae88af 100644 --- a/libsn/sn-monitor.h +++ b/libsn/sn-monitor.h @@ -73,6 +73,8 @@ Time sn_startup_sequence_get_timestamp (SnStartupSequence *se const char* sn_startup_sequence_get_wmclass (SnStartupSequence *sequence); const char* sn_startup_sequence_get_binary_name (SnStartupSequence *sequence); const char* sn_startup_sequence_get_icon_name (SnStartupSequence *sequence); +const char* sn_startup_sequence_get_application_id (SnStartupSequence *sequence); +const char* sn_startup_sequence_get_completed_by (SnStartupSequence *sequence); int sn_startup_sequence_get_screen (SnStartupSequence *sequence); void sn_startup_sequence_get_initiated_time (SnStartupSequence *sequence, -- 1.6.6
_______________________________________________ xdg mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/xdg
