summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2020-02-21 15:34:37 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2020-02-22 15:22:06 +0000
commitd505573ee608f8f26fd02458030d1755fd3af8b6 (patch)
tree4f1dce35ceb6bb4c8ee7921c81400118eba214dc
parent5f070ff233386eae3b3290d12ba67745833dcb8c (diff)
downloadgtk+-d505573ee608f8f26fd02458030d1755fd3af8b6.tar.gz
Drop GtkFileChooser:extra-widget
We have "choices" as a more rational (and portable) API; additionally, the ownership semantics of the extra widget property getter are a hack.
-rw-r--r--docs/reference/gtk/gtk4-sections.txt2
-rw-r--r--gtk/gtkfilechooser.c88
-rw-r--r--gtk/gtkfilechooser.h8
-rw-r--r--gtk/gtkfilechooserbutton.c2
-rw-r--r--gtk/gtkfilechoosernative.c8
-rw-r--r--gtk/gtkfilechoosernativequartz.c11
-rw-r--r--gtk/gtkfilechoosernativewin32.c4
-rw-r--r--gtk/gtkfilechooserutils.c3
-rw-r--r--gtk/gtkfilechooserutils.h1
-rw-r--r--gtk/gtkfilechooserwidget.c8
-rw-r--r--tests/testgtk.c24
11 files changed, 8 insertions, 151 deletions
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index dfa5dd17f8..59c45962a7 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -1158,8 +1158,6 @@ gtk_file_chooser_get_preview_widget_active
gtk_file_chooser_set_use_preview_label
gtk_file_chooser_get_use_preview_label
gtk_file_chooser_get_preview_file
-gtk_file_chooser_set_extra_widget
-gtk_file_chooser_get_extra_widget
<SUBSECTION>
gtk_file_chooser_add_filter
gtk_file_chooser_remove_filter
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index 25ea82ff36..bf1544509f 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -117,32 +117,15 @@
* }
* ]|
*
- * # Adding Extra Widgets
+ * # Adding options
*
* You can add extra widgets to a file chooser to provide options
- * that are not present in the default design. For example, you
- * can add a toggle button to give the user the option to open a
- * file in read-only mode. You can use
- * gtk_file_chooser_set_extra_widget() to insert additional
- * widgets in a file chooser.
- *
- * An example for adding extra widgets:
- * |[<!-- language="C" -->
- *
- * GtkWidget *toggle;
- *
- * ...
- *
- * toggle = gtk_check_button_new_with_label ("Open file read-only");
- * gtk_widget_show (toggle);
- * gtk_file_chooser_set_extra_widget (my_file_chooser, toggle);
- * }
- * ]|
- *
- * If you want to set more than one extra widget in the file
- * chooser, you can a container such as a #GtkBox or a #GtkGrid
- * and include your widgets in it. Then, set the container as
- * the whole extra widget.
+ * that are not present in the default design, by using
+ * gtk_file_chooser_add_choice(). Each choice has an identifier and
+ * a user visible label; additionally, each choice can have multiple
+ * options. If a choice has no option, it will be rendered as a
+ * check button with the given label; if a choice has options, it will
+ * be rendered as a combo box.
*/
@@ -386,12 +369,6 @@ gtk_file_chooser_default_init (GtkFileChooserInterface *iface)
TRUE,
GTK_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_object ("extra-widget",
- P_("Extra widget"),
- P_("Application supplied widget for extra options."),
- GTK_TYPE_WIDGET,
- GTK_PARAM_READWRITE));
- g_object_interface_install_property (iface,
g_param_spec_boolean ("select-multiple",
P_("Select Multiple"),
P_("Whether to allow multiple files to be selected"),
@@ -650,10 +627,7 @@ gtk_file_chooser_set_current_name (GtkFileChooser *chooser,
* text entry for “Name”.
*
* This is meant to be used in save dialogs, to get the currently typed filename
- * when the file itself does not exist yet. For example, an application that
- * adds a custom extra widget to the file chooser for “file format” may want to
- * change the extension of the typed filename based on the chosen format, say,
- * from “.jpg” to “.png”.
+ * when the file itself does not exist yet.
*
* Returns: The raw text from the file chooser’s “Name” entry. Free this with
* g_free(). Note that this string is not a full pathname or URI; it is
@@ -1108,50 +1082,6 @@ gtk_file_chooser_remove_shortcut_folder (GtkFileChooser *chooser,
}
/**
- * gtk_file_chooser_set_extra_widget:
- * @chooser: a #GtkFileChooser
- * @extra_widget: widget for extra options
- *
- * Sets an application-supplied widget to provide extra options to the user.
- **/
-void
-gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
- GtkWidget *extra_widget)
-{
- g_return_if_fail (GTK_IS_FILE_CHOOSER (chooser));
-
- g_object_set (chooser, "extra-widget", extra_widget, NULL);
-}
-
-/**
- * gtk_file_chooser_get_extra_widget:
- * @chooser: a #GtkFileChooser
- *
- * Gets the current extra widget; see
- * gtk_file_chooser_set_extra_widget().
- *
- * Returns: (nullable) (transfer none): the current extra widget, or %NULL
- **/
-GtkWidget *
-gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser)
-{
- GtkWidget *extra_widget;
-
- g_return_val_if_fail (GTK_IS_FILE_CHOOSER (chooser), NULL);
-
- g_object_get (chooser, "extra-widget", &extra_widget, NULL);
-
- /* Horrid hack; g_object_get() refs returned objects but
- * that contradicts the memory management conventions
- * for accessors.
- */
- if (extra_widget)
- g_object_unref (extra_widget);
-
- return extra_widget;
-}
-
-/**
* gtk_file_chooser_add_filter:
* @chooser: a #GtkFileChooser
* @filter: (transfer full): a #GtkFileFilter
@@ -1372,8 +1302,6 @@ gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
* a value using gtk_file_chooser_set_choice() before the dialog is shown,
* and you can obtain the user-selected value in the ::response signal handler
* using gtk_file_chooser_get_choice().
- *
- * Compare gtk_file_chooser_set_extra_widget().
*/
void
gtk_file_chooser_add_choice (GtkFileChooser *chooser,
diff --git a/gtk/gtkfilechooser.h b/gtk/gtkfilechooser.h
index 98cb71545a..ea684d6715 100644
--- a/gtk/gtkfilechooser.h
+++ b/gtk/gtkfilechooser.h
@@ -205,14 +205,6 @@ gboolean gtk_file_chooser_get_use_preview_label (GtkFileChooser *chooser);
GDK_AVAILABLE_IN_ALL
GFile *gtk_file_chooser_get_preview_file (GtkFileChooser *chooser);
-/* Extra widget
- */
-GDK_AVAILABLE_IN_ALL
-void gtk_file_chooser_set_extra_widget (GtkFileChooser *chooser,
- GtkWidget *extra_widget);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *gtk_file_chooser_get_extra_widget (GtkFileChooser *chooser);
-
/* List of user selectable filters
*/
GDK_AVAILABLE_IN_ALL
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index c14d01ead9..03e46ab791 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -925,7 +925,6 @@ gtk_file_chooser_button_set_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
case GTK_FILE_CHOOSER_PROP_CREATE_FOLDERS:
@@ -971,7 +970,6 @@ gtk_file_chooser_button_get_property (GObject *object,
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET:
case GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE:
case GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL:
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
case GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN:
case GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION:
diff --git a/gtk/gtkfilechoosernative.c b/gtk/gtkfilechoosernative.c
index a722587efb..c08c84fd54 100644
--- a/gtk/gtkfilechoosernative.c
+++ b/gtk/gtkfilechoosernative.c
@@ -165,8 +165,6 @@
* used. It supports many of the features that #GtkFileChooserDialog
* does, but there are some things it does not handle:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget().
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added using a mimetype or custom filter.
@@ -182,8 +180,6 @@
* be a GTK+ file chooser. In this situation, the following things are not
* supported and will be silently ignored:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget().
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added with a custom filter.
@@ -194,10 +190,6 @@
* file chooser dialogs. Some features provided by #GtkFileChooserDialog are
* not supported:
*
- * * Extra widgets added with gtk_file_chooser_set_extra_widget(), unless the
- * widget is an instance of GtkLabel, in which case the label text will be used
- * to set the NSSavePanel message instance property.
- *
* * Use of custom previews by connecting to #GtkFileChooser::update-preview.
*
* * Any #GtkFileFilter added with a custom filter.
diff --git a/gtk/gtkfilechoosernativequartz.c b/gtk/gtkfilechoosernativequartz.c
index 89fad7b3af..cb2e071a26 100644
--- a/gtk/gtkfilechoosernativequartz.c
+++ b/gtk/gtkfilechoosernativequartz.c
@@ -448,19 +448,8 @@ 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;
- 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))
return FALSE;
diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c
index e1534a5696..c368f84269 100644
--- a/gtk/gtkfilechoosernativewin32.c
+++ b/gtk/gtkfilechoosernativewin32.c
@@ -877,10 +877,6 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
GSList *filters, *l;
int n_filters, i;
- if (gtk_file_chooser_get_extra_widget (GTK_FILE_CHOOSER (self)) != NULL &&
- self->choices == NULL)
- return FALSE;
-
update_preview_signal = g_signal_lookup ("update-preview", GTK_TYPE_FILE_CHOOSER);
if (g_signal_has_handler_pending (self, update_preview_signal, 0, TRUE))
return FALSE;
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index fe71729933..7d39368729 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -100,9 +100,6 @@ _gtk_file_chooser_install_properties (GObjectClass *klass)
GTK_FILE_CHOOSER_PROP_ACTION,
"action");
g_object_class_override_property (klass,
- GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET,
- "extra-widget");
- g_object_class_override_property (klass,
GTK_FILE_CHOOSER_PROP_FILTER,
"filter");
g_object_class_override_property (klass,
diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h
index 6938791515..9a4e4cbb14 100644
--- a/gtk/gtkfilechooserutils.h
+++ b/gtk/gtkfilechooserutils.h
@@ -34,7 +34,6 @@ typedef enum {
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET,
GTK_FILE_CHOOSER_PROP_PREVIEW_WIDGET_ACTIVE,
GTK_FILE_CHOOSER_PROP_USE_PREVIEW_LABEL,
- GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET,
GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE,
GTK_FILE_CHOOSER_PROP_SHOW_HIDDEN,
GTK_FILE_CHOOSER_PROP_DO_OVERWRITE_CONFIRMATION,
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 832f9d04c2..225c502ba3 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3315,10 +3315,6 @@ gtk_file_chooser_widget_set_property (GObject *object,
update_preview_widget_visibility (impl);
break;
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
- set_extra_widget (impl, g_value_get_object (value));
- break;
-
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
{
gboolean select_multiple = g_value_get_boolean (value);
@@ -3405,10 +3401,6 @@ gtk_file_chooser_widget_get_property (GObject *object,
g_value_set_boolean (value, priv->use_preview_label);
break;
- case GTK_FILE_CHOOSER_PROP_EXTRA_WIDGET:
- g_value_set_object (value, priv->extra_widget);
- break;
-
case GTK_FILE_CHOOSER_PROP_SELECT_MULTIPLE:
g_value_set_boolean (value, priv->select_multiple);
break;
diff --git a/tests/testgtk.c b/tests/testgtk.c
index 6c65009cfc..98ee51798c 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -5787,25 +5787,6 @@ native_overwrite_confirmation_toggle (GtkWidget *checkbutton,
}
static void
-native_extra_widget_toggle (GtkWidget *checkbutton,
- GtkFileChooserNative *native)
-{
- gboolean extra_widget = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbutton));
-
- if (extra_widget)
- {
- GtkWidget *extra = gtk_check_button_new_with_label ("Extra toggle");
- gtk_widget_show (extra);
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (native), extra);
- }
- else
- {
- gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (native), NULL);
- }
-}
-
-
-static void
native_visible_notify_show (GObject *object,
GParamSpec *pspec,
GtkWidget *show_button)
@@ -6028,11 +6009,6 @@ create_native_dialogs (GtkWidget *widget)
G_CALLBACK (native_overwrite_confirmation_toggle), native);
gtk_container_add (GTK_CONTAINER (box), check_button);
- check_button = gtk_check_button_new_with_label ("Extra widget");
- g_signal_connect (check_button, "toggled",
- G_CALLBACK (native_extra_widget_toggle), native);
- gtk_container_add (GTK_CONTAINER (box), check_button);
-
show_button = gtk_button_new_with_label ("Show");
hide_button = gtk_button_new_with_label ("Hide");
gtk_widget_set_sensitive (hide_button, FALSE);