[gthumb] load and save the crop dialog options
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] load and save the crop dialog options
- Date: Wed, 23 Jun 2010 17:25:27 +0000 (UTC)
commit 09c665edc0d981072c4017baf9ddfcd42e1df49a
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Jun 23 17:54:05 2010 +0200
load and save the crop dialog options
extensions/file_tools/Makefile.am | 64 +++++++++++----
extensions/file_tools/data/Makefile.am | 15 ++++
.../file_tools/data/gthumb_crop_options.schemas.in | 65 ++++++++++++++
extensions/file_tools/gth-file-tool-crop.c | 89 ++++++++++----------
extensions/file_tools/gth-file-tool-crop.h | 16 ++++
extensions/file_tools/preferences.h | 38 ++++++++
6 files changed, 228 insertions(+), 59 deletions(-)
---
diff --git a/extensions/file_tools/Makefile.am b/extensions/file_tools/Makefile.am
index 4bfe8b6..45cb134 100644
--- a/extensions/file_tools/Makefile.am
+++ b/extensions/file_tools/Makefile.am
@@ -3,37 +3,67 @@ SUBDIRS = data
extensiondir = $(pkglibdir)/extensions
extension_LTLIBRARIES = libfile_tools.la
+ENUM_TYPES = \
+ enum-types.h \
+ enum-types.c
+
+HEADER_FILES = \
+ gth-file-tool-adjust-colors.h \
+ gth-file-tool-crop.h \
+ gth-file-tool-enhance.h \
+ gth-file-tool-equalize.h \
+ gth-file-tool-flip.h \
+ gth-file-tool-mirror.h \
+ gth-file-tool-negative.h \
+ gth-file-tool-redo.h \
+ gth-file-tool-resize.h \
+ gth-file-tool-rotate-left.h \
+ gth-file-tool-rotate-right.h \
+ gth-file-tool-save.h \
+ gth-file-tool-save-as.h \
+ gth-file-tool-undo.h \
+ preferences.h
+
+enum-types.h: $(HEADER_FILES) $(GLIB_MKENUMS)
+ $(AM_V_GEN)( $(GLIB_MKENUMS) \
+ --fhead "#ifndef ENUM_TYPES_H\n#define ENUM_TYPES_H\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \
+ --fprod "/* enumerations from \"@filename \" */\n" \
+ --vhead "GType @enum_name _get_type (void);\n#define GTH_TYPE_ ENUMSHORT@ (@enum_name _get_type())\n" \
+ --ftail "G_END_DECLS\n\n#endif /* ENUM_TYPES_H */" \
+ $^> xgen-$(@F) \
+ && (cmp -s xgen-$(@F) enum-types.h || cp xgen-$(@F) enum-types.h ) \
+ && rm -f xgen-$(@F) )
+
+enum-types.c: $(HEADER_FILES) enum-types.h
+ $(AM_V_GEN)( $(GLIB_MKENUMS) \
+ --fhead "#include <glib-object.h>\n" \
+ --fprod "\n/* enumerations from \"@filename \" */\n#include \"@filename \"" \
+ --vhead "GType\n enum_name@_get_type (void)\n{\n static GType etype = 0;\n if (etype == 0) {\n static const G Type@Value values[] = {" \
+ --vprod " { @VALUENAME@, \"@VALUENAME \", \"@valuenick \" }," \
+ --vtail " { 0, NULL, NULL }\n };\n etype = g_ type@_register_static (\"@EnumName \", values);\n }\n return etype;\n}\n" \
+ $^> xgen-$(@F) \
+ && (cmp -s xgen-$(@F) enum-types.c || cp xgen-$(@F) enum-types.c ) \
+ && rm -f xgen-$(@F) )
+
libfile_tools_la_SOURCES = \
+ $(ENUM_TYPES) \
+ $(HEADER_FILES) \
gth-file-tool-adjust-colors.c \
- gth-file-tool-adjust-colors.h \
gth-file-tool-crop.c \
- gth-file-tool-crop.h \
gth-file-tool-desaturate.c \
gth-file-tool-desaturate.h \
gth-file-tool-enhance.c \
- gth-file-tool-enhance.h \
gth-file-tool-equalize.c \
- gth-file-tool-equalize.h \
gth-file-tool-flip.c \
- gth-file-tool-flip.h \
gth-file-tool-mirror.c \
- gth-file-tool-mirror.h \
gth-file-tool-negative.c \
- gth-file-tool-negative.h \
gth-file-tool-redo.c \
- gth-file-tool-redo.h \
gth-file-tool-resize.c \
- gth-file-tool-resize.h \
gth-file-tool-rotate-left.c \
- gth-file-tool-rotate-left.h \
gth-file-tool-rotate-right.c \
- gth-file-tool-rotate-right.h \
gth-file-tool-save.c \
- gth-file-tool-save.h \
gth-file-tool-save-as.c \
- gth-file-tool-save-as.h \
gth-file-tool-undo.c \
- gth-file-tool-undo.h \
main.c
libfile_tools_la_CFLAGS = $(GTHUMB_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
@@ -49,7 +79,11 @@ extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
@GTHUMB_EXTENSION_RULE@
EXTRA_DIST = $(extensionini_in_files)
-
DISTCLEANFILES = $(extensionini_DATA)
+BUILT_SOURCES = $(ENUM_TYPES)
+CLEANFILES = $(BUILT_SOURCES)
+
+dist-hook:
+ cd $(distdir); rm -f $(CLEANFILES)
-include $(top_srcdir)/git.mk
diff --git a/extensions/file_tools/data/Makefile.am b/extensions/file_tools/data/Makefile.am
index 4d5385d..39b0d0e 100644
--- a/extensions/file_tools/data/Makefile.am
+++ b/extensions/file_tools/data/Makefile.am
@@ -1,2 +1,17 @@
SUBDIRS = ui
+
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_in_files = gthumb_crop_options.schemas.in
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+ INTLTOOL_SCHEMAS_RULE@
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+ GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/extensions/file_tools/data/$(schema_DATA)
+endif
+
+EXTRA_DIST = $(schema_in_files)
+CLEANFILES = $(schema_DATA)
+
-include $(top_srcdir)/git.mk
diff --git a/extensions/file_tools/data/gthumb_crop_options.schemas.in b/extensions/file_tools/data/gthumb_crop_options.schemas.in
new file mode 100644
index 0000000..900c933
--- /dev/null
+++ b/extensions/file_tools/data/gthumb_crop_options.schemas.in
@@ -0,0 +1,65 @@
+<gconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/crop/grid_type</key>
+ <applyto>/apps/gthumb/ext/crop/grid_type</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default>thirds</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/crop/aspect_ratio</key>
+ <applyto>/apps/gthumb/ext/crop/aspect_ratio</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default>none</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/crop/aspect_ratio_invert</key>
+ <applyto>/apps/gthumb/ext/crop/aspect_ratio_invert</applyto>
+ <owner>gthumb</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/crop/aspect_ratio_width</key>
+ <applyto>/apps/gthumb/ext/crop/aspect_ratio_width</applyto>
+ <owner>gthumb</owner>
+ <type>int</type>
+ <default>1</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/crop/aspect_ratio_height</key>
+ <applyto>/apps/gthumb/ext/crop/aspect_ratio_height</applyto>
+ <owner>gthumb</owner>
+ <type>int</type>
+ <default>1</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
diff --git a/extensions/file_tools/gth-file-tool-crop.c b/extensions/file_tools/gth-file-tool-crop.c
index 77ac1ed..6ad80dd 100644
--- a/extensions/file_tools/gth-file-tool-crop.c
+++ b/extensions/file_tools/gth-file-tool-crop.c
@@ -23,29 +23,14 @@
#include <config.h>
#include <gthumb.h>
#include <extensions/image_viewer/gth-image-viewer-page.h>
+#include "enum-types.h"
#include "gth-file-tool-crop.h"
+#include "preferences.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
-typedef enum {
- GTH_CROP_RATIO_NONE = 0,
- GTH_CROP_RATIO_SQUARE,
- GTH_CROP_RATIO_IMAGE,
- GTH_CROP_RATIO_DISPLAY,
- GTH_CROP_RATIO_5_4,
- GTH_CROP_RATIO_4_3,
- GTH_CROP_RATIO_7_5,
- GTH_CROP_RATIO_3_2,
- GTH_CROP_RATIO_16_10,
- GTH_CROP_RATIO_16_9,
- GTH_CROP_RATIO_185_100,
- GTH_CROP_RATIO_239_100,
- GTH_CROP_RATIO_CUSTOM
-} GthCropRatio;
-
-
static gpointer parent_class = NULL;
@@ -120,7 +105,7 @@ crop_button_clicked_cb (GtkButton *button,
static void
-selection_x_value_changed_cb (GtkSpinButton *spin,
+selection_x_value_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
gth_image_selector_set_selection_x (self->priv->selector, gtk_spin_button_get_value_as_int (spin));
@@ -128,7 +113,7 @@ selection_x_value_changed_cb (GtkSpinButton *spin,
static void
-selection_y_value_changed_cb (GtkSpinButton *spin,
+selection_y_value_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
gth_image_selector_set_selection_y (self->priv->selector, gtk_spin_button_get_value_as_int (spin));
@@ -136,7 +121,7 @@ selection_y_value_changed_cb (GtkSpinButton *spin,
static void
-selection_width_value_changed_cb (GtkSpinButton *spin,
+selection_width_value_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
gth_image_selector_set_selection_width (self->priv->selector, gtk_spin_button_get_value_as_int (spin));
@@ -144,7 +129,7 @@ selection_width_value_changed_cb (GtkSpinButton *spin,
static void
-selection_height_value_changed_cb (GtkSpinButton *spin,
+selection_height_value_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
gth_image_selector_set_selection_height (self->priv->selector, gtk_spin_button_get_value_as_int (spin));
@@ -153,10 +138,10 @@ selection_height_value_changed_cb (GtkSpinButton *spin,
static void
set_spin_range_value (GthFileToolCrop *self,
- GtkWidget *spin,
- int min,
- int max,
- int x)
+ GtkWidget *spin,
+ int min,
+ int max,
+ int x)
{
g_signal_handlers_block_by_data (G_OBJECT (spin), self);
gtk_spin_button_set_range (GTK_SPIN_BUTTON (spin), min, max);
@@ -167,7 +152,7 @@ set_spin_range_value (GthFileToolCrop *self,
static void
selector_selection_changed_cb (GthImageSelector *selector,
- GthFileToolCrop *self)
+ GthFileToolCrop *self)
{
GdkRectangle selection;
int min, max;
@@ -196,8 +181,8 @@ selector_selection_changed_cb (GthImageSelector *selector,
static void
set_spin_value (GthFileToolCrop *self,
- GtkWidget *spin,
- int x)
+ GtkWidget *spin,
+ int x)
{
g_signal_handlers_block_by_data (G_OBJECT (spin), self);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), x);
@@ -206,7 +191,7 @@ set_spin_value (GthFileToolCrop *self,
static void
-ratio_combobox_changed_cb (GtkComboBox *combobox,
+ratio_combobox_changed_cb (GtkComboBox *combobox,
GthFileToolCrop *self)
{
GtkWidget *ratio_w_spinbutton;
@@ -219,7 +204,7 @@ ratio_combobox_changed_cb (GtkComboBox *combobox,
ratio_h_spinbutton = GET_WIDGET ("ratio_h_spinbutton");
w = h = 1;
use_ratio = TRUE;
- idx = gtk_combo_box_get_active (combobox);
+ idx = gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->ratio_combobox));
switch (idx) {
case GTH_CROP_RATIO_NONE:
@@ -236,35 +221,35 @@ ratio_combobox_changed_cb (GtkComboBox *combobox,
w = self->priv->screen_width;
h = self->priv->screen_height;
break;
- case GTH_CROP_RATIO_5_4:
+ case GTH_CROP_RATIO_5x4:
w = 5;
h = 4;
break;
- case GTH_CROP_RATIO_4_3:
+ case GTH_CROP_RATIO_4x3:
w = 4;
h = 3;
break;
- case GTH_CROP_RATIO_7_5:
+ case GTH_CROP_RATIO_7x5:
w = 7;
h = 5;
break;
- case GTH_CROP_RATIO_3_2:
+ case GTH_CROP_RATIO_3x2:
w = 3;
h = 2;
break;
- case GTH_CROP_RATIO_16_10:
+ case GTH_CROP_RATIO_16x10:
w = 16;
h = 10;
break;
- case GTH_CROP_RATIO_16_9:
+ case GTH_CROP_RATIO_16x9:
w = 16;
h = 9;
break;
- case GTH_CROP_RATIO_185_100:
+ case GTH_CROP_RATIO_185x100:
w = 185;
h = 100;
break;
- case GTH_CROP_RATIO_239_100:
+ case GTH_CROP_RATIO_239x100:
w = 239;
h = 100;
break;
@@ -287,9 +272,9 @@ ratio_combobox_changed_cb (GtkComboBox *combobox,
static void
-update_ratio (GtkSpinButton *spin,
+update_ratio (GtkSpinButton *spin,
GthFileToolCrop *self,
- gboolean swap_x_and_y_to_start)
+ gboolean swap_x_and_y_to_start)
{
gboolean use_ratio;
int w, h;
@@ -311,7 +296,7 @@ update_ratio (GtkSpinButton *spin,
static void
-ratio_value_changed_cb (GtkSpinButton *spin,
+ratio_value_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
update_ratio (spin, self, FALSE);
@@ -319,7 +304,7 @@ ratio_value_changed_cb (GtkSpinButton *spin,
static void
-invert_ratio_changed_cb (GtkSpinButton *spin,
+invert_ratio_changed_cb (GtkSpinButton *spin,
GthFileToolCrop *self)
{
update_ratio (spin, self, TRUE);
@@ -394,7 +379,13 @@ gth_file_tool_crop_get_options (GthFileTool *base)
gtk_widget_show (self->priv->ratio_combobox);
gtk_box_pack_start (GTK_BOX (GET_WIDGET ("ratio_combobox_box")), self->priv->ratio_combobox, FALSE, FALSE, 0);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->ratio_combobox), eel_gconf_get_enum (PREF_CROP_ASPECT_RATIO, GTH_TYPE_CROP_RATIO, GTH_CROP_RATIO_NONE));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_w_spinbutton")), MAX (eel_gconf_get_integer (PREF_CROP_ASPECT_RATIO_WIDTH, 1), 1));
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_h_spinbutton")), MAX (eel_gconf_get_integer (PREF_CROP_ASPECT_RATIO_HEIGHT, 1), 1));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("invert_ratio_checkbutton")), eel_gconf_get_boolean (PREF_CROP_ASPECT_RATIO_INVERT, FALSE));
+
self->priv->grid_type_combobox = _gtk_combo_box_new_with_texts (_("None"), _("Rule of Thirds"), _("Golden Sections"), NULL);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->grid_type_combobox), eel_gconf_get_enum (PREF_CROP_GRID_TYPE, GTH_TYPE_GRID_TYPE, GTH_GRID_THIRDS));
gtk_widget_show (self->priv->grid_type_combobox);
gtk_box_pack_start (GTK_BOX (GET_WIDGET ("grid_type_combobox_box")), self->priv->grid_type_combobox, FALSE, FALSE, 0);
@@ -444,6 +435,7 @@ gth_file_tool_crop_get_options (GthFileTool *base)
self);
self->priv->selector = (GthImageSelector *) gth_image_selector_new (GTH_IMAGE_VIEWER (viewer), GTH_SELECTOR_TYPE_REGION);
+ gth_image_selector_set_grid_type (self->priv->selector, gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->grid_type_combobox)));
g_signal_connect (self->priv->selector,
"selection-changed",
G_CALLBACK (selector_selection_changed_cb),
@@ -453,9 +445,8 @@ gth_file_tool_crop_get_options (GthFileTool *base)
G_CALLBACK (selector_mask_visibility_changed_cb),
self);*/
- gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->ratio_combobox), 0);
gth_image_viewer_set_tool (GTH_IMAGE_VIEWER (viewer), (GthImageViewerTool *) self->priv->selector);
- gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->grid_type_combobox), GTH_GRID_THIRDS);
+ ratio_combobox_changed_cb (NULL, self);
return options;
}
@@ -471,6 +462,16 @@ gth_file_tool_crop_destroy_options (GthFileTool *base)
self = (GthFileToolCrop *) base;
+ /* save the dialog options */
+
+ eel_gconf_set_enum (PREF_CROP_GRID_TYPE, GTH_TYPE_GRID_TYPE, gth_image_selector_get_grid_type (self->priv->selector));
+ eel_gconf_set_integer (PREF_CROP_ASPECT_RATIO_WIDTH, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_w_spinbutton"))));
+ eel_gconf_set_integer (PREF_CROP_ASPECT_RATIO_HEIGHT, gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (GET_WIDGET ("ratio_h_spinbutton"))));
+ eel_gconf_set_enum (PREF_CROP_ASPECT_RATIO, GTH_TYPE_CROP_RATIO, gtk_combo_box_get_active (GTK_COMBO_BOX (self->priv->ratio_combobox)));
+ eel_gconf_set_boolean (PREF_CROP_ASPECT_RATIO_INVERT, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("invert_ratio_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/gth-file-tool-crop.h b/extensions/file_tools/gth-file-tool-crop.h
index d003ff7..f8f89f3 100644
--- a/extensions/file_tools/gth-file-tool-crop.h
+++ b/extensions/file_tools/gth-file-tool-crop.h
@@ -27,6 +27,22 @@
G_BEGIN_DECLS
+typedef enum {
+ GTH_CROP_RATIO_NONE = 0,
+ GTH_CROP_RATIO_SQUARE,
+ GTH_CROP_RATIO_IMAGE,
+ GTH_CROP_RATIO_DISPLAY,
+ GTH_CROP_RATIO_5x4,
+ GTH_CROP_RATIO_4x3,
+ GTH_CROP_RATIO_7x5,
+ GTH_CROP_RATIO_3x2,
+ GTH_CROP_RATIO_16x10,
+ GTH_CROP_RATIO_16x9,
+ GTH_CROP_RATIO_185x100,
+ GTH_CROP_RATIO_239x100,
+ GTH_CROP_RATIO_CUSTOM
+} GthCropRatio;
+
#define GTH_TYPE_FILE_TOOL_CROP (gth_file_tool_crop_get_type ())
#define GTH_FILE_TOOL_CROP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILE_TOOL_CROP, GthFileToolCrop))
#define GTH_FILE_TOOL_CROP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_FILE_TOOL_CROP, GthFileToolCropClass))
diff --git a/extensions/file_tools/preferences.h b/extensions/file_tools/preferences.h
new file mode 100644
index 0000000..27c43db
--- /dev/null
+++ b/extensions/file_tools/preferences.h
@@ -0,0 +1,38 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef PREFERENCES_H
+#define PREFERENCES_H
+
+#include <gthumb.h>
+
+G_BEGIN_DECLS
+
+#define PREF_CROP_GRID_TYPE "/apps/gthumb/ext/crop/grid_type"
+#define PREF_CROP_ASPECT_RATIO "/apps/gthumb/ext/crop/aspect_ratio"
+#define PREF_CROP_ASPECT_RATIO_INVERT "/apps/gthumb/ext/crop/aspect_ratio_invert"
+#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"
+
+G_END_DECLS
+
+#endif /* PREFERENCES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]