Skip to content

Commit

Permalink
GtkFileChooserNativeQuartz: add partial support for extra widget
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tschoonj authored and Matthias Clasen committed Jul 18, 2017
1 parent 44e90c4 commit 55d139b
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions gtk/gtkfilechoosernativequartz.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef struct {
char *accept_label;
char *cancel_label;
char *title;
char *message;

GSList *shortcut_uris;

Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 55d139b

Please sign in to comment.