* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
* #GtkFileChooserDialog is a dialog box suitable for use with
* "File/Open" or "File/Save as" commands. This widget works by
* putting a #GtkFileChooserWidget inside a #GtkDialog. It exposes
- * the #GtkFileChooserIface interface, so you can use all of the
+ * the #GtkFileChooser interface, so you can use all of the
* #GtkFileChooser functions on the file chooser dialog as well as
* those for #GtkDialog.
*
* gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
*
* if (user_edited_a_new_document)
- * {
- * gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), default_folder_for_saving);
- * gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Untitled document");
- * }
+ * gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "Untitled document");
* else
* gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), filename_for_existing_document);
*
* </programlisting></informalexample>
* </para>
* </example>
+ * <section id="gtkfilechooserdialog-setting-up">
+ * <title>Setting up a file chooser dialog</title>
+ * There are various cases in which you may need to use a #GtkFileChooserDialog:
+ * <itemizedlist><listitem>To select a file for opening, as for a
+ * <guimenuitem>File/Open</guimenuitem> command. Use
+ * #GTK_FILE_CHOOSER_ACTION_OPEN.
+ * </listitem>
+ * <listitem>To save a file for the first time, as for a
+ * <guimenuitem>File/Save</guimenuitem> command. Use
+ * #GTK_FILE_CHOOSER_ACTION_SAVE, and suggest a name such as
+ * "Untitled" with gtk_file_chooser_set_current_name().
+ * </listitem>
+ * <listitem>To save a file under a different name, as for a
+ * <guimenuitem>File/Save As</guimenuitem> command. Use
+ * #GTK_FILE_CHOOSER_ACTION_SAVE, and set the existing filename
+ * with gtk_file_chooser_set_filename().
+ * </listitem>
+ * <listitem>To choose a folder instead of a file. Use
+ * #GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER.
+ * </listitem></itemizedlist>
+ * <note>
+ * <para>
+ * Old versions of the file chooser's documentation suggested
+ * using gtk_file_chooser_set_current_folder() in various
+ * situations, with the intention of letting the application
+ * suggest a reasonable default folder. This is no longer
+ * considered to be a good policy, as now the file chooser is
+ * able to make good suggestions on its own. In general, you
+ * should only cause the file chooser to show a specific folder
+ * when it is appropriate to use gtk_file_chooser_set_filename(),
+ * i.e. when you are doing a <guimenuitem>File/Save
+ * As</guimenuitem> command <emphasis>and</emphasis> you already
+ * have a file saved somewhere.
+ * </para>
+ * </note>
+ * </section>
* <section id="gtkfilechooserdialog-response-codes">
* <title>Response Codes</title>
* #GtkFileChooserDialog inherits from #GtkDialog, so buttons that
GParamSpec *pspec);
static void gtk_file_chooser_dialog_map (GtkWidget *widget);
+static void gtk_file_chooser_dialog_unmap (GtkWidget *widget);
static void response_cb (GtkDialog *dialog,
gint response_id);
gobject_class->finalize = gtk_file_chooser_dialog_finalize;
widget_class->map = gtk_file_chooser_dialog_map;
+ widget_class->unmap = gtk_file_chooser_dialog_unmap;
+
+ gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILE_CHOOSER);
_gtk_file_chooser_install_properties (gobject_class);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
+ gtk_window_set_role (GTK_WINDOW (dialog), "GtkFileChooserDialog");
+
/* We do a signal connection here rather than overriding the method in
* class_init because GtkDialog::response is a RUN_LAST signal. We want *our*
* handler to be run *first*, regardless of whether the user installs response
GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->map (widget);
}
+static void
+save_dialog_geometry (GtkFileChooserDialog *dialog)
+{
+ GtkWindow *window;
+ GSettings *settings;
+ int x, y, width, height;
+
+ settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (dialog));
+
+ window = GTK_WINDOW (dialog);
+
+ gtk_window_get_position (window, &x, &y);
+ gtk_window_get_size (window, &width, &height);
+
+ g_settings_set (settings, SETTINGS_KEY_WINDOW_POSITION, "(ii)", x, y);
+ g_settings_set (settings, SETTINGS_KEY_WINDOW_SIZE, "(ii)", width, height);
+}
+
+/* GtkWidget::unmap handler */
+static void
+gtk_file_chooser_dialog_unmap (GtkWidget *widget)
+{
+ GtkFileChooserDialog *dialog = GTK_FILE_CHOOSER_DIALOG (widget);
+
+ save_dialog_geometry (dialog);
+
+ GTK_WIDGET_CLASS (gtk_file_chooser_dialog_parent_class)->unmap (widget);
+}
+
/* GtkDialog::response handler */
static void
response_cb (GtkDialog *dialog,
* @parent: (allow-none): Transient parent of the dialog, or %NULL
* @action: Open or save mode for the dialog
* @first_button_text: (allow-none): stock ID or text to go in the first button, or %NULL
- * @Varargs: response ID for the first button, then additional (button, id) pairs, ending with %NULL
+ * @...: response ID for the first button, then additional (button, id) pairs, ending with %NULL
*
* Creates a new #GtkFileChooserDialog. This function is analogous to
* gtk_dialog_new_with_buttons().