[gtk+/gtk-3-22] GtkFileChooserNativeQuartz: add partial support for extra widget
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-22] GtkFileChooserNativeQuartz: add partial support for extra widget
- Date: Tue, 18 Jul 2017 17:48:36 +0000 (UTC)
commit 6d104813cc3c762344df319f35f59f4f55e34e5c
Author: Tom Schoonjans <Tom Schoonjans diamond ac uk>
Date: Tue Jul 4 08:07:09 2017 +0100
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
gtk/gtkfilechoosernativequartz.c | 32 ++++++++++++++++++++++++--------
1 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index f6f6daf..1499fb5 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]