Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Codethink Limited
|
|
|
|
* Copyright © 2013 Canonical Limited
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the licence, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtkapplicationprivate.h"
|
2014-01-15 05:38:02 +00:00
|
|
|
#include "gtkbuilder.h"
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
#import <Cocoa/Cocoa.h>
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint cookie;
|
|
|
|
GtkApplicationInhibitFlags flags;
|
|
|
|
char *reason;
|
|
|
|
GtkWindow *window;
|
|
|
|
} GtkApplicationQuartzInhibitor;
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_quartz_inhibitor_free (GtkApplicationQuartzInhibitor *inhibitor)
|
|
|
|
{
|
|
|
|
g_free (inhibitor->reason);
|
|
|
|
g_clear_object (&inhibitor->window);
|
|
|
|
g_slice_free (GtkApplicationQuartzInhibitor, inhibitor);
|
|
|
|
}
|
|
|
|
|
|
|
|
typedef GtkApplicationImplClass GtkApplicationImplQuartzClass;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GtkApplicationImpl impl;
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
GtkActionMuxer *muxer;
|
|
|
|
GMenu *combined;
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
GSList *inhibitors;
|
2020-07-24 13:54:49 +00:00
|
|
|
int quit_inhibit;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
guint next_cookie;
|
2013-12-16 15:59:49 +00:00
|
|
|
NSObject *delegate;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
} GtkApplicationImplQuartz;
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkApplicationImplQuartz, gtk_application_impl_quartz, GTK_TYPE_APPLICATION_IMPL)
|
|
|
|
|
2013-12-16 15:59:49 +00:00
|
|
|
@interface GtkApplicationQuartzDelegate : NSObject
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
{
|
2013-12-16 15:59:49 +00:00
|
|
|
GtkApplicationImplQuartz *quartz;
|
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2013-12-16 15:59:49 +00:00
|
|
|
- (id)initWithImpl:(GtkApplicationImplQuartz*)impl;
|
|
|
|
- (NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender;
|
2020-06-16 14:59:06 +00:00
|
|
|
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames;
|
2013-12-16 15:59:49 +00:00
|
|
|
@end
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2013-12-16 15:59:49 +00:00
|
|
|
@implementation GtkApplicationQuartzDelegate
|
|
|
|
-(id)initWithImpl:(GtkApplicationImplQuartz*)impl
|
|
|
|
{
|
|
|
|
[super init];
|
|
|
|
quartz = impl;
|
|
|
|
return self;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
2013-12-16 15:59:49 +00:00
|
|
|
-(NSApplicationTerminateReply) applicationShouldTerminate:(NSApplication *)sender
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
{
|
2013-12-16 15:59:49 +00:00
|
|
|
/* We have no way to give our message other than to pop up a dialog
|
|
|
|
* ourselves, which we should not do since the OS will already show
|
|
|
|
* one when we return NSTerminateNow.
|
|
|
|
*
|
|
|
|
* Just let the OS show the generic message...
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
*/
|
2013-12-16 15:59:49 +00:00
|
|
|
return quartz->quit_inhibit == 0 ? NSTerminateNow : NSTerminateCancel;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
2020-06-16 14:59:06 +00:00
|
|
|
|
|
|
|
-(void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
|
|
|
|
{
|
|
|
|
GFile **files;
|
2020-07-24 13:54:49 +00:00
|
|
|
int i;
|
2020-06-16 14:59:06 +00:00
|
|
|
GApplicationFlags flags;
|
|
|
|
|
|
|
|
flags = g_application_get_flags (G_APPLICATION (quartz->impl.application));
|
|
|
|
|
|
|
|
if (~flags & G_APPLICATION_HANDLES_OPEN)
|
|
|
|
{
|
|
|
|
[theApplication replyToOpenOrPrint:NSApplicationDelegateReplyFailure];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
files = g_new (GFile *, [filenames count]);
|
|
|
|
|
|
|
|
for (i = 0; i < [filenames count]; i++)
|
|
|
|
files[i] = g_file_new_for_path ([(NSString *)[filenames objectAtIndex:i] UTF8String]);
|
|
|
|
|
|
|
|
g_application_open (G_APPLICATION (quartz->impl.application), files, [filenames count], "");
|
|
|
|
|
|
|
|
for (i = 0; i < [filenames count]; i++)
|
|
|
|
g_object_unref (files[i]);
|
|
|
|
|
|
|
|
g_free (files);
|
|
|
|
|
|
|
|
[theApplication replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
|
|
|
|
}
|
2013-12-16 15:59:49 +00:00
|
|
|
@end
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2014-01-15 05:38:02 +00:00
|
|
|
/* these exist only for accel handling */
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_hide (GSimpleAction *action,
|
|
|
|
GVariant *parameter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
[NSApp hide:NSApp];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_hide_others (GSimpleAction *action,
|
|
|
|
GVariant *parameter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
[NSApp hideOtherApplications:NSApp];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_show_all (GSimpleAction *action,
|
|
|
|
GVariant *parameter,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
[NSApp unhideAllApplications:NSApp];
|
|
|
|
}
|
|
|
|
|
|
|
|
static GActionEntry gtk_application_impl_quartz_actions[] = {
|
|
|
|
{ "hide", gtk_application_impl_quartz_hide },
|
|
|
|
{ "hide-others", gtk_application_impl_quartz_hide_others },
|
|
|
|
{ "show-all", gtk_application_impl_quartz_show_all }
|
|
|
|
};
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
|
|
|
gboolean register_session)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
2014-01-15 05:38:02 +00:00
|
|
|
GSimpleActionGroup *gtkinternal;
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *pref_accel[] = {"<Control>comma", NULL};
|
|
|
|
const char *hide_others_accel[] = {"<Control><Alt>h", NULL};
|
|
|
|
const char *hide_accel[] = {"<Control>h", NULL};
|
|
|
|
const char *quit_accel[] = {"<Control>q", NULL};
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
if (register_session)
|
2013-12-16 15:59:49 +00:00
|
|
|
{
|
|
|
|
quartz->delegate = [[GtkApplicationQuartzDelegate alloc] initWithImpl:quartz];
|
2020-11-19 03:56:51 +00:00
|
|
|
[NSApp setDelegate: (id<NSApplicationDelegate>)quartz->delegate];
|
2013-12-16 15:59:49 +00:00
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2020-10-10 03:08:23 +00:00
|
|
|
quartz->muxer = gtk_action_muxer_new (NULL);
|
2014-01-08 22:27:43 +00:00
|
|
|
gtk_action_muxer_set_parent (quartz->muxer, gtk_application_get_action_muxer (impl->application));
|
|
|
|
|
2014-01-15 05:38:02 +00:00
|
|
|
/* Add the default accels */
|
2014-08-03 20:24:16 +00:00
|
|
|
gtk_application_set_accels_for_action (impl->application, "app.preferences", pref_accel);
|
|
|
|
gtk_application_set_accels_for_action (impl->application, "gtkinternal.hide-others", hide_others_accel);
|
|
|
|
gtk_application_set_accels_for_action (impl->application, "gtkinternal.hide", hide_accel);
|
|
|
|
gtk_application_set_accels_for_action (impl->application, "app.quit", quit_accel);
|
2014-01-15 05:38:02 +00:00
|
|
|
|
|
|
|
/* and put code behind the 'special' accels */
|
|
|
|
gtkinternal = g_simple_action_group_new ();
|
|
|
|
g_action_map_add_action_entries (G_ACTION_MAP (gtkinternal), gtk_application_impl_quartz_actions,
|
|
|
|
G_N_ELEMENTS (gtk_application_impl_quartz_actions), quartz);
|
|
|
|
gtk_application_insert_action_group (impl->application, "gtkinternal", G_ACTION_GROUP (gtkinternal));
|
|
|
|
g_object_unref (gtkinternal);
|
|
|
|
|
|
|
|
/* now setup the menu */
|
2014-01-08 22:27:43 +00:00
|
|
|
gtk_application_impl_set_menubar (impl, gtk_application_get_menubar (impl->application));
|
|
|
|
|
|
|
|
/* OK. Now put it in the menu. */
|
|
|
|
gtk_application_impl_quartz_setup_menu (G_MENU_MODEL (quartz->combined), quartz->muxer);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
[NSApp finishLaunching];
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_shutdown (GtkApplicationImpl *impl)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
/* destroy our custom menubar */
|
|
|
|
[NSApp setMainMenu:[[[NSMenu alloc] init] autorelease]];
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
2013-12-16 15:59:49 +00:00
|
|
|
if (quartz->delegate)
|
|
|
|
{
|
|
|
|
[quartz->delegate release];
|
|
|
|
quartz->delegate = NULL;
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
g_slist_free_full (quartz->inhibitors, (GDestroyNotify) gtk_application_quartz_inhibitor_free);
|
|
|
|
quartz->inhibitors = NULL;
|
|
|
|
}
|
|
|
|
|
2020-12-03 03:42:07 +00:00
|
|
|
static void
|
|
|
|
on_window_unmap_cb (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
|
|
|
|
if ((GActionGroup *)window == gtk_action_muxer_get_group (quartz->muxer, "win"))
|
|
|
|
gtk_action_muxer_remove (quartz->muxer, "win");
|
|
|
|
}
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_active_window_changed (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
|
2020-12-03 03:42:07 +00:00
|
|
|
/* Track unmapping of the window so we can clear the "win" field.
|
|
|
|
* Without this, we might hold on to a reference of the window
|
|
|
|
* preventing it from getting disposed.
|
|
|
|
*/
|
|
|
|
if (window != NULL && !g_object_get_data (G_OBJECT (window), "quartz-muxer-umap"))
|
|
|
|
{
|
|
|
|
gulong handler_id = g_signal_connect_object (window,
|
|
|
|
"unmap",
|
|
|
|
G_CALLBACK (on_window_unmap_cb),
|
|
|
|
impl,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
g_object_set_data (G_OBJECT (window),
|
|
|
|
"quartz-muxer-unmap",
|
|
|
|
GSIZE_TO_POINTER (handler_id));
|
|
|
|
}
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
gtk_action_muxer_remove (quartz->muxer, "win");
|
|
|
|
|
|
|
|
if (G_IS_ACTION_GROUP (window))
|
|
|
|
gtk_action_muxer_insert (quartz->muxer, "win", G_ACTION_GROUP (window));
|
|
|
|
}
|
|
|
|
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_set_menubar (GtkApplicationImpl *impl,
|
|
|
|
GMenuModel *menubar)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
|
2021-05-30 00:02:18 +00:00
|
|
|
/* If we have the menubar, it is a section at index '0' */
|
|
|
|
if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
|
|
|
|
g_menu_remove (quartz->combined, 0);
|
2014-01-08 22:27:43 +00:00
|
|
|
|
|
|
|
if (menubar)
|
|
|
|
g_menu_append_section (quartz->combined, NULL, menubar);
|
2021-05-30 00:02:18 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Ensure that we will always have one menu.
|
|
|
|
char app_menu_key[] = "APP_MENU";
|
|
|
|
GMenuModel *app_menu = g_object_get_data (G_OBJECT (impl), app_menu_key);
|
|
|
|
if (app_menu == NULL)
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
|
|
|
|
|
|
|
// If the user didn't fill in their own menu yet, add ours.
|
|
|
|
builder = gtk_builder_new_from_resource ("/org/gtk/libgtk/ui/gtkapplication-quartz.ui");
|
|
|
|
app_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu"));
|
|
|
|
g_object_set_data_full (G_OBJECT (impl), app_menu_key, g_object_ref (app_menu), g_object_unref);
|
|
|
|
g_object_unref (builder);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_menu_append_submenu (quartz->combined, "Application", app_menu);
|
|
|
|
}
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static guint
|
|
|
|
gtk_application_impl_quartz_inhibit (GtkApplicationImpl *impl,
|
|
|
|
GtkWindow *window,
|
|
|
|
GtkApplicationInhibitFlags flags,
|
2020-07-24 18:40:36 +00:00
|
|
|
const char *reason)
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
GtkApplicationQuartzInhibitor *inhibitor;
|
|
|
|
|
|
|
|
inhibitor = g_slice_new (GtkApplicationQuartzInhibitor);
|
|
|
|
inhibitor->cookie = ++quartz->next_cookie;
|
|
|
|
inhibitor->flags = flags;
|
|
|
|
inhibitor->reason = g_strdup (reason);
|
|
|
|
inhibitor->window = window ? g_object_ref (window) : NULL;
|
|
|
|
|
|
|
|
quartz->inhibitors = g_slist_prepend (quartz->inhibitors, inhibitor);
|
|
|
|
|
|
|
|
if (flags & GTK_APPLICATION_INHIBIT_LOGOUT)
|
|
|
|
quartz->quit_inhibit++;
|
|
|
|
|
|
|
|
return inhibitor->cookie;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_uninhibit (GtkApplicationImpl *impl,
|
|
|
|
guint cookie)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
|
|
|
GSList *iter;
|
|
|
|
|
|
|
|
for (iter = quartz->inhibitors; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
GtkApplicationQuartzInhibitor *inhibitor = iter->data;
|
|
|
|
|
|
|
|
if (inhibitor->cookie == cookie)
|
|
|
|
{
|
|
|
|
if (inhibitor->flags & GTK_APPLICATION_INHIBIT_LOGOUT)
|
|
|
|
quartz->quit_inhibit--;
|
|
|
|
gtk_application_quartz_inhibitor_free (inhibitor);
|
|
|
|
quartz->inhibitors = g_slist_delete_link (quartz->inhibitors, iter);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_warning ("Invalid inhibitor cookie");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_init (GtkApplicationImplQuartz *quartz)
|
|
|
|
{
|
2020-06-18 19:08:28 +00:00
|
|
|
/* This is required so that Cocoa is not going to parse the
|
|
|
|
command line arguments by itself and generate OpenFile events.
|
|
|
|
We already parse the command line ourselves, so this is needed
|
|
|
|
to prevent opening files twice, etc. */
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:@"NO"
|
|
|
|
forKey:@"NSTreatUnknownArgumentsAsOpen"];
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
quartz->combined = g_menu_new ();
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) object;
|
|
|
|
|
2014-01-08 22:27:43 +00:00
|
|
|
g_clear_object (&quartz->combined);
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_application_impl_quartz_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_application_impl_quartz_class_init (GtkApplicationImplClass *class)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
|
|
|
|
|
|
|
|
class->startup = gtk_application_impl_quartz_startup;
|
|
|
|
class->shutdown = gtk_application_impl_quartz_shutdown;
|
2014-01-08 22:27:43 +00:00
|
|
|
class->active_window_changed = gtk_application_impl_quartz_active_window_changed;
|
Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect. As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.
Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication. Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.
GtkApplicationImpl
|
/--------------+-------------------\
| |
GtkApplicationImplDBus GtkApplicationImplQuartz
|
/-----------+-----------------\
| |
GtkApplicationImplX11 GtkApplicationImplWayland
GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)
With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).
Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.
https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 14:32:13 +00:00
|
|
|
class->set_menubar = gtk_application_impl_quartz_set_menubar;
|
|
|
|
class->inhibit = gtk_application_impl_quartz_inhibit;
|
|
|
|
class->uninhibit = gtk_application_impl_quartz_uninhibit;
|
|
|
|
|
|
|
|
gobject_class->finalize = gtk_application_impl_quartz_finalize;
|
|
|
|
}
|