gtk+ r22116 - in trunk: . gtk
- From: federico svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r22116 - in trunk: . gtk
- Date: Wed, 14 Jan 2009 20:18:24 +0000 (UTC)
Author: federico
Date: Wed Jan 14 20:18:23 2009
New Revision: 22116
URL: http://svn.gnome.org/viewvc/gtk+?rev=22116&view=rev
Log:
Add GtkFileChooserSettings for the dialog's geometry
2009-01-14 Federico Mena Quintero <federico novell com>
Remember the file chooser's geometry across invocations.
* gtk/gtkfilechoosersettings.h (struct _GtkFileChooserSettings):
New fields geometry_x, geometry_y, geometry_width, geometry_height.
(_gtk_file_chooser_settings_get_geometry): New prototype.
(_gtk_file_chooser_settings_set_geometry): New prototype.
* gtk/gtkfilechoosersettings.c (GEOMETRY_X_KEY, GEOMETRY_Y_KEY,
GEOMETRY_WIDTH_KEY, GEOMETRY_HEIGTH_KEY): New key names.
(ensure_settings_read): Read the geometry keys.
(_gtk_file_chooser_settings_save): Save the geometry keys.
(_gtk_file_chooser_settings_init): Initialize the geometry keys to
"don't have this value".
(_gtk_file_chooser_settings_get_geometry): New public function.
(_gtk_file_chooser_settings_set_geometry): New public function.
Signed-off-by: Federico Mena Quintero <federico novell com>
Modified:
trunk/ChangeLog
trunk/gtk/gtkfilechoosersettings.c
trunk/gtk/gtkfilechoosersettings.h
Modified: trunk/gtk/gtkfilechoosersettings.c
==============================================================================
--- trunk/gtk/gtkfilechoosersettings.c (original)
+++ trunk/gtk/gtkfilechoosersettings.c Wed Jan 14 20:18:23 2009
@@ -42,6 +42,10 @@
#define SHOW_HIDDEN_KEY "ShowHidden"
#define EXPAND_FOLDERS_KEY "ExpandFolders"
#define SHOW_SIZE_COLUMN_KEY "ShowSizeColumn"
+#define GEOMETRY_X_KEY "GeometryX"
+#define GEOMETRY_Y_KEY "GeometryY"
+#define GEOMETRY_WIDTH_KEY "GeometryWidth"
+#define GEOMETRY_HEIGHT_KEY "GeometryHeight"
#define MODE_PATH_BAR "path-bar"
#define MODE_FILENAME_ENTRY "filename-entry"
@@ -77,6 +81,24 @@
}
static void
+get_int_key (GKeyFile *key_file, const char *group, const char *key, int *out_value)
+{
+ GError *error;
+ int val;
+
+ error = NULL;
+ val = g_key_file_get_integer (key_file, group, key, &error);
+
+ if (val == 0 && error != NULL)
+ {
+ *out_value = -1;
+ g_error_free (error);
+ }
+ else
+ *out_value = val;
+}
+
+static void
ensure_settings_read (GtkFileChooserSettings *settings)
{
GError *error;
@@ -143,6 +165,11 @@
else
settings->show_size_column = value != FALSE;
+ get_int_key (key_file, SETTINGS_GROUP, GEOMETRY_X_KEY, &settings->geometry_x);
+ get_int_key (key_file, SETTINGS_GROUP, GEOMETRY_Y_KEY, &settings->geometry_y);
+ get_int_key (key_file, SETTINGS_GROUP, GEOMETRY_WIDTH_KEY, &settings->geometry_width);
+ get_int_key (key_file, SETTINGS_GROUP, GEOMETRY_HEIGHT_KEY, &settings->geometry_height);
+
out:
g_key_file_free (key_file);
@@ -165,6 +192,10 @@
settings->show_hidden = FALSE;
settings->expand_folders = FALSE;
settings->show_size_column = FALSE;
+ settings->geometry_x = -1;
+ settings->geometry_y = -1;
+ settings->geometry_width = -1;
+ settings->geometry_height = -1;
}
GtkFileChooserSettings *
@@ -229,6 +260,34 @@
settings->expand_folders = expand_folders != FALSE;
}
+void
+_gtk_file_chooser_settings_get_geometry (GtkFileChooserSettings *settings,
+ int *out_x,
+ int *out_y,
+ int *out_width,
+ int *out_height)
+{
+ ensure_settings_read (settings);
+
+ *out_x = settings->geometry_x;
+ *out_y = settings->geometry_y;
+ *out_width = settings->geometry_width;
+ *out_height = settings->geometry_height;
+}
+
+void
+_gtk_file_chooser_settings_set_geometry (GtkFileChooserSettings *settings,
+ int x,
+ int y,
+ int width,
+ int height)
+{
+ settings->geometry_x = x;
+ settings->geometry_y = y;
+ settings->geometry_width = width;
+ settings->geometry_height = height;
+}
+
gboolean
_gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
GError **error)
@@ -271,6 +330,14 @@
EXPAND_FOLDERS_KEY, settings->expand_folders);
g_key_file_set_boolean (key_file, SETTINGS_GROUP,
SHOW_SIZE_COLUMN_KEY, settings->show_size_column);
+ g_key_file_set_integer (key_file, SETTINGS_GROUP,
+ GEOMETRY_X_KEY, settings->geometry_x);
+ g_key_file_set_integer (key_file, SETTINGS_GROUP,
+ GEOMETRY_Y_KEY, settings->geometry_y);
+ g_key_file_set_integer (key_file, SETTINGS_GROUP,
+ GEOMETRY_WIDTH_KEY, settings->geometry_width);
+ g_key_file_set_integer (key_file, SETTINGS_GROUP,
+ GEOMETRY_HEIGHT_KEY, settings->geometry_height);
contents = g_key_file_to_data (key_file, &len, error);
g_key_file_free (key_file);
Modified: trunk/gtk/gtkfilechoosersettings.h
==============================================================================
--- trunk/gtk/gtkfilechoosersettings.h (original)
+++ trunk/gtk/gtkfilechoosersettings.h Wed Jan 14 20:18:23 2009
@@ -38,6 +38,11 @@
LocationMode location_mode;
+ int geometry_x;
+ int geometry_y;
+ int geometry_width;
+ int geometry_height;
+
guint settings_read : 1;
guint show_hidden : 1;
guint show_size_column : 1;
@@ -69,6 +74,17 @@
void _gtk_file_chooser_settings_set_show_size_column (GtkFileChooserSettings *settings,
gboolean show_column);
+void _gtk_file_chooser_settings_get_geometry (GtkFileChooserSettings *settings,
+ int *out_x,
+ int *out_y,
+ int *out_width,
+ int *out_heigth);
+void _gtk_file_chooser_settings_set_geometry (GtkFileChooserSettings *settings,
+ int x,
+ int y,
+ int width,
+ int heigth);
+
gboolean _gtk_file_chooser_settings_save (GtkFileChooserSettings *settings,
GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]