After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 95897 - gdk_spawn utility methods ?
gdk_spawn utility methods ?
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: X11
2.1.x
Other All
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
: 99461 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-10-16 04:30 UTC by Mark McLoughlin
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
implementation (10.68 KB, text/plain)
2002-10-16 04:32 UTC, Mark McLoughlin
  Details
header (2.95 KB, text/plain)
2002-10-16 04:33 UTC, Mark McLoughlin
  Details
updated patch (22.44 KB, patch)
2003-08-27 12:04 UTC, Mark McLoughlin
none Details | Review
final patch (19.02 KB, patch)
2003-12-10 13:51 UTC, Mark McLoughlin
none Details | Review

Description Mark McLoughlin 2002-10-16 04:30:35 UTC
Any multiscreen application which launches applications will need to ensure
that the launched applications appear on a certain screen.

It might make sense to have small utility wrappers around the gspawn
functions in gdk which will launch an app on a given screen.

I've put a proto implementation of these into
libegg/screen-exec/egg-spawn.[ch]. I'll attach them here.
Comment 1 Mark McLoughlin 2002-10-16 04:32:28 UTC
Created attachment 11580 [details]
implementation
Comment 2 Mark McLoughlin 2002-10-16 04:33:21 UTC
Created attachment 11581 [details]
header
Comment 3 Owen Taylor 2002-12-03 02:13:44 UTC
*** Bug 99461 has been marked as a duplicate of this bug. ***
Comment 4 Owen Taylor 2003-07-18 19:20:55 UTC
Really sort of torn on this one. On one hand, it *is*
something that is needed in various places. On the
other hand, it's ugly API (because g_spawn_* is ugly)
and doesn't fit in very well with what's in GDK currently.

Would getting rid of the synchronous variants make sense?
I don't think wanting to run a GUI app synchronously
from another GUI app is very common or ever correct (repaints
on the first app will not work)

Some comments reading through the patch:

 - Maybe keep egg_make_spawn_environment_for_screen
   private? It strikes me as an implementation detail.

 - We don't put in extra spaces *everywhere* - 
   'envp[i]', not 'envp [i]'

 - egg_make_spawn_environment_for_screen() cannot return
   NULL in correctly functioning program, so it should
   not be documented as returning NULL, and handling
   NULL returns isn't necessary.

- A helper function for:

  default_screen = gdk_display_get_default_screen (
				gdk_screen_get_display (screen));
  if (screen != default_screen)
    new_envp = egg_make_spawn_environment_for_screen (screen, envp);

  Would be a good idea.
Comment 5 Owen Taylor 2003-07-18 19:23:56 UTC
Other thing that needs dealing with is portability. 
On non-X11, this should just be a pass-through, so
probably best put in the port directories, with a
trivial implementation for win32 and linux-fb.
Comment 6 Mark McLoughlin 2003-07-21 11:05:11 UTC
Owen: yeah, I can understand why you're torn. But I think its going to
be pretty essential for most multiscreen apps ...

I agree that removing the sync versions make sense.

We could also make the function names a little less crufty:

gdk_spawn(), gdk_spawn_with_pipes and gdk_spawn_command_line().

But there are a couple of problems with that:

1) If we ever decide later to add the sync versions we'll end up with
gdk_spawn() and gdk_spawn_sync() instead of
gdk_spawn_async()/gdk_spawn_async(). I suppose that wouldn't be too
bad, though - it would give a clear indication that the async version
is the one you mostly want to use.

2) Moving from gspawn to gdkspawn is no longer a s/g/gdk/. But I think
that's fine - its not a sed-job as the extra argument is always going
to require more thought.


I can do all this pretty trivially (along with your other comments) as
I commit, if you think I should go ahead. Just let me know :-)
Comment 7 Mark McLoughlin 2003-08-27 12:04:01 UTC
Created attachment 19544 [details] [review]
updated patch
Comment 8 Mark McLoughlin 2003-08-27 12:11:31 UTC
I've updated the patch. Changes are:

 - privatise make_environment_for_screen
 - make_environment not documented as returning NULL
 - remove async() methods
 - fix the envp [i] vs. envp[i] stylistic issue
 - win32 and linux-fb implementations
 - rename functions removing _async and _on_screen bits
 - removed the 

     if (screen != default_screen)
        new_envp = make_env_for_screen ();

   bits as that breaks when you run with --screen or
   --display. What you really want to check is whether
   the current $DISPLAY value matches the return value
   from gdk_screen_make_display_name(), but after implenting
   that I decided it just complicates matters and we should
   just always pass in a modified environment.


I'm slightly worried now that its not obvious from looking
at the prototypes what gdk_spawn and co. are for. Initially
GdkScreen * was the first argument to each of these functions
but I changed that as it looks to much like a GdkScreen operation.
In retrospect I think it would go some way to making the API
more clear.
Comment 9 Owen Taylor 2003-12-09 17:42:36 UTC
Let's go ahead and add these.

 * The API docs should only be in the x11/ directory - they
   don't need to be duplicated (and that can actually cause
   problems for gtk-doc)

 * The names I'd like to see are:

   gdk_spawn_on_screen()
   gdk_spawn_on_screen_with_pipes()
   gdk_spawn_command_line_on_screen()

 * I would make the GdkScreen the first parameter; compare
   how all the _for_display() functions take the GdkDisplay
   as the first parameter.
 
Comment 10 Mark McLoughlin 2003-12-10 13:51:49 UTC
Created attachment 22291 [details] [review]
final patch
Comment 11 Mark McLoughlin 2003-12-10 13:52:42 UTC
Okay, I've gone ahead committed after making those changes. 

Thanks Owen.