On Mon, Mar 22, 2010 at 6:05 PM, Lubos Lunak <[email protected]> wrote:

>  I have trouble coming up with a case where this would actually apply. The
> protocol itself should provide all the information needed, so there's no need
> to read anything from the .desktop file. So you'd need the .desktop file only
> to be able to identify it, but if you don't know about it, you don't need to
> identify it anyway.

When an application is launched by a process external to the shell, we
need to know the .desktop file.  Simple example, you right click on a
file in Nautilus and launch GEdit.  What should happen effectively
*immediately* is that the "GEdit" application button in the shell UI
lights up; i.e. not when the gedit process has mapped a window and we
can read the WM_CLASS.

The application button is based on the .desktop file.  Now - we could
certainly do heuristic matching on the other things included in the
startup-notification message like the binary, icon, or description,
and try to figure out what .desktop file was launched (and I might
consider this), but ultimately, it's far better if the launching
process just tells us what it did.

>  But anyway, if you want the full path, how about then just 's/name/full
> path/' in what I wrote above? If you can't tell if others will be able to
> find the .desktop file or not, then it doesn't make sense to guess and
> include the path only sometimes.

You're absolutely right here, and I meant to make that change before,
but I attached an old patch previously =/  How about this one?

Thanks again for the review!
From 86df1bbfca157eec75c0557bd9a10d1b7e2c84f5 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 key

For moving GNOME to an application-based system, it's useful if
launcher systems say which .desktop file they're launching, so
that we can show it as the current focus even while a launch is
in progress.
---
 doc/startup-notification.txt |    9 +++++++++
 libsn/sn-launcher.c          |   23 +++++++++++++++++++++--
 libsn/sn-launcher.h          |    2 ++
 libsn/sn-monitor.c           |   22 +++++++++++++++++++---
 libsn/sn-monitor.h           |    1 +
 5 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/doc/startup-notification.txt b/doc/startup-notification.txt
index cf5b250..4f029e0 100644
--- a/doc/startup-notification.txt
+++ b/doc/startup-notification.txt
@@ -300,6 +300,15 @@ The following keys may be provided optionally in either a "new" or a
           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 absolute path to that file:
+          For example: "/usr/share/applications/foo.desktop".
+          Note that like all strings this should be UTF-8 in
+          the case where that differs from the filesystem
+          encoding.
+
 Some details of the startup sequence:
 
  - "new" and "change" messages are sent by the launcher code
diff --git a/libsn/sn-launcher.c b/libsn/sn-launcher.c
index 21344cd..089b5c2 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,9 +268,16 @@ 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);
-  
+
   names[i] = NULL;
   values[i] = NULL;
 
@@ -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..035d523 100644
--- a/libsn/sn-monitor.c
+++ b/libsn/sn-monitor.c
@@ -66,7 +66,8 @@ struct SnStartupSequence
   Time timestamp;
 
   char *binary_name;
-  char *icon_name;  
+  char *icon_name;
+  char *application_id;
 
   unsigned int completed : 1;
   unsigned int canceled : 1;
@@ -269,7 +270,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_display_unref (sequence->display);
       sn_free (sequence);
     }
@@ -337,6 +339,12 @@ 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;
+}
+
 int
 sn_startup_sequence_get_screen (SnStartupSequence *sequence)
 {
@@ -805,10 +813,18 @@ 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;
-              
+
               workspace = sn_internal_string_to_ulong (values[i]);
 
               sequence->workspace = workspace;
diff --git a/libsn/sn-monitor.h b/libsn/sn-monitor.h
index 15a38d7..b58581f 100644
--- a/libsn/sn-monitor.h
+++ b/libsn/sn-monitor.h
@@ -73,6 +73,7 @@ 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);
 int         sn_startup_sequence_get_screen                (SnStartupSequence *sequence);
 
 void        sn_startup_sequence_get_initiated_time        (SnStartupSequence *sequence,
-- 
1.6.6.1

_______________________________________________
xdg mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/xdg

Reply via email to