[gthumb] load and save the resize dialog options



commit 5847637de5b23b59588866cc82cf5554f2b2d5cc
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Jun 23 18:48:08 2010 +0200

    load and save the resize dialog options

 extensions/file_tools/data/Makefile.am             |    2 +-
 .../data/gthumb_resize_options.schemas.in          |   41 ++++++++++++++++++++
 extensions/file_tools/gth-file-tool-resize.c       |   27 +++++++------
 extensions/file_tools/preferences.h                |    4 ++
 4 files changed, 61 insertions(+), 13 deletions(-)
---
diff --git a/extensions/file_tools/data/Makefile.am b/extensions/file_tools/data/Makefile.am
index 39b0d0e..f4f2f1e 100644
--- a/extensions/file_tools/data/Makefile.am
+++ b/extensions/file_tools/data/Makefile.am
@@ -1,7 +1,7 @@
 SUBDIRS = ui
 
 schemadir = @GCONF_SCHEMA_FILE_DIR@
-schema_in_files = gthumb_crop_options.schemas.in
+schema_in_files = gthumb_crop_options.schemas.in gthumb_resize_options.schemas.in
 schema_DATA = $(schema_in_files:.schemas.in=.schemas)
 
 @INTLTOOL_SCHEMAS_RULE@
diff --git a/extensions/file_tools/data/gthumb_resize_options.schemas.in b/extensions/file_tools/data/gthumb_resize_options.schemas.in
new file mode 100644
index 0000000..0c87745
--- /dev/null
+++ b/extensions/file_tools/data/gthumb_resize_options.schemas.in
@@ -0,0 +1,41 @@
+<gconfschemafile>
+    <schemalist>
+
+      <schema>
+	<key>/schemas/apps/gthumb/ext/resize/unit</key>
+	<applyto>/apps/gthumb/ext/resize/unit</applyto>
+	<owner>gthumb</owner>
+	<type>string</type>
+	<default>percentage</default>
+	<locale name="C">
+	  <short></short>
+	  <long></long>
+	</locale>
+      </schema>
+
+      <schema>
+	<key>/schemas/apps/gthumb/ext/resize/keep_aspect_ratio</key>
+	<applyto>/apps/gthumb/ext/resize/keep_aspect_ratio</applyto>
+	<owner>gthumb</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+	  <short></short>
+	  <long></long>
+	</locale>
+      </schema>
+
+      <schema>
+	<key>/schemas/apps/gthumb/ext/resize/high_quality</key>
+	<applyto>/apps/gthumb/ext/resize/high_quality</applyto>
+	<owner>gthumb</owner>
+	<type>bool</type>
+	<default>true</default>
+	<locale name="C">
+	  <short></short>
+	  <long></long>
+	</locale>
+      </schema>
+
+    </schemalist>
+</gconfschemafile>
diff --git a/extensions/file_tools/gth-file-tool-resize.c b/extensions/file_tools/gth-file-tool-resize.c
index 9933ae9..95e83ff 100644
--- a/extensions/file_tools/gth-file-tool-resize.c
+++ b/extensions/file_tools/gth-file-tool-resize.c
@@ -25,6 +25,7 @@
 #include <gthumb.h>
 #include <extensions/image_viewer/gth-image-viewer-page.h>
 #include "gth-file-tool-resize.h"
+#include "preferences.h"
 
 
 #define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
@@ -81,12 +82,6 @@ static void
 cancel_button_clicked_cb (GtkButton         *button,
 			  GthFileToolResize *self)
 {
-	GtkWidget *window;
-	GtkWidget *viewer_page;
-
-	window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
-	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
-	gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
 	gth_file_tool_hide_options (GTH_FILE_TOOL (self));
 }
 
@@ -252,9 +247,9 @@ gth_file_tool_resize_get_options (GthFileTool *base)
 	self->priv->new_pixbuf = NULL;
 	self->priv->new_width = self->priv->original_width;
 	self->priv->new_height = self->priv->original_height;
-	self->priv->keep_ratio = TRUE;
-	self->priv->interpolation = HIGH_QUALITY_INTERPOLATION;
-	self->priv->unit = GTH_UNIT_PERCENTAGE;
+	self->priv->keep_ratio = eel_gconf_get_boolean (PREF_RESIZE_KEEP_ASPECT_RATIO, TRUE);
+	self->priv->interpolation = eel_gconf_get_boolean (PREF_RESIZE_HIGH_QUALITY, TRUE) ? HIGH_QUALITY_INTERPOLATION : GDK_INTERP_NEAREST;
+	self->priv->unit = eel_gconf_get_enum (PREF_RESIZE_UNIT, GTH_TYPE_UNIT, GTH_UNIT_PERCENTAGE);
 	self->priv->builder = _gtk_builder_new_from_file ("resize-options.ui", "file_tools");
 
 	options = _gtk_builder_get_widget (self->priv->builder, "options");
@@ -313,12 +308,20 @@ static void
 gth_file_tool_resize_destroy_options (GthFileTool *base)
 {
 	GthFileToolResize *self;
-	GtkWidget       *window;
-	GtkWidget       *viewer_page;
-	GtkWidget       *viewer;
+	GtkWidget         *window;
+	GtkWidget         *viewer_page;
+	GtkWidget         *viewer;
 
 	self = (GthFileToolResize *) base;
 
+	/* save the dialog options */
+
+	eel_gconf_set_enum (PREF_RESIZE_UNIT, GTH_TYPE_UNIT, gtk_combo_box_get_active (GTK_COMBO_BOX (GET_WIDGET ("unit_combobox"))));
+	eel_gconf_set_boolean (PREF_RESIZE_KEEP_ASPECT_RATIO, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_ratio_checkbutton"))));
+	eel_gconf_set_boolean (PREF_RESIZE_HIGH_QUALITY, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("high_quality_checkbutton"))));
+
+	/**/
+
 	window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
 	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
 	viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
diff --git a/extensions/file_tools/preferences.h b/extensions/file_tools/preferences.h
index 27c43db..3b8fb48 100644
--- a/extensions/file_tools/preferences.h
+++ b/extensions/file_tools/preferences.h
@@ -33,6 +33,10 @@ G_BEGIN_DECLS
 #define PREF_CROP_ASPECT_RATIO_WIDTH  "/apps/gthumb/ext/crop/aspect_ratio_width"
 #define PREF_CROP_ASPECT_RATIO_HEIGHT "/apps/gthumb/ext/crop/aspect_ratio_height"
 
+#define PREF_RESIZE_UNIT              "/apps/gthumb/ext/resize/unit"
+#define PREF_RESIZE_KEEP_ASPECT_RATIO "/apps/gthumb/ext/resize/keep_aspect_ratio"
+#define PREF_RESIZE_HIGH_QUALITY      "/apps/gthumb/ext/resize/high_quality"
+
 G_END_DECLS
 
 #endif /* PREFERENCES_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]