[gtk+/portal: 11/18] GtkFileChooser: Add abstract api for comboboxes and checkbuttons
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/portal: 11/18] GtkFileChooser: Add abstract api for comboboxes and checkbuttons
- Date: Wed, 6 Jul 2016 19:19:20 +0000 (UTC)
commit ca2967ed0a991776914794bce37b342af9bbddf7
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jul 5 22:09:56 2016 -0400
GtkFileChooser: Add abstract api for comboboxes and checkbuttons
This commit adds API for adding combo boxes and check buttons to
GtkFileChooser, and getting the selected value back in ::response.
In contrast to gtk_file_chooser_set_extra_widget, these APIs are
abstract and suitable for implementation in GtkFileChooserNative.
gtk/gtkfilechooser.c | 96 +++++++++++++++++++++++++++++++++++++++++++
gtk/gtkfilechooser.h | 17 ++++++++
gtk/gtkfilechooserprivate.h | 16 +++++++-
3 files changed, 128 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index 101decb..18cc5af 100644
--- a/gtk/gtkfilechooser.c
+++ b/gtk/gtkfilechooser.c
@@ -2263,3 +2263,99 @@ gtk_file_chooser_get_do_overwrite_confirmation (GtkFileChooser *chooser)
return do_overwrite_confirmation;
}
+
+/**
+ * gtk_file_chooser_add_choice:
+ * @chooser: a #GtkFileChooser
+ * @id: id for the added choice
+ * @label: user-visible label for the added choice
+ * @options: ids for the options of the choice, or %NULL for a boolean choice
+ * @option_labels: user-visible labels for the options, must be the same length as @options
+ *
+ * Adds a 'choice' to the file chooser. This is typically implemented
+ * as a combobox or, for boolean choices, as a checkbutton. You can select
+ * 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().
+ *
+ * Since: 3.22
+ */
+void
+gtk_file_chooser_add_choice (GtkFileChooser *chooser,
+ const char *id,
+ const char *label,
+ const char **options,
+ const char **option_labels)
+{
+ GtkFileChooserIface *iface = GTK_FILE_CHOOSER_GET_IFACE (chooser);
+
+ if (iface->add_choice)
+ iface->add_choice (chooser, id, label, options, option_labels);
+}
+
+/**
+ * gtk_file_chooser_remove_choice:
+ * @chooser: a #GtkFileChooser
+ * @id: the ID of the choice to remove
+ *
+ * Removes a 'choice' that has been added with gtk_file_chooser_add_choice().
+ *
+ * Since: 3.22
+ */
+void
+gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
+ const char *id)
+{
+ GtkFileChooserIface *iface = GTK_FILE_CHOOSER_GET_IFACE (chooser);
+
+ if (iface->remove_choice)
+ iface->remove_choice (chooser, id);
+}
+
+/**
+ * gtk_file_chooser_set_choice:
+ * @chooser: a #GtkFileChooser
+ * @id: the ID of the choice to set
+ * @selected: the ID of the option to select
+ *
+ * Selects an option in a 'choice' that has been added with
+ * gtk_file_chooser_add_choice(). For a boolean choice, the
+ * possible options are "true" and "false".
+ *
+ * Since: 3.22
+ */
+void
+gtk_file_chooser_set_choice (GtkFileChooser *chooser,
+ const char *id,
+ const char *option)
+{
+ GtkFileChooserIface *iface = GTK_FILE_CHOOSER_GET_IFACE (chooser);
+
+ if (iface->set_choice)
+ iface->set_choice (chooser, id, option);
+}
+
+/**
+ * gtk_file_chooser_get_choice:
+ * @chooser: a #GtkFileChooser
+ * @id: the ID of the choice to get
+ *
+ * Gets the currently selected option in the 'choice' with the given ID.
+ *
+ * Returns: the ID of the currenly selected option
+ * Since: 3.22
+ */
+const char *
+gtk_file_chooser_get_choice (GtkFileChooser *chooser,
+ const char *id)
+{
+ GtkFileChooserIface *iface = GTK_FILE_CHOOSER_GET_IFACE (chooser);
+
+ if (iface->get_choice)
+ return iface->get_choice (chooser, id);
+
+ return NULL;
+}
+
diff --git a/gtk/gtkfilechooser.h b/gtk/gtkfilechooser.h
index d1f5543..92cdbb3 100644
--- a/gtk/gtkfilechooser.h
+++ b/gtk/gtkfilechooser.h
@@ -304,6 +304,23 @@ gboolean gtk_file_chooser_remove_shortcut_folder_uri (GtkFileChooser *chooser,
GDK_AVAILABLE_IN_ALL
GSList *gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser);
+GDK_AVAILABLE_IN_3_22
+void gtk_file_chooser_add_choice (GtkFileChooser *chooser,
+ const char *id,
+ const char *label,
+ const char **options,
+ const char **option_labels);
+GDK_AVAILABLE_IN_3_22
+void gtk_file_chooser_remove_choice (GtkFileChooser *chooser,
+ const char *id);
+GDK_AVAILABLE_IN_3_22
+void gtk_file_chooser_set_choice (GtkFileChooser *chooser,
+ const char *id,
+ const char *option);
+GDK_AVAILABLE_IN_3_22
+const char *gtk_file_chooser_get_choice (GtkFileChooser *chooser,
+ const char *id);
+
G_END_DECLS
#endif /* __GTK_FILE_CHOOSER_H__ */
diff --git a/gtk/gtkfilechooserprivate.h b/gtk/gtkfilechooserprivate.h
index 2280da9..0094beb 100644
--- a/gtk/gtkfilechooserprivate.h
+++ b/gtk/gtkfilechooserprivate.h
@@ -87,7 +87,7 @@ struct _GtkFileChooserIface
GFile *file,
GError **error);
GSList * (*list_shortcut_folders) (GtkFileChooser *chooser);
-
+
/* Signals
*/
void (*current_folder_changed) (GtkFileChooser *chooser);
@@ -95,6 +95,20 @@ struct _GtkFileChooserIface
void (*update_preview) (GtkFileChooser *chooser);
void (*file_activated) (GtkFileChooser *chooser);
GtkFileChooserConfirmation (*confirm_overwrite) (GtkFileChooser *chooser);
+
+ /* 3.22 additions */
+ void (*add_choice) (GtkFileChooser *chooser,
+ const char *id,
+ const char *label,
+ const char **options,
+ const char **option_labels);
+ void (*remove_choice) (GtkFileChooser *chooser,
+ const char *id);
+ void (*set_choice) (GtkFileChooser *chooser,
+ const char *id,
+ const char *option);
+ const char * (*get_choice) (GtkFileChooser *chooser,
+ const char *id);
};
GtkFileSystem *_gtk_file_chooser_get_file_system (GtkFileChooser *chooser);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]