forked from AuroraMiddleware/gtk
macos: port gtk to GDK_WINDOWING_MACOS
For the various uses of GDK_WINDOWING_QUARTZ, we need to use alternatives from GDK_WINDOWING_MACOS. Some minor loss of functionality is here, such as icons sent with application menus. That can certainly be added back at a future point.
This commit is contained in:
parent
036b56a43b
commit
fb02c99868
@ -706,7 +706,7 @@ static gboolean
|
||||
append_keyval_symbol (guint accelerator_key,
|
||||
GString *gstring)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
switch (accelerator_key)
|
||||
{
|
||||
case GDK_KEY_Return:
|
||||
@ -777,7 +777,7 @@ append_keyval_symbol (guint accelerator_key,
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
#else /* !GDK_WINDOWING_QUARTZ */
|
||||
#else /* !GDK_WINDOWING_MACOS */
|
||||
return FALSE;
|
||||
#endif
|
||||
}
|
||||
@ -785,7 +785,7 @@ append_keyval_symbol (guint accelerator_key,
|
||||
static void
|
||||
append_separator (GString *string)
|
||||
{
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
g_string_append (string, "+");
|
||||
#else
|
||||
/* no separator on quartz */
|
||||
@ -825,7 +825,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
|
||||
if (accelerator_mods & GDK_SHIFT_MASK)
|
||||
{
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the shift key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -844,7 +844,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the control key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -863,7 +863,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the alt key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
@ -910,7 +910,7 @@ gtk_accelerator_print_label (GString *gstring,
|
||||
if (seen_mod)
|
||||
append_separator (gstring);
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
/* This is the text that should appear next to menu accelerators
|
||||
* that use the meta key. If the text on this key isn't typically
|
||||
* translated on keyboards used for your language, don't translate
|
||||
|
@ -23,10 +23,10 @@
|
||||
#include "gtkapplicationprivate.h"
|
||||
#include "gtkmenutrackerprivate.h"
|
||||
#include "gtkicontheme.h"
|
||||
#include "gtktoolbarprivate.h"
|
||||
#include "gtkquartz.h"
|
||||
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
#include <gdk/macos/gdkmacoskeymap-private.h>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@ -98,12 +98,13 @@ tracker_item_changed (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
icon_loaded (GObject *object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkIconPaintable *icon = GTK_ICON (object);
|
||||
GtkIconPaintable *icon = GTK_ICON_PAINTABLE (object);
|
||||
GNSMenuItem *item = user_data;
|
||||
GError *error = NULL;
|
||||
GdkPixbuf *pixbuf;
|
||||
@ -154,6 +155,7 @@ icon_loaded (GObject *object,
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@implementation GNSMenuItem
|
||||
|
||||
@ -229,7 +231,7 @@ icon_loaded (GObject *object,
|
||||
|
||||
- (void)didChangeLabel
|
||||
{
|
||||
char *label = _gtk_toolbar_elide_underscores (gtk_menu_tracker_item_get_label (trackerItem));
|
||||
const char *label = gtk_menu_tracker_item_get_label (trackerItem);
|
||||
|
||||
NSString *title = [NSString stringWithUTF8String:label ? : ""];
|
||||
|
||||
@ -254,12 +256,11 @@ icon_loaded (GObject *object,
|
||||
}
|
||||
|
||||
[self setTitle:title];
|
||||
|
||||
g_free (label);
|
||||
}
|
||||
|
||||
- (void)didChangeIcon
|
||||
{
|
||||
#if 0
|
||||
GIcon *icon = gtk_menu_tracker_item_get_icon (trackerItem);
|
||||
|
||||
if (cancellable != NULL)
|
||||
@ -311,6 +312,7 @@ icon_loaded (GObject *object,
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[self setImage:nil];
|
||||
}
|
||||
@ -322,7 +324,7 @@ icon_loaded (GObject *object,
|
||||
|
||||
- (void)didChangeToggled
|
||||
{
|
||||
[self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSOnState : NSOffState];
|
||||
[self setState:gtk_menu_tracker_item_get_toggled (trackerItem) ? NSControlStateValueOn : NSControlStateValueOff];
|
||||
}
|
||||
|
||||
- (void)didChangeAccel
|
||||
@ -338,18 +340,18 @@ icon_loaded (GObject *object,
|
||||
|
||||
gtk_accelerator_parse (accel, &key, &mask);
|
||||
|
||||
character = gdk_quartz_get_key_equivalent (key);
|
||||
character = _gdk_macos_keymap_get_equivalent (key);
|
||||
[self setKeyEquivalent:[NSString stringWithCharacters:&character length:1]];
|
||||
|
||||
modifiers = 0;
|
||||
if (mask & GDK_SHIFT_MASK)
|
||||
modifiers |= NSShiftKeyMask;
|
||||
modifiers |= NSEventModifierFlagShift;
|
||||
if (mask & GDK_CONTROL_MASK)
|
||||
modifiers |= NSControlKeyMask;
|
||||
modifiers |= NSEventModifierFlagControl;
|
||||
if (mask & GDK_ALT_MASK)
|
||||
modifiers |= NSAlternateKeyMask;
|
||||
modifiers |= NSEventModifierFlagOption;
|
||||
if (mask & GDK_META_MASK)
|
||||
modifiers |= NSCommandKeyMask;
|
||||
modifiers |= NSEventModifierFlagCommand;
|
||||
[self setKeyEquivalentModifierMask:modifiers];
|
||||
}
|
||||
else
|
||||
|
@ -147,6 +147,29 @@ static GActionEntry gtk_application_impl_quartz_actions[] = {
|
||||
{ "show-all", gtk_application_impl_quartz_show_all }
|
||||
};
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_app_menu (GtkApplicationImpl *impl,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
||||
|
||||
/* If there are any items at all, then the first one is the app menu */
|
||||
if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
|
||||
g_menu_remove (quartz->combined, 0);
|
||||
|
||||
if (app_menu)
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", app_menu);
|
||||
else
|
||||
{
|
||||
GMenu *empty;
|
||||
|
||||
/* We must preserve the rule that index 0 is the app menu */
|
||||
empty = g_menu_new ();
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", G_MENU_MODEL (empty));
|
||||
g_object_unref (empty);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
gboolean register_session)
|
||||
@ -165,7 +188,7 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
[NSApp setDelegate: quartz->delegate];
|
||||
}
|
||||
|
||||
quartz->muxer = gtk_action_muxer_new ();
|
||||
quartz->muxer = gtk_action_muxer_new (NULL);
|
||||
gtk_action_muxer_set_parent (quartz->muxer, gtk_application_get_action_muxer (impl->application));
|
||||
|
||||
/* Add the default accels */
|
||||
@ -182,7 +205,7 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
g_object_unref (gtkinternal);
|
||||
|
||||
/* now setup the menu */
|
||||
app_menu = gtk_application_get_app_menu (impl->application);
|
||||
app_menu = g_object_get_data (G_OBJECT (impl), "APP_MENU");
|
||||
if (app_menu == NULL)
|
||||
{
|
||||
GtkBuilder *builder;
|
||||
@ -193,11 +216,12 @@ gtk_application_impl_quartz_startup (GtkApplicationImpl *impl,
|
||||
* app menu at index 0 in 'combined'.
|
||||
*/
|
||||
builder = gtk_builder_new_from_resource ("/org/gtk/libgtk/ui/gtkapplication-quartz.ui");
|
||||
gtk_application_set_app_menu (impl->application, G_MENU_MODEL (gtk_builder_get_object (builder, "app-menu")));
|
||||
app_menu = G_MENU (gtk_builder_get_object (builder, "app-menu"));
|
||||
g_object_set_data_full (G_OBJECT (impl), "APP_DATA", g_object_ref (app_menu), g_object_unref);
|
||||
g_object_unref (builder);
|
||||
}
|
||||
else
|
||||
gtk_application_impl_set_app_menu (impl, app_menu);
|
||||
gtk_application_impl_quartz_set_app_menu (impl, app_menu);
|
||||
|
||||
/* This may or may not add an item to 'combined' */
|
||||
gtk_application_impl_set_menubar (impl, gtk_application_get_menubar (impl->application));
|
||||
@ -238,29 +262,6 @@ gtk_application_impl_quartz_active_window_changed (GtkApplicationImpl *impl,
|
||||
gtk_action_muxer_insert (quartz->muxer, "win", G_ACTION_GROUP (window));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_app_menu (GtkApplicationImpl *impl,
|
||||
GMenuModel *app_menu)
|
||||
{
|
||||
GtkApplicationImplQuartz *quartz = (GtkApplicationImplQuartz *) impl;
|
||||
|
||||
/* If there are any items at all, then the first one is the app menu */
|
||||
if (g_menu_model_get_n_items (G_MENU_MODEL (quartz->combined)))
|
||||
g_menu_remove (quartz->combined, 0);
|
||||
|
||||
if (app_menu)
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", app_menu);
|
||||
else
|
||||
{
|
||||
GMenu *empty;
|
||||
|
||||
/* We must preserve the rule that index 0 is the app menu */
|
||||
empty = g_menu_new ();
|
||||
g_menu_prepend_submenu (quartz->combined, "Application", G_MENU_MODEL (empty));
|
||||
g_object_unref (empty);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_application_impl_quartz_set_menubar (GtkApplicationImpl *impl,
|
||||
GMenuModel *menubar)
|
||||
|
@ -29,8 +29,8 @@
|
||||
#include <gdk/wayland/gdkwayland.h>
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (GtkApplicationImpl, gtk_application_impl, G_TYPE_OBJECT)
|
||||
@ -172,8 +172,8 @@ gtk_application_impl_new (GtkApplication *application,
|
||||
impl_type = gtk_application_impl_wayland_get_type ();
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (display))
|
||||
impl_type = gtk_application_impl_quartz_get_type ();
|
||||
#endif
|
||||
|
||||
|
@ -705,7 +705,7 @@ gtk_file_chooser_native_show (GtkNativeDialog *native)
|
||||
self->mode = MODE_WIN32;
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (gtk_file_chooser_native_quartz_show (self))
|
||||
self->mode = MODE_QUARTZ;
|
||||
#endif
|
||||
@ -734,7 +734,7 @@ gtk_file_chooser_native_hide (GtkNativeDialog *native)
|
||||
#endif
|
||||
break;
|
||||
case MODE_QUARTZ:
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
gtk_file_chooser_native_quartz_hide (self);
|
||||
#endif
|
||||
break;
|
||||
|
@ -36,9 +36,11 @@
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkheaderbar.h"
|
||||
#include "gtklabel.h"
|
||||
#include "gtknative.h"
|
||||
#include "gtkfilefilterprivate.h"
|
||||
|
||||
#include "quartz/gdkquartz.h"
|
||||
#include "macos/gdkmacos.h"
|
||||
#include "macos/gdkmacossurface-private.h"
|
||||
|
||||
typedef struct {
|
||||
GtkFileChooserNative *self;
|
||||
@ -180,7 +182,7 @@ chooser_set_current_name (FileChooserQuartzData *data,
|
||||
static void
|
||||
filechooser_quartz_data_free (FileChooserQuartzData *data)
|
||||
{
|
||||
|
||||
|
||||
if (data->filters)
|
||||
{
|
||||
[data->filters release];
|
||||
@ -190,7 +192,7 @@ filechooser_quartz_data_free (FileChooserQuartzData *data)
|
||||
{
|
||||
[data->filter_names release];
|
||||
}
|
||||
|
||||
|
||||
g_clear_object (&data->current_folder);
|
||||
g_clear_object (&data->current_file);
|
||||
g_free (data->current_name);
|
||||
@ -343,7 +345,7 @@ filechooser_quartz_launch (FileChooserQuartzData *data)
|
||||
}
|
||||
data->response = GTK_RESPONSE_CANCEL;
|
||||
|
||||
|
||||
|
||||
void (^handler)(NSInteger ret) = ^(NSInteger result) {
|
||||
|
||||
if (result == NSFileHandlingPanelOKButton)
|
||||
@ -412,7 +414,7 @@ strip_mnemonic (const char *s)
|
||||
{
|
||||
return g_strdup (s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
file_filter_to_quartz (GtkFileFilter *file_filter,
|
||||
@ -467,7 +469,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
data->filter_names = [NSMutableArray arrayWithCapacity:n_filters];
|
||||
[data->filter_names retain];
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
for (i = 0; i < n_filters; i++)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (filters, i);
|
||||
if (!file_filter_to_quartz (filter, data->filters, data->filter_names))
|
||||
@ -492,7 +494,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
|
||||
data->create_folders = gtk_file_chooser_get_create_folders (GTK_FILE_CHOOSER (self));
|
||||
|
||||
// shortcut_folder_uris support seems difficult if not impossible
|
||||
// shortcut_folder_uris support seems difficult if not impossible
|
||||
|
||||
// mnemonics are not supported on macOS, so remove the underscores
|
||||
data->accept_label = strip_mnemonic (self->accept_label);
|
||||
@ -516,7 +518,7 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self)
|
||||
if (transient_for)
|
||||
{
|
||||
gtk_widget_realize (GTK_WIDGET (transient_for));
|
||||
data->parent = gdk_quartz_surface_get_nswindow (gtk_native_get_surface (GTK_NATIVE (transient_for)));
|
||||
data->parent = _gdk_macos_surface_get_native (gtk_native_get_surface (GTK_NATIVE (transient_for)));
|
||||
|
||||
if (gtk_native_dialog_get_modal (GTK_NATIVE_DIALOG (self)))
|
||||
data->modal = TRUE;
|
||||
|
@ -625,7 +625,7 @@ gtk_file_filter_get_attributes (GtkFileFilter *filter)
|
||||
return (const char **)filter->attributes;
|
||||
}
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <gtk/gtkfilefilter.h>
|
||||
#include <gdk/gdkconfig.h>
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
@ -30,7 +30,7 @@ G_BEGIN_DECLS
|
||||
|
||||
char ** _gtk_file_filter_get_as_patterns (GtkFileFilter *filter);
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
NSArray * _gtk_file_filter_get_as_pattern_nsstrings (GtkFileFilter *filter);
|
||||
#endif
|
||||
|
||||
|
@ -25,10 +25,13 @@
|
||||
#include "gtk/gtkintl.h"
|
||||
#include "gtk/gtkimmoduleprivate.h"
|
||||
|
||||
#include "gdk/quartz/gdkquartz.h"
|
||||
#include "gdk/quartz/GdkQuartzView.h"
|
||||
#include "gdk/macos/gdkmacos.h"
|
||||
#include "gdk/macos/gdkmacosdisplay-private.h"
|
||||
#include "gdk/macos/gdkmacossurface-private.h"
|
||||
|
||||
#define GTK_IM_CONTEXT_TYPE_QUARTZ (type_quartz)
|
||||
#import "gdk/macos/GdkMacosBaseView.h"
|
||||
|
||||
#define GTK_IM_CONTEXT_TYPE_QUARTZ (gtk_im_context_quartz_get_type())
|
||||
#define GTK_IM_CONTEXT_QUARTZ(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartz))
|
||||
#define GTK_IM_CONTEXT_QUARTZ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_IM_CONTEXT_TYPE_QUARTZ, GtkIMContextQuartzClass))
|
||||
|
||||
@ -65,7 +68,7 @@ quartz_get_preedit_string (GtkIMContext *context,
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_get_preedit_string\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_get_preedit_string\n"));
|
||||
|
||||
if (str)
|
||||
*str = qc->preedit_str ? g_strdup (qc->preedit_str) : g_strdup ("");
|
||||
@ -120,7 +123,7 @@ output_result (GtkIMContext *context,
|
||||
marked_str = g_strdup (g_object_get_data (G_OBJECT (surface), TIC_MARKED_TEXT));
|
||||
if (fixed_str)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("tic-insert-text: %s\n", fixed_str));
|
||||
GTK_NOTE (MODULES, g_print ("tic-insert-text: %s\n", fixed_str));
|
||||
g_free (qc->preedit_str);
|
||||
qc->preedit_str = NULL;
|
||||
g_object_set_data (G_OBJECT (surface), TIC_INSERT_TEXT, NULL);
|
||||
@ -130,7 +133,7 @@ output_result (GtkIMContext *context,
|
||||
unsigned int filtered =
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
||||
GIC_FILTER_KEY));
|
||||
GTK_NOTE (MISC, g_print ("filtered, %d\n", filtered));
|
||||
GTK_NOTE (MODULES, g_print ("filtered, %d\n", filtered));
|
||||
if (filtered)
|
||||
retval = TRUE;
|
||||
else
|
||||
@ -138,7 +141,7 @@ output_result (GtkIMContext *context,
|
||||
}
|
||||
if (marked_str)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("tic-marked-text: %s\n", marked_str));
|
||||
GTK_NOTE (MODULES, g_print ("tic-marked-text: %s\n", marked_str));
|
||||
qc->cursor_index =
|
||||
GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (surface),
|
||||
TIC_SELECTED_POS));
|
||||
@ -166,52 +169,55 @@ quartz_filter_keypress (GtkIMContext *context,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
GdkEventType event_type;
|
||||
gboolean retval;
|
||||
NSView *nsview;
|
||||
GdkSurface *surface;
|
||||
guint keyval;
|
||||
guint keycode;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_filter_keypress\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress\n"));
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return FALSE;
|
||||
|
||||
nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
surface = (GdkSurface *)[ (GdkQuartzView *)nsview gdkSurface];
|
||||
GTK_NOTE (MISC, g_print ("client_surface: %p, win: %p, nsview: %p\n",
|
||||
qc->client_surface, surface, nsview));
|
||||
event_type = gdk_event_get_event_type (event);
|
||||
keyval = gdk_key_event_get_keyval (event);
|
||||
keycode = gdk_key_event_get_keycode (event);
|
||||
|
||||
NSEvent *nsevent = gdk_quartz_event_get_nsevent ((GdkEvent *)event);
|
||||
NSEvent *nsevent = _gdk_macos_display_get_nsevent ((GdkEvent *)event);
|
||||
|
||||
if (!nsevent)
|
||||
{
|
||||
if (event->hardware_keycode == 0 && event->keyval == 0xffffff)
|
||||
if (keycode == 0 && keyval == 0xffffff)
|
||||
/* update text input changes by mouse events */
|
||||
return output_result (context, surface);
|
||||
return output_result (context, qc->client_surface);
|
||||
else
|
||||
return gtk_im_context_filter_keypress (qc->helper, event);
|
||||
}
|
||||
|
||||
if (event->type == GDK_KEY_RELEASE)
|
||||
if (event_type == GDK_KEY_RELEASE)
|
||||
return FALSE;
|
||||
|
||||
if (event->hardware_keycode == 55) /* Command */
|
||||
if (keycode == 55) /* Command */
|
||||
return FALSE;
|
||||
|
||||
NSEventType etype = [nsevent type];
|
||||
if (etype == NSKeyDown)
|
||||
if (etype == NSEventTypeKeyDown)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (surface), TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (TRUE));
|
||||
[nsview keyDown: nsevent];
|
||||
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
||||
g_object_set_data (G_OBJECT (qc->client_surface),
|
||||
TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (TRUE));
|
||||
[nsview keyDown: nsevent];
|
||||
}
|
||||
/* JIS_Eisu || JIS_Kana */
|
||||
if (event->hardware_keycode == 102 || event->hardware_keycode == 104)
|
||||
if (keycode == 102 || keycode == 104)
|
||||
return FALSE;
|
||||
|
||||
retval = output_result(context, surface);
|
||||
g_object_set_data (G_OBJECT (surface), TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (FALSE));
|
||||
GTK_NOTE (MISC, g_print ("quartz_filter_keypress done\n"));
|
||||
retval = output_result(context, qc->client_surface);
|
||||
g_object_set_data (G_OBJECT (qc->client_surface),
|
||||
TIC_IN_KEY_DOWN,
|
||||
GUINT_TO_POINTER (FALSE));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_filter_keypress done\n"));
|
||||
|
||||
return retval;
|
||||
}
|
||||
@ -224,15 +230,15 @@ discard_preedit (GtkIMContext *context)
|
||||
if (!qc->client_surface)
|
||||
return;
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return;
|
||||
|
||||
NSView *nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
NSView *nsview = _gdk_macos_surface_get_view (GDK_MACOS_SURFACE (qc->client_surface));
|
||||
if (!nsview)
|
||||
return;
|
||||
|
||||
/* reset any partial input for this NSView */
|
||||
[(GdkQuartzView *)nsview unmarkText];
|
||||
[(GdkMacosBaseView *)nsview unmarkText];
|
||||
NSInputManager *currentInputManager = [NSInputManager currentInputManager];
|
||||
[currentInputManager markedTextAbandoned:nsview];
|
||||
|
||||
@ -249,24 +255,33 @@ discard_preedit (GtkIMContext *context)
|
||||
static void
|
||||
quartz_reset (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_reset\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_reset\n"));
|
||||
discard_preedit (context);
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_set_client_surface (GtkIMContext *context, GtkWidget *widget)
|
||||
quartz_set_client_surface (GtkIMContext *context,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_client_surface: %p\n", widget));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_client_surface: %p\n", widget));
|
||||
|
||||
qc->client_surface = gtk_widget_get_parent_surface (widget);
|
||||
qc->client_surface = NULL;
|
||||
|
||||
if (widget != NULL)
|
||||
{
|
||||
GtkNative *native = gtk_widget_get_native (widget);
|
||||
|
||||
if (native != NULL)
|
||||
qc->client_surface = gtk_native_get_surface (native);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_focus_in (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_focus_in\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_focus_in\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
qc->focused = TRUE;
|
||||
@ -275,7 +290,7 @@ quartz_focus_in (GtkIMContext *context)
|
||||
static void
|
||||
quartz_focus_out (GtkIMContext *context)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_focus_out\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_focus_out\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
qc->focused = FALSE;
|
||||
@ -289,10 +304,8 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
||||
{
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (context);
|
||||
int x, y;
|
||||
NSView *nsview;
|
||||
GdkSurface *surface;
|
||||
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_cursor_location\n"));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_cursor_location\n"));
|
||||
|
||||
if (!qc->client_surface)
|
||||
return;
|
||||
@ -310,18 +323,16 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
|
||||
qc->cursor_rect->x = area->x + x;
|
||||
qc->cursor_rect->y = area->y + y;
|
||||
|
||||
if (!GDK_IS_QUARTZ_SURFACE (qc->client_surface))
|
||||
if (!GDK_IS_MACOS_SURFACE (qc->client_surface))
|
||||
return;
|
||||
|
||||
nsview = gdk_quartz_surface_get_nsview (qc->client_surface);
|
||||
surface = (GdkSurface *)[ (GdkQuartzView*)nsview gdkSurface];
|
||||
g_object_set_data (G_OBJECT (surface), GIC_CURSOR_RECT, qc->cursor_rect);
|
||||
g_object_set_data (G_OBJECT (qc->client_surface), GIC_CURSOR_RECT, qc->cursor_rect);
|
||||
}
|
||||
|
||||
static void
|
||||
quartz_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
|
||||
GTK_NOTE (MODULES, g_print ("quartz_set_use_preedit: %d\n", use_preedit));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -333,7 +344,7 @@ commit_cb (GtkIMContext *context, const char *str, GtkIMContextQuartz *qc)
|
||||
static void
|
||||
imquartz_finalize (GObject *obj)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("imquartz_finalize\n"));
|
||||
GTK_NOTE (MODULES, g_print ("imquartz_finalize\n"));
|
||||
|
||||
GtkIMContextQuartz *qc = GTK_IM_CONTEXT_QUARTZ (obj);
|
||||
g_free (qc->preedit_str);
|
||||
@ -344,13 +355,13 @@ imquartz_finalize (GObject *obj)
|
||||
g_signal_handlers_disconnect_by_func (qc->helper, (gpointer)commit_cb, qc);
|
||||
g_object_unref (qc->helper);
|
||||
|
||||
gtk_im_context_quartz_parent_class->finalize (obj);
|
||||
G_OBJECT_CLASS (gtk_im_context_quartz_parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_class_init\n"));
|
||||
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_class_init\n"));
|
||||
|
||||
GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (class);
|
||||
@ -370,7 +381,7 @@ gtk_im_context_quartz_class_init (GtkIMContextQuartzClass *class)
|
||||
static void
|
||||
gtk_im_context_quartz_init (GtkIMContextQuartz *qc)
|
||||
{
|
||||
GTK_NOTE (MISC, g_print ("gtk_im_context_quartz_init\n"));
|
||||
GTK_NOTE (MODULES, g_print ("gtk_im_context_quartz_init\n"));
|
||||
|
||||
qc->preedit_str = g_strdup ("");
|
||||
qc->cursor_index = 0;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GType gtk_im_context_quartz_get_type (void) G_GNUC_CONST;
|
||||
GType gtk_im_context_quartz_get_type (void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
|
||||
* file for a list of people on the GTK+ Team. See the ChangeLog
|
||||
* files for a list of changes. These files are distributed with
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@ -58,8 +58,8 @@
|
||||
#include "gtkimcontextime.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#include "gtkimcontextquartz.h"
|
||||
#endif
|
||||
|
||||
@ -73,10 +73,10 @@
|
||||
/**
|
||||
* _gtk_im_module_create:
|
||||
* @context_id: the context ID for the context type to create
|
||||
*
|
||||
*
|
||||
* Create an IM context of a type specified by the string
|
||||
* ID @context_id.
|
||||
*
|
||||
*
|
||||
* Returns: a newly created input context of or @context_id, or
|
||||
* if that could not be created, a newly created GtkIMContextSimple.
|
||||
*/
|
||||
@ -132,8 +132,8 @@ match_backend (GdkDisplay *display,
|
||||
#endif
|
||||
|
||||
if (g_strcmp0 (context_id, "quartz") == 0)
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
return GDK_IS_QUARTZ_DISPLAY (display);
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
return GDK_IS_MACOS_DISPLAY (display);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
@ -175,9 +175,9 @@ lookup_immodule (GdkDisplay *display,
|
||||
* _gtk_im_module_get_default_context_id:
|
||||
* @display: The display to look up the module for
|
||||
*
|
||||
* Return the context_id of the best IM context type
|
||||
* Return the context_id of the best IM context type
|
||||
* for the given window.
|
||||
*
|
||||
*
|
||||
* Returns: the context ID (will never be %NULL)
|
||||
*/
|
||||
const char *
|
||||
@ -270,7 +270,7 @@ gtk_im_modules_init (void)
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
g_type_ensure (gtk_im_context_ime_get_type ());
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
g_type_ensure (gtk_im_context_quartz_get_type ());
|
||||
#endif
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "gtkresources.h"
|
||||
|
||||
|
||||
#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_QUARTZ && defined QUARTZ_RELOCATION)
|
||||
#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_MACOS && defined QUARTZ_RELOCATION)
|
||||
|
||||
const char *
|
||||
_gtk_get_datadir (void)
|
||||
|
214
gtk/gtkquartz.c
214
gtk/gtkquartz.c
@ -19,12 +19,12 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "gtkquartz.h"
|
||||
#include <gdk/quartz/gdkquartz.h>
|
||||
|
||||
#include <gdk/macos/gdkmacos.h>
|
||||
|
||||
static gboolean
|
||||
_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents)
|
||||
GdkRectangle *extents)
|
||||
{
|
||||
double x1, x2, y1, y2;
|
||||
cairo_t *cr;
|
||||
@ -59,7 +59,9 @@ _cairo_surface_extents (cairo_surface_t *surface,
|
||||
}
|
||||
|
||||
static void
|
||||
_data_provider_release_cairo_surface (void* info, const void* data, size_t size)
|
||||
_data_provider_release_cairo_surface (void *info,
|
||||
const void *data,
|
||||
size_t size)
|
||||
{
|
||||
cairo_surface_destroy ((cairo_surface_t *)info);
|
||||
}
|
||||
@ -121,212 +123,6 @@ _gtk_quartz_create_image_from_surface (cairo_surface_t *surface)
|
||||
return nsimage;
|
||||
}
|
||||
|
||||
NSSet *
|
||||
_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
|
||||
{
|
||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||
GList *list;
|
||||
|
||||
for (list = target_list->list; list; list = list->next)
|
||||
{
|
||||
GtkTargetPair *pair = list->data;
|
||||
g_return_val_if_fail (pair->flags < 16, NULL);
|
||||
[set addObject:gdk_quartz_atom_to_pasteboard_type_libgtk_only (pair->target)];
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
NSSet *
|
||||
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||
guint n_targets)
|
||||
{
|
||||
NSMutableSet *set = [[NSMutableSet alloc] init];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n_targets; i++)
|
||||
{
|
||||
[set addObject:gdk_quartz_target_to_pasteboard_type_libgtk_only (targets[i].target)];
|
||||
}
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
GList *
|
||||
_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array)
|
||||
{
|
||||
GList *result = NULL;
|
||||
int i;
|
||||
int count;
|
||||
|
||||
count = [array count];
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
GdkAtom atom = gdk_quartz_pasteboard_type_to_atom_libgtk_only ([array objectAtIndex:i]);
|
||||
|
||||
result = g_list_prepend (result, GDK_ATOM_TO_POINTER (atom));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GtkSelectionData *
|
||||
_gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
GdkAtom target,
|
||||
GdkAtom selection)
|
||||
{
|
||||
GtkSelectionData *selection_data = NULL;
|
||||
|
||||
selection_data = g_slice_new0 (GtkSelectionData);
|
||||
selection_data->selection = selection;
|
||||
selection_data->target = target;
|
||||
if (!selection_data->display)
|
||||
selection_data->display = gdk_display_get_default ();
|
||||
if (target == g_intern_static_string ("UTF8_STRING"))
|
||||
{
|
||||
NSString *s = [pasteboard stringForType:NSStringPboardType];
|
||||
|
||||
if (s)
|
||||
{
|
||||
const char *utf8_string = [s UTF8String];
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
(guchar *)utf8_string, strlen (utf8_string));
|
||||
}
|
||||
}
|
||||
else if (target == g_intern_static_string ("application/x-color"))
|
||||
{
|
||||
NSColor *nscolor = [[NSColor colorFromPasteboard:pasteboard]
|
||||
colorUsingColorSpaceName:NSDeviceRGBColorSpace];
|
||||
|
||||
guint16 color[4];
|
||||
|
||||
selection_data->target = target;
|
||||
|
||||
color[0] = 0xffff * [nscolor redComponent];
|
||||
color[1] = 0xffff * [nscolor greenComponent];
|
||||
color[2] = 0xffff * [nscolor blueComponent];
|
||||
color[3] = 0xffff * [nscolor alphaComponent];
|
||||
|
||||
gtk_selection_data_set (selection_data, target, 16, (guchar *)color, 8);
|
||||
}
|
||||
else if (target == g_intern_static_string ("text/uri-list"))
|
||||
{
|
||||
if ([[pasteboard types] containsObject:NSFilenamesPboardType])
|
||||
{
|
||||
char **uris;
|
||||
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
|
||||
int n_files = [files count];
|
||||
int i;
|
||||
|
||||
selection_data->target = g_intern_static_string ("text/uri-list");
|
||||
|
||||
uris = (char **) g_malloc (sizeof (char *) * (n_files + 1));
|
||||
for (i = 0; i < n_files; ++i)
|
||||
{
|
||||
NSString* uriString = [files objectAtIndex:i];
|
||||
uriString = [@"file://" stringByAppendingString:uriString];
|
||||
uriString = [uriString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
uris[i] = (char *) [uriString cStringUsingEncoding:NSUTF8StringEncoding];
|
||||
}
|
||||
uris[i] = NULL;
|
||||
|
||||
gtk_selection_data_set_uris (selection_data, uris);
|
||||
g_free (uris);
|
||||
}
|
||||
else if ([[pasteboard types] containsObject:NSURLPboardType])
|
||||
{
|
||||
char *uris[2];
|
||||
NSURL *url = [NSURL URLFromPasteboard:pasteboard];
|
||||
|
||||
selection_data->target = g_intern_static_string ("text/uri-list");
|
||||
|
||||
uris[0] = (char *) [[url description] UTF8String];
|
||||
|
||||
uris[1] = NULL;
|
||||
gtk_selection_data_set_uris (selection_data, uris);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSData *data;
|
||||
const char *name;
|
||||
|
||||
name = (const char *)target;
|
||||
|
||||
if (strcmp (name, "image/tiff") == 0)
|
||||
data = [pasteboard dataForType:NSTIFFPboardType];
|
||||
else
|
||||
data = [pasteboard dataForType:[NSString stringWithUTF8String:name]];
|
||||
|
||||
if (data)
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
[data bytes], [data length]);
|
||||
}
|
||||
}
|
||||
|
||||
return selection_data;
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
NSString *type;
|
||||
GdkDisplay *display;
|
||||
int format;
|
||||
const guchar *data;
|
||||
NSUInteger length;
|
||||
|
||||
display = gtk_selection_data_get_display (selection_data);
|
||||
format = gtk_selection_data_get_format (selection_data);
|
||||
data = gtk_selection_data_get_data (selection_data);
|
||||
length = gtk_selection_data_get_length (selection_data);
|
||||
|
||||
type = gdk_quartz_atom_to_pasteboard_type_libgtk_only (gtk_selection_data_get_target (selection_data));
|
||||
|
||||
if ([type isEqualTo:NSStringPboardType])
|
||||
[pasteboard setString:[NSString stringWithUTF8String:(const char *)data]
|
||||
forType:type];
|
||||
else if ([type isEqualTo:NSColorPboardType])
|
||||
{
|
||||
guint16 *color = (guint16 *)data;
|
||||
float red, green, blue, alpha;
|
||||
NSColor *nscolor;
|
||||
|
||||
red = (float)color[0] / 0xffff;
|
||||
green = (float)color[1] / 0xffff;
|
||||
blue = (float)color[2] / 0xffff;
|
||||
alpha = (float)color[3] / 0xffff;
|
||||
|
||||
nscolor = [NSColor colorWithDeviceRed:red green:green blue:blue alpha:alpha];
|
||||
[nscolor writeToPasteboard:pasteboard];
|
||||
}
|
||||
else if ([type isEqualTo:NSURLPboardType])
|
||||
{
|
||||
char **uris;
|
||||
|
||||
uris = gtk_selection_data_get_uris (selection_data);
|
||||
if (uris != NULL)
|
||||
{
|
||||
NSURL *url;
|
||||
|
||||
url = [NSURL URLWithString:[NSString stringWithUTF8String:uris[0]]];
|
||||
[url writeToPasteboard:pasteboard];
|
||||
}
|
||||
g_strfreev (uris);
|
||||
}
|
||||
else
|
||||
[pasteboard setData:[NSData dataWithBytesNoCopy:(void *)data
|
||||
length:length
|
||||
freeWhenDone:NO]
|
||||
forType:type];
|
||||
}
|
||||
|
||||
#ifdef QUARTZ_RELOCATION
|
||||
|
||||
/* Bundle-based functions for various directories. These almost work
|
||||
|
@ -20,31 +20,18 @@
|
||||
#define __GTK_QUARTZ_H__
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include <gtk/gtkselection.h>
|
||||
|
||||
#include <cairo.h>
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
NSSet *_gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list);
|
||||
NSSet *_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||
guint n_targets);
|
||||
|
||||
GList *_gtk_quartz_pasteboard_types_to_atom_list (NSArray *array);
|
||||
|
||||
GtkSelectionData *_gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
GdkAtom target,
|
||||
GdkAtom selection);
|
||||
|
||||
void _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
||||
GtkSelectionData *selection_data);
|
||||
|
||||
NSImage *_gtk_quartz_create_image_from_surface (cairo_surface_t *surface);
|
||||
void _gtk_clipboard_handle_event (GdkEventOwnerChange *event);
|
||||
void _gtk_clipboard_store_all (void);
|
||||
const char * _gtk_get_datadir (void);
|
||||
const char * _gtk_get_libdir (void);
|
||||
const char * _gtk_get_localedir (void);
|
||||
const char * _gtk_get_sysconfdir (void);
|
||||
const char * _gtk_get_data_prefix (void);
|
||||
NSImage *_gtk_quartz_create_image_from_surface (cairo_surface_t *surface);
|
||||
const char *_gtk_get_datadir (void);
|
||||
const char *_gtk_get_libdir (void);
|
||||
const char *_gtk_get_localedir (void);
|
||||
const char *_gtk_get_sysconfdir (void);
|
||||
const char *_gtk_get_data_prefix (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -2196,7 +2196,7 @@ gtk_range_scroll_controller_scroll (GtkEventControllerScroll *scroll,
|
||||
gboolean handled;
|
||||
GtkOrientation move_orientation;
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
scroll_unit = 1;
|
||||
#else
|
||||
scroll_unit = gtk_adjustment_get_page_increment (priv->adjustment);
|
||||
|
@ -1188,7 +1188,7 @@ get_scroll_unit (GtkScrolledWindow *sw,
|
||||
{
|
||||
double scroll_unit;
|
||||
|
||||
#ifndef GDK_WINDOWING_QUARTZ
|
||||
#ifndef GDK_WINDOWING_MACOS
|
||||
GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
|
||||
GtkScrollbar *scrollbar;
|
||||
GtkAdjustment *adj;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "gtksearchenginequartz.h"
|
||||
#include "gtkintl.h"
|
||||
|
||||
#include <gdk/gdk.h> /* for GDK_WINDOWING_QUARTZ */
|
||||
#include <gdk/gdk.h> /* for GDK_WINDOWING_MACOS */
|
||||
|
||||
#if defined(HAVE_TRACKER3)
|
||||
#include "gtksearchenginetracker3.h"
|
||||
@ -340,7 +340,7 @@ _gtk_search_engine_new (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
engine->priv->native = _gtk_search_engine_quartz_new ();
|
||||
if (engine->priv->native)
|
||||
{
|
||||
|
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
#include <quartz/gdkquartz.h>
|
||||
#include <macos/gdkmacos.h>
|
||||
|
||||
#include "gtksearchenginequartz.h"
|
||||
|
||||
@ -262,7 +262,7 @@ _gtk_search_engine_quartz_init (GtkSearchEngineQuartz *engine)
|
||||
GtkSearchEngine *
|
||||
_gtk_search_engine_quartz_new (void)
|
||||
{
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
return g_object_new (GTK_TYPE_SEARCH_ENGINE_QUARTZ, NULL);
|
||||
#else
|
||||
return NULL;
|
||||
|
@ -49,15 +49,15 @@
|
||||
#include "broadway/gdkbroadway.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WIN32
|
||||
#include "win32/gdkwin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#define PRINT_PREVIEW_COMMAND "open -b com.apple.Preview %f"
|
||||
#else
|
||||
#define PRINT_PREVIEW_COMMAND "evince --unlink-tempfile --preview --print-settings %s %f"
|
||||
@ -1095,10 +1095,9 @@ gtk_settings_create_for_display (GdkDisplay *display)
|
||||
{
|
||||
GtkSettings *settings;
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display))
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (display))
|
||||
settings = g_object_new (GTK_TYPE_SETTINGS,
|
||||
"gtk-key-theme-name", "Mac",
|
||||
"gtk-shell-shows-app-menu", TRUE,
|
||||
"gtk-shell-shows-menubar", TRUE,
|
||||
NULL);
|
||||
|
@ -44,8 +44,8 @@
|
||||
#include "win32/gdkwin32.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
#include "quartz/gdkquartz.h"
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
#include "macos/gdkmacos.h"
|
||||
#endif
|
||||
|
||||
#ifdef GDK_WINDOWING_WAYLAND
|
||||
@ -134,9 +134,9 @@ init_version (GtkInspectorGeneral *gen)
|
||||
backend = "Windows";
|
||||
else
|
||||
#endif
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
if (GDK_IS_QUARTZ_DISPLAY (gen->display))
|
||||
backend = "Quartz";
|
||||
#ifdef GDK_WINDOWING_MACOS
|
||||
if (GDK_IS_MACOS_DISPLAY (gen->display))
|
||||
backend = "MacOS";
|
||||
else
|
||||
#endif
|
||||
backend = "Unknown";
|
||||
@ -565,7 +565,7 @@ populate_monitor (gpointer item,
|
||||
gtk_widget_add_css_class (GTK_WIDGET (list), "rich-list");
|
||||
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
|
||||
|
||||
/* XXX: add monitor # here when porting to listview */
|
||||
/* XXX: add monitor # here when porting to listview */
|
||||
name = g_strdup_printf ("Monitor %d", 1);
|
||||
manufacturer = gdk_monitor_get_manufacturer (monitor);
|
||||
model = gdk_monitor_get_model (monitor);
|
||||
|
@ -487,7 +487,7 @@ static char *
|
||||
get_data_path (const char *subdir)
|
||||
{
|
||||
char *base_datadir, *full_datadir;
|
||||
#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_QUARTZ)
|
||||
#if defined (GDK_WINDOWING_WIN32) || defined (GDK_WINDOWING_MACOS)
|
||||
base_datadir = g_strdup (_gtk_get_datadir ());
|
||||
#else
|
||||
base_datadir = g_strdup (GTK_DATADIR);
|
||||
|
@ -806,21 +806,21 @@ if win32_enabled
|
||||
gtk_sources += ['gtkmountoperation-stub.c']
|
||||
endif
|
||||
|
||||
if quartz_enabled
|
||||
if macos_enabled
|
||||
gtk_sources += files([
|
||||
'gtksearchenginequartz.c',
|
||||
'gtkmountoperation-stub.c',
|
||||
'gtkapplication-quartz.c',
|
||||
'gtkapplication-quartz-menu.c',
|
||||
'gtkfilechoosernativequartz.c',
|
||||
'gtkimcontextquartz.c',
|
||||
'gtkquartz.c',
|
||||
])
|
||||
gtk_sources += ['gtkimcontextquartz.c']
|
||||
|
||||
gtk_cargs += ['-xobjective-c'] # FIXME? maybe add_languages() instead?
|
||||
endif
|
||||
|
||||
if not (x11_enabled or win32_enabled or quartz_enabled)
|
||||
if not (x11_enabled or win32_enabled or macos_enabled)
|
||||
gtk_sources += ['gtkmountoperation-stub.c', ]
|
||||
endif
|
||||
|
||||
@ -1041,6 +1041,14 @@ if x11_enabled or wayland_enabled
|
||||
gtk_deps += pangoft_dep
|
||||
endif
|
||||
|
||||
if macos_enabled
|
||||
gtk_macos_frameworks = [
|
||||
'AppKit',
|
||||
'Foundation',
|
||||
]
|
||||
gtk_deps += [dependency('appleframeworks', modules: gtk_macos_frameworks)]
|
||||
endif
|
||||
|
||||
gtk_deps += cloudproviders_dep
|
||||
|
||||
if os_unix
|
||||
|
@ -113,7 +113,6 @@ os_unix = not os_win32
|
||||
if os_darwin
|
||||
wayland_enabled = false
|
||||
else
|
||||
quartz_enabled = false
|
||||
macos_enabled = false
|
||||
endif
|
||||
|
||||
@ -418,7 +417,7 @@ pc_gdk_extra_libs = []
|
||||
cairo_backends = []
|
||||
foreach backend: [ ['cairo-xlib', cairo_req, x11_enabled],
|
||||
['cairo-win32', cairo_req, win32_enabled],
|
||||
['cairo-quartz', cairo_req, quartz_enabled],
|
||||
['cairo-quartz', cairo_req, macos_enabled],
|
||||
['cairo', cairo_req, broadway_enabled or wayland_enabled], ]
|
||||
backend_enabled = backend.get(2)
|
||||
cairo_backend_req = backend.get(1)
|
||||
@ -591,7 +590,7 @@ if broadway_enabled
|
||||
backend_immodules += ['broadway']
|
||||
endif
|
||||
|
||||
if quartz_enabled
|
||||
if macos_enabled
|
||||
pc_gdk_extra_libs += ['-framework Cocoa', '-framework Carbon']
|
||||
backend_immodules += ['quartz']
|
||||
endif
|
||||
@ -814,7 +813,7 @@ pkgs = [ 'gtk4.pc' ]
|
||||
|
||||
pkg_targets = ''
|
||||
display_backends = []
|
||||
foreach backend: [ 'broadway', 'quartz', 'macos', 'wayland', 'win32', 'x11', ]
|
||||
foreach backend: [ 'broadway', 'macos', 'wayland', 'win32', 'x11', ]
|
||||
if get_variable('@0@_enabled'.format(backend))
|
||||
pkgs += ['gtk4-@0@.pc'.format(backend)]
|
||||
pkg_targets += ' ' + backend
|
||||
|
Loading…
Reference in New Issue
Block a user