gnome-scan r733 - in trunk: . modules/gsane
- From: bersace svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-scan r733 - in trunk: . modules/gsane
- Date: Sun, 21 Dec 2008 19:07:45 +0000 (UTC)
Author: bersace
Date: Sun Dec 21 19:07:45 2008
New Revision: 733
URL: http://svn.gnome.org/viewvc/gnome-scan?rev=733&view=rev
Log:
Added helper function to list SANE enum values.
Modified:
trunk/ChangeLog
trunk/modules/gsane/gsane-option-handler-generic.c
trunk/modules/gsane/gsane-option-handler.c
trunk/modules/gsane/gsane-option-handler.h
Modified: trunk/modules/gsane/gsane-option-handler-generic.c
==============================================================================
--- trunk/modules/gsane/gsane-option-handler-generic.c (original)
+++ trunk/modules/gsane/gsane-option-handler-generic.c Sun Dec 21 19:07:45 2008
@@ -231,79 +231,6 @@
}
}
-static GSList*
-gsane_option_handler_generic_enum_list_int_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
-{
- GSList *list = NULL;
- gint count = desc->constraint.word_list[0];
- gint i, intval;
- GValue* values = g_new0(GValue, count);
- GValue* value;
- GnomeScanEnumValue* evalues = g_new0(GnomeScanEnumValue, count);
- GnomeScanEnumValue* evalue;
-
- /* list values */
- for(i = 0; i < count; i++) {
- value = values+i;
- evalue = evalues+i;
- intval = desc->constraint.word_list[i+1];
-
- g_value_init(value, G_TYPE_INT);
- g_value_set_int(value, intval);
-
- gnome_scan_enum_value_init(evalue, value, g_strdup_printf("%i", intval), NULL);
- list = g_slist_append(list, evalue);
- }
- g_free(values);
- return list;
-}
-
-static GSList*
-gsane_option_handler_generic_enum_list_double_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
-{
- GSList *list = NULL;
- gint count = desc->constraint.word_list[0];
- gint i;
- gdouble doubleval;
- GValue *value, *values = g_new0(GValue, count);
- GnomeScanEnumValue *evalue, *evalues = g_new0(GnomeScanEnumValue, count);
-
- for(i = 0; i < count; i++) {
- value = values + i;
- evalue = evalues + i;
- doubleval = SANE_UNFIX(desc->constraint.word_list[i+1]);
- g_value_init(value, G_TYPE_DOUBLE);
- g_value_set_double(value, doubleval);
- gnome_scan_enum_value_init(evalue, value, g_strdup_printf("%.2f", doubleval), NULL);
- list = g_slist_append(list, evalue);
- }
- g_free(values);
- return list;
-}
-
-static GSList*
-gsane_option_handler_generic_enum_list_string_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
-{
- GSList *list = NULL;
- gint i;
- const gchar*strval;
- GValue *value;
- GnomeScanEnumValue *evalue;
- const SANE_String_Const *strlist = desc->constraint.string_list;
-
- for(i = 0; strlist[i]; i++) {
- strval = strlist[i];
- value = g_new0(GValue, 1);
- evalue = g_new0(GnomeScanEnumValue, 1);
- g_value_init(value, G_TYPE_STRING);
- g_value_set_string(value, strval);
- gnome_scan_enum_value_init(evalue, value, S_(strval), SANE_GETTEXT_PACKAGE);
- list = g_slist_append(list, evalue);
- g_free(value);
- }
- return list;
-}
-
static void
gsane_option_handler_generic_handle_list_option(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
@@ -319,17 +246,17 @@
if (array_length > 1)
g_debug("Ignoring int enum array option %s", desc->name);
else
- values = gsane_option_handler_generic_enum_list_int_values(handler, desc, n, group);
+ values = gsane_option_handler_enum_list_int_values(handler, desc, n, group);
break;
case SANE_TYPE_FIXED:
array_length = desc->size/sizeof(SANE_Fixed);
if (array_length > 1)
g_debug("Ignoring double enum array option %s", desc->name);
else
- values = gsane_option_handler_generic_enum_list_double_values(handler, desc, n, group);
+ values = gsane_option_handler_enum_list_double_values(handler, desc, n, group);
break;
case SANE_TYPE_STRING:
- values = gsane_option_handler_generic_enum_list_string_values(handler, desc, n, group);
+ values = gsane_option_handler_enum_list_string_values(handler, desc, n, group);
break;
default:
g_debug("\toption %d : <unhandled> %s", n, desc->name);
Modified: trunk/modules/gsane/gsane-option-handler.c
==============================================================================
--- trunk/modules/gsane/gsane-option-handler.c (original)
+++ trunk/modules/gsane/gsane-option-handler.c Sun Dec 21 19:07:45 2008
@@ -105,6 +105,81 @@
GSANE_OPTION_HANDLER_GET_CLASS(self)->reload_options(self);
}
+
+GSList*
+gsane_option_handler_enum_list_int_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
+{
+ GSList *list = NULL;
+ gint count = desc->constraint.word_list[0];
+ gint i, intval;
+ GValue* values = g_new0(GValue, count);
+ GValue* value;
+ GnomeScanEnumValue* evalues = g_new0(GnomeScanEnumValue, count);
+ GnomeScanEnumValue* evalue;
+
+ /* list values */
+ for(i = 0; i < count; i++) {
+ value = values+i;
+ evalue = evalues+i;
+ intval = desc->constraint.word_list[i+1];
+
+ g_value_init(value, G_TYPE_INT);
+ g_value_set_int(value, intval);
+
+ gnome_scan_enum_value_init(evalue, value, g_strdup_printf("%i", intval), NULL);
+ list = g_slist_append(list, evalue);
+ }
+ g_free(values);
+ return list;
+}
+
+GSList*
+gsane_option_handler_enum_list_double_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
+{
+ GSList *list = NULL;
+ gint count = desc->constraint.word_list[0];
+ gint i;
+ gdouble doubleval;
+ GValue *value, *values = g_new0(GValue, count);
+ GnomeScanEnumValue *evalue, *evalues = g_new0(GnomeScanEnumValue, count);
+
+ for(i = 0; i < count; i++) {
+ value = values + i;
+ evalue = evalues + i;
+ doubleval = SANE_UNFIX(desc->constraint.word_list[i+1]);
+ g_value_init(value, G_TYPE_DOUBLE);
+ g_value_set_double(value, doubleval);
+ gnome_scan_enum_value_init(evalue, value, g_strdup_printf("%.2f", doubleval), NULL);
+ list = g_slist_append(list, evalue);
+ }
+ g_free(values);
+ return list;
+}
+
+GSList*
+gsane_option_handler_enum_list_string_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group)
+{
+ GSList *list = NULL;
+ gint i;
+ const gchar*strval;
+ GValue *value;
+ GnomeScanEnumValue *evalue;
+ const SANE_String_Const *strlist = desc->constraint.string_list;
+
+ for(i = 0; strlist[i]; i++) {
+ strval = strlist[i];
+ value = g_new0(GValue, 1);
+ evalue = g_new0(GnomeScanEnumValue, 1);
+ g_value_init(value, G_TYPE_STRING);
+ g_value_set_string(value, strval);
+ gnome_scan_enum_value_init(evalue, value, S_(strval), SANE_GETTEXT_PACKAGE);
+ list = g_slist_append(list, evalue);
+ g_free(value);
+ }
+ return list;
+}
+
+
/* wrapper aroung sane_control_option handling errors and propagating
reload signals */
static gboolean
Modified: trunk/modules/gsane/gsane-option-handler.h
==============================================================================
--- trunk/modules/gsane/gsane-option-handler.h (original)
+++ trunk/modules/gsane/gsane-option-handler.h Sun Dec 21 19:07:45 2008
@@ -96,6 +96,11 @@
void gsane_option_handler_handle_option(GSaneOptionHandler *self, const SANE_Option_Descriptor* desc, SANE_Int n, const gchar*group);
void gsane_option_handler_reload_options(GSaneOptionHandler *self);
+/* helper for option initialiazation. */
+GSList* gsane_option_handler_enum_list_int_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group);
+GSList* gsane_option_handler_enum_list_double_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group);
+GSList* gsane_option_handler_enum_list_string_values(GSaneOptionHandler *handler, const SANE_Option_Descriptor*desc, SANE_Int n, const gchar* group);
+
gboolean gsane_option_handler_get_bool(GSaneOptionHandler *self, const SANE_Option_Descriptor* desc, SANE_Int index, GError **error);
gboolean gsane_option_handler_set_bool(GSaneOptionHandler *self, const SANE_Option_Descriptor* desc, SANE_Int index, gboolean value, GError **error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]