summaryrefslogtreecommitdiff
path: root/src/gtkglue.h
blob: 00b1666b1edffea1221ecd04249ae418ca0072e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef gtkglue_h
#define gtkglue_h

#include <sys/types.h>

#include <gtk/gtk.h>

#include "../include/sane/config.h"
#include <sane/sane.h>

struct GSGDialog;

typedef void (*GSGCallback) (struct GSGDialog *dialog, void *arg);

typedef enum
  {
    GSG_TL_X,	/* top-left x */
    GSG_TL_Y,	/* top-left y */
    GSG_BR_X,	/* bottom-right x */
    GSG_BR_Y	/* bottom-right y */
  }
GSGCornerCoordinates;

typedef struct
  {
    /* The option number of the well-known options.  Each of these may
       be -1 in case the backend doesn't define the respective option.  */
    int preview;
    int dpi;
    int coord[4];
  }
GSGWellKnownOptions;

typedef struct
  {
    gchar *label;
    struct GSGDialogElement *elem;
    gint index;
  }
GSGMenuItem;

typedef struct GSGDialogElement
  {
    struct GSGDialog *dialog;	/* wasteful, but is there a better solution? */
    GtkWidget *automatic;	/* auto button for options that support this */
    GtkWidget *widget;
    GtkObject *data;
    int menu_size;		/* # of items in menu (if any) */
    GSGMenuItem *menu;
  }
GSGDialogElement;

typedef struct GSGDialog
  {
    GtkWidget *window;
    GtkWidget *main_hbox;
    GtkWidget *advanced_vbox;
    int twocolumn;
    GtkTooltips *tooltips;
    GdkColor tooltips_fg;
    GdkColor tooltips_bg;
    SANE_Handle *dev;
    const char *dev_name;
    GSGWellKnownOptions well_known;
    int num_elements;
    GSGDialogElement *element;
    gint idle_id;
    u_int rebuild : 1;
    u_int advanced : 1;
    /* This callback gets invoked whenever the backend notifies us
       that the option descriptors have changed.  */
    GSGCallback option_reload_callback;
    void *option_reload_arg;
    /* This callback gets invoked whenever the backend notifies us
       that the parameters have changed.  */
    GSGCallback param_change_callback;
    void *param_change_arg;
  }
GSGDialog;


extern int gsg_message_dialog_active;

/* Construct the path and return it in filename_ret (this buffer must
   be at least max_len bytes long).  The path is constructed as
   follows:

      ~/.sane/${PROG_NAME}/${PREFIX}${DEV_NAME}${POSTFIX}

   If PROG_NAME is NULL, an empty string is used and the leading slash
   is removed.  On success, 0 is returned, on error a negative number and
   ERRNO is set to the appropriate value.  */
extern int gsg_make_path (size_t max_len, char *filename_ret,
			  const char *prog_name,
			  const char *prefix, const char *dev_name,
			  const char *postfix);

extern void gsg_message (gchar *title, gchar * message);
extern void gsg_error (gchar * error_message);
extern void gsg_warning (gchar * warning_message);
extern int gsg_get_filename (const char *label, const char *default_name,
			     size_t max_len, char *filename);

extern GSGDialog *gsg_create_dialog (GtkWidget *window,
				     const char *device_name,
				     GSGCallback option_reload_callback,
				     void *option_reload_arg,
				     GSGCallback param_callback,
				     void *param_arg);
extern void gsg_sync (GSGDialog *dialog);
extern void gsg_refresh_dialog (GSGDialog *dialog);
extern void gsg_update_scan_window (GSGDialog *dialog);
extern void gsg_set_advanced (GSGDialog *dialog, int advanced);
extern void gsg_set_tooltips (GSGDialog *dialog, int enable);
extern void gsg_set_twocolumn (GSGDialog *dialog, int enable);
extern void gsg_set_sensitivity (GSGDialog *dialog, int sensitive);
extern void gsg_destroy_dialog (GSGDialog * dialog);

#define gsg_dialog_get_device(dialog)	((dialog)->dev)

#endif /* gtkglue_h */