-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdialogs.cpp
240 lines (176 loc) · 6.41 KB
/
dialogs.cpp
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include <iostream>
#include <gtk/gtk.h>
#include "imagesource.h"
#include "pathsupport.h"
#include "patheditor.h"
#include "generaldialogs.h"
#include "profileselector.h"
#include "intentselector.h"
#include "simplecombo.h"
#include "util.h"
#include "config.h"
#include "gettext.h"
#define _(x) gettext(x)
#define N_(x) gettext_noop(x)
#include "dialogs.h"
using namespace std;
#define RESPONSE_SAVE 1
struct prefsdialogdata
{
ProfileManager *pm;
GtkWidget *monprof;
GtkWidget *monactive;
GtkWidget *cmpatheditor;
GtkWidget *argyllpatheditor;
GtkWidget *gspatheditor;
};
static void checkbox_changed(GtkWidget *wid,gpointer *ud)
{
prefsdialogdata *ob=(prefsdialogdata *)ud;
int ma=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(ob->monactive));
gtk_widget_set_sensitive(ob->monprof,ma);
}
static void paths_changed(GtkWidget *widget,gpointer user_data)
{
struct prefsdialogdata *dd=(struct prefsdialogdata *)user_data;
patheditor_get_paths(PATHEDITOR(widget),dd->pm);
profileselector_refresh(PROFILESELECTOR(dd->monprof));
}
void PreferencesDialog(GtkWindow *parent,CMYKTool_Core &core)
{
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *profilepage;
GtkWidget *extutilspage;
GtkWidget *vbox;
GtkWidget *label;
ProfileManager &pm=core.GetProfileManager();
char *savedpaths=pm.GetPaths();
struct prefsdialogdata dd;
dd.pm=±
dialog=gtk_dialog_new_with_buttons(_("Preferences..."),
parent,GtkDialogFlags(0),
GTK_STOCK_SAVE,RESPONSE_SAVE,
GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,
GTK_STOCK_OK,GTK_RESPONSE_OK,
NULL);
gtk_window_set_default_size (GTK_WINDOW (dialog), 450,350);
notebook=gtk_notebook_new();
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox),notebook,TRUE,TRUE,0);
gtk_widget_show(GTK_WIDGET(notebook));
// Colour management page:
label=gtk_label_new(_("Colour Management"));
gtk_widget_show(label);
profilepage=gtk_vbox_new(FALSE,0);
gtk_widget_show(GTK_WIDGET(profilepage));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),GTK_WIDGET(profilepage),GTK_WIDGET(label));
GtkWidget *table=gtk_table_new(2,4,FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table),8);
gtk_table_set_col_spacing(GTK_TABLE(table),0,10);
gtk_table_set_row_spacings(GTK_TABLE(table),8);
gtk_box_pack_start(GTK_BOX(profilepage),table,TRUE,TRUE,5);
gtk_widget_show(table);
int row=0;
// Paths...
label=gtk_label_new(_("ICC colour profile paths"));
gtk_misc_set_alignment(GTK_MISC(label),0.0,0.5);
gtk_table_attach(GTK_TABLE(table),label,0,1,row,row+1,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_show(label);
++row;
GtkAttachOptions gao = (GtkAttachOptions)(GTK_EXPAND|GTK_FILL);
dd.cmpatheditor = patheditor_new(&pm);
g_signal_connect(dd.cmpatheditor,"changed",G_CALLBACK(paths_changed),&dd);
gtk_table_attach(GTK_TABLE(table),dd.cmpatheditor,0,2,row,row+1,gao,gao,0,0);
gtk_widget_show(dd.cmpatheditor);
++row;
// Profiles...
dd.monactive=gtk_check_button_new_with_label(_("Monitor Profile:"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dd.monactive),pm.FindInt("MonitorProfileActive"));
g_signal_connect(G_OBJECT(dd.monactive),"toggled",G_CALLBACK(checkbox_changed),&dd);
gtk_table_attach(GTK_TABLE(table),dd.monactive,0,1,row,row+1,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_show(dd.monactive);
dd.monprof=profileselector_new(&pm,IS_TYPE_RGB,false);
gtk_table_attach(GTK_TABLE(table),dd.monprof,1,2,row,row+1,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_show(dd.monprof);
profileselector_set_filename(PROFILESELECTOR(dd.monprof),pm.FindString("MonitorProfile"));
++row;
// External utilities
label=gtk_label_new(_("External utilities"));
gtk_widget_show(label);
extutilspage=gtk_vbox_new(FALSE,0);
gtk_widget_show(GTK_WIDGET(extutilspage));
gtk_notebook_append_page(GTK_NOTEBOOK(notebook),GTK_WIDGET(extutilspage),GTK_WIDGET(label));
table=gtk_table_new(2,4,FALSE);
gtk_container_set_border_width(GTK_CONTAINER(table),8);
gtk_table_set_col_spacing(GTK_TABLE(table),0,10);
gtk_table_set_row_spacings(GTK_TABLE(table),8);
gtk_box_pack_start(GTK_BOX(extutilspage),table,TRUE,TRUE,5);
gtk_widget_show(table);
row=0;
// Paths...
label=gtk_label_new(_("Search paths for Argyll utilities (TIFFGamut, ColLink, etc.)"));
gtk_misc_set_alignment(GTK_MISC(label),0.0,0.5);
gtk_table_attach(GTK_TABLE(table),label,0,1,row,row+1,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_show(label);
++row;
// FIXME - replace test_sp with a real searchpath
SearchPathHandler test_sp;
test_sp.AddPath(core.FindString("ArgyllPath"));
dd.argyllpatheditor = patheditor_new(&test_sp);
// g_signal_connect(dd.cmpatheditor,"changed",G_CALLBACK(paths_changed),&dd);
gtk_table_attach(GTK_TABLE(table),dd.argyllpatheditor,0,2,row,row+1,gao,gao,0,0);
gtk_widget_show(dd.argyllpatheditor);
++row;
label=gtk_label_new(_("Search paths for GhostScript executable"));
gtk_misc_set_alignment(GTK_MISC(label),0.0,0.5);
gtk_table_attach(GTK_TABLE(table),label,0,1,row,row+1,GTK_SHRINK,GTK_SHRINK,0,0);
gtk_widget_show(label);
++row;
// FIXME - replace test_sp2 with a real searchpath
SearchPathHandler test_sp2;
dd.gspatheditor = patheditor_new(&test_sp2);
// g_signal_connect(dd.cmpatheditor,"changed",G_CALLBACK(paths_changed),&dd);
gtk_table_attach(GTK_TABLE(table),dd.gspatheditor,0,2,row,row+1,gao,gao,0,0);
gtk_widget_show(dd.gspatheditor);
++row;
gtk_widget_show(dialog);
bool done=false;
while(!done)
{
gint result=gtk_dialog_run(GTK_DIALOG(dialog));
switch(result)
{
case GTK_RESPONSE_CANCEL:
pm.ClearPaths();
pm.AddPath(savedpaths);
done=true;
break;
case GTK_RESPONSE_OK:
case RESPONSE_SAVE:
done=true;
pm.SetString("MonitorProfile",profileselector_get_filename(PROFILESELECTOR(dd.monprof)));
pm.SetInt("MonitorProfileActive",gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dd.monactive)));
char *tmppaths=pm.GetPaths();
pm.SetString("ProfilePath",tmppaths);
free(tmppaths);
patheditor_get_paths(PATHEDITOR(dd.argyllpatheditor),&test_sp);
char *argyllpath=test_sp.GetPaths();
Debug[TRACE] << "ArgyllPath: " << argyllpath << endl;
core.SetString("ArgyllPath",argyllpath);
free(argyllpath);
patheditor_get_paths(PATHEDITOR(dd.gspatheditor),&test_sp2);
char *gspath=test_sp2.GetPaths();
Debug[TRACE] << "GhostscriptPath: " << gspath << endl;
core.SetString("GhostscriptPath",gspath);
free(gspath);
if(result==RESPONSE_SAVE)
{
core.SaveConfig();
}
break;
}
}
gtk_widget_destroy(dialog);
if(savedpaths)
free(savedpaths);
}