file chooser dialog: Drop the priv pointer

This commit is contained in:
Matthias Clasen 2019-05-28 02:48:26 +00:00
parent 2ae531ee9f
commit 236983d2aa

View File

@ -210,8 +210,6 @@ typedef struct _GtkFileChooserDialogClass GtkFileChooserDialogClass;
struct _GtkFileChooserDialog
{
GtkDialog parent_instance;
GtkFileChooserDialogPrivate *priv;
};
struct _GtkFileChooserDialogClass
@ -302,14 +300,15 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
static void
gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
{
dialog->priv = gtk_file_chooser_dialog_get_instance_private (dialog);
dialog->priv->response_requested = FALSE;
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
priv->response_requested = FALSE;
gtk_widget_init_template (GTK_WIDGET (dialog));
gtk_dialog_set_use_header_bar_from_setting (GTK_DIALOG (dialog));
_gtk_file_chooser_set_delegate (GTK_FILE_CHOOSER (dialog),
GTK_FILE_CHOOSER (dialog->priv->widget));
GTK_FILE_CHOOSER (priv->widget));
}
static GtkWidget *
@ -362,12 +361,10 @@ static void
file_chooser_widget_default_size_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv;
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
gint default_width, default_height;
GtkRequisition req, widget_req;
priv = gtk_file_chooser_dialog_get_instance_private (dialog);
/* Unset any previously set size */
gtk_widget_set_size_request (GTK_WIDGET (dialog), -1, -1);
@ -390,6 +387,7 @@ static void
file_chooser_widget_selection_changed (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
GtkWidget *button;
GSList *uris;
gboolean sensitive;
@ -398,7 +396,7 @@ file_chooser_widget_selection_changed (GtkWidget *widget,
if (button == NULL)
return;
uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (dialog->priv->widget));
uris = gtk_file_chooser_get_uris (GTK_FILE_CHOOSER (priv->widget));
sensitive = (uris != NULL);
gtk_widget_set_sensitive (button, sensitive);
@ -409,9 +407,10 @@ static void
file_chooser_widget_response_requested (GtkWidget *widget,
GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
GtkWidget *button;
dialog->priv->response_requested = TRUE;
priv->response_requested = TRUE;
button = get_accept_action_widget (GTK_DIALOG (dialog), TRUE);
if (button)
@ -420,7 +419,7 @@ file_chooser_widget_response_requested (GtkWidget *widget,
return;
}
dialog->priv->response_requested = FALSE;
priv->response_requested = FALSE;
}
static void
@ -430,9 +429,7 @@ gtk_file_chooser_dialog_set_property (GObject *object,
GParamSpec *pspec)
{
GtkFileChooserDialogPrivate *priv;
priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object));
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object));
g_object_set_property (G_OBJECT (priv->widget), pspec->name, value);
}
@ -443,9 +440,7 @@ gtk_file_chooser_dialog_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GtkFileChooserDialogPrivate *priv;
priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object));
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (object));
g_object_get_property (G_OBJECT (priv->widget), pspec->name, value);
}
@ -465,20 +460,22 @@ static void
add_button (GtkWidget *button, gpointer data)
{
GtkFileChooserDialog *dialog = data;
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
if (GTK_IS_BUTTON (button))
gtk_size_group_add_widget (dialog->priv->buttons, button);
gtk_size_group_add_widget (priv->buttons, button);
}
static void
setup_search (GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
gboolean use_header;
if (dialog->priv->search_setup)
if (priv->search_setup)
return;
dialog->priv->search_setup = TRUE;
priv->search_setup = TRUE;
g_object_get (dialog, "use-header-bar", &use_header, NULL);
if (use_header)
@ -496,9 +493,9 @@ setup_search (GtkFileChooserDialog *dialog)
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), button);
g_object_bind_property (button, "active",
dialog->priv->widget, "search-mode",
priv->widget, "search-mode",
G_BINDING_BIDIRECTIONAL);
g_object_bind_property (dialog->priv->widget, "subtitle",
g_object_bind_property (priv->widget, "subtitle",
header, "subtitle",
G_BINDING_SYNC_CREATE);
@ -509,6 +506,7 @@ setup_search (GtkFileChooserDialog *dialog)
static void
setup_save_entry (GtkFileChooserDialog *dialog)
{
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
gboolean use_header;
GtkFileChooserAction action;
gboolean need_entry;
@ -527,7 +525,7 @@ setup_save_entry (GtkFileChooserDialog *dialog)
need_entry = action == GTK_FILE_CHOOSER_ACTION_SAVE ||
action == GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
if (need_entry && !dialog->priv->has_entry)
if (need_entry && !priv->has_entry)
{
GtkWidget *box;
GtkWidget *label;
@ -543,15 +541,15 @@ setup_save_entry (GtkFileChooserDialog *dialog)
gtk_container_add (GTK_CONTAINER (box), entry);
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), box);
gtk_file_chooser_widget_set_save_entry (GTK_FILE_CHOOSER_WIDGET (dialog->priv->widget), entry);
gtk_file_chooser_widget_set_save_entry (GTK_FILE_CHOOSER_WIDGET (priv->widget), entry);
}
else if (!need_entry && dialog->priv->has_entry)
else if (!need_entry && priv->has_entry)
{
gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), NULL);
gtk_file_chooser_widget_set_save_entry (GTK_FILE_CHOOSER_WIDGET (dialog->priv->widget), NULL);
gtk_file_chooser_widget_set_save_entry (GTK_FILE_CHOOSER_WIDGET (priv->widget), NULL);
}
dialog->priv->has_entry = need_entry;
priv->has_entry = need_entry;
}
static void
@ -568,7 +566,7 @@ static void
gtk_file_chooser_dialog_map (GtkWidget *widget)
{
GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
GtkFileChooserDialogPrivate *priv = dialog->priv;
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (dialog);
setup_search (dialog);
setup_save_entry (dialog);
@ -606,9 +604,7 @@ static void
response_cb (GtkDialog *dialog,
gint response_id)
{
GtkFileChooserDialogPrivate *priv;
priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (dialog));
GtkFileChooserDialogPrivate *priv = gtk_file_chooser_dialog_get_instance_private (GTK_FILE_CHOOSER_DIALOG (dialog));
/* Act only on response IDs we recognize */
if (is_accept_response_id (response_id) &&