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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
/* file-selector.h -- customized file selection dialog -*- C++ -*-
Copyright (C) 2003, 2005, 2008 SEIKO EPSON CORPORATION
This file is part of the `iscan' program.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
As a special exception, the copyright holders give permission
to link the code of this program with the esmod library and
distribute linked combinations including the two. You must obey
the GNU General Public License in all respects for all of the
code used other then esmod.
*/
#ifndef ISCAN_FILE_SELECTOR_H
#define ISCAN_FILE_SELECTOR_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/types.h>
#include <regex.h>
#include <gtk/gtk.h>
#include "pisa_error.h"
#include "imgstream.hh" // for iscan::file_format
#define G_CALLBACK_API public /* EEK! */
class file_selector
{
public:
void init ();
void create_window (GtkWindow *window, GtkWidget *parent,
bool do_consecutive_scanning = false,
bool show_match_direction = false,
const char* default_format = NULL);
void destroy ();
char *get_pathname () const;
int get_sequence_number () const;
bool valid_pathname (const std::string& path) const;
bool save_pathname (); // really G_CALLBACK_API only
void hide () const;
std::string get_format_name () const;
iscan::file_format get_type () const;
bool multi_page_mode ();
bool has_left_edge_binding ();
G_CALLBACK_API:
void destroy (bool really);
void delete_text (gint start, gint end);
void insert_text (gchar *text, gint len, gint *pos);
void change_format (int index);
void change_seqnum ();
void change_digits ();
void change_page_mode (bool mode);
void change_binding_edge (bool match);
private:
char *canonize (const char *text) const;
void add_dialog_extensions (gint index = 0);
bool permission (const char *file) const;
bool show_message (const pisa_error& oops,
const char *yes = NULL,
const char *no = NULL) const;
void set_entry (const char *text);
void regerror (int code, regex_t *regex) const;
gint get_index (const char* name) const;
bool is_supported (const char* format) const;
bool possible_overwrite (const std::string& current) const;
int check_overwrite (const char *regexp) const;
GtkWidget *_parent;
GtkFileSelection *_widget;
char *_filename; // relative filename
char *_pathname; // absolute filename
bool _using_adf;
bool _do_duplex; // indicates whether to display a binding
// location selector (default: left edge)
int _format_index; // index into file format menu indicating
// the currently selected item
bool _deleted_all;
bool _multi_page_mode;
bool _has_left_edge_binding; // indicates whether the document is bound
// on the left hand side
int _number; // for consecutive scans
GtkAdjustment *_seqnum;
GtkAdjustment *_digits;
typedef struct // graphic format info
{
const char *name; // used in option menu
const char *lib; // library providing support
const char *ext; // default filename extension
const char *rgx; // filename extension regex
const iscan::file_format type;
} format;
static const format _format[];
const format **_fmt;
char *_ext_regex;
};
#endif /* ISCAN_FILE_SELECTOR_H */
|