Skip to content

Commit

Permalink
GtkFilechooserNative: add macOS support
Browse files Browse the repository at this point in the history
Based on the Win32 implementation, as well as the macOS file chooser
from
https://github.com/GNOME/gedit/blob/master/gedit/gedit-file-chooser-dialog-osx.[ch]
Not fully tested yet, but working properly so far.
TODO: filter support, extra widget (label), documentation...

https://bugzilla.gnome.org/show_bug.cgi?id=784723
  • Loading branch information
tschoonj authored and Matthias Clasen committed Jul 18, 2017
1 parent a9a25e2 commit ff2c5e3
Show file tree
Hide file tree
Showing 4 changed files with 447 additions and 0 deletions.
1 change: 1 addition & 0 deletions gtk/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ gtk_use_quartz_c_sources = \
gtkmountoperation-stub.c \
gtkapplication-quartz.c \
gtkapplication-quartz-menu.c \
gtkfilechoosernativequartz.c \
gtkquartz.c
gtk_use_stub_c_sources = \
gtkmountoperation-stub.c
Expand Down
12 changes: 12 additions & 0 deletions gtk/gtkfilechoosernative.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
enum {
MODE_FALLBACK,
MODE_WIN32,
MODE_QUARTZ,
MODE_PORTAL,
};

Expand Down Expand Up @@ -697,6 +698,7 @@ gtk_file_chooser_native_get_files (GtkFileChooser *chooser)
{
case MODE_PORTAL:
case MODE_WIN32:
case MODE_QUARTZ:
return g_slist_copy_deep (self->custom_files, (GCopyFunc)g_object_ref, NULL);

case MODE_FALLBACK:
Expand All @@ -717,6 +719,11 @@ gtk_file_chooser_native_show (GtkNativeDialog *native)
self->mode = MODE_WIN32;
#endif

#ifdef GDK_WINDOWING_QUARTZ
if (gtk_file_chooser_native_quartz_show (self))
self->mode = MODE_QUARTZ;
#endif

if (self->mode == MODE_FALLBACK &&
gtk_file_chooser_native_portal_show (self))
self->mode = MODE_PORTAL;
Expand All @@ -738,6 +745,11 @@ gtk_file_chooser_native_hide (GtkNativeDialog *native)
case MODE_WIN32:
#ifdef GDK_WINDOWING_WIN32
gtk_file_chooser_native_win32_hide (self);
#endif
break;
case MODE_QUARTZ:
#ifdef GDK_WINDOWING_QUARTZ
gtk_file_chooser_native_quartz_hide (self);
#endif
break;
case MODE_PORTAL:
Expand Down
3 changes: 3 additions & 0 deletions gtk/gtkfilechoosernativeprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ struct _GtkFileChooserNative
gboolean gtk_file_chooser_native_win32_show (GtkFileChooserNative *self);
void gtk_file_chooser_native_win32_hide (GtkFileChooserNative *self);

gboolean gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self);
void gtk_file_chooser_native_quartz_hide (GtkFileChooserNative *self);

gboolean gtk_file_chooser_native_portal_show (GtkFileChooserNative *self);
void gtk_file_chooser_native_portal_hide (GtkFileChooserNative *self);

Expand Down
Loading

0 comments on commit ff2c5e3

Please sign in to comment.