From: Tom Schoonjans Date: Tue, 4 Jul 2017 07:07:09 +0000 (+0100) Subject: GtkFileChooserNativeQuartz: add partial support for extra widget X-Git-Tag: archive/raspbian/3.24.39-1+rpi1~1^2~65^2~39^2~480 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=6d104813cc3c762344df319f35f59f4f55e34e5c;p=gtk%2B3.0.git GtkFileChooserNativeQuartz: add partial support for extra widget When the extra widget is a GtkLabel, then its text will be displayed as a message in the NSSavePanel or NSOpenPanel https://bugzilla.gnome.org/show_bug.cgi?id=784723 --- diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c index f6f6daf04e..1499fb55ae 100644 --- a/gtk/gtkfilechoosernativequartz.c +++ b/gtk/gtkfilechoosernativequartz.c @@ -61,6 +61,7 @@ typedef struct { char *accept_label; char *cancel_label; char *title; + char *message; GSList *shortcut_uris; @@ -165,6 +166,7 @@ filechooser_quartz_data_free (FileChooserQuartzData *data) g_free (data->accept_label); g_free (data->cancel_label); g_free (data->title); + g_free (data->message); g_free (data); } @@ -242,6 +244,9 @@ filechooser_quartz_launch (FileChooserQuartzData *data) if (data->title) [data->panel setTitle:[NSString stringWithUTF8String:data->title]]; + if (data->message) + [data->panel setMessage:[NSString stringWithUTF8String:data->message]]; + if (data->current_file) { GFile *folder; @@ -328,13 +333,13 @@ strip_mnemonic (const gchar *s) pango_parse_markup (escaped, -1, '_', NULL, &ret, NULL, NULL); if (ret != NULL) - { - return ret; - } + { + return ret; + } else - { - return g_strdup (s); - } + { + return g_strdup (s); + } } gboolean @@ -347,9 +352,18 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self) guint update_preview_signal; GSList *filters, *l; int n_filters, i; + GtkWidget *extra_widget = NULL; + char *message = NULL; - if (gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)) != NULL) - return FALSE; + extra_widget = gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)); + // if the extra_widget is a GtkLabel, then use its text to set the dialog message + if (extra_widget != NULL) + { + if (!GTK_IS_LABEL (extra_widget)) + return FALSE; + else + message = g_strdup (gtk_label_get_text (GTK_LABEL (extra_widget))); + } update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER); if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE)) @@ -407,6 +421,8 @@ gtk_file_chooser_native_quartz_show (GtkFileChooserNative *self) data->title = g_strdup (gtk_native_dialog_get_title (GTK_NATIVE_DIALOG (self))); + data->message = message; + if (self->current_file) data->current_file = g_object_ref (self->current_file); else