gnome-scan r500 - in trunk: . lib src
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r500 - in trunk: . lib src
- Date: Sun, 24 Feb 2008 17:43:38 +0000 (GMT)
Author: bersace
Date: Sun Feb 24 17:43:37 2008
New Revision: 500
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=500&view=rev
Log:
Automatic per app settings saving in gconf.
Modified:
trunk/ChangeLog
trunk/NEWS
trunk/lib/gnome-scan-dialog.c
trunk/lib/gnome-scan-param-widget.c
trunk/lib/gnome-scan-settings.c
trunk/src/flegita-output-filename-widget.c
trunk/src/flegita-sink.c
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS (original)
+++ trunk/NEWS Sun Feb 24 17:43:37 2008
@@ -6,6 +6,21 @@
Gnome Scan aim to provide a sane scan infrastructure. Flegita provide
app and plugin on top of Gnome Scan for the desktop.
+Changes in version 0.5.6
+========================
+
+ * Add an Automatic color enhancement option in common processing.
+
+ * Use 75. dpi for preview, avoid some bugs in preview area selection.
+
+ * Manual page orientation handling.
+
+ * Show preview acquisition progress bar again.
+
+ * Port to latest GEGL.
+
+ * Automatic per app settings saving in gconf. Now depends on gconf.
+
Changes in version 0.5.4
========================
@@ -14,7 +29,7 @@
* Almost finished preview area and roi selection/resizing/moving.
- * By default, flegita no save pictures in XDG_PICTURES_DIR.
+ * By default, flegita now save pictures in XDG_PICTURES_DIR.
* Handle page orientation.
Modified: trunk/lib/gnome-scan-dialog.c
==============================================================================
--- trunk/lib/gnome-scan-dialog.c (original)
+++ trunk/lib/gnome-scan-dialog.c Sun Feb 24 17:43:37 2008
@@ -501,7 +501,7 @@
* See: #GnomeScanJob
**/
void
- gnome_scan_dialog_run (GnomeScanDialog *dialog)
+gnome_scan_dialog_run (GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate* priv = GET_PRIVATE (dialog);
GtkWidget* acquisition_dialog;
@@ -541,11 +541,11 @@
/* INTERNAL */
static void
- gsd_message_dialog (GnomeScanDialog *dialog,
- GtkMessageType mtype,
- GtkButtonsType btype,
- const gchar* primary,
- const gchar* secondary)
+gsd_message_dialog (GnomeScanDialog *dialog,
+ GtkMessageType mtype,
+ GtkButtonsType btype,
+ const gchar* primary,
+ const gchar* secondary)
{
GtkWidget* message_dialog;
GtkWindow* parent = NULL;
@@ -574,7 +574,7 @@
static void
- gsd_build_group_box (GnomeScanDialog *dialog, GtkWidget *page, GtkBox *box, GnomeScanPlugin *plugin, GQuark group)
+gsd_build_group_box (GnomeScanDialog *dialog, GtkWidget *page, GtkBox *box, GnomeScanPlugin *plugin, GQuark group)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE(dialog);
GtkWidget *label, *group_box, *alignment, *table, *widget, *eventbox;
@@ -711,7 +711,7 @@
}
static void
- gsd_show_hide_param_widget (GParamSpec *param, GnomeScanDialog *dialog)
+gsd_show_hide_param_widget (GParamSpec *param, GnomeScanDialog *dialog)
{
gboolean show = param->flags & G_PARAM_WRITABLE;
GtkWidget *widget = g_param_spec_get_qdata (param, GSD_WIDGET_QUARK);
@@ -806,7 +806,7 @@
/* INTERNALS */
static void
- gsd_load_backends (GnomeScanDialog *dialog)
+gsd_load_backends (GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (dialog);
GnomeScanBackend *backend;
@@ -841,7 +841,7 @@
}
static void
- gsd_scanner_added (GnomeScanBackend *backend, GnomeScanner *scanner, GnomeScanDialog *dialog)
+gsd_scanner_added (GnomeScanBackend *backend, GnomeScanner *scanner, GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (dialog);
GtkTreeIter* iter = g_new0 (GtkTreeIter, 1);
@@ -861,7 +861,7 @@
}
static void
- gsd_scanner_removed (GnomeScanBackend *backend, GnomeScanner *scanner, GnomeScanDialog *dialog)
+gsd_scanner_removed (GnomeScanBackend *backend, GnomeScanner *scanner, GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (dialog);
GtkTreeIter *iter;
@@ -873,7 +873,7 @@
static void
- gsd_scanner_status_changed (GnomeScanner *scanner, GnomeScanDialog *gsd)
+gsd_scanner_status_changed (GnomeScanner *scanner, GnomeScanDialog *gsd)
{
GtkTreeIter *iter;
iter = g_object_get_data (G_OBJECT (scanner), "iter");
@@ -883,7 +883,7 @@
}
static void
- gsd_plugin_params_changed (GnomeScanPlugin *plugin, GParamSpec *pspec, GnomeScanDialog* gsd)
+gsd_plugin_params_changed (GnomeScanPlugin *plugin, GParamSpec *pspec, GnomeScanDialog* gsd)
{
if (pspec) {
gsd_show_hide_param_widget (pspec, gsd);
@@ -891,7 +891,7 @@
}
static void
- gsd_probe_done (GnomeScanBackend *backend, GnomeScanDialog *dialog)
+gsd_probe_done (GnomeScanBackend *backend, GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (dialog);
priv->probe_done = !--priv->probing_backends;
@@ -904,7 +904,7 @@
/* GENERAL */
static void
- gsd_build_general_ui (GnomeScanDialog *dialog)
+gsd_build_general_ui (GnomeScanDialog *dialog)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (dialog);
GtkWidget *tree_view, *scrolled;
@@ -1007,7 +1007,7 @@
static gboolean
- gsd_select_scanner_if_ready (GnomeScanDialog *gsd)
+gsd_select_scanner_if_ready (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GnomeScanner *scanner = gnome_scan_job_get_scanner (priv->job);
@@ -1027,7 +1027,7 @@
}
static void
- gsd_build_sink_ui (GnomeScanDialog *gsd)
+gsd_build_sink_ui (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GnomeScanSink *sink = gnome_scan_job_get_sink (priv->job);
@@ -1059,7 +1059,7 @@
static void
- gsd_build_scanner_ui (GnomeScanDialog *gsd)
+gsd_build_scanner_ui (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GtkWidget *widget;
@@ -1146,7 +1146,7 @@
static void
- gsd_update_scanner_ui (GnomeScanDialog *gsd)
+gsd_update_scanner_ui (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GnomeScanner *scanner = gnome_scan_job_get_scanner (priv->job);
@@ -1159,7 +1159,7 @@
/* PROCESSING */
static void
- gsd_build_processing_ui(GnomeScanDialog *gsd)
+gsd_build_processing_ui(GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GSList *proc;
@@ -1188,7 +1188,7 @@
/* PREVIEW */
static void
- gsd_preview_scanner_selected (GnomeScanDialog *gsd)
+gsd_preview_scanner_selected (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GtkWidget*widget = GTK_WIDGET (gsd);
@@ -1254,7 +1254,7 @@
}
static gboolean
- gsd_preview_end_refresh (GnomeScanDialog *gsd)
+gsd_preview_end_refresh (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
GnomeScanPreviewSink *sink = GNOME_SCAN_PREVIEW_SINK (gnome_scan_job_get_sink (priv->preview_job));
@@ -1283,7 +1283,7 @@
}
static gboolean
- gsd_preview_monitor (GnomeScanDialog *gsd)
+gsd_preview_monitor (GnomeScanDialog *gsd)
{
GnomeScanDialogPrivate *priv = GET_PRIVATE (gsd);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (priv->preview_progress),
Modified: trunk/lib/gnome-scan-param-widget.c
==============================================================================
--- trunk/lib/gnome-scan-param-widget.c (original)
+++ trunk/lib/gnome-scan-param-widget.c Sun Feb 24 17:43:37 2008
@@ -123,13 +123,13 @@
unit = NULL;
break;
};
+
if (unit) {
priv->unit = gtk_label_new (unit);
gtk_box_pack_start (GTK_BOX (object), priv->unit, FALSE, FALSE, 0);
}
}
-
klass->set (gspw, gspw->value);
/*klass->show (gspw);*/
Modified: trunk/lib/gnome-scan-settings.c
==============================================================================
--- trunk/lib/gnome-scan-settings.c (original)
+++ trunk/lib/gnome-scan-settings.c Sun Feb 24 17:43:37 2008
@@ -34,6 +34,7 @@
* feature easily added with this design.
**/
+#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
#include "gnome-scan-settings.h"
@@ -46,6 +47,7 @@
/* using GParamSpec name as key, and GValue as value */
GHashTable *values;
GConfClient *gconf;
+ gboolean disposed;
};
enum
@@ -68,19 +70,159 @@
priv->gconf = gconf_client_get_default();
}
+static gchar*
+gss_gconf_key(gchar *name)
+{
+ gchar *key;
+ gchar *tmp = g_strdup_printf ("/apps/gnome-scan/%s", g_get_prgname ());
+
+ if (name)
+ key = g_strdup_printf("%s/%s", tmp, name);
+ else
+ key = g_strdup(tmp);
+
+ g_free(tmp);
+
+ return key;
+}
+
+static GValue*
+gss_gconf_value_to_gvalue(GConfValue *value)
+{
+ GType gtype = G_TYPE_NONE;
+ GValue *gvalue = g_new0(GValue, 1);
+
+ switch(value->type) {
+ case GCONF_VALUE_STRING:
+ gtype = G_TYPE_STRING;
+ break;
+ case GCONF_VALUE_INT:
+ gtype = G_TYPE_INT;
+ break;
+ case GCONF_VALUE_FLOAT:
+ gtype = G_TYPE_FLOAT;
+ break;
+ case GCONF_VALUE_BOOL:
+ gtype = G_TYPE_BOOLEAN;
+ break;
+ }
+
+ g_value_init(gvalue, gtype);
+
+ switch(value->type) {
+ case GCONF_VALUE_STRING:
+ g_value_set_static_string(gvalue,
+ gconf_value_get_string(value));
+ break;
+ case GCONF_VALUE_INT:
+ g_value_set_int(gvalue,
+ gconf_value_get_int(value));
+ break;
+ case GCONF_VALUE_FLOAT:
+ g_value_set_float(gvalue,
+ gconf_value_get_float(value));
+ break;
+ case GCONF_VALUE_BOOL:
+ g_value_set_boolean(gvalue,
+ gconf_value_get_bool(value));
+ break;
+ }
+
+ if (gtype == G_TYPE_NONE) {
+ g_free(gvalue);
+ gvalue = NULL;
+ }
+
+ return gvalue;
+}
+
+static GConfValue*
+gss_gvalue_to_gconf_value(GValue *gvalue)
+{
+ GConfValueType type = GCONF_VALUE_INVALID;
+ GConfValue *value;
+ GValue *trans = g_new0(GValue, 1);
+ GType gtype = G_VALUE_TYPE(gvalue);
+ switch(gtype) {
+ case G_TYPE_STRING:
+ type = GCONF_VALUE_STRING;
+ break;
+ case G_TYPE_INT:
+ type = GCONF_VALUE_INT;
+ break;
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE:
+ type = GCONF_VALUE_FLOAT;
+ break;
+ case G_TYPE_BOOLEAN:
+ type = GCONF_VALUE_BOOL;
+ break;
+ }
+
+ value = gconf_value_new(type);
+
+ switch(gtype) {
+ case G_TYPE_STRING:
+ gconf_value_set_string(value,
+ g_value_get_string(gvalue));
+ break;
+ case G_TYPE_INT:
+ gconf_value_set_int(value,
+ g_value_get_int(gvalue));
+ break;
+ case G_TYPE_FLOAT:
+ case G_TYPE_DOUBLE:
+ g_value_init(trans, G_TYPE_FLOAT);
+ g_value_transform (gvalue, trans);
+ gconf_value_set_int(value,
+ g_value_get_float(trans));
+ break;
+ case G_TYPE_BOOLEAN:
+ gconf_value_set_bool(value,
+ g_value_get_boolean (gvalue));
+ break;
+ }
+
+ if (!GCONF_VALUE_TYPE_VALID(type)) {
+ g_free(value);
+ value = NULL;
+ }
+
+ g_free(trans);
+
+ return value;
+}
+
static GObject*
gnome_scan_settings_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
+ GnomeScanSettingsPrivate *priv;
+ GSList *entries;
+ gchar *dir = gss_gconf_key(NULL);
+ gchar *name;
+ GError *error = NULL;
+ GConfEntry *entry;
+ GValue *gvalue;
object =
G_OBJECT_CLASS(parent_class)->constructor(type,
- n_params,
- params);
+ n_params,
+ params);
+ priv = GET_PRIVATE(object);
+ entries = gconf_client_all_entries(priv->gconf, dir, &error);
+ for (; entries; entries = entries->next) {
+ entry = entries->data;
+ name = g_path_get_basename(entry->key);
+ if (gvalue = gss_gconf_value_to_gvalue(entry->value))
+ gnome_scan_settings_set(GNOME_SCAN_SETTINGS(object),
+ name, gvalue);
+ g_free(name);
+ }
- g_debug("Loading from %s", g_get_prgname());
+ g_free(dir);
return object;
}
@@ -88,10 +230,47 @@
static void
gnome_scan_settings_finalize (GObject *object)
{
- g_debug("Saving to %s", g_get_prgname());
G_OBJECT_CLASS (parent_class)->finalize (object);
}
+void
+gss_store_key(gchar *name, GValue *gvalue, GnomeScanSettings *settings)
+{
+ GnomeScanSettingsPrivate *priv = GET_PRIVATE(settings);
+ GConfValue *value;
+ gchar *key = gss_gconf_key(name);
+ GError *error = NULL;
+
+ if (value = gss_gvalue_to_gconf_value(gvalue)) {
+ gconf_client_set(priv->gconf,
+ key, value,
+ &error);
+
+ if (error) {
+ g_warning("Failed saving %s option : %s",
+ name, dgettext(g_quark_to_string (error->domain),
+ error->message));
+ }
+ }
+
+ g_free(key);
+}
+
+static void
+gnome_scan_settings_dispose (GObject *object)
+{
+ GnomeScanSettingsPrivate *priv = GET_PRIVATE(object);
+
+ if (priv->disposed == FALSE) {
+ g_hash_table_foreach (priv->values,
+ (GHFunc) gss_store_key,
+ object);
+ priv->disposed = TRUE;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
static void
gnome_scan_settings_class_init (GnomeScanSettingsClass *klass)
{
@@ -101,6 +280,7 @@
g_type_class_add_private (klass, sizeof (GnomeScanSettingsPrivate));
object_class->constructor = gnome_scan_settings_constructor;
object_class->finalize = gnome_scan_settings_finalize;
+ object_class->dispose = gnome_scan_settings_dispose;
/**
* GnomeScanParamWidget::changed:
@@ -138,17 +318,18 @@
void
gnome_scan_settings_init_value (GnomeScanSettings *settings,
- GParamSpec *pspec)
+ GParamSpec *pspec)
{
- g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings));
- GValue *value = g_new0 (GValue, 1);
- g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- g_param_value_set_default (pspec, value);
- gnome_scan_settings_set (settings,
- g_param_spec_get_name (pspec),
- value);
- g_value_reset (value);
- g_free (value);
+ /* TODO: store schemas in gconf */
+ g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings));
+ GValue *value = g_new0 (GValue, 1);
+ g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+ g_param_value_set_default (pspec, value);
+ gnome_scan_settings_set (settings,
+ g_param_spec_get_name (pspec),
+ value);
+ g_value_reset (value);
+ g_free (value);
}
/**
@@ -165,10 +346,10 @@
const gchar *name,
const GValue *value)
{
- g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings) && G_IS_VALUE (value));
- g_hash_table_insert (GET_PRIVATE (settings)->values, g_strdup (name),
- g_boxed_copy (G_TYPE_VALUE, value));
- g_signal_emit (settings, signals[CHANGED], 0, name);
+ g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings) && G_IS_VALUE (value));
+ g_hash_table_insert (GET_PRIVATE (settings)->values, g_strdup (name),
+ g_boxed_copy (G_TYPE_VALUE, value));
+ g_signal_emit (settings, signals[CHANGED], 0, name);
}
/**
@@ -188,18 +369,18 @@
const gchar *name,
const GValue *value)
{
- g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings) && G_IS_VALUE (value));
- GValue *v = gnome_scan_settings_get (settings, name);
- if (v) {
- g_value_transform (value, v);
- }
- else {
- v = g_boxed_copy (G_TYPE_VALUE, value);
- }
-
- g_hash_table_insert (GET_PRIVATE (settings)->values, g_strdup (name),
- v);
- g_signal_emit (settings, signals[CHANGED], 0, name);
+ g_return_if_fail (GNOME_IS_SCAN_SETTINGS (settings) && G_IS_VALUE (value));
+ GValue *v = gnome_scan_settings_get (settings, name);
+ if (v) {
+ g_value_transform (value, v);
+ }
+ else {
+ v = g_boxed_copy (G_TYPE_VALUE, value);
+ }
+
+ g_hash_table_insert (GET_PRIVATE (settings)->values, g_strdup (name),
+ v);
+ g_signal_emit (settings, signals[CHANGED], 0, name);
}
/**
Modified: trunk/src/flegita-output-filename-widget.c
==============================================================================
--- trunk/src/flegita-output-filename-widget.c (original)
+++ trunk/src/flegita-output-filename-widget.c Sun Feb 24 17:43:37 2008
@@ -136,6 +136,15 @@
flegita_output_filename_widget_set (GnomeScanParamWidget *widget,
GValue *value)
{
+ FlegitaOutputFilenameWidgetPrivate *priv = GET_PRIVATE(widget);
+ const gchar *path = g_value_get_string(value);
+ gchar *dir = g_path_get_dirname (path);
+ gchar *file = g_path_get_basename (path);
+ gchar **parts = g_strsplit (file, ".", 2);
+
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER(priv->filechooser),
+ dir);
+ gtk_entry_set_text (GTK_ENTRY(priv->entry), parts[0]);
}
@@ -157,13 +166,19 @@
SUFFIX_NAME, &suffix,
-1);
- g_value_set_string (gspw->value,
- g_strdup_printf ("%s%c%s.%s",
- gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->filechooser)),
- G_DIR_SEPARATOR,
- gtk_entry_get_text (GTK_ENTRY (priv->entry)),
- suffix));
+ gchar *path = g_strdup_printf ("%s%c%s.%s",
+ gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->filechooser)),
+ G_DIR_SEPARATOR,
+ gtk_entry_get_text (GTK_ENTRY (priv->entry)),
+ suffix);
+
+ if (!g_str_equal (path, g_value_get_string(gspw->value))) {
+ g_value_set_string (gspw->value,
+ path);
+
+ gnome_scan_param_widget_changed (gspw);
+ }
- gnome_scan_param_widget_changed (gspw);
+ g_free (path);
return FALSE;
}
Modified: trunk/src/flegita-sink.c
==============================================================================
--- trunk/src/flegita-sink.c (original)
+++ trunk/src/flegita-sink.c Sun Feb 24 17:43:37 2008
@@ -112,20 +112,20 @@
#endif
/* FORMAT */
- formats = g_slist_append (formats,
- gnome_scan_format_new ("png",
- GETTEXT_PACKAGE,
- N_("PNG picture"),
- png_mime,
- png_exts));
+ formats = g_slist_append (formats,
+ gnome_scan_format_new ("png",
+ GETTEXT_PACKAGE,
+ N_("PNG picture"),
+ png_mime,
+ png_exts));
- pspec = priv->output_filename_spec =
- flegita_param_spec_output_filename ("output-filename",
- N_("File"),
- N_("Output filename"),
- GS_PARAM_GROUP_SINK_FRONT,
- formats,
- G_PARAM_WRITABLE);
+ pspec = priv->output_filename_spec =
+ flegita_param_spec_output_filename ("output-filename",
+ N_("File"),
+ N_("Output filename"),
+ GS_PARAM_GROUP_SINK_FRONT,
+ formats,
+ G_PARAM_WRITABLE);
gs_param_spec_set_domain (pspec, GETTEXT_PACKAGE);
gs_param_spec_set_unit (pspec, GS_UNIT_NONE);
gnome_scan_plugin_params_add (GNOME_SCAN_PLUGIN (object),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]