]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserdialog.c
GtkBubbleWindow: allocate CSS borders and paddings
[~andy/gtk] / gtk / gtkfilechooserdialog.c
index de61afdc2d1dafdd7047cdb2128ed6bbba0331f0..6ed41b68f31928d982878e43b9cc3438f878890d 100644 (file)
@@ -14,9 +14,7 @@
  * 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"
@@ -44,7 +42,7 @@
  * #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.
  *
@@ -212,6 +210,7 @@ static void     gtk_file_chooser_dialog_get_property (GObject               *obj
                                                      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);
@@ -232,6 +231,7 @@ gtk_file_chooser_dialog_class_init (GtkFileChooserDialogClass *class)
   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);
 
@@ -259,6 +259,8 @@ gtk_file_chooser_dialog_init (GtkFileChooserDialog *dialog)
   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
@@ -537,6 +539,35 @@ gtk_file_chooser_dialog_map (GtkWidget *widget)
   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,
@@ -592,7 +623,7 @@ gtk_file_chooser_dialog_new_valist (const gchar          *title,
  * @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().