summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-07-05 22:09:56 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-07-07 00:07:01 -0400
commit0d9c2d28de0af53a943e7b02bbe3d21a4c7801b9 (patch)
treee3eabe0fa1625e94f9e26c2cb837f00bfaefed3f
parent68f8b21ae417ee019b65c506ba210d0b0289ba13 (diff)
downloadgtk+-0d9c2d28de0af53a943e7b02bbe3d21a4c7801b9.tar.gz
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.
-rw-r--r--gtk/gtkfilechooser.c96
-rw-r--r--gtk/gtkfilechooser.h17
-rw-r--r--gtk/gtkfilechooserprivate.h16
3 files changed, 128 insertions, 1 deletions
diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c
index 101decb5e3..18cc5aff74 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 d1f5543e52..92cdbb3658 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 2280da9ae7..0094beb299 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);