Re: Ige-mac-integration: New version with Cocoa interface available.



On May 18, 2010, at 11:28 AM, Colin Walters wrote:

> On Tue, May 18, 2010 at 2:05 PM, John Ralls <jralls ceridwen us> wrote:
>> 
>> It has some useful bits, and seems mostly harmless, but I don't think that it will get much use in its present form.
> 
> Right - in reality I expect people to be using *Gtk*Application.  So
> please look at that too.
> 
>> The action registry is a potentially useful piece of infrastructure, but it doesn't really go far enough to insulate the application developer from having to learn more than she wants to about each platform that she's targeting. She'll still have to have large sections of ifdef'd code catching the various signals from each operating system and invoking the actions, which will then emit signals that she'll have to connect to with her callbacks.
> 
> Can you give an example here?  Catching what signals?
> 
>> I don't think that there's much benefit to get_mainloop, run, and quit. If the event loop needs to be abstracted for a platform, that should be done in the platform's GMainLoop override.
> 
> I thought other platforms just hooked in window system event sources
> in GDK?  Or are you talking about something else?
> 
>> The multiple/single invocation feature is something OSX handles by setting a key in the app's Info.plist. I suppose on Linux you'd have to register a key with dbus to indicate that the app already had a running instance. Just quitting seems rude to the end user, though. On OSX, LaunchServices "activates" the running instance.
> 
> Nothing stops gapplication-osx.c from doing this.
> 
>> I haven't spent much time with gdbus (or dbus either, for that matter). Is there some magic that allows other compilation units to see the static functions in gunixapplication.c?
> 
> No - the rename to "unix" is a misnomer because it has nothing to do
> with the POSIX layer, but rather the freedesktop layered on top.

Where's gtkapplication.c? I can't find it in http://git.gnome.org/browse/gtk+/tree/gtk and I don't see an obvious branch.

Maybe I should ask you to look at GtkOSXApplication. The URLs are in the original message of this thread. But here's the code for the "NSApplicationShouldTerminate" message, and example of the use-case I understand for GApplicationAction:

gtk_osxapplication_class_init creates the following signal:
gtk_osxapplication_signals[BlockTermination] =
    g_signal_new("NSApplicationBlockTermination",
	       GTK_TYPE_OSX_APPLICATION,
	       G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION,
	       0, block_termination_accumulator, NULL,
	       g_cclosure_marshal_BOOLEAN__VOID,
	       G_TYPE_BOOLEAN, 0);

In the case of an NSApplicationShouldTerminate, the NSApplication receives the notification in Apple-provided code and calls the following function in the application delegate:

- (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
{
  GtkOSXApplication *app = g_object_new(GTK_TYPE_OSX_APPLICATION, NULL);
  guint sig = g_signal_lookup("NSApplicationBlockTermination", 
			      GTK_TYPE_OSX_APPLICATION);
  gboolean result = FALSE;
  if (sig)
      g_signal_emit(app, sig, 0, &result);

  g_object_unref(app);
  if (!result)
    return NSTerminateNow;
  else
    return NSTerminateCancel;
}

It's up to the application's code to connect to the signal and do whatever it needs to do in the callback. I could use a GApplicationAction instead of explicitly creating and emitting the signal. If this wasn't the use-case you're thinking of, what is?

All the platforms I'm familiar (which is only X11, MSWin, and Quartz) do just hook the platform sources. The only point I can see to providing a g_application_main_loop() is to replace the GMainLoop with something else, and I don't think that GApplication is the right place to do that.

gunixapplication.c rename? I don't see any deletes in http://git.gnome.org/browse/glib/commit/?h=wip/gapplication&id=dfd5dd47d4008fd0cffce35957db0ce0116da4cf. How is it a rename?

Regards,
John Ralls




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]