forked from blackfiveimaging/photoprint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpp_menu_options.cpp
212 lines (170 loc) · 7 KB
/
pp_menu_options.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
#include <iostream>
#include <gtk/gtkstock.h>
#include <gtk/gtkradioaction.h>
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkmain.h>
#include "config.h"
#include "errordialogqueue.h"
#include "pp_mainwindow.h"
#include "dialogs.h"
#include "miscwidgets/generaldialogs.h"
#include "progressbar.h"
#include "debug.h"
#include "profilemanager/profilemanager.h"
#include "pp_menu_options.h"
#include "gettext.h"
#define _(x) gettext(x)
#define N_(x) gettext_noop(x)
using namespace std;
static void options_paths(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
Paths_Dialog(GTK_WINDOW(mw),*mw->state);
pp_mainwindow_refresh(mw);
}
static void options_colourmanagement(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
ColourManagement_Dialog(GTK_WINDOW(mw),*mw->state);
mw->state->layout->FlushHRPreviews();
mw->state->layout->FlushThumbnails();
pp_mainwindow_refresh(mw);
OptionsMenu_SetProofMode(mw->uim,CMProofMode(mw->state->profilemanager.FindInt("ProofMode")));
}
static void options_colourresponsetag(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
ColourResponseTag_Dialog(GTK_WIDGET(mw),*mw->state);
}
static void options_units(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
Units_Dialog(GTK_WINDOW(mw),*mw->state);
(mw->state->layout->SetUnitFunc())(mw->layout,mw->state->GetUnits());
}
static void options_scaling(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
Scaling_Dialog(GTK_WINDOW(mw),*mw->state);
}
static void options_renderingresolution(GtkAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
RenderingResolution_Dialog(GTK_WINDOW(mw),*mw->state);
}
static void options_highres(GtkToggleAction *act,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
bool checked=gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(act));
mw->state->SetInt("HighresPreviews",checked);
if(checked)
pp_mainwindow_refresh(mw);
}
static gboolean radioidlefunc(gpointer userdata)
{
pp_MainWindow *mw=(pp_MainWindow *)userdata;
Debug[TRACE] << "In Idle function - reverting menu item" << endl;
OptionsMenu_SetProofMode(mw->uim,CM_PROOFMODE_NONE);
Debug[TRACE] << "done" << endl;
return(FALSE);
}
static void optionsmenu_radio_dispatch(GtkAction *act,GtkRadioAction *ra,gpointer *ob)
{
pp_MainWindow *mw=(pp_MainWindow *)ob;
enum CMProofMode proofmode=CMProofMode(gtk_radio_action_get_current_value(ra));
Debug[TRACE] << "Proofmode set to: " << proofmode << endl;
try
{
mw->state->layout->FlushHRPreviews();
mw->state->layout->FlushThumbnails();
mw->state->profilemanager.SetProofMode(proofmode);
pp_mainwindow_refresh(mw);
}
catch(const char *err)
{
ErrorMessage_Dialog(err,GTK_WIDGET(mw));
Debug[TRACE] << "Dialog displayed - adding idle function..." << endl;
gtk_idle_add(radioidlefunc,mw);
}
}
static GtkActionEntry optionsmenu_entries[] = {
{ "OptionsMenu", NULL, N_("_Options") },
{ "Paths", NULL, N_("_Paths..."), NULL, N_("Set search paths for ICC profiles, borders, etc."), G_CALLBACK(options_paths) },
{ "ColourManagement", NULL, N_("_Colour Management..."), NULL, N_("Set colour management options"), G_CALLBACK(options_colourmanagement) },
{ "ColourResponseHash", NULL, N_("Colour Response _Hash..."), NULL, N_("Create a hash for verifying printer settings"), G_CALLBACK(options_colourresponsetag) },
{ "Units", NULL, N_("_Units..."), NULL, N_("Select the units used throughout PhotoPrint"), G_CALLBACK(options_units) },
{ "Scaling", NULL, N_("_Scaling..."), NULL, N_("Select the preferred scaling method."), G_CALLBACK(options_scaling) },
{ "RenderingResolution", NULL, N_("_Rendering Resolution..."), NULL, N_("Set the resolution at which pages are rendered."), G_CALLBACK(options_renderingresolution) },
};
static GtkToggleActionEntry optionsmenu_toggle_entries[] = {
{ "HighresPreviews", NULL, N_("High-res Previews"), NULL, N_("Render high-resolution previews in the background"), G_CALLBACK(options_highres), FALSE }
};
static GtkRadioActionEntry optionsmenu_radio_entries[] = {
{ "NormalDisplay", NULL, N_("_Normal Display"), NULL, N_("Display colours with no print simulation"), CM_PROOFMODE_NONE},
{ "SimulatePrint", NULL, N_("Simulate Prin_t"), NULL, N_("Adjust colours on screen to imitate printed colours, including paper white"), CM_PROOFMODE_SIMULATEPRINT},
{ "SimulatePrintAdaptWhite", NULL, N_("Simulate Print, _Adapt White"), NULL, N_("Adjust colours to imitate printed colours, excluding paper white"), CM_PROOFMODE_SIMULATEPRINTADAPTWHITE},
};
static const char *optionsmenu_ui_description =
"<ui>"
" <menubar name='MainMenu'>"
" <menu action='OptionsMenu'>"
" <menuitem action='Paths'/>"
" <menuitem action='Units'/>"
" <menuitem action='Scaling'/>"
" <menuitem action='RenderingResolution'/>"
" <menuitem action='ColourManagement'/>"
" <menuitem action='ColourResponseHash'/>"
" <separator/>"
" <menuitem action='NormalDisplay'/>"
" <menuitem action='SimulatePrint'/>"
" <menuitem action='SimulatePrintAdaptWhite'/>"
" <separator/>"
" <menuitem action='HighresPreviews'/>"
" </menu>"
" </menubar>"
"</ui>";
void BuildOptionsMenu(void *userdata,GtkUIManager *ui_manager)
{
GError *error=NULL;
GtkActionGroup *action_group;
action_group = gtk_action_group_new ("OptionsMenuActions");
gtk_action_group_set_translation_domain(action_group,PACKAGE);
gtk_action_group_add_actions (action_group, optionsmenu_entries, G_N_ELEMENTS (optionsmenu_entries), userdata);
gtk_action_group_add_toggle_actions (action_group, optionsmenu_toggle_entries, G_N_ELEMENTS (optionsmenu_toggle_entries), userdata);
gtk_action_group_add_radio_actions (action_group, optionsmenu_radio_entries, G_N_ELEMENTS (optionsmenu_radio_entries), 0, G_CALLBACK(optionsmenu_radio_dispatch), userdata);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
if (!gtk_ui_manager_add_ui_from_string (ui_manager, optionsmenu_ui_description, -1, &error))
throw error->message;
}
void OptionsMenu_SetHighresPreviews(GtkUIManager *ui_manager,int hrpreview)
{
GtkAction *act=gtk_ui_manager_get_action(ui_manager,"/MainMenu/OptionsMenu/HighresPreviews");
if(act)
gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act),hrpreview);
}
void OptionsMenu_SetProofMode(GtkUIManager *ui_manager,enum CMProofMode item)
{
Debug[TRACE] << "Setting proof mode to " << item << endl;
#if 1
// GTK installations should by-and-large be new enough now for this to work!
GtkAction *act=gtk_ui_manager_get_action(ui_manager,"/MainMenu/OptionsMenu/NormalDisplay");
if(act)
gtk_radio_action_set_current_value(GTK_RADIO_ACTION(act),item);
#else
const char *menupaths[]=
{
"/MainMenu/OptionsMenu/NormalDisplay",
"/MainMenu/OptionsMenu/SimulatePrint",
"/MainMenu/OptionsMenu/SimulatePrintAdaptWhite"
};
GtkWidget *w;
for(unsigned int i=0;i<(sizeof(menupaths)/sizeof(const char *));++i)
{
w=gtk_ui_manager_get_widget(ui_manager,menupaths[i]);
if(w)
{
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),(enum CMProofMode)i==item);
}
}
#endif
}