# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=487475
diff -urw ../xsane-0.996.orig/src/xsane-back-gtk.c ./src/xsane-back-gtk.c
old
|
new
|
|
2226 | 2226 | /* ----------------------------------------------------------------------------------------------------------------- */ |
2227 | 2227 | |
2228 | 2228 | void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *str_list[], |
2229 | | const char *val, DialogElement *elem, |
| 2229 | const char *val, SANE_Constraint_Type constraint_type, DialogElement *elem, |
2230 | 2230 | GtkTooltips *tooltips, const char *desc, SANE_Int settable) |
2231 | 2231 | { |
2232 | 2232 | GtkWidget *hbox, *label, *option_menu, *menu, *item; |
2233 | 2233 | MenuItem *menu_items; |
| 2234 | int dup_string; |
| 2235 | char *strval; |
2234 | 2236 | int i, num_items; |
2235 | 2237 | |
2236 | 2238 | DBG(DBG_proc, "xsane_back_gtk_option_menu_new(%s)\n", name); |
… |
… |
|
2248 | 2250 | |
2249 | 2251 | menu_items = malloc((num_items + 1) * sizeof(menu_items[0])); |
2250 | 2252 | |
| 2253 | dup_string = (constraint_type == SANE_CONSTRAINT_STRING_LIST); |
| 2254 | |
2251 | 2255 | menu = gtk_menu_new(); |
2252 | 2256 | for (i = 0; i < num_items; ++i) |
2253 | 2257 | { |
2254 | | item = gtk_menu_item_new_with_label(_BGT(str_list[i])); |
| 2258 | if (dup_string) |
| 2259 | strval = strdup(str_list[i]); |
| 2260 | else |
| 2261 | strval = str_list[i]; |
| 2262 | |
| 2263 | item = gtk_menu_item_new_with_label(_BGT(strval)); |
2255 | 2264 | gtk_container_add(GTK_CONTAINER(menu), item); |
2256 | 2265 | g_signal_connect(GTK_OBJECT(item), "activate", (GtkSignalFunc) xsane_back_gtk_option_menu_callback, menu_items + i); |
2257 | 2266 | |
2258 | 2267 | gtk_widget_show(item); |
2259 | 2268 | |
2260 | | menu_items[i].label = str_list[i]; |
| 2269 | menu_items[i].label = strval; |
2261 | 2270 | menu_items[i].elem = elem; |
2262 | 2271 | menu_items[i].index = i; |
2263 | 2272 | } |
… |
… |
|
2403 | 2412 | xsane.standard_hbox = NULL; |
2404 | 2413 | xsane.advanced_hbox = NULL; |
2405 | 2414 | |
2406 | | /* free the menu labels of integer/fix-point word-lists: */ |
| 2415 | /* free the menu labels */ |
2407 | 2416 | for (i = 0; i < xsane.num_elements; ++i) |
2408 | 2417 | { |
2409 | 2418 | if (xsane.element[i].menu) |
2410 | 2419 | { |
2411 | 2420 | opt = xsane_get_option_descriptor(xsane.dev, i); |
2412 | 2421 | elem = xsane.element + i; |
2413 | | if (opt->type != SANE_TYPE_STRING) |
| 2422 | if ((opt->type != SANE_TYPE_STRING) |
| 2423 | || (opt->constraint_type == SANE_CONSTRAINT_STRING_LIST)) |
2414 | 2424 | { |
2415 | 2425 | for (j = 0; j < elem->menu_size; ++j) |
2416 | 2426 | { |
diff -urw ../xsane-0.996.orig/src/xsane-back-gtk.h ./src/xsane-back-gtk.h
old
|
new
|
|
117 | 117 | gfloat quant, int automatic, |
118 | 118 | DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable); |
119 | 119 | extern void xsane_back_gtk_option_menu_new(GtkWidget *parent, const char *name, char *str_list[], |
120 | | const char *val, DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable); |
| 120 | const char *val, SANE_Constraint_Type constraint_type, DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable); |
121 | 121 | extern void xsane_back_gtk_text_entry_new(GtkWidget *parent, const char *name, const char *val, |
122 | 122 | DialogElement *elem, GtkTooltips *tooltips, const char *desc, SANE_Int settable); |
123 | 123 | extern void xsane_back_gtk_push_button_callback(GtkWidget *widget, gpointer data); |
diff -urw ../xsane-0.996.orig/src/xsane-front-gtk.c ./src/xsane-front-gtk.c
old
|
new
|
|
64 | 64 | int *state, void *xsane_toggle_button_callback); |
65 | 65 | GtkWidget *xsane_button_new_with_pixmap(GdkWindow *window, GtkWidget *parent, const char *xpm_d[], const char *desc, |
66 | 66 | void *xsane_button_callback, gpointer data); |
67 | | void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, int option_number, const char *desc, |
| 67 | void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, SANE_Constraint_Type constraint_type, int option_number, const char *desc, |
68 | 68 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name); |
69 | 69 | void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc, |
70 | | char *str_list[], const char *val, |
| 70 | char *str_list[], const char *val, SANE_Constraint_Type constraint_type, |
71 | 71 | GtkWidget **data, int option, |
72 | 72 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name); |
73 | 73 | void xsane_range_new(GtkBox *parent, char *labeltext, const char *desc, |
… |
… |
|
1007 | 1007 | |
1008 | 1008 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
1009 | 1009 | |
1010 | | void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, int option_number, const char *desc, |
| 1010 | void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, SANE_Constraint_Type constraint_type, int option_number, const char *desc, |
1011 | 1011 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name) |
1012 | 1012 | { |
1013 | 1013 | GtkWidget *option_menu, *menu, *item; |
1014 | 1014 | MenuItem *menu_items; |
1015 | 1015 | DialogElement *elem; |
| 1016 | int dup_string; |
| 1017 | char *strval; |
1016 | 1018 | int i, num_items; |
1017 | 1019 | |
1018 | 1020 | DBG(DBG_proc, "xsane_option_menu_new\n"); |
… |
… |
|
1031 | 1033 | gtk_widget_set_name(menu, widget_name); |
1032 | 1034 | } |
1033 | 1035 | |
| 1036 | dup_string = (constraint_type == SANE_CONSTRAINT_STRING_LIST); |
| 1037 | |
1034 | 1038 | for (i = 0; i < num_items; ++i) |
1035 | 1039 | { |
1036 | | item = gtk_menu_item_new_with_label(_BGT(str_list[i])); |
| 1040 | if (dup_string) |
| 1041 | strval = strdup(str_list[i]); |
| 1042 | else |
| 1043 | strval = str_list[i]; |
| 1044 | |
| 1045 | item = gtk_menu_item_new_with_label(_BGT(strval)); |
1037 | 1046 | gtk_container_add(GTK_CONTAINER(menu), item); |
1038 | 1047 | |
1039 | 1048 | if (option_menu_callback) |
… |
… |
|
1047 | 1056 | |
1048 | 1057 | gtk_widget_show(item); |
1049 | 1058 | |
1050 | | menu_items[i].label = str_list[i]; |
| 1059 | menu_items[i].label = strval; |
1051 | 1060 | menu_items[i].elem = elem; |
1052 | 1061 | menu_items[i].index = i; |
1053 | 1062 | } |
… |
… |
|
1075 | 1084 | /* ---------------------------------------------------------------------------------------------------------------------- */ |
1076 | 1085 | |
1077 | 1086 | void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc, |
1078 | | char *str_list[], const char *val, |
| 1087 | char *str_list[], const char *val, SANE_Constraint_Type constraint_type, |
1079 | 1088 | GtkWidget **data, int option, |
1080 | 1089 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name) |
1081 | 1090 | { |
… |
… |
|
1094 | 1103 | gtk_box_pack_start(GTK_BOX(hbox), pixmapwidget, FALSE, FALSE, 2); |
1095 | 1104 | gtk_widget_show(pixmapwidget); |
1096 | 1105 | |
1097 | | xsane_option_menu_new(hbox, str_list, val, option, desc, option_menu_callback, settable, widget_name); |
| 1106 | xsane_option_menu_new(hbox, str_list, val, constraint_type, option, desc, option_menu_callback, settable, widget_name); |
1098 | 1107 | gtk_widget_show(hbox); |
1099 | 1108 | } |
1100 | 1109 | |
diff -urw ../xsane-0.996.orig/src/xsane-front-gtk.h ./src/xsane-front-gtk.h
old
|
new
|
|
54 | 54 | extern GtkWidget *xsane_button_new_with_pixmap(GdkWindow *window, GtkWidget *parent, const char *xpm_d[], const char *desc, |
55 | 55 | void *xsane_button_callback, gpointer data); |
56 | 56 | extern void xsane_pixmap_new(GtkWidget *parent, char *title, int width, int height, XsanePixmap *hist); |
57 | | extern void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, int option_number, const char *desc, |
| 57 | extern void xsane_option_menu_new(GtkWidget *parent, char *str_list[], const char *val, SANE_Constraint_Type constraint_type, int option_number, const char *desc, |
58 | 58 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name); |
59 | 59 | extern void xsane_option_menu_new_with_pixmap(GdkWindow *window, GtkBox *parent, const char *xpm_d[], const char *desc, |
60 | | char *str_list[], const char *val, |
| 60 | char *str_list[], const char *val, SANE_Constraint_Type constraint_type, |
61 | 61 | GtkWidget **data, int option, |
62 | 62 | void *option_menu_callback, SANE_Int settable, const gchar *widget_name); |
63 | 63 | extern void xsane_range_new(GtkBox *parent, char *labeltext, const char *desc, |
diff -urw ../xsane-0.996.orig/src/xsane.c ./src/xsane.c
old
|
new
|
|
876 | 876 | str_list[j] = 0; |
877 | 877 | sprintf(str, "%d", (int) val); |
878 | 878 | |
879 | | xsane_option_menu_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, str_list, str, &resolution_widget, well_known_option, |
| 879 | xsane_option_menu_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, str_list, str, opt->constraint_type, &resolution_widget, well_known_option, |
880 | 880 | xsane_resolution_list_callback, SANE_OPTION_IS_SETTABLE(opt->cap), widget_name); |
881 | 881 | |
882 | 882 | free(str_list); |
… |
… |
|
931 | 931 | |
932 | 932 | |
933 | 933 | xsane_option_menu_new_with_pixmap(xsane.xsane_window->window, GTK_BOX(parent), image_xpm, desc, |
934 | | str_list, str, &resolution_widget, well_known_option, |
| 934 | str_list, str, opt->constraint_type, &resolution_widget, well_known_option, |
935 | 935 | xsane_resolution_list_callback, SANE_OPTION_IS_SETTABLE(opt->cap), widget_name); |
936 | 936 | free(str_list); |
937 | 937 | } |
… |
… |
|
1490 | 1490 | set = malloc(opt->size); |
1491 | 1491 | status = xsane_control_option(xsane.dev, xsane.well_known.scansource, SANE_ACTION_GET_VALUE, set, 0); |
1492 | 1492 | |
1493 | | xsane_option_menu_new(hbox, (char **) opt->constraint.string_list, set, xsane.well_known.scansource, |
| 1493 | xsane_option_menu_new(hbox, (char **) opt->constraint.string_list, set, opt->constraint_type, xsane.well_known.scansource, |
1494 | 1494 | _BGT(opt->desc), 0, SANE_OPTION_IS_SETTABLE(opt->cap), 0); |
1495 | 1495 | } |
1496 | 1496 | break; |
… |
… |
|
1529 | 1529 | set = malloc(opt->size); |
1530 | 1530 | status = xsane_control_option(xsane.dev, xsane.well_known.scanmode, SANE_ACTION_GET_VALUE, set, 0); |
1531 | 1531 | |
1532 | | xsane_option_menu_new(hbox, (char **) opt->constraint.string_list, set, xsane.well_known.scanmode, |
| 1532 | xsane_option_menu_new(hbox, (char **) opt->constraint.string_list, set, opt->constraint_type, xsane.well_known.scanmode, |
1533 | 1533 | _BGT(opt->desc), xsane_scanmode_menu_callback, SANE_OPTION_IS_SETTABLE(opt->cap), 0); |
1534 | 1534 | } |
1535 | 1535 | break; |
… |
… |
|
4634 | 4634 | } |
4635 | 4635 | str_list[j] = 0; |
4636 | 4636 | sprintf(str, "%d", val); |
4637 | | xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc), |
| 4637 | xsane_back_gtk_option_menu_new(parent, title, str_list, str, opt->constraint_type, elem, xsane.tooltips, _BGT(opt->desc), |
4638 | 4638 | SANE_OPTION_IS_SETTABLE(opt->cap)); |
4639 | 4639 | free(str_list); |
4640 | 4640 | gtk_widget_show(parent->parent); |
… |
… |
|
4732 | 4732 | } |
4733 | 4733 | str_list[j] = 0; |
4734 | 4734 | sprintf(str, "%g", SANE_UNFIX(val)); |
4735 | | xsane_back_gtk_option_menu_new(parent, title, str_list, str, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap)); |
| 4735 | xsane_back_gtk_option_menu_new(parent, title, str_list, str, opt->constraint_type, elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap)); |
4736 | 4736 | free (str_list); |
4737 | 4737 | gtk_widget_show(parent->parent); |
4738 | 4738 | } |
… |
… |
|
4769 | 4769 | (strcmp (opt->name, SANE_NAME_SCAN_SOURCE) != 0) ) /* do not show scansource */ |
4770 | 4770 | { |
4771 | 4771 | /* use a "list-selection" widget */ |
4772 | | xsane_back_gtk_option_menu_new(parent, title, (char **) opt->constraint.string_list, buf, |
| 4772 | xsane_back_gtk_option_menu_new(parent, title, (char **) opt->constraint.string_list, buf, opt->constraint_type, |
4773 | 4773 | elem, xsane.tooltips, _BGT(opt->desc), SANE_OPTION_IS_SETTABLE(opt->cap)); |
4774 | 4774 | gtk_widget_show (parent->parent); |
4775 | 4775 | } |