Don't try to print non-readable options. Don't try to write non-writable options

(bug #300621). Don't print warnings for options without constraints.
merge-requests/2/head
Henning Geinitz 2004-10-03 19:16:57 +00:00
rodzic 37309355cb
commit 2dfb50d908
2 zmienionych plików z 55 dodań i 12 usunięć

Wyświetl plik

@ -1,3 +1,9 @@
2004-10-03 Henning Meier-Geinitz <henning@meier-geinitz.de>
* src/gtkglue.c: Don't try to print non-readable options. Don't
try to write non-writable options (bug #300621). Don't print
warnings for options without constraints.
2004-07-09 Henning Meier-Geinitz <henning@meier-geinitz.de>
* doc/scanadf.man src/scanadf.c: Added -N option to stop scanadf

Wyświetl plik

@ -411,7 +411,8 @@ button_update (GtkWidget * widget, GSGDialogElement * elem)
static void
button_new (GtkWidget * parent, const char *name, SANE_Word val,
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc)
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc,
gint is_settable)
{
GtkWidget *button;
@ -421,6 +422,8 @@ button_new (GtkWidget * parent, const char *name, SANE_Word val,
(GtkSignalFunc) button_update,
elem);
gtk_box_pack_start (GTK_BOX (parent), button, FALSE, TRUE, 0);
if (!is_settable)
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
gtk_widget_show (button);
set_tooltip (tooltips, button, desc);
@ -499,7 +502,8 @@ value_changed:
static void
scale_new (GtkWidget * parent, const char *name, gfloat val,
gfloat min, gfloat max, gfloat quant, int automatic,
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc)
GSGDialogElement * elem, GtkTooltips *tooltips, const char *desc,
gint is_settable)
{
GtkWidget *hbox, *label, *scale;
@ -533,6 +537,9 @@ scale_new (GtkWidget * parent, const char *name, gfloat val,
gtk_widget_show (label);
gtk_widget_show (scale);
if (!is_settable)
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
gtk_widget_show (hbox);
elem->widget = scale;
@ -598,7 +605,8 @@ option_menu_callback (GtkWidget * widget, gpointer data)
static void
option_menu_new (GtkWidget *parent, const char *name, char *str_list[],
const char *val, GSGDialogElement * elem,
GtkTooltips *tooltips, const char *desc)
GtkTooltips *tooltips, const char *desc,
gint is_settable)
{
GtkWidget *hbox, *label, *option_menu, *menu, *item;
GSGMenuItem *menu_items;
@ -639,6 +647,8 @@ option_menu_new (GtkWidget *parent, const char *name, char *str_list[],
gtk_widget_show (label);
gtk_widget_show (option_menu);
if (!is_settable)
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
gtk_widget_show (hbox);
elem->widget = option_menu;
@ -677,7 +687,8 @@ text_entry_callback (GtkWidget *w, gpointer data)
static void
text_entry_new (GtkWidget * parent, const char *name, const char *val,
GSGDialogElement * elem,
GtkTooltips *tooltips, const char *desc)
GtkTooltips *tooltips, const char *desc,
gint is_settable)
{
GtkWidget *hbox, *text, *label;
@ -696,6 +707,8 @@ text_entry_new (GtkWidget * parent, const char *name, const char *val,
set_tooltip (tooltips, text, desc);
gtk_widget_show (hbox);
if (!is_settable)
gtk_widget_set_sensitive (GTK_WIDGET (hbox), FALSE);
gtk_widget_show (label);
gtk_widget_show (text);
@ -958,7 +971,6 @@ panel_build (GSGDialog * dialog)
opt = sane_get_option_descriptor (dev, i);
if (!SANE_OPTION_IS_ACTIVE (opt->cap))
continue;
/* pick up well-known options as we go: */
if (opt->name)
{
@ -1006,19 +1018,24 @@ panel_build (GSGDialog * dialog)
case SANE_TYPE_BOOL:
if ((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced)
break;
if (!(opt->cap & SANE_CAP_SOFT_DETECT))
break;
assert (opt->size == sizeof (SANE_Word));
status = sane_control_option (dialog->dev, i, SANE_ACTION_GET_VALUE,
&val, 0);
if (status != SANE_STATUS_GOOD)
goto get_value_failed;
button_new (parent, title, val, elem, dialog->tooltips, opt->desc);
button_new (parent, title, val, elem, dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
break;
case SANE_TYPE_INT:
if ((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced)
break;
if (!(opt->cap & SANE_CAP_SOFT_DETECT))
break;
if (opt->size != sizeof (SANE_Word))
{
vector_opts[num_vector_opts++] = i;
@ -1040,7 +1057,8 @@ panel_build (GSGDialog * dialog)
opt->constraint.range->min,
opt->constraint.range->max, quant,
(opt->cap & SANE_CAP_AUTOMATIC), elem,
dialog->tooltips, opt->desc);
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1056,11 +1074,17 @@ panel_build (GSGDialog * dialog)
str_list[j] = 0;
sprintf (str, "%d", val);
option_menu_new (parent, title, str_list, str, elem,
dialog->tooltips, opt->desc);
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
free (str_list);
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
/* having no constraint for an int is strange but allowed
by the SANE standard so we just ignore such options here */
break;
default:
fprintf (stderr, "panel_build: unknown constraint %d!\n",
opt->constraint_type);
@ -1071,6 +1095,8 @@ panel_build (GSGDialog * dialog)
case SANE_TYPE_FIXED:
if ((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced)
break;
if (!(opt->cap & SANE_CAP_SOFT_DETECT))
break;
if (opt->size != sizeof (SANE_Word))
{
vector_opts[num_vector_opts++] = i;
@ -1101,7 +1127,8 @@ panel_build (GSGDialog * dialog)
}
scale_new (parent, title, dval, dmin, dmax, dquant,
(opt->cap & SANE_CAP_AUTOMATIC), elem,
dialog->tooltips, opt->desc);
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
break;
@ -1118,11 +1145,17 @@ panel_build (GSGDialog * dialog)
str_list[j] = 0;
sprintf (str, "%g", SANE_UNFIX (val));
option_menu_new (parent, title, str_list, str, elem,
dialog->tooltips, opt->desc);
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
free (str_list);
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
/* having no constraint for a fixed is strange but allowed
by the SANE standard so we just ignore such options here */
break;
default:
fprintf (stderr, "panel_build: unknown constraint %d!\n",
opt->constraint_type);
@ -1133,6 +1166,8 @@ panel_build (GSGDialog * dialog)
case SANE_TYPE_STRING:
if ((opt->cap & SANE_CAP_ADVANCED) && !dialog->advanced)
break;
if (!(opt->cap & SANE_CAP_SOFT_DETECT))
break;
buf = malloc (opt->size);
status = sane_control_option (dialog->dev, i, SANE_ACTION_GET_VALUE,
buf, 0);
@ -1148,13 +1183,15 @@ panel_build (GSGDialog * dialog)
/* use a "list-selection" widget */
option_menu_new (parent, title,
(char **) opt->constraint.string_list, buf,
elem, dialog->tooltips, opt->desc);
elem, dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
break;
case SANE_CONSTRAINT_NONE:
text_entry_new (parent, title, buf, elem,
dialog->tooltips, opt->desc);
dialog->tooltips, opt->desc,
SANE_OPTION_IS_SETTABLE(opt->cap));
gtk_widget_show (parent->parent);
break;