| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifdef HAVE_CONFIG_H |
| 24 |
#include <config.h> |
| 25 |
#endif |
| 26 |
|
| 27 |
#define MAX_PREVIEW_PPI (400) |
| 28 |
#define INCH 72 |
| 29 |
#define FINCH ((gdouble) INCH) |
| 30 |
#define ROUNDUP(x, y) (((x) + ((y) - 1)) / (y)) |
| 31 |
#define SCALE(x, y) ((x) * (y)) |
| 32 |
|
| 33 |
#include <gutenprint/gutenprint-intl-internal.h> |
| 34 |
#include <gutenprintui2/gutenprintui.h> |
| 35 |
#include "gutenprintui-internal.h" |
| 36 |
|
| 37 |
#include <string.h> |
| 38 |
#include <stdio.h> |
| 39 |
#include <math.h> |
| 40 |
|
| 41 |
#define MAXIMUM_PARAMETER_LEVEL STP_PARAMETER_LEVEL_ADVANCED4 |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
static int preview_size_vert = 360; |
| 47 |
static int preview_size_horiz = 300; |
| 48 |
static gdouble minimum_image_percent = 5.0; |
| 49 |
|
| 50 |
#define MOVE_CONSTRAIN 0 |
| 51 |
#define MOVE_HORIZONTAL 1 |
| 52 |
#define MOVE_VERTICAL 2 |
| 53 |
#define MOVE_ANY (MOVE_HORIZONTAL | MOVE_VERTICAL) |
| 54 |
#define MOVE_GRID 4 |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
static GtkWidget *main_vbox; |
| 61 |
static GtkWidget *main_hbox; |
| 62 |
static GtkWidget *right_vbox; |
| 63 |
static GtkWidget *notebook; |
| 64 |
|
| 65 |
static GtkWidget *output_color_vbox; |
| 66 |
static GtkWidget *cyan_button; |
| 67 |
static GtkWidget *magenta_button; |
| 68 |
static GtkWidget *yellow_button; |
| 69 |
static GtkWidget *black_button; |
| 70 |
static GtkWidget *red_button; |
| 71 |
static GtkWidget *green_button; |
| 72 |
static GtkWidget *blue_button; |
| 73 |
|
| 74 |
static GtkWidget *print_dialog; |
| 75 |
|
| 76 |
static GtkWidget *recenter_button; |
| 77 |
static GtkWidget *recenter_vertical_button; |
| 78 |
static GtkWidget *recenter_horizontal_button; |
| 79 |
|
| 80 |
static GtkWidget *left_entry; |
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
static GtkWidget *right_border_entry; |
| 85 |
static GtkWidget *top_entry; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
static GtkWidget *bottom_border_entry; |
| 90 |
static GtkWidget *width_entry; |
| 91 |
static GtkWidget *height_entry; |
| 92 |
static GtkWidget *units_hbox; |
| 93 |
static GtkWidget *units_label; |
| 94 |
|
| 95 |
static GtkWidget *custom_size_width; |
| 96 |
static GtkWidget *custom_size_height; |
| 97 |
static GtkWidget *show_all_paper_sizes_button; |
| 98 |
static GtkWidget *auto_paper_size_button; |
| 99 |
|
| 100 |
static GtkWidget *orientation_menu; |
| 101 |
|
| 102 |
static GtkWidget *scaling_percent; |
| 103 |
static GtkWidget *scaling_ppi; |
| 104 |
static GtkWidget *scaling_image; |
| 105 |
static GtkObject *scaling_adjustment; |
| 106 |
|
| 107 |
static GtkWidget *setup_dialog; |
| 108 |
static GtkWidget *printer_driver; |
| 109 |
static GtkWidget *printer_model_label; |
| 110 |
static GtkWidget *printer_crawler; |
| 111 |
static GtkWidget *printer_combo; |
| 112 |
static GtkWidget *manufacturer_clist; |
| 113 |
static GtkWidget *manufacturer_crawler; |
| 114 |
static gint plist_callback_id = -1; |
| 115 |
static GtkWidget *ppd_file; |
| 116 |
static GtkWidget *ppd_box; |
| 117 |
static GtkWidget *ppd_label; |
| 118 |
static GtkWidget *ppd_button; |
| 119 |
static GtkWidget *ppd_browser; |
| 120 |
static GtkWidget *ppd_model_label; |
| 121 |
static GtkWidget *ppd_model; |
| 122 |
static GtkWidget *new_printer_dialog; |
| 123 |
static GtkWidget *new_printer_entry; |
| 124 |
static GtkWidget *file_button; |
| 125 |
static GtkWidget *file_entry; |
| 126 |
static GtkWidget *file_browser; |
| 127 |
static GtkWidget *standard_cmd_entry; |
| 128 |
static GtkWidget *custom_command_entry; |
| 129 |
static GtkWidget *queue_combo; |
| 130 |
static gint queue_callback_id = -1; |
| 131 |
|
| 132 |
static GtkWidget *adjust_color_button; |
| 133 |
static GtkWidget *about_dialog; |
| 134 |
|
| 135 |
static GtkWidget *page_size_table; |
| 136 |
static GtkWidget *printer_features_table; |
| 137 |
static GtkWidget *color_adjustment_table; |
| 138 |
|
| 139 |
static GtkWidget *copy_count_spin_button; |
| 140 |
|
| 141 |
static gboolean preview_valid = FALSE; |
| 142 |
static gboolean frame_valid = FALSE; |
| 143 |
static gboolean need_exposure = FALSE; |
| 144 |
static gboolean suppress_scaling_adjustment = FALSE; |
| 145 |
static gboolean suppress_scaling_callback = FALSE; |
| 146 |
static gboolean thumbnail_update_pending = FALSE; |
| 147 |
static gboolean thumbnail_needs_rebuild = FALSE; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
static gint suppress_preview_update = 0; |
| 152 |
static gint suppress_preview_reset = 0; |
| 153 |
|
| 154 |
static GtkDrawingArea *preview = NULL; |
| 155 |
static GtkDrawingArea *swatch = NULL; |
| 156 |
static gint mouse_x, mouse_y; |
| 157 |
static gint orig_top, orig_left; |
| 158 |
static gint buttons_pressed = 0; |
| 159 |
static gint preview_active = 0; |
| 160 |
static gint buttons_mask = 0; |
| 161 |
static gint move_constraint = 0; |
| 162 |
static gint mouse_button = -1; |
| 163 |
static gint preview_thumbnail_w, preview_thumbnail_h; |
| 164 |
static gint preview_x, preview_y, preview_w, preview_h; |
| 165 |
|
| 166 |
static gint physical_orientation = -2; |
| 167 |
|
| 168 |
static gdouble paper_width, paper_height; |
| 169 |
static gdouble printable_width, printable_height; |
| 170 |
static gdouble print_width, print_height; |
| 171 |
static gdouble left, right, top, bottom; |
| 172 |
static gdouble image_width, image_height; |
| 173 |
static gdouble image_true_width, image_true_height; |
| 174 |
static gdouble image_xres, image_yres; |
| 175 |
static gint do_update_thumbnail = 0; |
| 176 |
static gint saveme = 0; |
| 177 |
static gint runme = 0; |
| 178 |
static gint exit_after_file_ok = 0; |
| 179 |
static gint auto_paper_size = 0; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
static void scaling_update (GtkAdjustment *adjustment); |
| 184 |
static void scaling_callback (GtkWidget *widget); |
| 185 |
static void plist_callback (GtkWidget *widget, gpointer data); |
| 186 |
static void queue_callback (GtkWidget *widget, gpointer data); |
| 187 |
static void custom_media_size_callback(GtkWidget *widget, gpointer data); |
| 188 |
static void show_all_paper_sizes_callback(GtkWidget *widget, gpointer data); |
| 189 |
static void auto_paper_size_callback(GtkWidget *widget, gpointer data); |
| 190 |
static void combo_callback (GtkWidget *widget, gpointer data); |
| 191 |
static void output_type_callback (GtkWidget *widget, gpointer data); |
| 192 |
static void unit_callback (GtkWidget *widget, gpointer data); |
| 193 |
static void orientation_callback (GtkWidget *widget, gpointer data); |
| 194 |
static void ppd_file_callback (GtkWidget *widget, gpointer data); |
| 195 |
static void printandsave_callback (void); |
| 196 |
static void about_callback (void); |
| 197 |
static void print_callback (void); |
| 198 |
static void save_callback (void); |
| 199 |
static void setup_callback (GtkWidget *widget); |
| 200 |
|
| 201 |
static void setup_update (void); |
| 202 |
static void setup_open_callback (void); |
| 203 |
static void setup_ok_callback (void); |
| 204 |
static void setup_cancel_callback (void); |
| 205 |
static void new_printer_open_callback (void); |
| 206 |
static void new_printer_ok_callback (void); |
| 207 |
static void ppd_browse_callback (void); |
| 208 |
static void ppd_ok_callback (void); |
| 209 |
static void file_browse_callback (void); |
| 210 |
static void file_ok_callback (void); |
| 211 |
static void file_cancel_callback (void); |
| 212 |
static void build_printer_driver_clist(void); |
| 213 |
static void print_driver_callback (GtkWidget *widget, |
| 214 |
gint row, |
| 215 |
gint column, |
| 216 |
GdkEventButton *event, |
| 217 |
gpointer data); |
| 218 |
static void manufacturer_callback (GtkWidget *widget, |
| 219 |
gint row, |
| 220 |
gint column, |
| 221 |
GdkEventButton *event, |
| 222 |
gpointer data); |
| 223 |
static void command_type_callback (GtkWidget *widget, gpointer data); |
| 224 |
|
| 225 |
static void do_preview_thumbnail (void); |
| 226 |
static void invalidate_preview_thumbnail (void); |
| 227 |
static void invalidate_frame (void); |
| 228 |
|
| 229 |
static GtkWidget *color_adjust_dialog; |
| 230 |
|
| 231 |
static void preview_update (void); |
| 232 |
static void preview_expose (void); |
| 233 |
static void preview_button_callback (GtkWidget *widget, |
| 234 |
GdkEventButton *bevent, |
| 235 |
gpointer data); |
| 236 |
static void preview_motion_callback (GtkWidget *widget, |
| 237 |
GdkEventMotion *mevent, |
| 238 |
gpointer data); |
| 239 |
static void position_callback (GtkWidget *widget); |
| 240 |
static void position_button_callback (GtkWidget *widget, |
| 241 |
gpointer data); |
| 242 |
static void copy_count_callback (GtkAdjustment *widget, |
| 243 |
gpointer data); |
| 244 |
static void plist_build_combo(GtkWidget *combo, |
| 245 |
GtkWidget *label, |
| 246 |
stp_string_list_t *items, |
| 247 |
int active, |
| 248 |
const gchar *cur_item, |
| 249 |
const gchar *def_value, |
| 250 |
GCallback callback, |
| 251 |
gint *callback_id, |
| 252 |
int (*check_func)(const char *string), |
| 253 |
gpointer data); |
| 254 |
static void initialize_thumbnail(void); |
| 255 |
static void reset_callback (GtkObject *widget, gpointer data); |
| 256 |
static void set_color_defaults (void); |
| 257 |
static void set_printer_defaults (void); |
| 258 |
static void redraw_color_swatch (void); |
| 259 |
static void color_update (GtkAdjustment *adjustment); |
| 260 |
static void dimension_update (GtkAdjustment *adjustment); |
| 261 |
static void integer_update (GtkAdjustment *adjustment); |
| 262 |
static void set_controls_active (GtkObject *checkbutton, gpointer optno); |
| 263 |
static void update_adjusted_thumbnail (gboolean regenerate_image); |
| 264 |
|
| 265 |
static void set_media_size(const gchar *new_media_size); |
| 266 |
static const stp_printer_t *tmp_printer = NULL; |
| 267 |
|
| 268 |
static option_t *current_options = NULL; |
| 269 |
static unsigned int current_option_count = 0; |
| 270 |
|
| 271 |
static unit_t units[] = |
| 272 |
{ |
| 273 |
{ N_("Inch"), N_("Set the base unit of measurement to inches"), |
| 274 |
72.0, NULL, "%.4f" }, |
| 275 |
{ N_("cm"), N_("Set the base unit of measurement to centimetres"), |
| 276 |
72.0 / 2.54, NULL, "%.4f" }, |
| 277 |
{ N_("Points"), N_("Set the base unit of measurement to points (1/72\")"), |
| 278 |
1.0, NULL, "%.2f" }, |
| 279 |
{ N_("mm"), N_("Set the base unit of measurement to millimetres"), |
| 280 |
72.0 / 25.4, NULL, "%.3f" }, |
| 281 |
{ N_("Pica"), N_("Set the base unit of measurement to picas (1/12\")"), |
| 282 |
72.0 / 12.0, NULL, "%.3f" }, |
| 283 |
}; |
| 284 |
static const gint unit_count = sizeof(units) / sizeof(unit_t); |
| 285 |
|
| 286 |
static radio_group_t output_types[] = |
| 287 |
{ |
| 288 |
{ N_("Color"), N_("Color output"), "Color", NULL }, |
| 289 |
{ N_("Grayscale"), |
| 290 |
N_("Print in shades of gray using black ink"), "BW", NULL } |
| 291 |
}; |
| 292 |
|
| 293 |
static const gint output_type_count = (sizeof(output_types) / |
| 294 |
sizeof(radio_group_t)); |
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
static radio_group_t command_options[] = |
| 301 |
{ |
| 302 |
{ N_("Standard Command"), N_("Use standard print command"), "Standard", NULL }, |
| 303 |
{ N_("Custom Command"), N_("Use custom print command"), "Custom", NULL }, |
| 304 |
{ N_("File"), N_("Print to a file"), "File", NULL } |
| 305 |
}; |
| 306 |
|
| 307 |
static const gint command_options_count = (sizeof(command_options) / |
| 308 |
sizeof(radio_group_t)); |
| 309 |
|
| 310 |
static gdouble preview_ppi = 10; |
| 311 |
|
| 312 |
static stp_string_list_t *printer_list = 0; |
| 313 |
static stpui_plist_t *pv; |
| 314 |
static const char *manufacturer = 0; |
| 315 |
|
| 316 |
static gint thumbnail_w, thumbnail_h, thumbnail_bpp; |
| 317 |
static guchar *thumbnail_data; |
| 318 |
static guchar *adjusted_thumbnail_data; |
| 319 |
static guchar *preview_thumbnail_data; |
| 320 |
|
| 321 |
static void |
| 322 |
set_stpui_curve_values(GtkWidget *gcurve, const stp_curve_t *seed) |
| 323 |
{ |
| 324 |
if (stp_curve_get_gamma(seed)) |
| 325 |
{ |
| 326 |
stpui_curve_set_gamma(STPUI_CURVE(gcurve), stp_curve_get_gamma(seed)); |
| 327 |
} |
| 328 |
else |
| 329 |
{ |
| 330 |
stp_curve_t *copy = stp_curve_create_copy(seed); |
| 331 |
const float *fdata; |
| 332 |
size_t count; |
| 333 |
stp_curve_resample(copy, 256); |
| 334 |
fdata = stp_curve_get_float_data(copy, &count); |
| 335 |
stpui_curve_set_vector(STPUI_CURVE(gcurve), count, fdata); |
| 336 |
stp_curve_destroy(copy); |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
static void |
| 341 |
set_stp_curve_values(GtkWidget *widget, option_t *opt) |
| 342 |
{ |
| 343 |
int i; |
| 344 |
double lo, hi; |
| 345 |
gfloat vector[256]; |
| 346 |
GtkWidget *gcurve = GTK_WIDGET(widget); |
| 347 |
stp_curve_t *curve = stp_curve_create_copy(opt->info.curve.deflt); |
| 348 |
stpui_curve_get_vector(STPUI_CURVE(gcurve), 256, vector); |
| 349 |
stp_curve_get_bounds(opt->info.curve.deflt, &lo, &hi); |
| 350 |
for (i = 0; i < 256; i++) |
| 351 |
{ |
| 352 |
if (vector[i] > hi) |
| 353 |
vector[i] = hi; |
| 354 |
else if (vector[i] < lo) |
| 355 |
vector[i] = lo; |
| 356 |
} |
| 357 |
switch (STPUI_CURVE(gcurve)->curve_type) |
| 358 |
{ |
| 359 |
case STPUI_CURVE_TYPE_SPLINE: |
| 360 |
stp_curve_set_interpolation_type(curve, STP_CURVE_TYPE_SPLINE); |
| 361 |
break; |
| 362 |
default: |
| 363 |
stp_curve_set_interpolation_type(curve, STP_CURVE_TYPE_LINEAR); |
| 364 |
break; |
| 365 |
} |
| 366 |
stp_curve_set_float_data(curve, 256, vector); |
| 367 |
stp_set_curve_parameter(pv->v, opt->fast_desc->name, curve); |
| 368 |
stp_curve_destroy(curve); |
| 369 |
} |
| 370 |
|
| 371 |
static int |
| 372 |
open_curve_editor(GtkObject *button, gpointer xopt) |
| 373 |
{ |
| 374 |
(void)button; |
| 375 |
option_t *opt = (option_t *)xopt; |
| 376 |
if (opt->info.curve.is_visible == FALSE) |
| 377 |
{ |
| 378 |
GtkWidget *gcurve = |
| 379 |
GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve); |
| 380 |
const stp_curve_t *seed = |
| 381 |
stp_get_curve_parameter(pv->v, opt->fast_desc->name); |
| 382 |
stp_curve_t *nseed = NULL; |
| 383 |
if (!seed) |
| 384 |
seed = opt->info.curve.deflt; |
| 385 |
if (seed) |
| 386 |
nseed = stp_curve_create_copy(seed); |
| 387 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->checkbox), FALSE); |
| 388 |
gtk_widget_show(GTK_WIDGET(opt->info.curve.dialog)); |
| 389 |
set_stpui_curve_values(gcurve, seed); |
| 390 |
opt->info.curve.is_visible = TRUE; |
| 391 |
if (opt->info.curve.current) |
| 392 |
stp_curve_destroy(opt->info.curve.current); |
| 393 |
opt->info.curve.current = nseed; |
| 394 |
invalidate_preview_thumbnail(); |
| 395 |
update_adjusted_thumbnail(FALSE); |
| 396 |
} |
| 397 |
|
| 398 |
return 1; |
| 399 |
} |
| 400 |
|
| 401 |
static int |
| 402 |
set_default_curve_callback(GtkObject *button, gpointer xopt) |
| 403 |
{ |
| 404 |
(void)button; |
| 405 |
option_t *opt = (option_t *)xopt; |
| 406 |
GtkWidget *gcurve = |
| 407 |
GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve); |
| 408 |
const stp_curve_t *seed = opt->info.curve.deflt; |
| 409 |
set_stpui_curve_values(gcurve, seed); |
| 410 |
set_stp_curve_values(gcurve, opt); |
| 411 |
invalidate_preview_thumbnail(); |
| 412 |
update_adjusted_thumbnail(TRUE); |
| 413 |
return 1; |
| 414 |
} |
| 415 |
|
| 416 |
static int |
| 417 |
set_previous_curve_callback(GtkObject *button, gpointer xopt) |
| 418 |
{ |
| 419 |
(void)button; |
| 420 |
option_t *opt = (option_t *)xopt; |
| 421 |
GtkWidget *gcurve = |
| 422 |
GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve); |
| 423 |
const stp_curve_t *seed = opt->info.curve.current; |
| 424 |
if (!seed) |
| 425 |
seed = opt->info.curve.deflt; |
| 426 |
set_stpui_curve_values(gcurve, seed); |
| 427 |
set_stp_curve_values(gcurve, opt); |
| 428 |
invalidate_preview_thumbnail(); |
| 429 |
update_adjusted_thumbnail(TRUE); |
| 430 |
return 1; |
| 431 |
} |
| 432 |
|
| 433 |
static int |
| 434 |
set_curve_callback(GtkObject *button, gpointer xopt) |
| 435 |
{ |
| 436 |
(void)button; |
| 437 |
option_t *opt = (option_t *)xopt; |
| 438 |
GtkWidget *gcurve = |
| 439 |
GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve); |
| 440 |
gtk_widget_hide(opt->info.curve.dialog); |
| 441 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->checkbox), TRUE); |
| 442 |
opt->info.curve.is_visible = FALSE; |
| 443 |
set_stp_curve_values(gcurve, opt); |
| 444 |
if (opt->info.curve.current) |
| 445 |
stp_curve_destroy(opt->info.curve.current); |
| 446 |
opt->info.curve.current = NULL; |
| 447 |
invalidate_preview_thumbnail(); |
| 448 |
update_adjusted_thumbnail(TRUE); |
| 449 |
return 1; |
| 450 |
} |
| 451 |
|
| 452 |
static gint |
| 453 |
curve_draw_callback(GtkWidget *widget, GdkEvent *event, gpointer xopt) |
| 454 |
{ |
| 455 |
option_t *opt = (option_t *)xopt; |
| 456 |
switch (event->type) |
| 457 |
{ |
| 458 |
case GDK_BUTTON_RELEASE: |
| 459 |
set_stp_curve_values(widget, opt); |
| 460 |
invalidate_preview_thumbnail(); |
| 461 |
update_adjusted_thumbnail(TRUE); |
| 462 |
break; |
| 463 |
default: |
| 464 |
break; |
| 465 |
} |
| 466 |
return 1; |
| 467 |
} |
| 468 |
|
| 469 |
static gint |
| 470 |
curve_type_changed(GtkWidget *widget, gpointer xopt) |
| 471 |
{ |
| 472 |
option_t *opt = (option_t *)xopt; |
| 473 |
set_stp_curve_values(widget, opt); |
| 474 |
invalidate_preview_thumbnail(); |
| 475 |
update_adjusted_thumbnail(TRUE); |
| 476 |
return 1; |
| 477 |
} |
| 478 |
|
| 479 |
static int |
| 480 |
cancel_curve_callback(GtkObject *button, gpointer xopt) |
| 481 |
{ |
| 482 |
(void)button; |
| 483 |
option_t *opt = (option_t *)xopt; |
| 484 |
if (opt->info.curve.is_visible) |
| 485 |
{ |
| 486 |
stp_set_curve_parameter(pv->v, opt->fast_desc->name, |
| 487 |
opt->info.curve.current); |
| 488 |
stp_curve_destroy(opt->info.curve.current); |
| 489 |
opt->info.curve.current = NULL; |
| 490 |
gtk_widget_hide(opt->info.curve.dialog); |
| 491 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->checkbox), TRUE); |
| 492 |
opt->info.curve.is_visible = FALSE; |
| 493 |
invalidate_preview_thumbnail(); |
| 494 |
update_adjusted_thumbnail(TRUE); |
| 495 |
} |
| 496 |
return 1; |
| 497 |
} |
| 498 |
|
| 499 |
static void |
| 500 |
stpui_create_curve(option_t *opt, |
| 501 |
GtkTable *table, |
| 502 |
gint column, |
| 503 |
gint row, |
| 504 |
const gchar *text, |
| 505 |
const stp_curve_t *deflt, |
| 506 |
gboolean is_optional) |
| 507 |
{ |
| 508 |
double lower, upper; |
| 509 |
(void)deflt; |
| 510 |
opt->checkbox = gtk_check_button_new(); |
| 511 |
gtk_table_attach(GTK_TABLE(table), opt->checkbox, |
| 512 |
column, column + 1, row, row + 1, |
| 513 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 514 |
if (is_optional) |
| 515 |
gtk_widget_show(opt->checkbox); |
| 516 |
else |
| 517 |
gtk_widget_hide(opt->checkbox); |
| 518 |
|
| 519 |
opt->info.curve.label = gtk_label_new(text); |
| 520 |
gtk_misc_set_alignment (GTK_MISC (opt->info.curve.label), 0.0, 0.5); |
| 521 |
gtk_table_attach (GTK_TABLE (table), opt->info.curve.label, |
| 522 |
column + 1, column + 2, row, row + 1, |
| 523 |
GTK_FILL, GTK_FILL, 0, 0); |
| 524 |
gtk_widget_show (opt->info.curve.label); |
| 525 |
|
| 526 |
opt->info.curve.button = gtk_button_new_with_label(_("Edit Curve...")); |
| 527 |
g_signal_connect(G_OBJECT(opt->info.curve.button), "clicked", |
| 528 |
G_CALLBACK(open_curve_editor), opt); |
| 529 |
gtk_table_attach (GTK_TABLE (table), opt->info.curve.button, |
| 530 |
column + 2, column + 3, row, row + 1, |
| 531 |
GTK_FILL, GTK_FILL, 0, 0); |
| 532 |
gtk_widget_show(opt->info.curve.button); |
| 533 |
|
| 534 |
opt->info.curve.dialog = |
| 535 |
stpui_dialog_new(gettext(opt->fast_desc->text), |
| 536 |
GTK_WIN_POS_MOUSE, TRUE, |
| 537 |
_("Set Default"), set_default_curve_callback, |
| 538 |
opt, NULL, NULL, FALSE, FALSE, |
| 539 |
_("Restore Previous"), set_previous_curve_callback, |
| 540 |
opt, NULL, NULL, FALSE, FALSE, |
| 541 |
_("OK"), set_curve_callback, |
| 542 |
opt, NULL, NULL, FALSE, FALSE, |
| 543 |
_("Cancel"), cancel_curve_callback, |
| 544 |
opt, NULL, NULL, FALSE, FALSE, |
| 545 |
NULL); |
| 546 |
opt->info.curve.gamma_curve = stpui_gamma_curve_new(); |
| 547 |
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(opt->info.curve.dialog)->vbox), |
| 548 |
opt->info.curve.gamma_curve, TRUE, TRUE, 0); |
| 549 |
stp_curve_get_bounds(opt->info.curve.deflt, &lower, &upper); |
| 550 |
stpui_curve_set_range |
| 551 |
(STPUI_CURVE (STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve), |
| 552 |
0.0, 1.0, lower, upper); |
| 553 |
gtk_widget_set_usize |
| 554 |
(GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve), 256, 256); |
| 555 |
gtk_widget_show(opt->info.curve.gamma_curve); |
| 556 |
|
| 557 |
g_signal_connect |
| 558 |
(G_OBJECT(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve), |
| 559 |
"curve-type-changed", G_CALLBACK(curve_type_changed), opt); |
| 560 |
g_signal_connect |
| 561 |
(G_OBJECT(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve), |
| 562 |
"event", G_CALLBACK(curve_draw_callback), opt); |
| 563 |
|
| 564 |
if (opt->fast_desc->help) |
| 565 |
{ |
| 566 |
stpui_set_help_data (opt->info.curve.label, opt->fast_desc->help); |
| 567 |
stpui_set_help_data (opt->info.curve.button, opt->fast_desc->help); |
| 568 |
stpui_set_help_data (opt->info.curve.gamma_curve, opt->fast_desc->help); |
| 569 |
} |
| 570 |
} |
| 571 |
|
| 572 |
static int |
| 573 |
open_file_browser(GtkObject *button, gpointer xopt) |
| 574 |
{ |
| 575 |
(void)button; |
| 576 |
option_t *opt = (option_t *)xopt; |
| 577 |
GtkWidget *browser = opt->info.file.f_browser; |
| 578 |
GtkWidget *entry = opt->info.file.f_entry; |
| 579 |
gtk_file_selection_set_filename (GTK_FILE_SELECTION (browser), |
| 580 |
gtk_entry_get_text (GTK_ENTRY (entry))); |
| 581 |
gtk_widget_show(opt->info.file.f_browser); |
| 582 |
return 1; |
| 583 |
} |
| 584 |
|
| 585 |
static void |
| 586 |
file_entry_callback(GtkWidget *widget, gpointer xopt) |
| 587 |
{ |
| 588 |
const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget)); |
| 589 |
if (name && pv && pv->v) |
| 590 |
{ |
| 591 |
option_t *opt = (option_t *)xopt; |
| 592 |
stp_set_file_parameter(pv->v, opt->fast_desc->name, name); |
| 593 |
} |
| 594 |
} |
| 595 |
|
| 596 |
static int |
| 597 |
file_browser_ok_callback(GtkObject *browser_ok, gpointer xopt) |
| 598 |
{ |
| 599 |
(void)browser_ok; |
| 600 |
option_t *opt = (option_t *)xopt; |
| 601 |
GtkWidget *entry = opt->info.file.f_entry; |
| 602 |
GtkWidget *browser = opt->info.file.f_browser; |
| 603 |
gtk_widget_hide(opt->info.file.f_browser); |
| 604 |
gtk_entry_set_text |
| 605 |
(GTK_ENTRY (entry), |
| 606 |
gtk_file_selection_get_filename (GTK_FILE_SELECTION (browser))); |
| 607 |
file_entry_callback(entry, xopt); |
| 608 |
return 1; |
| 609 |
} |
| 610 |
|
| 611 |
static void |
| 612 |
stpui_create_file_browser(option_t *opt, |
| 613 |
GtkTable *table, |
| 614 |
gint column, |
| 615 |
gint row, |
| 616 |
const gchar *text, |
| 617 |
gboolean is_optional) |
| 618 |
{ |
| 619 |
opt->checkbox = gtk_check_button_new(); |
| 620 |
gtk_table_attach(GTK_TABLE(table), opt->checkbox, |
| 621 |
column, column + 1, row, row + 1, |
| 622 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 623 |
if (is_optional) |
| 624 |
gtk_widget_show(opt->checkbox); |
| 625 |
else |
| 626 |
gtk_widget_hide(opt->checkbox); |
| 627 |
|
| 628 |
opt->info.file.f_label = gtk_label_new(text); |
| 629 |
gtk_misc_set_alignment (GTK_MISC (opt->info.file.f_label), 0.0, 0.5); |
| 630 |
gtk_table_attach (GTK_TABLE (table), opt->info.file.f_label, |
| 631 |
column + 1, column + 2, row, row + 1, |
| 632 |
GTK_FILL, GTK_FILL, 0, 0); |
| 633 |
gtk_widget_show (opt->info.file.f_label); |
| 634 |
|
| 635 |
opt->info.file.f_entry = gtk_entry_new(); |
| 636 |
gtk_table_attach (GTK_TABLE (table), opt->info.file.f_entry, |
| 637 |
column + 2, column + 3, row, row + 1, |
| 638 |
GTK_FILL, GTK_FILL, 0, 0); |
| 639 |
g_signal_connect(G_OBJECT(opt->info.file.f_entry), "activate", |
| 640 |
G_CALLBACK(file_entry_callback), opt); |
| 641 |
if (stp_get_file_parameter(pv->v, opt->fast_desc->name)) |
| 642 |
gtk_entry_set_text |
| 643 |
(GTK_ENTRY (opt->info.file.f_entry), |
| 644 |
stp_get_file_parameter(pv->v, opt->fast_desc->name)); |
| 645 |
gtk_widget_show (opt->info.file.f_entry); |
| 646 |
|
| 647 |
opt->info.file.f_button = gtk_button_new_with_label(_("Select File...")); |
| 648 |
g_signal_connect(G_OBJECT(opt->info.file.f_button), "clicked", |
| 649 |
G_CALLBACK(open_file_browser), opt); |
| 650 |
gtk_table_attach (GTK_TABLE (table), opt->info.file.f_button, |
| 651 |
column + 3, column + 4, row, row + 1, |
| 652 |
GTK_FILL, GTK_FILL, 0, 0); |
| 653 |
gtk_widget_show(opt->info.file.f_button); |
| 654 |
|
| 655 |
opt->info.file.f_browser = |
| 656 |
gtk_file_selection_new(gettext(opt->fast_desc->text)); |
| 657 |
|
| 658 |
g_signal_connect |
| 659 |
(G_OBJECT (GTK_FILE_SELECTION (opt->info.file.f_browser)->ok_button), "clicked", |
| 660 |
G_CALLBACK (file_browser_ok_callback), opt); |
| 661 |
g_signal_connect_object |
| 662 |
(G_OBJECT (GTK_FILE_SELECTION (opt->info.file.f_browser)->cancel_button), "clicked", |
| 663 |
G_CALLBACK (gtk_widget_hide), G_OBJECT (opt->info.file.f_browser), G_CONNECT_SWAPPED); |
| 664 |
|
| 665 |
if (opt->fast_desc->help) |
| 666 |
{ |
| 667 |
stpui_set_help_data (opt->info.file.f_label, opt->fast_desc->help); |
| 668 |
stpui_set_help_data (opt->info.file.f_button, opt->fast_desc->help); |
| 669 |
stpui_set_help_data (opt->info.file.f_entry, opt->fast_desc->help); |
| 670 |
stpui_set_help_data (opt->info.file.f_browser, opt->fast_desc->help); |
| 671 |
} |
| 672 |
} |
| 673 |
|
| 674 |
static int |
| 675 |
checkbox_callback(GtkObject *button, gpointer xopt) |
| 676 |
{ |
| 677 |
option_t *opt = (option_t *)xopt; |
| 678 |
GtkWidget *checkbox = GTK_WIDGET(opt->info.bool.checkbox); |
| 679 |
opt->info.bool.current = |
| 680 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbox)); |
| 681 |
stp_set_boolean_parameter(pv->v, opt->fast_desc->name, |
| 682 |
opt->info.bool.current); |
| 683 |
invalidate_frame(); |
| 684 |
invalidate_preview_thumbnail(); |
| 685 |
update_adjusted_thumbnail(TRUE); |
| 686 |
preview_update(); |
| 687 |
|
| 688 |
(void)button; |
| 689 |
return 1; |
| 690 |
} |
| 691 |
|
| 692 |
static int |
| 693 |
print_mode_is_color(const stp_vars_t *v) |
| 694 |
{ |
| 695 |
const char *printing_mode = stp_get_string_parameter(v, "PrintingMode"); |
| 696 |
if (!printing_mode) |
| 697 |
{ |
| 698 |
int answer = 1; |
| 699 |
stp_parameter_t desc; |
| 700 |
stp_describe_parameter(v, "PrintingMode", &desc); |
| 701 |
if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST && |
| 702 |
strcmp(desc.deflt.str, "BW") == 0) |
| 703 |
answer = 0; |
| 704 |
stp_parameter_description_destroy(&desc); |
| 705 |
return answer; |
| 706 |
} |
| 707 |
if (strcmp(printing_mode, "BW") == 0) |
| 708 |
return 0; |
| 709 |
else |
| 710 |
return 1; |
| 711 |
} |
| 712 |
|
| 713 |
static void |
| 714 |
set_current_printer(void) |
| 715 |
{ |
| 716 |
pv = &(stpui_plist[stpui_plist_current]); |
| 717 |
if (print_mode_is_color(pv->v)) |
| 718 |
stp_set_string_parameter(pv->v, "PrintingMode", "Color"); |
| 719 |
else |
| 720 |
stp_set_string_parameter(pv->v, "PrintingMode", "BW"); |
| 721 |
} |
| 722 |
|
| 723 |
|
| 724 |
static void |
| 725 |
stpui_create_boolean(option_t *opt, |
| 726 |
GtkTable *table, |
| 727 |
gint column, |
| 728 |
gint row, |
| 729 |
const gchar *text, |
| 730 |
int deflt, |
| 731 |
gboolean is_optional) |
| 732 |
{ |
| 733 |
(void)text; |
| 734 |
(void)deflt; |
| 735 |
opt->checkbox = gtk_check_button_new(); |
| 736 |
gtk_table_attach(GTK_TABLE(table), opt->checkbox, |
| 737 |
column, column + 1, row, row + 1, |
| 738 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 739 |
if (is_optional) |
| 740 |
gtk_widget_show(opt->checkbox); |
| 741 |
else |
| 742 |
gtk_widget_hide(opt->checkbox); |
| 743 |
|
| 744 |
opt->info.bool.checkbox = |
| 745 |
gtk_toggle_button_new_with_label(gettext(opt->fast_desc->text)); |
| 746 |
gtk_table_attach(GTK_TABLE(table), opt->info.bool.checkbox, |
| 747 |
column + 1, column + 3, row, row + 1, |
| 748 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 749 |
gtk_widget_show(opt->info.bool.checkbox); |
| 750 |
gtk_toggle_button_set_active |
| 751 |
(GTK_TOGGLE_BUTTON(opt->info.bool.checkbox), |
| 752 |
stp_get_boolean_parameter(pv->v, opt->fast_desc->name)); |
| 753 |
g_signal_connect(G_OBJECT(opt->info.bool.checkbox), "toggled", |
| 754 |
G_CALLBACK(checkbox_callback), opt); |
| 755 |
} |
| 756 |
|
| 757 |
static void |
| 758 |
build_queue_combo(void) |
| 759 |
{ |
| 760 |
plist_build_combo(queue_combo, |
| 761 |
NULL, |
| 762 |
stpui_system_print_queues, |
| 763 |
1, |
| 764 |
stpui_plist_get_queue_name(pv), |
| 765 |
NULL, |
| 766 |
G_CALLBACK(queue_callback), |
| 767 |
&queue_callback_id, |
| 768 |
NULL, |
| 769 |
NULL); |
| 770 |
} |
| 771 |
|
| 772 |
static void |
| 773 |
build_printer_combo(void) |
| 774 |
{ |
| 775 |
int i; |
| 776 |
if (printer_list) |
| 777 |
stp_string_list_destroy(printer_list); |
| 778 |
printer_list = stp_string_list_create(); |
| 779 |
for (i = 0; i < stpui_plist_count; i++) |
| 780 |
stp_string_list_add_string_unsafe(printer_list, |
| 781 |
stpui_plist[i].name, stpui_plist[i].name); |
| 782 |
plist_build_combo(printer_combo, |
| 783 |
NULL, |
| 784 |
printer_list, |
| 785 |
1, |
| 786 |
stp_string_list_param(printer_list, stpui_plist_current)->name, |
| 787 |
NULL, |
| 788 |
G_CALLBACK(plist_callback), |
| 789 |
&plist_callback_id, |
| 790 |
NULL, |
| 791 |
NULL); |
| 792 |
} |
| 793 |
|
| 794 |
static int |
| 795 |
check_page_size(const char *paper_size) |
| 796 |
{ |
| 797 |
const stp_papersize_t *ps = stp_describe_papersize(pv->v, paper_size); |
| 798 |
int page_size_ok = (ps && (ps->paper_unit == PAPERSIZE_ENGLISH_STANDARD || |
| 799 |
ps->paper_unit == PAPERSIZE_METRIC_STANDARD)); |
| 800 |
return page_size_ok; |
| 801 |
} |
| 802 |
|
| 803 |
static void |
| 804 |
build_page_size_combo(option_t *option) |
| 805 |
{ |
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
if (stpui_show_all_paper_sizes || |
| 811 |
stp_string_list_count(option->info.list.params) < 10) |
| 812 |
plist_build_combo(option->info.list.combo, option->info.list.label, |
| 813 |
option->info.list.params, option->is_active, |
| 814 |
stp_get_string_parameter(pv->v, option->fast_desc->name), |
| 815 |
option->info.list.default_val,G_CALLBACK(combo_callback), |
| 816 |
&(option->info.list.callback_id), NULL, option); |
| 817 |
else |
| 818 |
plist_build_combo(option->info.list.combo, option->info.list.label, |
| 819 |
option->info.list.params, option->is_active, |
| 820 |
stp_get_string_parameter(pv->v, option->fast_desc->name), |
| 821 |
option->info.list.default_val,G_CALLBACK(combo_callback), |
| 822 |
&(option->info.list.callback_id), |
| 823 |
check_page_size, option); |
| 824 |
} |
| 825 |
|
| 826 |
static void |
| 827 |
build_a_combo(option_t *option) |
| 828 |
{ |
| 829 |
const gchar *new_value; |
| 830 |
stp_parameter_activity_t active; |
| 831 |
if (option->fast_desc && |
| 832 |
option->fast_desc->p_type == STP_PARAMETER_TYPE_STRING_LIST) |
| 833 |
{ |
| 834 |
const gchar *val = stp_get_string_parameter(pv->v, |
| 835 |
option->fast_desc->name); |
| 836 |
if (option->info.list.params == NULL || ! option->is_active || |
| 837 |
stp_string_list_count(option->info.list.params) == 0) |
| 838 |
stp_set_string_parameter(pv->v, option->fast_desc->name, NULL); |
| 839 |
else if (!val || strlen(val) == 0 || |
| 840 |
! stp_string_list_is_present(option->info.list.params, val)) |
| 841 |
stp_set_string_parameter(pv->v, option->fast_desc->name, |
| 842 |
option->info.list.default_val); |
| 843 |
if (strcmp(option->fast_desc->name, "PageSize") == 0) |
| 844 |
build_page_size_combo(option); |
| 845 |
else |
| 846 |
plist_build_combo(option->info.list.combo, option->info.list.label, |
| 847 |
option->info.list.params, |
| 848 |
option->is_active, |
| 849 |
stp_get_string_parameter(pv->v, |
| 850 |
option->fast_desc->name), |
| 851 |
option->info.list.default_val, G_CALLBACK(combo_callback), |
| 852 |
&(option->info.list.callback_id), NULL, option); |
| 853 |
if (strcmp(option->fast_desc->name, "PageSize") == 0) |
| 854 |
set_media_size |
| 855 |
(stp_get_string_parameter(pv->v, option->fast_desc->name)); |
| 856 |
} |
| 857 |
else |
| 858 |
plist_build_combo(option->info.list.combo, option->info.list.label, |
| 859 |
NULL, 0, "", "", G_CALLBACK(combo_callback), |
| 860 |
&(option->info.list.callback_id), NULL, option); |
| 861 |
new_value = |
| 862 |
stpui_combo_get_name(option->info.list.combo, option->info.list.params); |
| 863 |
active = stp_get_string_parameter_active(pv->v, option->fast_desc->name); |
| 864 |
stp_set_string_parameter(pv->v, option->fast_desc->name, new_value); |
| 865 |
stp_set_string_parameter_active(pv->v, option->fast_desc->name, active); |
| 866 |
} |
| 867 |
|
| 868 |
static void |
| 869 |
populate_options(const stp_vars_t *v) |
| 870 |
{ |
| 871 |
stp_parameter_list_t params = stp_get_parameter_list(v); |
| 872 |
unsigned int i; |
| 873 |
int idx; |
| 874 |
if (current_options) |
| 875 |
{ |
| 876 |
for (i = 0; i < current_option_count; i++) |
| 877 |
{ |
| 878 |
option_t *opt = &(current_options[i]); |
| 879 |
switch (opt->fast_desc->p_type) |
| 880 |
{ |
| 881 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 882 |
if (opt->info.list.combo) |
| 883 |
{ |
| 884 |
gtk_widget_destroy(opt->info.list.combo); |
| 885 |
gtk_widget_destroy(opt->info.list.label); |
| 886 |
if (opt->info.list.params) |
| 887 |
stp_string_list_destroy(opt->info.list.params); |
| 888 |
g_free(opt->info.list.default_val); |
| 889 |
} |
| 890 |
break; |
| 891 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 892 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 893 |
case STP_PARAMETER_TYPE_INT: |
| 894 |
if (opt->info.flt.adjustment) |
| 895 |
{ |
| 896 |
gtk_widget_destroy |
| 897 |
(GTK_WIDGET |
| 898 |
(SCALE_ENTRY_SCALE(opt->info.flt.adjustment))); |
| 899 |
gtk_widget_destroy |
| 900 |
(GTK_WIDGET |
| 901 |
(SCALE_ENTRY_LABEL(opt->info.flt.adjustment))); |
| 902 |
gtk_widget_destroy |
| 903 |
(GTK_WIDGET |
| 904 |
(SCALE_ENTRY_SPINBUTTON(opt->info.flt.adjustment))); |
| 905 |
} |
| 906 |
break; |
| 907 |
case STP_PARAMETER_TYPE_CURVE: |
| 908 |
gtk_widget_destroy(GTK_WIDGET(opt->info.curve.label)); |
| 909 |
gtk_widget_destroy(GTK_WIDGET(opt->info.curve.button)); |
| 910 |
gtk_widget_destroy(GTK_WIDGET(opt->info.curve.dialog)); |
| 911 |
if (opt->info.curve.current) |
| 912 |
stp_curve_destroy(opt->info.curve.current); |
| 913 |
break; |
| 914 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 915 |
gtk_widget_destroy(GTK_WIDGET(opt->info.bool.checkbox)); |
| 916 |
break; |
| 917 |
case STP_PARAMETER_TYPE_FILE: |
| 918 |
gtk_widget_destroy(GTK_WIDGET(opt->info.file.f_label)); |
| 919 |
gtk_widget_destroy(GTK_WIDGET(opt->info.file.f_button)); |
| 920 |
gtk_widget_destroy(GTK_WIDGET(opt->info.file.f_entry)); |
| 921 |
gtk_widget_destroy(GTK_WIDGET(opt->info.file.f_browser)); |
| 922 |
break; |
| 923 |
default: |
| 924 |
break; |
| 925 |
} |
| 926 |
if (opt->checkbox) |
| 927 |
gtk_widget_destroy(GTK_WIDGET(opt->checkbox)); |
| 928 |
if (opt->reset_btn) |
| 929 |
gtk_widget_destroy(GTK_WIDGET(opt->reset_btn)); |
| 930 |
} |
| 931 |
g_free(current_options); |
| 932 |
} |
| 933 |
current_option_count = stp_parameter_list_count(params); |
| 934 |
current_options = g_malloc(sizeof(option_t) * current_option_count); |
| 935 |
|
| 936 |
for (idx = 0, i = 0; i < current_option_count; i++) |
| 937 |
{ |
| 938 |
stp_parameter_t desc; |
| 939 |
const stp_parameter_t *param = stp_parameter_list_param(params, i); |
| 940 |
if (!param->read_only && |
| 941 |
(param->p_class == STP_PARAMETER_CLASS_OUTPUT || |
| 942 |
param->p_class == STP_PARAMETER_CLASS_FEATURE || |
| 943 |
(param->p_class == STP_PARAMETER_CLASS_CORE && |
| 944 |
strcmp(param->name, "PageSize") == 0))) |
| 945 |
{ |
| 946 |
option_t *opt = &(current_options[idx]); |
| 947 |
opt->fast_desc = stp_parameter_list_param(params, i); |
| 948 |
stp_describe_parameter(v, opt->fast_desc->name, &desc); |
| 949 |
opt->checkbox = NULL; |
| 950 |
opt->reset_btn = NULL; |
| 951 |
opt->is_active = 0; |
| 952 |
opt->is_enabled = 0; |
| 953 |
switch (opt->fast_desc->p_type) |
| 954 |
{ |
| 955 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 956 |
opt->info.list.callback_id = -1; |
| 957 |
opt->info.list.default_val = g_strdup(desc.deflt.str); |
| 958 |
if (desc.bounds.str) |
| 959 |
opt->info.list.params = |
| 960 |
stp_string_list_create_copy(desc.bounds.str); |
| 961 |
else |
| 962 |
opt->info.list.params = NULL; |
| 963 |
opt->info.list.combo = NULL; |
| 964 |
opt->info.list.label = NULL; |
| 965 |
opt->is_active = desc.is_active; |
| 966 |
break; |
| 967 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 968 |
opt->info.flt.adjustment = NULL; |
| 969 |
opt->info.flt.upper = desc.bounds.dbl.upper; |
| 970 |
opt->info.flt.lower = desc.bounds.dbl.lower; |
| 971 |
opt->info.flt.deflt = desc.deflt.dbl; |
| 972 |
opt->info.flt.scale = 1.0; |
| 973 |
opt->is_active = desc.is_active; |
| 974 |
break; |
| 975 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 976 |
opt->info.flt.adjustment = NULL; |
| 977 |
opt->info.flt.upper = desc.bounds.dimension.upper; |
| 978 |
opt->info.flt.lower = desc.bounds.dimension.lower; |
| 979 |
opt->info.flt.deflt = desc.deflt.dimension; |
| 980 |
opt->info.flt.scale = 1.0; |
| 981 |
opt->is_active = desc.is_active; |
| 982 |
break; |
| 983 |
case STP_PARAMETER_TYPE_INT: |
| 984 |
opt->info.flt.adjustment = NULL; |
| 985 |
opt->info.flt.upper = desc.bounds.integer.upper; |
| 986 |
opt->info.flt.lower = desc.bounds.integer.lower; |
| 987 |
opt->info.flt.deflt = desc.deflt.dimension; |
| 988 |
opt->info.flt.scale = 1.0; |
| 989 |
opt->is_active = desc.is_active; |
| 990 |
break; |
| 991 |
case STP_PARAMETER_TYPE_CURVE: |
| 992 |
opt->info.curve.label = NULL; |
| 993 |
opt->info.curve.button = NULL; |
| 994 |
opt->info.curve.dialog = NULL; |
| 995 |
opt->info.curve.gamma_curve = NULL; |
| 996 |
opt->info.curve.current = NULL; |
| 997 |
opt->info.curve.deflt = desc.deflt.curve; |
| 998 |
opt->info.curve.is_visible = FALSE; |
| 999 |
opt->is_active = desc.is_active; |
| 1000 |
break; |
| 1001 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 1002 |
opt->info.bool.checkbox = NULL; |
| 1003 |
opt->info.bool.current = 0; |
| 1004 |
opt->info.bool.deflt = desc.deflt.boolean; |
| 1005 |
opt->is_active = desc.is_active; |
| 1006 |
break; |
| 1007 |
case STP_PARAMETER_TYPE_FILE: |
| 1008 |
opt->info.file.f_label = NULL; |
| 1009 |
opt->info.file.f_button = NULL; |
| 1010 |
opt->info.file.f_entry = NULL; |
| 1011 |
opt->info.file.f_browser = NULL; |
| 1012 |
opt->info.file.f_is_visible = FALSE; |
| 1013 |
opt->is_active = desc.is_active; |
| 1014 |
break; |
| 1015 |
default: |
| 1016 |
break; |
| 1017 |
} |
| 1018 |
idx++; |
| 1019 |
stp_parameter_description_destroy(&desc); |
| 1020 |
} |
| 1021 |
} |
| 1022 |
current_option_count = idx; |
| 1023 |
stp_parameter_list_destroy(params); |
| 1024 |
} |
| 1025 |
|
| 1026 |
static void |
| 1027 |
destroy_something(GtkWidget *widget, gpointer data) |
| 1028 |
{ |
| 1029 |
(void)data; |
| 1030 |
gtk_widget_destroy(widget); |
| 1031 |
} |
| 1032 |
|
| 1033 |
static void |
| 1034 |
add_reset_button(option_t *opt, GtkWidget *table, gint column, gint row) |
| 1035 |
{ |
| 1036 |
GtkWidget *button = gtk_button_new_with_label(_("Reset")); |
| 1037 |
gtk_table_attach(GTK_TABLE(table), button, column, column + 1, |
| 1038 |
row, row + 1, GTK_FILL, GTK_FILL, 0, 0); |
| 1039 |
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(reset_callback), opt); |
| 1040 |
opt->reset_btn = button; |
| 1041 |
gtk_widget_show(button); |
| 1042 |
} |
| 1043 |
|
| 1044 |
static void |
| 1045 |
populate_option_table(GtkWidget *table, int p_class) |
| 1046 |
{ |
| 1047 |
unsigned int i, j; |
| 1048 |
int current_pos = 0; |
| 1049 |
GtkWidget *previous_sep = NULL; |
| 1050 |
int counts[STP_PARAMETER_LEVEL_INVALID][STP_PARAMETER_TYPE_INVALID]; |
| 1051 |
int vpos[STP_PARAMETER_LEVEL_INVALID][STP_PARAMETER_TYPE_INVALID]; |
| 1052 |
for (i = 0; i < STP_PARAMETER_LEVEL_INVALID; i++) |
| 1053 |
for (j = 0; j < STP_PARAMETER_TYPE_INVALID; j++) |
| 1054 |
{ |
| 1055 |
vpos[i][j] = 0; |
| 1056 |
counts[i][j] = 0; |
| 1057 |
} |
| 1058 |
|
| 1059 |
|
| 1060 |
gtk_container_foreach(GTK_CONTAINER(table), destroy_something, NULL); |
| 1061 |
|
| 1062 |
|
| 1063 |
for (i = 0; i < current_option_count; i++) |
| 1064 |
{ |
| 1065 |
const stp_parameter_t *desc = current_options[i].fast_desc; |
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
if (!desc->read_only && desc->p_class == (stp_parameter_class_t)p_class && |
| 1071 |
(desc->p_class != STP_PARAMETER_CLASS_CORE || |
| 1072 |
strcmp(desc->name, "PageSize") == 0)) |
| 1073 |
{ |
| 1074 |
switch (desc->p_type) |
| 1075 |
{ |
| 1076 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 1077 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 1078 |
case STP_PARAMETER_TYPE_INT: |
| 1079 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 1080 |
case STP_PARAMETER_TYPE_CURVE: |
| 1081 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 1082 |
case STP_PARAMETER_TYPE_FILE: |
| 1083 |
counts[desc->p_level][desc->p_type]++; |
| 1084 |
break; |
| 1085 |
default: |
| 1086 |
break; |
| 1087 |
} |
| 1088 |
} |
| 1089 |
} |
| 1090 |
|
| 1091 |
|
| 1092 |
for (i = 0; i <= MAXIMUM_PARAMETER_LEVEL + 1; i++) |
| 1093 |
{ |
| 1094 |
int level_count = 0; |
| 1095 |
if (i <= MAXIMUM_PARAMETER_LEVEL) |
| 1096 |
for (j = 0; j < STP_PARAMETER_TYPE_INVALID; j++) |
| 1097 |
level_count += counts[i][j]; |
| 1098 |
if (level_count > 0 && current_pos > 0) |
| 1099 |
{ |
| 1100 |
GtkWidget *sep = gtk_hseparator_new(); |
| 1101 |
gtk_table_attach (GTK_TABLE(table), sep, 0, 4, |
| 1102 |
current_pos, current_pos + 1, |
| 1103 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 1104 |
if (previous_sep) |
| 1105 |
gtk_widget_show(previous_sep); |
| 1106 |
previous_sep = sep; |
| 1107 |
current_pos++; |
| 1108 |
} |
| 1109 |
if (i <= MAXIMUM_PARAMETER_LEVEL) |
| 1110 |
for (j = 0; j < STP_PARAMETER_TYPE_INVALID; j++) |
| 1111 |
{ |
| 1112 |
vpos[i][j] = current_pos; |
| 1113 |
current_pos += counts[i][j]; |
| 1114 |
} |
| 1115 |
} |
| 1116 |
|
| 1117 |
for (i = 0; i < current_option_count; i++) |
| 1118 |
{ |
| 1119 |
option_t *opt = &(current_options[i]); |
| 1120 |
const stp_curve_t *xcurve; |
| 1121 |
const stp_parameter_t *desc = opt->fast_desc; |
| 1122 |
if (!desc->read_only && desc->p_class == (stp_parameter_class_t)p_class && |
| 1123 |
(desc->p_class != STP_PARAMETER_CLASS_CORE || |
| 1124 |
strcmp(desc->name, "PageSize") == 0)) |
| 1125 |
{ |
| 1126 |
gdouble unit_scaler; |
| 1127 |
gdouble minor_increment; |
| 1128 |
gint digits; |
| 1129 |
if (p_class == STP_PARAMETER_CLASS_OUTPUT) |
| 1130 |
opt->reset_all = FALSE; |
| 1131 |
else |
| 1132 |
opt->reset_all = TRUE; |
| 1133 |
switch (desc->p_type) |
| 1134 |
{ |
| 1135 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 1136 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1137 |
stpui_create_new_combo(opt, table, 0, |
| 1138 |
vpos[desc->p_level][desc->p_type]++, |
| 1139 |
!(desc->is_mandatory)); |
| 1140 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1141 |
stp_set_string_parameter_active(pv->v, desc->name, |
| 1142 |
STP_PARAMETER_INACTIVE); |
| 1143 |
break; |
| 1144 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 1145 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1146 |
stpui_create_scale_entry(opt, GTK_TABLE(table), 0, |
| 1147 |
vpos[desc->p_level][desc->p_type]++, |
| 1148 |
gettext(desc->text), 200, 0, |
| 1149 |
opt->info.flt.deflt, |
| 1150 |
opt->info.flt.lower, |
| 1151 |
opt->info.flt.upper, |
| 1152 |
.001, .01, 3, TRUE, 0, 0, NULL, |
| 1153 |
!(desc->is_mandatory)); |
| 1154 |
stpui_set_adjustment_tooltip(opt->info.flt.adjustment, |
| 1155 |
gettext(desc->help)); |
| 1156 |
g_signal_connect(G_OBJECT(opt->info.flt.adjustment), |
| 1157 |
"value_changed", |
| 1158 |
G_CALLBACK(color_update), opt); |
| 1159 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1160 |
stp_set_float_parameter_active(pv->v, desc->name, |
| 1161 |
STP_PARAMETER_INACTIVE); |
| 1162 |
break; |
| 1163 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 1164 |
unit_scaler = units[pv->unit].scale; |
| 1165 |
if (unit_scaler > 100) |
| 1166 |
{ |
| 1167 |
digits = 3; |
| 1168 |
minor_increment = .001; |
| 1169 |
} |
| 1170 |
else |
| 1171 |
{ |
| 1172 |
digits = 2; |
| 1173 |
minor_increment = .01; |
| 1174 |
} |
| 1175 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1176 |
stpui_create_scale_entry(opt, GTK_TABLE(table), 0, |
| 1177 |
vpos[desc->p_level][desc->p_type]++, |
| 1178 |
gettext(desc->text), 200, 0, |
| 1179 |
opt->info.flt.deflt / unit_scaler, |
| 1180 |
opt->info.flt.lower / unit_scaler, |
| 1181 |
opt->info.flt.upper / unit_scaler, |
| 1182 |
minor_increment, 1.0, |
| 1183 |
digits, TRUE, 0, 0, NULL, |
| 1184 |
!(desc->is_mandatory)); |
| 1185 |
stpui_set_adjustment_tooltip(opt->info.flt.adjustment, |
| 1186 |
gettext(desc->help)); |
| 1187 |
g_signal_connect(G_OBJECT(opt->info.flt.adjustment), |
| 1188 |
"value_changed", |
| 1189 |
G_CALLBACK(dimension_update), opt); |
| 1190 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1191 |
stp_set_dimension_parameter_active(pv->v, desc->name, |
| 1192 |
STP_PARAMETER_INACTIVE); |
| 1193 |
break; |
| 1194 |
case STP_PARAMETER_TYPE_INT: |
| 1195 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1196 |
stpui_create_scale_entry(opt, GTK_TABLE(table), 0, |
| 1197 |
vpos[desc->p_level][desc->p_type]++, |
| 1198 |
gettext(desc->text), 200, 0, |
| 1199 |
opt->info.flt.deflt, |
| 1200 |
opt->info.flt.lower, |
| 1201 |
opt->info.flt.upper, |
| 1202 |
1, 10, 0, TRUE, 0, 0, NULL, |
| 1203 |
!(desc->is_mandatory)); |
| 1204 |
stpui_set_adjustment_tooltip(opt->info.flt.adjustment, |
| 1205 |
gettext(desc->help)); |
| 1206 |
g_signal_connect(G_OBJECT(opt->info.flt.adjustment), |
| 1207 |
"value_changed", |
| 1208 |
G_CALLBACK(integer_update), opt); |
| 1209 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1210 |
stp_set_int_parameter_active(pv->v, desc->name, |
| 1211 |
STP_PARAMETER_INACTIVE); |
| 1212 |
break; |
| 1213 |
case STP_PARAMETER_TYPE_CURVE: |
| 1214 |
xcurve = stp_get_curve_parameter(pv->v, opt->fast_desc->name); |
| 1215 |
if (xcurve) |
| 1216 |
opt->info.curve.current = stp_curve_create_copy(xcurve); |
| 1217 |
else |
| 1218 |
opt->info.curve.current = NULL; |
| 1219 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1220 |
stpui_create_curve(opt, GTK_TABLE(table), 0, |
| 1221 |
vpos[desc->p_level][desc->p_type]++, |
| 1222 |
gettext(desc->text), opt->info.curve.deflt, |
| 1223 |
!(desc->is_mandatory)); |
| 1224 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1225 |
stp_set_curve_parameter_active(pv->v, desc->name, |
| 1226 |
STP_PARAMETER_INACTIVE); |
| 1227 |
break; |
| 1228 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 1229 |
opt->info.bool.current = |
| 1230 |
stp_get_boolean_parameter(pv->v, opt->fast_desc->name); |
| 1231 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1232 |
stpui_create_boolean(opt, GTK_TABLE(table), 0, |
| 1233 |
vpos[desc->p_level][desc->p_type]++, |
| 1234 |
gettext(desc->text), opt->info.bool.deflt, |
| 1235 |
!(desc->is_mandatory)); |
| 1236 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1237 |
stp_set_boolean_parameter_active(pv->v, desc->name, |
| 1238 |
STP_PARAMETER_INACTIVE); |
| 1239 |
break; |
| 1240 |
case STP_PARAMETER_TYPE_RAW: |
| 1241 |
stp_set_raw_parameter_active(pv->v, opt->fast_desc->name, |
| 1242 |
STP_PARAMETER_INACTIVE); |
| 1243 |
break; |
| 1244 |
case STP_PARAMETER_TYPE_FILE: |
| 1245 |
if (strcmp(opt->fast_desc->name, "PPDFile") != 0) |
| 1246 |
{ |
| 1247 |
add_reset_button(opt, table, 4, vpos[desc->p_level][desc->p_type]); |
| 1248 |
stpui_create_file_browser(opt, GTK_TABLE(table), 0, |
| 1249 |
vpos[desc->p_level][desc->p_type]++, |
| 1250 |
gettext(desc->text), |
| 1251 |
!(desc->is_mandatory)); |
| 1252 |
} |
| 1253 |
if (desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1254 |
stp_set_file_parameter_active(pv->v, desc->name, |
| 1255 |
STP_PARAMETER_INACTIVE); |
| 1256 |
break; |
| 1257 |
default: |
| 1258 |
break; |
| 1259 |
} |
| 1260 |
if (opt->checkbox) |
| 1261 |
g_signal_connect |
| 1262 |
(G_OBJECT(opt->checkbox), "toggled", |
| 1263 |
G_CALLBACK(set_controls_active), opt); |
| 1264 |
} |
| 1265 |
} |
| 1266 |
} |
| 1267 |
|
| 1268 |
static void |
| 1269 |
set_options_active(const char *omit) |
| 1270 |
{ |
| 1271 |
unsigned int i; |
| 1272 |
for (i = 0; i < current_option_count; i++) |
| 1273 |
{ |
| 1274 |
option_t *opt = &(current_options[i]); |
| 1275 |
const stp_parameter_t *desc = opt->fast_desc; |
| 1276 |
GtkObject *adj; |
| 1277 |
if (omit && strcmp(omit, opt->fast_desc->name) == 0) |
| 1278 |
continue; |
| 1279 |
switch (desc->p_type) |
| 1280 |
{ |
| 1281 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 1282 |
build_a_combo(opt); |
| 1283 |
break; |
| 1284 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 1285 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 1286 |
case STP_PARAMETER_TYPE_INT: |
| 1287 |
adj = opt->info.flt.adjustment; |
| 1288 |
if (adj) |
| 1289 |
{ |
| 1290 |
if (opt->is_active && desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 1291 |
{ |
| 1292 |
gtk_widget_show(GTK_WIDGET(SCALE_ENTRY_LABEL(adj))); |
| 1293 |
gtk_widget_show(GTK_WIDGET(SCALE_ENTRY_SCALE(adj))); |
| 1294 |
gtk_widget_show(GTK_WIDGET(SCALE_ENTRY_SPINBUTTON(adj))); |
| 1295 |
} |
| 1296 |
else |
| 1297 |
{ |
| 1298 |
gtk_widget_hide(GTK_WIDGET(SCALE_ENTRY_LABEL(adj))); |
| 1299 |
gtk_widget_hide(GTK_WIDGET(SCALE_ENTRY_SCALE(adj))); |
| 1300 |
gtk_widget_hide(GTK_WIDGET(SCALE_ENTRY_SPINBUTTON(adj))); |
| 1301 |
} |
| 1302 |
} |
| 1303 |
break; |
| 1304 |
case STP_PARAMETER_TYPE_CURVE: |
| 1305 |
if (opt->is_active && desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 1306 |
{ |
| 1307 |
gtk_widget_show(GTK_WIDGET(opt->info.curve.label)); |
| 1308 |
gtk_widget_show(GTK_WIDGET(opt->info.curve.button)); |
| 1309 |
} |
| 1310 |
else |
| 1311 |
{ |
| 1312 |
gtk_widget_hide(GTK_WIDGET(opt->info.curve.label)); |
| 1313 |
gtk_widget_hide(GTK_WIDGET(opt->info.curve.button)); |
| 1314 |
gtk_widget_hide(GTK_WIDGET(opt->info.curve.dialog)); |
| 1315 |
} |
| 1316 |
break; |
| 1317 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 1318 |
if (opt->is_active && desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 1319 |
{ |
| 1320 |
gtk_widget_show(GTK_WIDGET(opt->info.bool.checkbox)); |
| 1321 |
} |
| 1322 |
else |
| 1323 |
{ |
| 1324 |
gtk_widget_hide(GTK_WIDGET(opt->info.bool.checkbox)); |
| 1325 |
} |
| 1326 |
break; |
| 1327 |
case STP_PARAMETER_TYPE_FILE: |
| 1328 |
if (opt->is_active && desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 1329 |
{ |
| 1330 |
gtk_widget_show(GTK_WIDGET(opt->info.file.f_label)); |
| 1331 |
gtk_widget_show(GTK_WIDGET(opt->info.file.f_button)); |
| 1332 |
gtk_widget_show(GTK_WIDGET(opt->info.file.f_entry)); |
| 1333 |
} |
| 1334 |
else |
| 1335 |
{ |
| 1336 |
gtk_widget_hide(GTK_WIDGET(opt->info.file.f_label)); |
| 1337 |
gtk_widget_hide(GTK_WIDGET(opt->info.file.f_button)); |
| 1338 |
gtk_widget_hide(GTK_WIDGET(opt->info.file.f_entry)); |
| 1339 |
gtk_widget_hide(GTK_WIDGET(opt->info.file.f_browser)); |
| 1340 |
} |
| 1341 |
break; |
| 1342 |
default: |
| 1343 |
break; |
| 1344 |
} |
| 1345 |
if (!(opt->is_active) || desc->p_level > MAXIMUM_PARAMETER_LEVEL) |
| 1346 |
{ |
| 1347 |
if (opt->checkbox) |
| 1348 |
gtk_widget_hide(GTK_WIDGET(opt->checkbox)); |
| 1349 |
if (opt->reset_btn) |
| 1350 |
gtk_widget_hide(GTK_WIDGET(opt->reset_btn)); |
| 1351 |
} |
| 1352 |
else |
| 1353 |
{ |
| 1354 |
if (opt->checkbox) |
| 1355 |
{ |
| 1356 |
if (!desc->is_mandatory) |
| 1357 |
gtk_widget_show(GTK_WIDGET(opt->checkbox)); |
| 1358 |
else |
| 1359 |
gtk_widget_hide(GTK_WIDGET(opt->checkbox)); |
| 1360 |
} |
| 1361 |
if (opt->reset_btn) |
| 1362 |
gtk_widget_show(GTK_WIDGET(opt->reset_btn)); |
| 1363 |
} |
| 1364 |
} |
| 1365 |
} |
| 1366 |
|
| 1367 |
static void |
| 1368 |
color_button_callback(GtkWidget *widget, gpointer data) |
| 1369 |
{ |
| 1370 |
(void)widget; |
| 1371 |
(void)data; |
| 1372 |
invalidate_preview_thumbnail(); |
| 1373 |
update_adjusted_thumbnail(TRUE); |
| 1374 |
} |
| 1375 |
|
| 1376 |
static void |
| 1377 |
create_top_level_structure(void) |
| 1378 |
{ |
| 1379 |
gchar *plug_in_name; |
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
plug_in_name = g_strdup_printf (_("%s -- Print v%s"), |
| 1385 |
stpui_get_image_filename(), |
| 1386 |
VERSION " - " RELEASE_DATE); |
| 1387 |
|
| 1388 |
print_dialog = |
| 1389 |
stpui_dialog_new (plug_in_name, |
| 1390 |
GTK_WIN_POS_MOUSE, |
| 1391 |
TRUE, |
| 1392 |
|
| 1393 |
_("About"), about_callback, |
| 1394 |
NULL, NULL, NULL, FALSE, FALSE, |
| 1395 |
_("Print and\nSave Settings"), printandsave_callback, |
| 1396 |
NULL, NULL, NULL, FALSE, FALSE, |
| 1397 |
_("Save\nSettings"), save_callback, |
| 1398 |
NULL, NULL, NULL, FALSE, FALSE, |
| 1399 |
_("Print"), print_callback, |
| 1400 |
NULL, NULL, NULL, FALSE, FALSE, |
| 1401 |
_("Cancel"), gtk_widget_destroy, |
| 1402 |
NULL, (GObject *) 1, NULL, FALSE, TRUE, |
| 1403 |
|
| 1404 |
NULL); |
| 1405 |
|
| 1406 |
g_free (plug_in_name); |
| 1407 |
|
| 1408 |
g_signal_connect (G_OBJECT (print_dialog), "destroy", |
| 1409 |
G_CALLBACK (gtk_main_quit), NULL); |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
main_vbox = gtk_vbox_new (FALSE, 2); |
| 1416 |
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6); |
| 1417 |
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (print_dialog)->vbox), main_vbox, |
| 1418 |
TRUE, TRUE, 0); |
| 1419 |
gtk_widget_show (main_vbox); |
| 1420 |
|
| 1421 |
main_hbox = gtk_hbox_new (FALSE, 4); |
| 1422 |
gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0); |
| 1423 |
gtk_widget_show (main_hbox); |
| 1424 |
|
| 1425 |
right_vbox = gtk_vbox_new (FALSE, 2); |
| 1426 |
gtk_box_pack_end (GTK_BOX (main_hbox), right_vbox, FALSE, FALSE, 0); |
| 1427 |
gtk_widget_show (right_vbox); |
| 1428 |
|
| 1429 |
notebook = gtk_notebook_new (); |
| 1430 |
gtk_box_pack_start (GTK_BOX (right_vbox), notebook, TRUE, TRUE, 0); |
| 1431 |
gtk_widget_show (notebook); |
| 1432 |
} |
| 1433 |
|
| 1434 |
static gint |
| 1435 |
drawing_area_resize_callback(GtkWidget *widget, GdkEventConfigure *event) |
| 1436 |
{ |
| 1437 |
(void)widget; |
| 1438 |
|
| 1439 |
preview_size_vert = event->height - 1; |
| 1440 |
preview_size_horiz = event->width - 1; |
| 1441 |
invalidate_preview_thumbnail(); |
| 1442 |
invalidate_frame(); |
| 1443 |
preview_update(); |
| 1444 |
return 1; |
| 1445 |
} |
| 1446 |
|
| 1447 |
#pragma GCC diagnostic ignored "-Woverlength-strings" |
| 1448 |
static void |
| 1449 |
create_preview (void) |
| 1450 |
{ |
| 1451 |
GtkWidget *frame; |
| 1452 |
GtkWidget *event_box; |
| 1453 |
|
| 1454 |
frame = gtk_frame_new (_("Preview")); |
| 1455 |
gtk_box_pack_start (GTK_BOX (main_hbox), frame, TRUE, TRUE, 0); |
| 1456 |
gtk_widget_show (frame); |
| 1457 |
|
| 1458 |
preview = (GtkDrawingArea *) gtk_drawing_area_new (); |
| 1459 |
gtk_drawing_area_size(preview, preview_size_horiz + 1, preview_size_vert +1); |
| 1460 |
g_signal_connect(G_OBJECT(preview), "configure_event", |
| 1461 |
G_CALLBACK(drawing_area_resize_callback), NULL); |
| 1462 |
event_box = gtk_event_box_new (); |
| 1463 |
gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (preview)); |
| 1464 |
gtk_container_add (GTK_CONTAINER (frame), event_box); |
| 1465 |
gtk_widget_show (event_box); |
| 1466 |
|
| 1467 |
g_signal_connect (G_OBJECT (preview), "expose_event", |
| 1468 |
G_CALLBACK (preview_expose), NULL); |
| 1469 |
g_signal_connect (G_OBJECT (preview), "button_press_event", |
| 1470 |
G_CALLBACK (preview_button_callback), NULL); |
| 1471 |
g_signal_connect (G_OBJECT (preview), "button_release_event", |
| 1472 |
G_CALLBACK (preview_button_callback), NULL); |
| 1473 |
g_signal_connect (G_OBJECT (preview), "motion_notify_event", |
| 1474 |
G_CALLBACK (preview_motion_callback), NULL); |
| 1475 |
gtk_widget_show (GTK_WIDGET (preview)); |
| 1476 |
|
| 1477 |
stpui_set_help_data |
| 1478 |
(event_box, |
| 1479 |
_("Position the image on the page.\n" |
| 1480 |
"Click and drag with the primary button to position the image.\n" |
| 1481 |
"Click and drag with the second button to move the image with finer precision; " |
| 1482 |
"each unit of motion moves the image one point (1/72\")\n" |
| 1483 |
"Click and drag with the third (middle) button to move the image in units of " |
| 1484 |
"the image size.\n" |
| 1485 |
"Holding down the shift key while clicking and dragging constrains the image to " |
| 1486 |
"only horizontal or vertical motion.\n" |
| 1487 |
"If you click another button while dragging the mouse, the image will return " |
| 1488 |
"to its original position.")); |
| 1489 |
|
| 1490 |
gtk_widget_set_events (GTK_WIDGET (preview), |
| 1491 |
GDK_EXPOSURE_MASK | GDK_BUTTON_MOTION_MASK | |
| 1492 |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); |
| 1493 |
} |
| 1494 |
|
| 1495 |
static GtkWidget * |
| 1496 |
create_positioning_entry(GtkWidget *table, int hpos, int vpos, |
| 1497 |
const char *text, const char *help) |
| 1498 |
{ |
| 1499 |
return stpui_create_entry |
| 1500 |
(table, hpos, vpos, text, help, G_CALLBACK(position_callback)); |
| 1501 |
} |
| 1502 |
|
| 1503 |
static GtkWidget * |
| 1504 |
create_positioning_button(GtkWidget *box, int invalid, |
| 1505 |
const char *text, const char *help) |
| 1506 |
{ |
| 1507 |
GtkWidget *button = gtk_button_new_with_label(gettext(text)); |
| 1508 |
gtk_box_pack_start(GTK_BOX(box), button, FALSE, TRUE, 0); |
| 1509 |
gtk_widget_show(button); |
| 1510 |
stpui_set_help_data(button, help); |
| 1511 |
g_signal_connect(G_OBJECT(button), "clicked", |
| 1512 |
G_CALLBACK(position_button_callback), |
| 1513 |
gint2p(invalid)); |
| 1514 |
return button; |
| 1515 |
} |
| 1516 |
|
| 1517 |
static void |
| 1518 |
create_paper_size_frame(void) |
| 1519 |
{ |
| 1520 |
GtkWidget *frame; |
| 1521 |
GtkWidget *vbox; |
| 1522 |
GtkWidget *media_size_table; |
| 1523 |
GtkWidget *table; |
| 1524 |
int vpos = 0; |
| 1525 |
|
| 1526 |
frame = gtk_frame_new (_("Paper Size")); |
| 1527 |
gtk_box_pack_start (GTK_BOX (right_vbox), frame, FALSE, TRUE, 0); |
| 1528 |
gtk_widget_show (frame); |
| 1529 |
|
| 1530 |
vbox = gtk_vbox_new (FALSE, 2); |
| 1531 |
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); |
| 1532 |
gtk_container_add (GTK_CONTAINER (frame), vbox); |
| 1533 |
gtk_widget_show (vbox); |
| 1534 |
|
| 1535 |
table = gtk_table_new (1, 1, FALSE); |
| 1536 |
gtk_container_add (GTK_CONTAINER (vbox), table); |
| 1537 |
gtk_widget_show (table); |
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
page_size_table = gtk_table_new(1, 1, FALSE); |
| 1544 |
gtk_widget_show (page_size_table); |
| 1545 |
gtk_table_attach_defaults(GTK_TABLE(table), page_size_table, |
| 1546 |
0, 2, vpos, vpos + 1); |
| 1547 |
vpos++; |
| 1548 |
show_all_paper_sizes_button = |
| 1549 |
gtk_check_button_new_with_label(_("Show All Paper Sizes")); |
| 1550 |
gtk_table_attach_defaults |
| 1551 |
(GTK_TABLE(table), show_all_paper_sizes_button, 0, 2, vpos, vpos + 1); |
| 1552 |
gtk_toggle_button_set_active |
| 1553 |
(GTK_TOGGLE_BUTTON(show_all_paper_sizes_button), |
| 1554 |
stpui_show_all_paper_sizes); |
| 1555 |
g_signal_connect(G_OBJECT(show_all_paper_sizes_button), "toggled", |
| 1556 |
G_CALLBACK(show_all_paper_sizes_callback), NULL); |
| 1557 |
gtk_widget_show(show_all_paper_sizes_button); |
| 1558 |
vpos++; |
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
media_size_table = gtk_table_new (1, 1, FALSE); |
| 1565 |
stpui_table_attach_aligned(GTK_TABLE (table), 0, vpos++, _("Dimensions:"), |
| 1566 |
0.0, 0.5, media_size_table, 1, TRUE); |
| 1567 |
gtk_table_set_col_spacings (GTK_TABLE (media_size_table), 4); |
| 1568 |
|
| 1569 |
custom_size_width = stpui_create_entry |
| 1570 |
(media_size_table, 0, 3, _("Width:"), |
| 1571 |
_("Width of the paper that you wish to print to"), |
| 1572 |
G_CALLBACK(custom_media_size_callback)); |
| 1573 |
|
| 1574 |
custom_size_height = stpui_create_entry |
| 1575 |
(media_size_table, 2, 3, _("Height:"), |
| 1576 |
_("Height of the paper that you wish to print to"), |
| 1577 |
G_CALLBACK(custom_media_size_callback)); |
| 1578 |
|
| 1579 |
vpos++; |
| 1580 |
auto_paper_size_button = |
| 1581 |
gtk_check_button_new_with_label(_("Automatic Paper Size")); |
| 1582 |
gtk_table_attach_defaults |
| 1583 |
(GTK_TABLE(table), auto_paper_size_button, 0, 2, vpos, vpos + 1); |
| 1584 |
gtk_toggle_button_set_active |
| 1585 |
(GTK_TOGGLE_BUTTON(auto_paper_size_button), FALSE); |
| 1586 |
g_signal_connect(G_OBJECT(auto_paper_size_button), "toggled", |
| 1587 |
G_CALLBACK(auto_paper_size_callback), NULL); |
| 1588 |
} |
| 1589 |
|
| 1590 |
static void |
| 1591 |
create_copy_number_frame(void) |
| 1592 |
{ |
| 1593 |
GtkWidget *frame; |
| 1594 |
GtkWidget *vbox; |
| 1595 |
GtkWidget *event_box; |
| 1596 |
GtkAdjustment *adj; |
| 1597 |
|
| 1598 |
frame = gtk_frame_new (_("Number of Copies")); |
| 1599 |
gtk_box_pack_start (GTK_BOX (right_vbox), frame, FALSE, TRUE, 0); |
| 1600 |
gtk_widget_show (frame); |
| 1601 |
|
| 1602 |
vbox = gtk_hbox_new (FALSE, 2); |
| 1603 |
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); |
| 1604 |
gtk_container_add (GTK_CONTAINER (frame), vbox); |
| 1605 |
gtk_widget_show (vbox); |
| 1606 |
|
| 1607 |
event_box = gtk_event_box_new (); |
| 1608 |
gtk_container_add (GTK_CONTAINER (vbox), event_box); |
| 1609 |
stpui_set_help_data(event_box, |
| 1610 |
_("Select the number of copies to print; " |
| 1611 |
"a value between 1 and 100")); |
| 1612 |
gtk_widget_show (event_box); |
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
adj = (GtkAdjustment *) gtk_adjustment_new (1.0f, 1.0f, 100.0f, |
| 1619 |
1.0f, 5.0f, 0.0f); |
| 1620 |
copy_count_spin_button = gtk_spin_button_new (adj, 0, 0); |
| 1621 |
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (copy_count_spin_button), FALSE); |
| 1622 |
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (copy_count_spin_button), TRUE); |
| 1623 |
gtk_spin_button_set_update_policy (GTK_SPIN_BUTTON (copy_count_spin_button), |
| 1624 |
GTK_UPDATE_IF_VALID); |
| 1625 |
|
| 1626 |
g_signal_connect(G_OBJECT (adj), "value_changed", |
| 1627 |
G_CALLBACK (copy_count_callback), |
| 1628 |
NULL); |
| 1629 |
|
| 1630 |
gtk_container_add (GTK_CONTAINER (event_box), copy_count_spin_button); |
| 1631 |
gtk_widget_show(copy_count_spin_button); |
| 1632 |
} |
| 1633 |
|
| 1634 |
static void |
| 1635 |
create_positioning_frame (void) |
| 1636 |
{ |
| 1637 |
GtkWidget *frame; |
| 1638 |
GtkWidget *table; |
| 1639 |
GtkWidget *box; |
| 1640 |
GtkWidget *sep; |
| 1641 |
|
| 1642 |
frame = gtk_frame_new (_("Image Position")); |
| 1643 |
gtk_box_pack_start (GTK_BOX (right_vbox), frame, FALSE, TRUE, 0); |
| 1644 |
gtk_widget_show (frame); |
| 1645 |
|
| 1646 |
table = gtk_table_new (1, 1, FALSE); |
| 1647 |
gtk_table_set_col_spacings (GTK_TABLE (table), 2); |
| 1648 |
gtk_table_set_row_spacings (GTK_TABLE (table), 2); |
| 1649 |
gtk_container_set_border_width (GTK_CONTAINER (table), 4); |
| 1650 |
gtk_container_add (GTK_CONTAINER (frame), table); |
| 1651 |
gtk_widget_show (table); |
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
orientation_menu = |
| 1658 |
stpui_option_menu_new (FALSE, |
| 1659 |
_("Auto"), orientation_callback, |
| 1660 |
(gpointer) ORIENT_AUTO, NULL, NULL, 0, |
| 1661 |
_("Portrait"), orientation_callback, |
| 1662 |
(gpointer) ORIENT_PORTRAIT, NULL, NULL, 0, |
| 1663 |
_("Landscape"), orientation_callback, |
| 1664 |
(gpointer) ORIENT_LANDSCAPE, NULL, NULL, 0, |
| 1665 |
_("Upside down"), orientation_callback, |
| 1666 |
(gpointer) ORIENT_UPSIDEDOWN, NULL, NULL, 0, |
| 1667 |
_("Seascape"), orientation_callback, |
| 1668 |
(gpointer) ORIENT_SEASCAPE, NULL, NULL, 0, |
| 1669 |
NULL); |
| 1670 |
stpui_set_help_data (orientation_menu, |
| 1671 |
_("Select the orientation: portrait, landscape, " |
| 1672 |
"upside down, or seascape (upside down landscape)")); |
| 1673 |
stpui_table_attach_aligned (GTK_TABLE (table), 0, 0, _("Orientation:"), |
| 1674 |
1.0, 0.5, orientation_menu, 4, TRUE); |
| 1675 |
sep = gtk_hseparator_new (); |
| 1676 |
gtk_table_attach_defaults (GTK_TABLE (table), sep, 0, 6, 1, 2); |
| 1677 |
gtk_widget_show (sep); |
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
left_entry = create_positioning_entry |
| 1684 |
(table, 0, 2, _("Left:"), |
| 1685 |
_("Distance from the left of the paper to the image")); |
| 1686 |
#if 0 |
| 1687 |
right_entry = create_positioning_entry |
| 1688 |
(table, 0, 3, _("Right:"), |
| 1689 |
_("Distance from the left of the paper to the right of the image")); |
| 1690 |
#endif |
| 1691 |
right_border_entry = create_positioning_entry |
| 1692 |
(table, 0, 4, _("Right:"), |
| 1693 |
_("Distance from the right of the paper to the image")); |
| 1694 |
top_entry = create_positioning_entry |
| 1695 |
(table, 3, 2, _("Top:"), |
| 1696 |
_("Distance from the top of the paper to the image")); |
| 1697 |
#if 0 |
| 1698 |
bottom_entry = create_positioning_entry |
| 1699 |
(table, 3, 3, _("Bottom:"), |
| 1700 |
_("Distance from the top of the paper to bottom of the image")); |
| 1701 |
#endif |
| 1702 |
bottom_border_entry = create_positioning_entry |
| 1703 |
(table, 3, 4, _("Bottom:"), |
| 1704 |
_("Distance from the bottom of the paper to the image")); |
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
sep = gtk_hseparator_new (); |
| 1710 |
gtk_table_attach_defaults (GTK_TABLE (table), sep, 0, 6, 5, 6); |
| 1711 |
gtk_widget_show (sep); |
| 1712 |
|
| 1713 |
box = gtk_hbox_new (TRUE, 4); |
| 1714 |
stpui_table_attach_aligned (GTK_TABLE (table), 0, 7, _("Center:"), 0.5, 0.5, |
| 1715 |
box, 5, TRUE); |
| 1716 |
recenter_horizontal_button = create_positioning_button |
| 1717 |
(box, INVALID_LEFT, _("Horizontal"), |
| 1718 |
_("Center the image horizontally on the paper")); |
| 1719 |
recenter_button = create_positioning_button |
| 1720 |
(box, INVALID_LEFT | INVALID_TOP, _("Both"), |
| 1721 |
_("Center the image on the paper")); |
| 1722 |
recenter_vertical_button = create_positioning_button |
| 1723 |
(box, INVALID_TOP, _("Vertical"), |
| 1724 |
_("Center the image vertically on the paper")); |
| 1725 |
} |
| 1726 |
|
| 1727 |
static void |
| 1728 |
create_printer_dialog (void) |
| 1729 |
{ |
| 1730 |
GtkWidget *table; |
| 1731 |
GtkWidget *label; |
| 1732 |
GtkWidget *event_box; |
| 1733 |
GSList *group; |
| 1734 |
gint i; |
| 1735 |
stp_string_list_t *manufacturer_list = stp_string_list_create(); |
| 1736 |
|
| 1737 |
setup_dialog = stpui_dialog_new(_("Setup Printer"), |
| 1738 |
GTK_WIN_POS_MOUSE, TRUE, |
| 1739 |
_("OK"), setup_ok_callback, |
| 1740 |
NULL, NULL, NULL, TRUE, FALSE, |
| 1741 |
_("Cancel"), setup_cancel_callback, |
| 1742 |
NULL, (GObject *) 1, NULL, FALSE, TRUE, |
| 1743 |
NULL); |
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
table = gtk_table_new (4, 4, FALSE); |
| 1750 |
gtk_container_set_border_width (GTK_CONTAINER (table), 6); |
| 1751 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 1752 |
gtk_table_set_row_spacing (GTK_TABLE (table), 0, 150); |
| 1753 |
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (setup_dialog)->vbox), table, |
| 1754 |
TRUE, TRUE, 0); |
| 1755 |
gtk_widget_show (table); |
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
label = gtk_label_new (_("Printer Make:")); |
| 1762 |
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); |
| 1763 |
gtk_table_attach (GTK_TABLE (table), label, 1, 2, 0, 2, |
| 1764 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1765 |
gtk_widget_show (label); |
| 1766 |
|
| 1767 |
event_box = gtk_event_box_new (); |
| 1768 |
gtk_table_attach (GTK_TABLE (table), event_box, 2, 4, 0, 2, |
| 1769 |
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); |
| 1770 |
gtk_widget_show (event_box); |
| 1771 |
|
| 1772 |
stpui_set_help_data (event_box, _("Select the make of your printer")); |
| 1773 |
|
| 1774 |
manufacturer_crawler = gtk_scrolled_window_new (NULL, NULL); |
| 1775 |
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (manufacturer_crawler), |
| 1776 |
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 1777 |
gtk_container_add (GTK_CONTAINER (event_box), manufacturer_crawler); |
| 1778 |
gtk_widget_show (manufacturer_crawler); |
| 1779 |
|
| 1780 |
manufacturer_clist = gtk_clist_new (1); |
| 1781 |
gtk_widget_set_usize (manufacturer_clist, 200, 0); |
| 1782 |
gtk_clist_set_selection_mode(GTK_CLIST(manufacturer_clist),GTK_SELECTION_SINGLE); |
| 1783 |
gtk_container_add (GTK_CONTAINER (manufacturer_crawler), manufacturer_clist); |
| 1784 |
gtk_widget_show (manufacturer_clist); |
| 1785 |
|
| 1786 |
g_signal_connect (G_OBJECT (manufacturer_clist), "select_row", |
| 1787 |
G_CALLBACK (manufacturer_callback), NULL); |
| 1788 |
|
| 1789 |
|
| 1790 |
label = gtk_label_new (_("Printer Model:")); |
| 1791 |
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); |
| 1792 |
gtk_table_attach (GTK_TABLE (table), label, 4, 5, 0, 2, |
| 1793 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1794 |
gtk_widget_show (label); |
| 1795 |
|
| 1796 |
event_box = gtk_event_box_new (); |
| 1797 |
gtk_table_attach (GTK_TABLE (table), event_box, 5, 7, 0, 2, |
| 1798 |
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, 0, 0); |
| 1799 |
gtk_widget_show (event_box); |
| 1800 |
|
| 1801 |
stpui_set_help_data (event_box, _("Select your printer model")); |
| 1802 |
|
| 1803 |
printer_crawler = gtk_scrolled_window_new (NULL, NULL); |
| 1804 |
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (printer_crawler), |
| 1805 |
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 1806 |
gtk_container_add (GTK_CONTAINER (event_box), printer_crawler); |
| 1807 |
gtk_widget_show (printer_crawler); |
| 1808 |
|
| 1809 |
printer_driver = gtk_clist_new (1); |
| 1810 |
gtk_widget_set_usize (printer_driver, 200, 0); |
| 1811 |
gtk_clist_set_selection_mode(GTK_CLIST(printer_driver),GTK_SELECTION_SINGLE); |
| 1812 |
gtk_container_add (GTK_CONTAINER (printer_crawler), printer_driver); |
| 1813 |
gtk_widget_show (printer_driver); |
| 1814 |
|
| 1815 |
g_signal_connect (G_OBJECT (printer_driver), "select_row", |
| 1816 |
G_CALLBACK (print_driver_callback), NULL); |
| 1817 |
|
| 1818 |
|
| 1819 |
for (i = 0; i < stp_printer_model_count (); i ++) |
| 1820 |
{ |
| 1821 |
const stp_printer_t *the_printer = stp_get_printer_by_index (i); |
| 1822 |
|
| 1823 |
if (strcmp(stp_printer_get_long_name (the_printer), "") != 0 && |
| 1824 |
strcmp(stp_printer_get_family(the_printer), "raw") != 0) |
| 1825 |
{ |
| 1826 |
const gchar *make = stp_printer_get_manufacturer(the_printer); |
| 1827 |
if (! stp_string_list_is_present(manufacturer_list, make)) |
| 1828 |
stp_string_list_add_string_unsafe(manufacturer_list, make, make); |
| 1829 |
} |
| 1830 |
} |
| 1831 |
|
| 1832 |
for (i = 0; i < (int)stp_string_list_count(manufacturer_list); i++) |
| 1833 |
{ |
| 1834 |
const stp_param_string_t *param = |
| 1835 |
stp_string_list_param(manufacturer_list, i); |
| 1836 |
gchar *xname = g_strdup(param->name); |
| 1837 |
gtk_clist_insert(GTK_CLIST(manufacturer_clist), i, &xname); |
| 1838 |
gtk_clist_set_row_data_full(GTK_CLIST(manufacturer_clist), i, xname, |
| 1839 |
g_free); |
| 1840 |
} |
| 1841 |
stp_string_list_destroy(manufacturer_list); |
| 1842 |
gtk_clist_sort(GTK_CLIST(manufacturer_clist)); |
| 1843 |
build_printer_driver_clist(); |
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
ppd_label = gtk_label_new (_("PPD File:")); |
| 1850 |
gtk_misc_set_alignment (GTK_MISC (ppd_label), 1.0, 0.5); |
| 1851 |
gtk_table_attach (GTK_TABLE (table), ppd_label, 1, 2, 3, 4, |
| 1852 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1853 |
gtk_widget_show (ppd_label); |
| 1854 |
|
| 1855 |
ppd_box = gtk_hbox_new (FALSE, 8); |
| 1856 |
gtk_table_attach (GTK_TABLE (table), ppd_box, 2, 7, 3, 4, |
| 1857 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1858 |
|
| 1859 |
ppd_file = gtk_entry_new (); |
| 1860 |
g_signal_connect(G_OBJECT(ppd_file), "activate", |
| 1861 |
G_CALLBACK(ppd_file_callback), NULL); |
| 1862 |
gtk_box_pack_start (GTK_BOX (ppd_box), ppd_file, TRUE, TRUE, 0); |
| 1863 |
gtk_widget_show (ppd_file); |
| 1864 |
|
| 1865 |
stpui_set_help_data(ppd_file,_("Enter the correct PPD filename for your printer")); |
| 1866 |
|
| 1867 |
ppd_button = gtk_button_new_with_label (_("Browse")); |
| 1868 |
gtk_misc_set_padding (GTK_MISC (GTK_BIN (ppd_button)->child), 2, 0); |
| 1869 |
gtk_box_pack_start (GTK_BOX (ppd_box), ppd_button, FALSE, FALSE, 0); |
| 1870 |
gtk_widget_show (ppd_button); |
| 1871 |
gtk_widget_show (ppd_box); |
| 1872 |
|
| 1873 |
stpui_set_help_data(ppd_button, |
| 1874 |
_("Choose the correct PPD filename for your printer")); |
| 1875 |
g_signal_connect (G_OBJECT (ppd_button), "clicked", |
| 1876 |
G_CALLBACK (ppd_browse_callback), NULL); |
| 1877 |
|
| 1878 |
ppd_model_label = gtk_label_new (_("Printer Model:")); |
| 1879 |
gtk_misc_set_alignment (GTK_MISC (ppd_model_label), 1.0, 0.5); |
| 1880 |
gtk_table_attach (GTK_TABLE (table), ppd_model_label, 1, 2, 4, 5, |
| 1881 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1882 |
gtk_widget_show (ppd_model_label); |
| 1883 |
|
| 1884 |
ppd_model = gtk_label_new (""); |
| 1885 |
gtk_misc_set_alignment (GTK_MISC (ppd_model), 0.0, 0.5); |
| 1886 |
gtk_table_attach (GTK_TABLE (table), ppd_model, 2, 7, 4, 5, |
| 1887 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1888 |
gtk_widget_show (ppd_model); |
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
|
| 1895 |
group = NULL; |
| 1896 |
for (i = 0; i < command_options_count; i++) |
| 1897 |
group = stpui_create_radio_button(&(command_options[i]), group, table, |
| 1898 |
0, i > 0 ? i + 6 : i + 5, |
| 1899 |
G_CALLBACK(command_type_callback)); |
| 1900 |
|
| 1901 |
standard_cmd_entry = gtk_entry_new(); |
| 1902 |
gtk_table_attach (GTK_TABLE (table), standard_cmd_entry, 2, 7, 6, 7, |
| 1903 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1904 |
gtk_entry_set_editable(GTK_ENTRY(standard_cmd_entry), FALSE); |
| 1905 |
gtk_widget_set_sensitive(standard_cmd_entry, FALSE); |
| 1906 |
gtk_widget_show (standard_cmd_entry); |
| 1907 |
|
| 1908 |
queue_combo = gtk_combo_new (); |
| 1909 |
event_box = gtk_event_box_new (); |
| 1910 |
gtk_container_add (GTK_CONTAINER (event_box), queue_combo); |
| 1911 |
gtk_widget_show (queue_combo); |
| 1912 |
gtk_widget_show (event_box); |
| 1913 |
build_queue_combo(); |
| 1914 |
|
| 1915 |
stpui_set_help_data(event_box, |
| 1916 |
_("Select the name of the output queue (not the type, " |
| 1917 |
"or model, of printer) that you wish to print to")); |
| 1918 |
label = gtk_label_new(_("Printer Queue:")); |
| 1919 |
gtk_widget_show(label); |
| 1920 |
gtk_table_attach (GTK_TABLE (table), label, 2, 3, 5, 6, |
| 1921 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1922 |
gtk_table_attach (GTK_TABLE (table), event_box, 3, 7, 5, 6, |
| 1923 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1924 |
|
| 1925 |
custom_command_entry = gtk_entry_new (); |
| 1926 |
gtk_table_attach (GTK_TABLE (table), custom_command_entry, 2, 7, 7, 8, |
| 1927 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1928 |
g_signal_connect(G_OBJECT(custom_command_entry), "activate", |
| 1929 |
G_CALLBACK(setup_callback), NULL); |
| 1930 |
gtk_widget_set_sensitive(custom_command_entry, FALSE); |
| 1931 |
gtk_widget_show (custom_command_entry); |
| 1932 |
|
| 1933 |
stpui_set_help_data |
| 1934 |
(custom_command_entry, _("Enter the correct command to print to your printer. ")); |
| 1935 |
|
| 1936 |
file_entry = gtk_entry_new (); |
| 1937 |
gtk_table_attach (GTK_TABLE (table), file_entry, 2, 6, 8, 9, |
| 1938 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1939 |
g_signal_connect(G_OBJECT(file_entry), "activate", |
| 1940 |
G_CALLBACK(setup_callback), NULL); |
| 1941 |
gtk_widget_show (file_entry); |
| 1942 |
|
| 1943 |
gtk_widget_set_sensitive(file_entry, FALSE); |
| 1944 |
stpui_set_help_data |
| 1945 |
(file_entry, _("Enter the file to print to. ")); |
| 1946 |
|
| 1947 |
file_button = gtk_button_new_with_label (_("Browse")); |
| 1948 |
|
| 1949 |
gtk_table_attach (GTK_TABLE (table), file_button, 6, 7, 8, 9, |
| 1950 |
GTK_FILL, GTK_FILL, 0, 0); |
| 1951 |
gtk_widget_show (file_button); |
| 1952 |
|
| 1953 |
stpui_set_help_data(file_button, _("File to print to")); |
| 1954 |
g_signal_connect (G_OBJECT (file_button), "clicked", |
| 1955 |
G_CALLBACK (file_browse_callback), NULL); |
| 1956 |
|
| 1957 |
|
| 1958 |
|
| 1959 |
|
| 1960 |
|
| 1961 |
file_browser = gtk_file_selection_new (_("Print To File")); |
| 1962 |
|
| 1963 |
g_signal_connect |
| 1964 |
(G_OBJECT (GTK_FILE_SELECTION (file_browser)->ok_button), "clicked", |
| 1965 |
G_CALLBACK (file_ok_callback), NULL); |
| 1966 |
g_signal_connect |
| 1967 |
(G_OBJECT (GTK_FILE_SELECTION (file_browser)->cancel_button), "clicked", |
| 1968 |
G_CALLBACK (file_cancel_callback), NULL); |
| 1969 |
|
| 1970 |
|
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
ppd_browser = gtk_file_selection_new (_("PPD File")); |
| 1975 |
gtk_file_selection_hide_fileop_buttons (GTK_FILE_SELECTION (ppd_browser)); |
| 1976 |
|
| 1977 |
g_signal_connect |
| 1978 |
(G_OBJECT (GTK_FILE_SELECTION (ppd_browser)->ok_button), "clicked", |
| 1979 |
G_CALLBACK (ppd_ok_callback), NULL); |
| 1980 |
g_signal_connect_object |
| 1981 |
(G_OBJECT (GTK_FILE_SELECTION (ppd_browser)->cancel_button), "clicked", |
| 1982 |
G_CALLBACK (gtk_widget_hide), G_OBJECT (ppd_browser), G_CONNECT_SWAPPED); |
| 1983 |
} |
| 1984 |
|
| 1985 |
static void |
| 1986 |
create_new_printer_dialog (void) |
| 1987 |
{ |
| 1988 |
GtkWidget *table; |
| 1989 |
|
| 1990 |
new_printer_dialog = |
| 1991 |
stpui_dialog_new (_("Define New Printer"), |
| 1992 |
GTK_WIN_POS_MOUSE, FALSE, |
| 1993 |
_("OK"), new_printer_ok_callback, |
| 1994 |
NULL, NULL, NULL, TRUE, FALSE, |
| 1995 |
_("Cancel"), gtk_widget_hide, |
| 1996 |
NULL, (GObject *) 1, NULL, FALSE, TRUE, |
| 1997 |
NULL); |
| 1998 |
|
| 1999 |
table = gtk_table_new (1, 1, FALSE); |
| 2000 |
gtk_container_set_border_width (GTK_CONTAINER (table), 6); |
| 2001 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2002 |
gtk_table_set_row_spacings (GTK_TABLE (table), 8); |
| 2003 |
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (new_printer_dialog)->vbox), table, |
| 2004 |
FALSE, FALSE, 0); |
| 2005 |
gtk_widget_show (table); |
| 2006 |
|
| 2007 |
new_printer_entry = gtk_entry_new (); |
| 2008 |
gtk_entry_set_max_length (GTK_ENTRY (new_printer_entry), 127); |
| 2009 |
stpui_table_attach_aligned(GTK_TABLE (table), 0, 0, _("Printer Name:"), 1.0, |
| 2010 |
0.5, new_printer_entry, 1, TRUE); |
| 2011 |
|
| 2012 |
stpui_set_help_data(new_printer_entry, |
| 2013 |
_("Enter the name you wish to give this logical printer")); |
| 2014 |
g_signal_connect (G_OBJECT (new_printer_entry), "activate", |
| 2015 |
G_CALLBACK (new_printer_ok_callback), NULL); |
| 2016 |
} |
| 2017 |
|
| 2018 |
static void |
| 2019 |
create_about_dialog (void) |
| 2020 |
{ |
| 2021 |
GtkWidget *label; |
| 2022 |
about_dialog = |
| 2023 |
stpui_dialog_new (_("About Gutenprint " PLUG_IN_VERSION), |
| 2024 |
GTK_WIN_POS_MOUSE, FALSE, |
| 2025 |
_("OK"), gtk_widget_hide, |
| 2026 |
NULL, (GObject *) 1, NULL, TRUE, TRUE, |
| 2027 |
NULL); |
| 2028 |
|
| 2029 |
label = gtk_label_new |
| 2030 |
(_("Gutenprint Version " PLUG_IN_VERSION "\n" |
| 2031 |
"\n" |
| 2032 |
"Copyright (C) 1997-2003 Michael Sweet, Robert Krawitz,\n" |
| 2033 |
"and the rest of the Gutenprint Development Team.\n" |
| 2034 |
"\n" |
| 2035 |
"Please visit our web site at http://gimp-print.sourceforge.net.\n" |
| 2036 |
"\n" |
| 2037 |
"This program is free software; you can redistribute it and/or modify\n" |
| 2038 |
"it under the terms of the GNU General Public License as published by\n" |
| 2039 |
"the Free Software Foundation; either version 2 of the License, or\n" |
| 2040 |
"(at your option) any later version.\n" |
| 2041 |
"\n" |
| 2042 |
"This program is distributed in the hope that it will be useful,\n" |
| 2043 |
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" |
| 2044 |
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" |
| 2045 |
"GNU General Public License for more details.\n" |
| 2046 |
"\n" |
| 2047 |
"You should have received a copy of the GNU General Public License\n" |
| 2048 |
"along with this program. If not, see <https://www.gnu.org/licenses/>.\n" |
| 2049 |
"USA\n")); |
| 2050 |
|
| 2051 |
gtk_misc_set_padding (GTK_MISC (label), 12, 4); |
| 2052 |
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (about_dialog)->vbox), label, |
| 2053 |
FALSE, FALSE, 0); |
| 2054 |
gtk_widget_show (label); |
| 2055 |
} |
| 2056 |
|
| 2057 |
static void |
| 2058 |
create_printer_settings_frame (void) |
| 2059 |
{ |
| 2060 |
GtkWidget *table; |
| 2061 |
GtkWidget *sep; |
| 2062 |
GtkWidget *printer_hbox; |
| 2063 |
GtkWidget *button; |
| 2064 |
GtkWidget *event_box; |
| 2065 |
GtkWidget *scrolled_window; |
| 2066 |
gint vpos = 0; |
| 2067 |
|
| 2068 |
create_printer_dialog (); |
| 2069 |
create_about_dialog (); |
| 2070 |
create_new_printer_dialog (); |
| 2071 |
|
| 2072 |
table = gtk_table_new (1, 1, FALSE); |
| 2073 |
gtk_table_set_col_spacings (GTK_TABLE (table), 2); |
| 2074 |
gtk_table_set_row_spacings (GTK_TABLE (table), 2); |
| 2075 |
gtk_container_set_border_width (GTK_CONTAINER (table), 4); |
| 2076 |
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), table, |
| 2077 |
gtk_label_new (_("Printer Settings"))); |
| 2078 |
gtk_widget_show (table); |
| 2079 |
|
| 2080 |
|
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
printer_combo = gtk_combo_new (); |
| 2085 |
event_box = gtk_event_box_new (); |
| 2086 |
gtk_container_add (GTK_CONTAINER (event_box), printer_combo); |
| 2087 |
gtk_widget_show (printer_combo); |
| 2088 |
|
| 2089 |
stpui_set_help_data(event_box, |
| 2090 |
_("Select the name of the printer (not the type, " |
| 2091 |
"or model, of printer) that you wish to print to")); |
| 2092 |
stpui_table_attach_aligned(GTK_TABLE (table), 0, vpos++, _("Printer Name:"), |
| 2093 |
0.0, 0.5, event_box, 1, TRUE); |
| 2094 |
printer_model_label = gtk_label_new (""); |
| 2095 |
stpui_table_attach_aligned(GTK_TABLE (table), 0, vpos++, _("Printer Model:"), |
| 2096 |
0.0, 0.0, printer_model_label, 1, TRUE); |
| 2097 |
printer_hbox = gtk_hbox_new (TRUE, 4); |
| 2098 |
gtk_table_attach (GTK_TABLE (table), printer_hbox, |
| 2099 |
1, 4, vpos, vpos + 1, GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 2100 |
vpos += 2; |
| 2101 |
gtk_widget_show (printer_hbox); |
| 2102 |
|
| 2103 |
|
| 2104 |
|
| 2105 |
|
| 2106 |
|
| 2107 |
button = gtk_button_new_with_label (_("Setup Printer...")); |
| 2108 |
stpui_set_help_data(button, |
| 2109 |
_("Choose the printer model, PPD file, and command " |
| 2110 |
"that is used to print to this printer")); |
| 2111 |
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0); |
| 2112 |
gtk_box_pack_start (GTK_BOX (printer_hbox), button, FALSE, TRUE, 0); |
| 2113 |
gtk_widget_show (button); |
| 2114 |
|
| 2115 |
g_signal_connect (G_OBJECT (button), "clicked", |
| 2116 |
G_CALLBACK (setup_open_callback), NULL); |
| 2117 |
|
| 2118 |
|
| 2119 |
|
| 2120 |
|
| 2121 |
|
| 2122 |
button = gtk_button_new_with_label (_("New Printer...")); |
| 2123 |
stpui_set_help_data (button, _("Define a new logical printer. This can be used to " |
| 2124 |
"name a collection of settings that you wish to " |
| 2125 |
"remember for future use.")); |
| 2126 |
gtk_box_pack_start (GTK_BOX (printer_hbox), button, FALSE, TRUE, 0); |
| 2127 |
gtk_widget_show (button); |
| 2128 |
|
| 2129 |
g_signal_connect (G_OBJECT (button), "clicked", |
| 2130 |
G_CALLBACK (new_printer_open_callback), NULL); |
| 2131 |
|
| 2132 |
sep = gtk_hseparator_new (); |
| 2133 |
gtk_table_attach (GTK_TABLE (table), sep, 0, 5, vpos, vpos + 1, |
| 2134 |
GTK_EXPAND|GTK_FILL, GTK_FILL, 0, 0); |
| 2135 |
gtk_widget_show (sep); |
| 2136 |
vpos++; |
| 2137 |
|
| 2138 |
printer_features_table = gtk_table_new(1, 1, FALSE); |
| 2139 |
gtk_table_set_col_spacings (GTK_TABLE (printer_features_table), 2); |
| 2140 |
gtk_table_set_row_spacings (GTK_TABLE (printer_features_table), 0); |
| 2141 |
gtk_widget_show (printer_features_table); |
| 2142 |
|
| 2143 |
scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 2144 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
| 2145 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
| 2146 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
| 2147 |
printer_features_table); |
| 2148 |
gtk_table_attach_defaults(GTK_TABLE(table), scrolled_window, |
| 2149 |
0, 6, vpos, vpos + 1); |
| 2150 |
gtk_widget_show(scrolled_window); |
| 2151 |
vpos++; |
| 2152 |
|
| 2153 |
button = gtk_button_new_with_label (_("Set Printer Option Defaults")); |
| 2154 |
stpui_set_help_data (button, _("Set all printer options to their defaults")); |
| 2155 |
gtk_table_attach(GTK_TABLE(table), button, 0, 6, vpos, vpos + 1, |
| 2156 |
GTK_EXPAND|GTK_FILL, GTK_SHRINK|GTK_FILL, 0, 0); |
| 2157 |
gtk_widget_show (button); |
| 2158 |
|
| 2159 |
g_signal_connect (G_OBJECT (button), "clicked", |
| 2160 |
G_CALLBACK (set_printer_defaults), NULL); |
| 2161 |
|
| 2162 |
} |
| 2163 |
|
| 2164 |
static void |
| 2165 |
create_scaling_frame (void) |
| 2166 |
{ |
| 2167 |
GtkWidget *frame; |
| 2168 |
GtkWidget *vbox; |
| 2169 |
GtkWidget *hbox; |
| 2170 |
GtkWidget *table; |
| 2171 |
GtkWidget *box; |
| 2172 |
GtkWidget *label; |
| 2173 |
GtkWidget *event_box; |
| 2174 |
GtkWidget *sep; |
| 2175 |
GSList *group; |
| 2176 |
|
| 2177 |
frame = gtk_frame_new (_("Image Size")); |
| 2178 |
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0); |
| 2179 |
gtk_widget_show (frame); |
| 2180 |
|
| 2181 |
hbox = gtk_hbox_new (FALSE, 2); |
| 2182 |
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); |
| 2183 |
gtk_container_add (GTK_CONTAINER (frame), hbox); |
| 2184 |
gtk_widget_show (hbox); |
| 2185 |
|
| 2186 |
vbox = gtk_vbox_new (FALSE, 2); |
| 2187 |
|
| 2188 |
gtk_container_add (GTK_CONTAINER (hbox), vbox); |
| 2189 |
gtk_widget_show (vbox); |
| 2190 |
|
| 2191 |
table = gtk_table_new (1, 1, FALSE); |
| 2192 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2193 |
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); |
| 2194 |
gtk_widget_show (table); |
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
|
| 2200 |
|
| 2201 |
scaling_adjustment = |
| 2202 |
stpui_scale_entry_new (GTK_TABLE (table), 0, 0, _("Scaling:"), 100, 75, |
| 2203 |
100.0, minimum_image_percent, 100.0, |
| 2204 |
1.0, 10.0, 2, TRUE, 0, 0, NULL); |
| 2205 |
stpui_set_adjustment_tooltip(scaling_adjustment, |
| 2206 |
_("Set the scale (size) of the image")); |
| 2207 |
g_signal_connect (G_OBJECT (scaling_adjustment), "value_changed", |
| 2208 |
G_CALLBACK (scaling_update), NULL); |
| 2209 |
|
| 2210 |
box = gtk_hbox_new (FALSE, 4); |
| 2211 |
gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0); |
| 2212 |
gtk_widget_show (box); |
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
|
| 2218 |
table = gtk_table_new (1, 1, FALSE); |
| 2219 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2220 |
gtk_box_pack_start (GTK_BOX (box), table, FALSE, FALSE, 0); |
| 2221 |
gtk_widget_show (table); |
| 2222 |
|
| 2223 |
event_box = gtk_event_box_new (); |
| 2224 |
gtk_table_attach (GTK_TABLE (table), event_box, 0, 1, 0, 1, |
| 2225 |
GTK_FILL, GTK_FILL, 0, 0); |
| 2226 |
gtk_widget_show (event_box); |
| 2227 |
|
| 2228 |
label = gtk_label_new (_("Scale by:")); |
| 2229 |
gtk_container_add (GTK_CONTAINER (event_box), label); |
| 2230 |
gtk_widget_show (label); |
| 2231 |
|
| 2232 |
stpui_set_help_data(event_box, |
| 2233 |
_("Select whether scaling is measured as percent of " |
| 2234 |
"available page size or number of output dots per inch")); |
| 2235 |
|
| 2236 |
scaling_percent = gtk_radio_button_new_with_label (NULL, _("Percent")); |
| 2237 |
group = gtk_radio_button_group (GTK_RADIO_BUTTON (scaling_percent)); |
| 2238 |
stpui_table_attach_aligned(GTK_TABLE (table), 0, 0, NULL, 0.5, 0.5, |
| 2239 |
scaling_percent, 2, TRUE); |
| 2240 |
|
| 2241 |
stpui_set_help_data(scaling_percent, _("Scale the print to the size of the page")); |
| 2242 |
g_signal_connect (G_OBJECT (scaling_percent), "toggled", |
| 2243 |
G_CALLBACK (scaling_callback), NULL); |
| 2244 |
|
| 2245 |
scaling_ppi = gtk_radio_button_new_with_label (group, _("PPI")); |
| 2246 |
stpui_table_attach_aligned(GTK_TABLE (table), 2, 0, NULL, 0.5, 0.5, |
| 2247 |
scaling_ppi, 1, TRUE); |
| 2248 |
|
| 2249 |
stpui_set_help_data(scaling_ppi, |
| 2250 |
_("Scale the print to the number of dots per inch")); |
| 2251 |
g_signal_connect (G_OBJECT (scaling_ppi), "toggled", |
| 2252 |
G_CALLBACK (scaling_callback), NULL); |
| 2253 |
|
| 2254 |
sep = gtk_vseparator_new (); |
| 2255 |
gtk_box_pack_start (GTK_BOX (hbox), sep, FALSE, FALSE, 8); |
| 2256 |
gtk_widget_show (sep); |
| 2257 |
|
| 2258 |
|
| 2259 |
|
| 2260 |
|
| 2261 |
|
| 2262 |
table = gtk_table_new (1, 1, FALSE); |
| 2263 |
gtk_table_set_col_spacings (GTK_TABLE (table), 2); |
| 2264 |
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 0); |
| 2265 |
gtk_widget_show (table); |
| 2266 |
|
| 2267 |
width_entry = create_positioning_entry |
| 2268 |
(table, 0, 0, _("Width:"), _("Set the width of the print")); |
| 2269 |
height_entry = create_positioning_entry |
| 2270 |
(table, 0, 1, _("Height:"), _("Set the height of the print")); |
| 2271 |
|
| 2272 |
|
| 2273 |
|
| 2274 |
|
| 2275 |
|
| 2276 |
scaling_image = gtk_button_new_with_label (_("Use Original\nImage Size")); |
| 2277 |
gtk_misc_set_padding (GTK_MISC (GTK_BIN (scaling_image)->child), 2, 2); |
| 2278 |
gtk_box_pack_end (GTK_BOX (hbox), scaling_image, FALSE, FALSE, 0); |
| 2279 |
gtk_widget_show (scaling_image); |
| 2280 |
|
| 2281 |
stpui_set_help_data(scaling_image, |
| 2282 |
_("Set the print size to the size of the image")); |
| 2283 |
g_signal_connect (G_OBJECT (scaling_image), "clicked", |
| 2284 |
G_CALLBACK (scaling_callback), NULL); |
| 2285 |
} |
| 2286 |
|
| 2287 |
|
| 2288 |
|
| 2289 |
|
| 2290 |
|
| 2291 |
|
| 2292 |
|
| 2293 |
|
| 2294 |
static void |
| 2295 |
create_color_adjust_window (void) |
| 2296 |
{ |
| 2297 |
GtkWidget *table; |
| 2298 |
GtkWidget *label; |
| 2299 |
GtkWidget *event_box; |
| 2300 |
GtkWidget *scrolled_window; |
| 2301 |
gint x, y; |
| 2302 |
|
| 2303 |
initialize_thumbnail(); |
| 2304 |
|
| 2305 |
color_adjust_dialog = |
| 2306 |
stpui_dialog_new(_("Print Color Adjust"), |
| 2307 |
GTK_WIN_POS_MOUSE, TRUE, |
| 2308 |
|
| 2309 |
_("Set Defaults"), set_color_defaults, |
| 2310 |
NULL, NULL, NULL, FALSE, FALSE, |
| 2311 |
_("Close"), gtk_widget_hide, |
| 2312 |
NULL, (GObject *) 1, NULL, TRUE, TRUE, |
| 2313 |
NULL); |
| 2314 |
|
| 2315 |
table = gtk_table_new (1, 1, FALSE); |
| 2316 |
gtk_container_set_border_width (GTK_CONTAINER (table), 6); |
| 2317 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2318 |
gtk_table_set_row_spacings (GTK_TABLE (table), 0); |
| 2319 |
|
| 2320 |
|
| 2321 |
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (color_adjust_dialog)->vbox), |
| 2322 |
table, TRUE, TRUE, 0); |
| 2323 |
gtk_widget_show (table); |
| 2324 |
|
| 2325 |
|
| 2326 |
|
| 2327 |
|
| 2328 |
|
| 2329 |
event_box = gtk_event_box_new (); |
| 2330 |
gtk_widget_show (GTK_WIDGET (event_box)); |
| 2331 |
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (event_box), |
| 2332 |
0, 1, 0, 1, 0, 0, 0, 0); |
| 2333 |
|
| 2334 |
swatch = (GtkDrawingArea *) gtk_drawing_area_new (); |
| 2335 |
gtk_widget_set_events (GTK_WIDGET (swatch), GDK_EXPOSURE_MASK); |
| 2336 |
gtk_drawing_area_size (swatch, thumbnail_w, thumbnail_h); |
| 2337 |
gtk_container_add (GTK_CONTAINER (event_box), GTK_WIDGET (swatch)); |
| 2338 |
gtk_widget_show (GTK_WIDGET (swatch)); |
| 2339 |
|
| 2340 |
stpui_set_help_data (GTK_WIDGET (event_box), _("Image preview")); |
| 2341 |
g_signal_connect (G_OBJECT (swatch), "expose_event", |
| 2342 |
G_CALLBACK (redraw_color_swatch), |
| 2343 |
NULL); |
| 2344 |
|
| 2345 |
event_box = gtk_event_box_new (); |
| 2346 |
gtk_widget_show (GTK_WIDGET (event_box)); |
| 2347 |
gtk_table_attach (GTK_TABLE (table), GTK_WIDGET (event_box), |
| 2348 |
1, 2, 0, 1, 0, 0, 0, 0); |
| 2349 |
|
| 2350 |
output_color_vbox = gtk_vbox_new(TRUE, 0); |
| 2351 |
gtk_container_add(GTK_CONTAINER(event_box), output_color_vbox); |
| 2352 |
gtk_widget_show(GTK_WIDGET(output_color_vbox)); |
| 2353 |
|
| 2354 |
label = gtk_label_new(_("View Output Channels:")); |
| 2355 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), label, TRUE, TRUE, 0); |
| 2356 |
gtk_widget_show(GTK_WIDGET(label)); |
| 2357 |
|
| 2358 |
cyan_button = gtk_toggle_button_new_with_label(_("Cyan")); |
| 2359 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), cyan_button, TRUE, TRUE, 0); |
| 2360 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cyan_button), TRUE); |
| 2361 |
gtk_widget_show(GTK_WIDGET(cyan_button)); |
| 2362 |
g_signal_connect (G_OBJECT (cyan_button), "toggled", |
| 2363 |
G_CALLBACK (color_button_callback), NULL); |
| 2364 |
|
| 2365 |
magenta_button = gtk_toggle_button_new_with_label(_("Magenta")); |
| 2366 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), magenta_button, TRUE, TRUE,0); |
| 2367 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(magenta_button), TRUE); |
| 2368 |
gtk_widget_show(GTK_WIDGET(magenta_button)); |
| 2369 |
g_signal_connect (G_OBJECT (magenta_button), "toggled", |
| 2370 |
G_CALLBACK (color_button_callback), NULL); |
| 2371 |
|
| 2372 |
yellow_button = gtk_toggle_button_new_with_label(_("Yellow")); |
| 2373 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), yellow_button, TRUE, TRUE, 0); |
| 2374 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(yellow_button), TRUE); |
| 2375 |
gtk_widget_show(GTK_WIDGET(yellow_button)); |
| 2376 |
g_signal_connect (G_OBJECT (yellow_button), "toggled", |
| 2377 |
G_CALLBACK (color_button_callback), NULL); |
| 2378 |
|
| 2379 |
black_button = gtk_toggle_button_new_with_label(_("Black")); |
| 2380 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), black_button, TRUE, TRUE, 0); |
| 2381 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(black_button), TRUE); |
| 2382 |
gtk_widget_show(GTK_WIDGET(black_button)); |
| 2383 |
g_signal_connect (G_OBJECT (black_button), "toggled", |
| 2384 |
G_CALLBACK (color_button_callback), NULL); |
| 2385 |
|
| 2386 |
red_button = gtk_toggle_button_new_with_label(_("Red")); |
| 2387 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), red_button, TRUE, TRUE, 0); |
| 2388 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(red_button), TRUE); |
| 2389 |
gtk_widget_show(GTK_WIDGET(red_button)); |
| 2390 |
g_signal_connect (G_OBJECT (red_button), "toggled", |
| 2391 |
G_CALLBACK (color_button_callback), NULL); |
| 2392 |
|
| 2393 |
green_button = gtk_toggle_button_new_with_label(_("Green")); |
| 2394 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), green_button, TRUE, TRUE,0); |
| 2395 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(green_button), TRUE); |
| 2396 |
gtk_widget_show(GTK_WIDGET(green_button)); |
| 2397 |
g_signal_connect (G_OBJECT (green_button), "toggled", |
| 2398 |
G_CALLBACK (color_button_callback), NULL); |
| 2399 |
|
| 2400 |
blue_button = gtk_toggle_button_new_with_label(_("Blue")); |
| 2401 |
gtk_box_pack_start(GTK_BOX(output_color_vbox), blue_button, TRUE, TRUE, 0); |
| 2402 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(blue_button), TRUE); |
| 2403 |
gtk_widget_show(GTK_WIDGET(blue_button)); |
| 2404 |
g_signal_connect (G_OBJECT (blue_button), "toggled", |
| 2405 |
G_CALLBACK (color_button_callback), NULL); |
| 2406 |
|
| 2407 |
color_adjustment_table = gtk_table_new(1, 1, FALSE); |
| 2408 |
gtk_table_set_col_spacings (GTK_TABLE (color_adjustment_table), 2); |
| 2409 |
gtk_table_set_row_spacings (GTK_TABLE (color_adjustment_table), 0); |
| 2410 |
gtk_container_set_border_width (GTK_CONTAINER (color_adjustment_table), 4); |
| 2411 |
gtk_widget_show (color_adjustment_table); |
| 2412 |
|
| 2413 |
scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 2414 |
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), |
| 2415 |
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
| 2416 |
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), |
| 2417 |
color_adjustment_table); |
| 2418 |
gtk_table_attach_defaults(GTK_TABLE(table), scrolled_window, |
| 2419 |
0, 2, 1, 2); |
| 2420 |
gtk_widget_show(scrolled_window); |
| 2421 |
|
| 2422 |
|
| 2423 |
|
| 2424 |
gtk_window_get_size(GTK_WINDOW(color_adjust_dialog), &x, &y); |
| 2425 |
gtk_window_set_default_size(GTK_WINDOW(color_adjust_dialog), x, y+300); |
| 2426 |
} |
| 2427 |
|
| 2428 |
static void |
| 2429 |
create_image_settings_frame (void) |
| 2430 |
{ |
| 2431 |
GtkWidget *vbox; |
| 2432 |
GtkWidget *hbox; |
| 2433 |
GtkWidget *table; |
| 2434 |
GtkWidget *label; |
| 2435 |
GtkWidget *event_box; |
| 2436 |
GtkWidget *sep; |
| 2437 |
GSList *group; |
| 2438 |
gint i; |
| 2439 |
|
| 2440 |
create_color_adjust_window (); |
| 2441 |
|
| 2442 |
vbox = gtk_vbox_new (FALSE, 4); |
| 2443 |
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); |
| 2444 |
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, |
| 2445 |
gtk_label_new (_("Output"))); |
| 2446 |
gtk_widget_show (vbox); |
| 2447 |
|
| 2448 |
table = gtk_table_new (1, 1, FALSE); |
| 2449 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2450 |
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); |
| 2451 |
gtk_widget_show (table); |
| 2452 |
|
| 2453 |
event_box = gtk_event_box_new (); |
| 2454 |
gtk_table_attach (GTK_TABLE (table), event_box, 0, 1, 0, 1, |
| 2455 |
GTK_FILL, GTK_FILL, 0, 0); |
| 2456 |
gtk_widget_show (event_box); |
| 2457 |
|
| 2458 |
|
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
table = gtk_table_new (1, 1, FALSE); |
| 2463 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2464 |
|
| 2465 |
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); |
| 2466 |
gtk_widget_show (table); |
| 2467 |
|
| 2468 |
event_box = gtk_event_box_new (); |
| 2469 |
gtk_table_attach (GTK_TABLE (table), event_box, 0, 1, 0, 1, |
| 2470 |
GTK_FILL, GTK_FILL, 0, 0); |
| 2471 |
gtk_widget_show (event_box); |
| 2472 |
|
| 2473 |
label = gtk_label_new (_("Output Type:")); |
| 2474 |
gtk_container_add (GTK_CONTAINER (event_box), label); |
| 2475 |
gtk_widget_show (label); |
| 2476 |
|
| 2477 |
stpui_set_help_data(event_box, _("Select the desired output type")); |
| 2478 |
|
| 2479 |
group = NULL; |
| 2480 |
for (i = 0; i < output_type_count; i++) |
| 2481 |
group = stpui_create_radio_button(&(output_types[i]), group, table, 0, i, |
| 2482 |
G_CALLBACK(output_type_callback)); |
| 2483 |
|
| 2484 |
sep = gtk_hseparator_new (); |
| 2485 |
gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); |
| 2486 |
gtk_widget_show (sep); |
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
|
| 2491 |
hbox = gtk_hbox_new (FALSE, 4); |
| 2492 |
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); |
| 2493 |
gtk_widget_show(hbox); |
| 2494 |
label = gtk_label_new(""); |
| 2495 |
gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
| 2496 |
gtk_widget_show(label); |
| 2497 |
|
| 2498 |
adjust_color_button = gtk_button_new_with_label (_("Adjust Output...")); |
| 2499 |
gtk_misc_set_padding (GTK_MISC (GTK_BIN (adjust_color_button)->child), 4, 0); |
| 2500 |
gtk_box_pack_start (GTK_BOX (hbox), adjust_color_button, FALSE, FALSE, 0); |
| 2501 |
gtk_widget_show(adjust_color_button); |
| 2502 |
label = gtk_label_new(""); |
| 2503 |
gtk_box_pack_end(GTK_BOX(hbox), label, TRUE, TRUE, 0); |
| 2504 |
gtk_widget_show(label); |
| 2505 |
|
| 2506 |
stpui_set_help_data(adjust_color_button, |
| 2507 |
_("Adjust color balance, brightness, contrast, " |
| 2508 |
"saturation, and dither algorithm")); |
| 2509 |
g_signal_connect_object (G_OBJECT (adjust_color_button), "clicked", |
| 2510 |
G_CALLBACK (gtk_widget_show), |
| 2511 |
G_OBJECT (color_adjust_dialog), |
| 2512 |
G_CONNECT_SWAPPED); |
| 2513 |
} |
| 2514 |
|
| 2515 |
static void |
| 2516 |
create_units_frame (void) |
| 2517 |
{ |
| 2518 |
GtkWidget *vbox; |
| 2519 |
GtkWidget *table; |
| 2520 |
GtkWidget *label; |
| 2521 |
GtkWidget *event_box; |
| 2522 |
GSList *group; |
| 2523 |
gint i; |
| 2524 |
|
| 2525 |
units_hbox = gtk_hbox_new(FALSE, 0); |
| 2526 |
label = gtk_label_new(_("Size Units:")); |
| 2527 |
gtk_widget_show(label); |
| 2528 |
gtk_box_pack_start(GTK_BOX(units_hbox), label, TRUE, TRUE, 0); |
| 2529 |
units_label = gtk_label_new(_(" ")); |
| 2530 |
gtk_widget_show(units_label); |
| 2531 |
gtk_box_pack_start(GTK_BOX(units_hbox), units_label, TRUE, TRUE, 0); |
| 2532 |
gtk_widget_show(units_hbox); |
| 2533 |
|
| 2534 |
vbox = gtk_vbox_new (FALSE, 4); |
| 2535 |
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4); |
| 2536 |
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, units_hbox); |
| 2537 |
gtk_widget_show (vbox); |
| 2538 |
|
| 2539 |
|
| 2540 |
|
| 2541 |
|
| 2542 |
|
| 2543 |
table = gtk_table_new (1, 1, FALSE); |
| 2544 |
gtk_table_set_col_spacings (GTK_TABLE (table), 4); |
| 2545 |
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0); |
| 2546 |
gtk_widget_show (table); |
| 2547 |
|
| 2548 |
event_box = gtk_event_box_new (); |
| 2549 |
gtk_table_attach (GTK_TABLE (table), event_box, 0, 1, 0, 1, |
| 2550 |
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); |
| 2551 |
gtk_widget_show (event_box); |
| 2552 |
|
| 2553 |
label = gtk_label_new (_("Units:")); |
| 2554 |
gtk_container_add (GTK_CONTAINER (event_box), label); |
| 2555 |
gtk_widget_show (label); |
| 2556 |
|
| 2557 |
stpui_set_help_data(event_box, |
| 2558 |
_("Select the base unit of measurement for printing")); |
| 2559 |
|
| 2560 |
group = NULL; |
| 2561 |
for (i = 0; i < unit_count; i++) |
| 2562 |
{ |
| 2563 |
unit_t *unit = &(units[i]); |
| 2564 |
unit->checkbox = gtk_radio_button_new_with_label(group, gettext(unit->name)); |
| 2565 |
group = gtk_radio_button_group(GTK_RADIO_BUTTON(unit->checkbox)); |
| 2566 |
stpui_table_attach_aligned(GTK_TABLE(table), i / 2, i % 2, NULL, 0.5, |
| 2567 |
0.5, unit->checkbox, 1, TRUE); |
| 2568 |
stpui_set_help_data(unit->checkbox, gettext(unit->help)); |
| 2569 |
g_signal_connect(G_OBJECT(unit->checkbox), "toggled", |
| 2570 |
G_CALLBACK(unit_callback), gint2p(i)); |
| 2571 |
} |
| 2572 |
} |
| 2573 |
|
| 2574 |
|
| 2575 |
|
| 2576 |
|
| 2577 |
static void |
| 2578 |
create_main_window (void) |
| 2579 |
{ |
| 2580 |
gint x, y; |
| 2581 |
|
| 2582 |
set_current_printer(); |
| 2583 |
manufacturer = stp_printer_get_manufacturer(stp_get_printer(pv->v)); |
| 2584 |
|
| 2585 |
|
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
stpui_help_init(); |
| 2591 |
|
| 2592 |
create_top_level_structure (); |
| 2593 |
|
| 2594 |
create_preview (); |
| 2595 |
create_printer_settings_frame (); |
| 2596 |
create_units_frame(); |
| 2597 |
create_paper_size_frame(); |
| 2598 |
create_copy_number_frame(); |
| 2599 |
create_positioning_frame (); |
| 2600 |
create_scaling_frame (); |
| 2601 |
create_image_settings_frame (); |
| 2602 |
|
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
do_update_thumbnail = 1; |
| 2608 |
build_printer_combo (); |
| 2609 |
plist_callback (NULL, gint2p(stpui_plist_current)); |
| 2610 |
update_adjusted_thumbnail (TRUE); |
| 2611 |
|
| 2612 |
|
| 2613 |
|
| 2614 |
gtk_window_get_size(GTK_WINDOW(print_dialog), &x, &y); |
| 2615 |
gtk_window_set_default_size(GTK_WINDOW(print_dialog), x, y+80); |
| 2616 |
|
| 2617 |
gtk_widget_show (print_dialog); |
| 2618 |
} |
| 2619 |
|
| 2620 |
#pragma GCC diagnostic push |
| 2621 |
#pragma GCC diagnostic ignored "-Wformat-nonliteral" |
| 2622 |
static void |
| 2623 |
set_entry_value(GtkWidget *entry, double value, int block) |
| 2624 |
{ |
| 2625 |
gchar s[255]; |
| 2626 |
gdouble unit_scaler = units[pv->unit].scale; |
| 2627 |
const gchar *format = units[pv->unit].format; |
| 2628 |
|
| 2629 |
g_snprintf(s, sizeof(s), format, value / unit_scaler); |
| 2630 |
if (block) |
| 2631 |
g_signal_handlers_block_matched (G_OBJECT (entry), |
| 2632 |
G_SIGNAL_MATCH_DATA, |
| 2633 |
0, |
| 2634 |
0, |
| 2635 |
NULL, |
| 2636 |
NULL, |
| 2637 |
NULL); |
| 2638 |
|
| 2639 |
gtk_entry_set_text (GTK_ENTRY (entry), s); |
| 2640 |
if (block) |
| 2641 |
g_signal_handlers_unblock_matched (G_OBJECT (entry), |
| 2642 |
G_SIGNAL_MATCH_DATA, |
| 2643 |
0, |
| 2644 |
0, |
| 2645 |
NULL, |
| 2646 |
NULL, |
| 2647 |
NULL); |
| 2648 |
} |
| 2649 |
#pragma GCC diagnostic pop |
| 2650 |
|
| 2651 |
static void |
| 2652 |
reset_preview(void) |
| 2653 |
{ |
| 2654 |
if (!suppress_preview_reset) |
| 2655 |
{ |
| 2656 |
stpui_enable_help(); |
| 2657 |
buttons_pressed = preview_active = 0; |
| 2658 |
} |
| 2659 |
} |
| 2660 |
|
| 2661 |
static void |
| 2662 |
invalidate_preview_thumbnail (void) |
| 2663 |
{ |
| 2664 |
preview_valid = FALSE; |
| 2665 |
} |
| 2666 |
|
| 2667 |
static void |
| 2668 |
invalidate_frame (void) |
| 2669 |
{ |
| 2670 |
frame_valid = FALSE; |
| 2671 |
} |
| 2672 |
|
| 2673 |
static void |
| 2674 |
compute_scaling_limits(gdouble *min_ppi_scaling, gdouble *max_ppi_scaling) |
| 2675 |
{ |
| 2676 |
if (auto_paper_size) |
| 2677 |
{ |
| 2678 |
*min_ppi_scaling = |
| 2679 |
FINCH * (gdouble) image_width / (gdouble) printable_width; |
| 2680 |
} |
| 2681 |
else |
| 2682 |
{ |
| 2683 |
gdouble min_ppi_scaling1 = |
| 2684 |
FINCH * (gdouble) image_width / (gdouble) printable_width; |
| 2685 |
gdouble min_ppi_scaling2 = |
| 2686 |
FINCH * (gdouble) image_height / (gdouble) printable_height; |
| 2687 |
|
| 2688 |
if (min_ppi_scaling1 > min_ppi_scaling2) |
| 2689 |
*min_ppi_scaling = min_ppi_scaling1; |
| 2690 |
else |
| 2691 |
*min_ppi_scaling = min_ppi_scaling2; |
| 2692 |
} |
| 2693 |
|
| 2694 |
*max_ppi_scaling = *min_ppi_scaling * 100 / minimum_image_percent; |
| 2695 |
if (*max_ppi_scaling < image_xres) |
| 2696 |
*max_ppi_scaling = image_xres; |
| 2697 |
if (*max_ppi_scaling < image_yres) |
| 2698 |
*max_ppi_scaling = image_yres; |
| 2699 |
minimum_image_percent = *min_ppi_scaling * 100 / *max_ppi_scaling; |
| 2700 |
} |
| 2701 |
|
| 2702 |
|
| 2703 |
|
| 2704 |
|
| 2705 |
static void |
| 2706 |
scaling_update (GtkAdjustment *adjustment) |
| 2707 |
{ |
| 2708 |
reset_preview (); |
| 2709 |
|
| 2710 |
if (pv->scaling != adjustment->value) |
| 2711 |
{ |
| 2712 |
invalidate_preview_thumbnail (); |
| 2713 |
if (GTK_TOGGLE_BUTTON (scaling_ppi)->active) |
| 2714 |
pv->scaling = -adjustment->value; |
| 2715 |
else |
| 2716 |
pv->scaling = adjustment->value; |
| 2717 |
|
| 2718 |
suppress_scaling_adjustment = TRUE; |
| 2719 |
preview_update (); |
| 2720 |
suppress_scaling_adjustment = FALSE; |
| 2721 |
} |
| 2722 |
} |
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
static void |
| 2728 |
scaling_callback (GtkWidget *widget) |
| 2729 |
{ |
| 2730 |
gdouble max_ppi_scaling; |
| 2731 |
gdouble min_ppi_scaling; |
| 2732 |
gdouble current_scale; |
| 2733 |
|
| 2734 |
reset_preview (); |
| 2735 |
|
| 2736 |
if (suppress_scaling_callback) |
| 2737 |
return; |
| 2738 |
|
| 2739 |
compute_scaling_limits(&min_ppi_scaling, &max_ppi_scaling); |
| 2740 |
|
| 2741 |
if (widget == scaling_ppi) |
| 2742 |
{ |
| 2743 |
if (! GTK_TOGGLE_BUTTON (scaling_ppi)->active) |
| 2744 |
return; |
| 2745 |
|
| 2746 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = min_ppi_scaling; |
| 2747 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = max_ppi_scaling; |
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
|
| 2752 |
|
| 2753 |
current_scale = GTK_ADJUSTMENT (scaling_adjustment)->value; |
| 2754 |
GTK_ADJUSTMENT (scaling_adjustment)->value = |
| 2755 |
min_ppi_scaling / (current_scale / 100.0); |
| 2756 |
pv->scaling = 0.0; |
| 2757 |
} |
| 2758 |
else if (widget == scaling_percent) |
| 2759 |
{ |
| 2760 |
gdouble new_percent; |
| 2761 |
|
| 2762 |
if (! GTK_TOGGLE_BUTTON (scaling_percent)->active) |
| 2763 |
return; |
| 2764 |
|
| 2765 |
current_scale = GTK_ADJUSTMENT (scaling_adjustment)->value; |
| 2766 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = minimum_image_percent; |
| 2767 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = 100.0; |
| 2768 |
|
| 2769 |
new_percent = 100.0 * min_ppi_scaling / current_scale; |
| 2770 |
|
| 2771 |
if (new_percent > 100) |
| 2772 |
new_percent = 100; |
| 2773 |
if (new_percent < minimum_image_percent) |
| 2774 |
new_percent = minimum_image_percent; |
| 2775 |
|
| 2776 |
GTK_ADJUSTMENT (scaling_adjustment)->value = new_percent; |
| 2777 |
pv->scaling = 0.0; |
| 2778 |
} |
| 2779 |
else if (widget == scaling_image) |
| 2780 |
{ |
| 2781 |
gdouble yres = image_yres; |
| 2782 |
|
| 2783 |
invalidate_preview_thumbnail (); |
| 2784 |
|
| 2785 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = min_ppi_scaling; |
| 2786 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = max_ppi_scaling; |
| 2787 |
|
| 2788 |
if (yres < min_ppi_scaling) |
| 2789 |
yres = min_ppi_scaling; |
| 2790 |
if (yres > max_ppi_scaling) |
| 2791 |
yres = max_ppi_scaling; |
| 2792 |
|
| 2793 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scaling_ppi), TRUE); |
| 2794 |
GTK_ADJUSTMENT (scaling_adjustment)->value = yres; |
| 2795 |
pv->scaling = 0.0; |
| 2796 |
} |
| 2797 |
|
| 2798 |
if (widget == scaling_ppi || widget == scaling_percent) |
| 2799 |
suppress_preview_update++; |
| 2800 |
gtk_adjustment_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 2801 |
gtk_adjustment_value_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 2802 |
if (auto_paper_size) |
| 2803 |
set_media_size(stp_get_string_parameter(pv->v, "PageSize")); |
| 2804 |
if (widget == scaling_ppi || widget == scaling_percent) |
| 2805 |
suppress_preview_update--; |
| 2806 |
} |
| 2807 |
|
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
|
| 2812 |
|
| 2813 |
static void |
| 2814 |
plist_build_combo (GtkWidget *combo, |
| 2815 |
GtkWidget *label, |
| 2816 |
stp_string_list_t *items, |
| 2817 |
int active, |
| 2818 |
const gchar *cur_item, |
| 2819 |
const gchar *def_value, |
| 2820 |
GCallback callback, |
| 2821 |
gint *callback_id, |
| 2822 |
int (*check_func)(const char *string), |
| 2823 |
gpointer data) |
| 2824 |
{ |
| 2825 |
gint i; |
| 2826 |
GList *list = 0; |
| 2827 |
gint num_items = 0; |
| 2828 |
GtkEntry *entry = GTK_ENTRY (GTK_COMBO (combo)->entry); |
| 2829 |
|
| 2830 |
if (check_func && items) |
| 2831 |
{ |
| 2832 |
stp_string_list_t *new_items = stp_string_list_create(); |
| 2833 |
num_items = stp_string_list_count(items); |
| 2834 |
for (i = 0; i < num_items; i++) |
| 2835 |
{ |
| 2836 |
stp_param_string_t *param = stp_string_list_param(items, i); |
| 2837 |
if ((*check_func)(param->name)) |
| 2838 |
stp_string_list_add_string(new_items, param->name, param->text); |
| 2839 |
} |
| 2840 |
items = new_items; |
| 2841 |
} |
| 2842 |
|
| 2843 |
if (items) |
| 2844 |
num_items = stp_string_list_count(items); |
| 2845 |
|
| 2846 |
if (*callback_id != -1) |
| 2847 |
g_signal_handler_disconnect (G_OBJECT (entry), *callback_id); |
| 2848 |
gtk_entry_set_editable (entry, FALSE); |
| 2849 |
|
| 2850 |
if (!active || num_items == 0) |
| 2851 |
{ |
| 2852 |
list = g_list_append (list, _("Standard")); |
| 2853 |
gtk_combo_set_popdown_strings (GTK_COMBO (combo), list); |
| 2854 |
*callback_id = -1; |
| 2855 |
gtk_widget_set_sensitive (combo, FALSE); |
| 2856 |
gtk_widget_hide (combo); |
| 2857 |
if (label) |
| 2858 |
gtk_widget_hide(label); |
| 2859 |
if (check_func && items) |
| 2860 |
stp_string_list_destroy(items); |
| 2861 |
return; |
| 2862 |
} |
| 2863 |
|
| 2864 |
for (i = 0; i < num_items; i ++) |
| 2865 |
list = g_list_append(list, g_strdup(stp_string_list_param(items, i)->text)); |
| 2866 |
|
| 2867 |
gtk_combo_set_popdown_strings (GTK_COMBO (combo), list); |
| 2868 |
|
| 2869 |
if (cur_item) |
| 2870 |
for (i = 0; i < num_items; i ++) |
| 2871 |
if (strcmp(stp_string_list_param(items, i)->name, cur_item) == 0) |
| 2872 |
break; |
| 2873 |
|
| 2874 |
if (i >= num_items && def_value) |
| 2875 |
for (i = 0; i < num_items; i ++) |
| 2876 |
if (strcmp(stp_string_list_param(items, i)->name, def_value) == 0) |
| 2877 |
break; |
| 2878 |
|
| 2879 |
if (i >= num_items) |
| 2880 |
i = 0; |
| 2881 |
|
| 2882 |
gtk_entry_set_text (entry, stp_string_list_param(items, i)->text); |
| 2883 |
|
| 2884 |
gtk_combo_set_value_in_list (GTK_COMBO (combo), TRUE, FALSE); |
| 2885 |
gtk_widget_set_sensitive (combo, TRUE); |
| 2886 |
gtk_widget_show (combo); |
| 2887 |
if (label) |
| 2888 |
gtk_widget_show(label); |
| 2889 |
|
| 2890 |
*callback_id = g_signal_connect (G_OBJECT (entry), "changed", callback, |
| 2891 |
data); |
| 2892 |
if (check_func && items) |
| 2893 |
stp_string_list_destroy(items); |
| 2894 |
} |
| 2895 |
|
| 2896 |
void |
| 2897 |
stpui_set_image_dimensions(gint width, gint height) |
| 2898 |
{ |
| 2899 |
image_true_width = (gdouble) width; |
| 2900 |
image_true_height = (gdouble) height; |
| 2901 |
} |
| 2902 |
|
| 2903 |
void |
| 2904 |
stpui_set_image_resolution(gdouble xres, gdouble yres) |
| 2905 |
{ |
| 2906 |
image_xres = xres; |
| 2907 |
image_yres = yres; |
| 2908 |
} |
| 2909 |
|
| 2910 |
gint |
| 2911 |
stpui_compute_orientation(void) |
| 2912 |
{ |
| 2913 |
if (auto_paper_size || |
| 2914 |
(printable_width >= printable_height && |
| 2915 |
image_true_width >= image_true_height) || |
| 2916 |
(printable_height >= printable_width && |
| 2917 |
image_true_height >= image_true_width)) |
| 2918 |
return ORIENT_PORTRAIT; |
| 2919 |
else |
| 2920 |
return ORIENT_LANDSCAPE; |
| 2921 |
} |
| 2922 |
|
| 2923 |
static void |
| 2924 |
compute_printable_region(void) |
| 2925 |
{ |
| 2926 |
stp_get_media_size(pv->v, &paper_width, &paper_height); |
| 2927 |
stp_get_imageable_area(pv->v, &left, &right, &bottom, &top); |
| 2928 |
printable_width = right - left; |
| 2929 |
printable_height = bottom - top; |
| 2930 |
} |
| 2931 |
|
| 2932 |
static void |
| 2933 |
set_orientation(int orientation) |
| 2934 |
{ |
| 2935 |
compute_printable_region(); |
| 2936 |
pv->orientation = orientation; |
| 2937 |
if (orientation == ORIENT_AUTO) |
| 2938 |
orientation = stpui_compute_orientation(); |
| 2939 |
physical_orientation = orientation; |
| 2940 |
switch (orientation) |
| 2941 |
{ |
| 2942 |
case ORIENT_PORTRAIT: |
| 2943 |
case ORIENT_UPSIDEDOWN: |
| 2944 |
image_height = image_true_height; |
| 2945 |
image_width = image_true_width; |
| 2946 |
preview_thumbnail_h = thumbnail_h; |
| 2947 |
preview_thumbnail_w = thumbnail_w; |
| 2948 |
break; |
| 2949 |
case ORIENT_LANDSCAPE: |
| 2950 |
case ORIENT_SEASCAPE: |
| 2951 |
image_height = image_true_width; |
| 2952 |
image_width = image_true_height; |
| 2953 |
preview_thumbnail_h = thumbnail_w; |
| 2954 |
preview_thumbnail_w = thumbnail_h; |
| 2955 |
break; |
| 2956 |
} |
| 2957 |
update_adjusted_thumbnail(FALSE); |
| 2958 |
} |
| 2959 |
|
| 2960 |
static void |
| 2961 |
position_button_callback(GtkWidget *widget, gpointer data) |
| 2962 |
{ |
| 2963 |
(void)widget; |
| 2964 |
reset_preview(); |
| 2965 |
pv->invalid_mask |= p2gint(data); |
| 2966 |
preview_update (); |
| 2967 |
} |
| 2968 |
|
| 2969 |
|
| 2970 |
|
| 2971 |
|
| 2972 |
static void |
| 2973 |
position_callback (GtkWidget *widget) |
| 2974 |
{ |
| 2975 |
gdouble new_printed_value = atof (gtk_entry_get_text (GTK_ENTRY (widget))); |
| 2976 |
gdouble new_value = SCALE(new_printed_value, units[pv->unit].scale); |
| 2977 |
|
| 2978 |
reset_preview (); |
| 2979 |
suppress_preview_update++; |
| 2980 |
|
| 2981 |
if (widget == top_entry) |
| 2982 |
stp_set_top(pv->v, new_value); |
| 2983 |
|
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
else if (widget == bottom_border_entry) |
| 2988 |
stp_set_top (pv->v, paper_height - print_height - new_value); |
| 2989 |
else if (widget == left_entry) |
| 2990 |
stp_set_left (pv->v, new_value); |
| 2991 |
|
| 2992 |
|
| 2993 |
|
| 2994 |
|
| 2995 |
else if (widget == right_border_entry) |
| 2996 |
stp_set_left (pv->v, paper_width - print_width - new_value); |
| 2997 |
else if (widget == width_entry || widget == height_entry) |
| 2998 |
{ |
| 2999 |
gboolean was_percent = (pv->scaling >= 0); |
| 3000 |
if (pv->scaling >= 0) |
| 3001 |
{ |
| 3002 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scaling_ppi), TRUE); |
| 3003 |
scaling_callback (scaling_ppi); |
| 3004 |
} |
| 3005 |
if (widget == width_entry) |
| 3006 |
GTK_ADJUSTMENT (scaling_adjustment)->value = |
| 3007 |
((gdouble) image_width) / (new_value / FINCH); |
| 3008 |
else |
| 3009 |
GTK_ADJUSTMENT (scaling_adjustment)->value = |
| 3010 |
((gdouble) image_height) / (new_value / FINCH); |
| 3011 |
gtk_adjustment_value_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 3012 |
if (was_percent) |
| 3013 |
{ |
| 3014 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(scaling_percent),TRUE); |
| 3015 |
gtk_adjustment_value_changed(GTK_ADJUSTMENT (scaling_adjustment)); |
| 3016 |
} |
| 3017 |
} |
| 3018 |
|
| 3019 |
suppress_preview_update--; |
| 3020 |
preview_update (); |
| 3021 |
} |
| 3022 |
|
| 3023 |
static void |
| 3024 |
set_adjustment_active(option_t *opt, gboolean active, gboolean do_toggle) |
| 3025 |
{ |
| 3026 |
GtkObject *adj = opt->info.flt.adjustment; |
| 3027 |
if (do_toggle) |
| 3028 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt->checkbox), active); |
| 3029 |
gtk_widget_set_sensitive (GTK_WIDGET (SCALE_ENTRY_LABEL (adj)), active); |
| 3030 |
gtk_widget_set_sensitive (GTK_WIDGET (SCALE_ENTRY_SCALE (adj)), active); |
| 3031 |
gtk_widget_set_sensitive (GTK_WIDGET (SCALE_ENTRY_SPINBUTTON (adj)), active); |
| 3032 |
gtk_widget_set_sensitive (GTK_WIDGET (opt->reset_btn), active); |
| 3033 |
} |
| 3034 |
|
| 3035 |
static void |
| 3036 |
set_combo_active(option_t *opt, gboolean active, gboolean do_toggle) |
| 3037 |
{ |
| 3038 |
if (do_toggle) |
| 3039 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt->checkbox), active); |
| 3040 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.list.combo), active); |
| 3041 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.list.label), active); |
| 3042 |
gtk_widget_set_sensitive (GTK_WIDGET (opt->reset_btn), active); |
| 3043 |
} |
| 3044 |
|
| 3045 |
static void |
| 3046 |
set_curve_active(option_t *opt, gboolean active, gboolean do_toggle) |
| 3047 |
{ |
| 3048 |
if (do_toggle) |
| 3049 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt->checkbox), active); |
| 3050 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.curve.button), active); |
| 3051 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.curve.label), active); |
| 3052 |
if (active) |
| 3053 |
{ |
| 3054 |
if (opt->info.curve.is_visible) |
| 3055 |
gtk_widget_show(GTK_WIDGET(opt->info.curve.dialog)); |
| 3056 |
} |
| 3057 |
else |
| 3058 |
gtk_widget_hide(GTK_WIDGET(opt->info.curve.dialog)); |
| 3059 |
gtk_widget_set_sensitive (GTK_WIDGET (opt->reset_btn), active); |
| 3060 |
} |
| 3061 |
|
| 3062 |
static void |
| 3063 |
set_bool_active(option_t *opt, gboolean active, gboolean do_toggle) |
| 3064 |
{ |
| 3065 |
if (do_toggle) |
| 3066 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt->checkbox), active); |
| 3067 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.bool.checkbox), active); |
| 3068 |
gtk_widget_set_sensitive (GTK_WIDGET (opt->reset_btn), active); |
| 3069 |
} |
| 3070 |
|
| 3071 |
static void |
| 3072 |
set_file_active(option_t *opt, gboolean active, gboolean do_toggle) |
| 3073 |
{ |
| 3074 |
if (do_toggle) |
| 3075 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(opt->checkbox), active); |
| 3076 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.file.f_label), active); |
| 3077 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.file.f_button), active); |
| 3078 |
gtk_widget_set_sensitive(GTK_WIDGET(opt->info.file.f_entry), active); |
| 3079 |
if (active) |
| 3080 |
{ |
| 3081 |
if (opt->info.file.f_is_visible) |
| 3082 |
gtk_widget_show(GTK_WIDGET(opt->info.file.f_browser)); |
| 3083 |
} |
| 3084 |
else |
| 3085 |
gtk_widget_hide(GTK_WIDGET(opt->info.file.f_browser)); |
| 3086 |
gtk_widget_set_sensitive (GTK_WIDGET (opt->reset_btn), active); |
| 3087 |
} |
| 3088 |
|
| 3089 |
static void |
| 3090 |
do_color_updates (void) |
| 3091 |
{ |
| 3092 |
unsigned int i; |
| 3093 |
for (i = 0; i < current_option_count; i++) |
| 3094 |
{ |
| 3095 |
option_t *opt = &(current_options[i]); |
| 3096 |
if (opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 3097 |
{ |
| 3098 |
switch (opt->fast_desc->p_type) |
| 3099 |
{ |
| 3100 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 3101 |
if (stp_check_float_parameter(pv->v, opt->fast_desc->name, |
| 3102 |
STP_PARAMETER_INACTIVE)) |
| 3103 |
gtk_adjustment_set_value |
| 3104 |
(GTK_ADJUSTMENT(opt->info.flt.adjustment), |
| 3105 |
stp_get_float_parameter(pv->v, opt->fast_desc->name)); |
| 3106 |
if (stp_check_float_parameter(pv->v, opt->fast_desc->name, |
| 3107 |
STP_PARAMETER_ACTIVE) || |
| 3108 |
opt->fast_desc->is_mandatory) |
| 3109 |
set_adjustment_active(opt, TRUE, TRUE); |
| 3110 |
else |
| 3111 |
set_adjustment_active(opt, FALSE, TRUE); |
| 3112 |
break; |
| 3113 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 3114 |
if (stp_check_dimension_parameter(pv->v, opt->fast_desc->name, |
| 3115 |
STP_PARAMETER_INACTIVE)) |
| 3116 |
{ |
| 3117 |
gdouble unit_scaler = units[pv->unit].scale; |
| 3118 |
gtk_adjustment_set_value |
| 3119 |
(GTK_ADJUSTMENT(opt->info.flt.adjustment), |
| 3120 |
(stp_get_dimension_parameter(pv->v, opt->fast_desc->name) / |
| 3121 |
unit_scaler)); |
| 3122 |
} |
| 3123 |
if (stp_check_dimension_parameter(pv->v, opt->fast_desc->name, |
| 3124 |
STP_PARAMETER_ACTIVE) || |
| 3125 |
opt->fast_desc->is_mandatory) |
| 3126 |
set_adjustment_active(opt, TRUE, TRUE); |
| 3127 |
else |
| 3128 |
set_adjustment_active(opt, FALSE, TRUE); |
| 3129 |
break; |
| 3130 |
case STP_PARAMETER_TYPE_INT: |
| 3131 |
if (stp_check_int_parameter(pv->v, opt->fast_desc->name, |
| 3132 |
STP_PARAMETER_INACTIVE)) |
| 3133 |
{ |
| 3134 |
gtk_adjustment_set_value |
| 3135 |
(GTK_ADJUSTMENT(opt->info.flt.adjustment), |
| 3136 |
(stp_get_int_parameter(pv->v, opt->fast_desc->name))); |
| 3137 |
} |
| 3138 |
if (stp_check_int_parameter(pv->v, opt->fast_desc->name, |
| 3139 |
STP_PARAMETER_ACTIVE) || |
| 3140 |
opt->fast_desc->is_mandatory) |
| 3141 |
set_adjustment_active(opt, TRUE, TRUE); |
| 3142 |
else |
| 3143 |
set_adjustment_active(opt, FALSE, TRUE); |
| 3144 |
break; |
| 3145 |
case STP_PARAMETER_TYPE_CURVE: |
| 3146 |
if (stp_check_curve_parameter(pv->v, opt->fast_desc->name, |
| 3147 |
STP_PARAMETER_ACTIVE) || |
| 3148 |
opt->fast_desc->is_mandatory) |
| 3149 |
set_curve_active(opt, TRUE, TRUE); |
| 3150 |
else |
| 3151 |
set_curve_active(opt, FALSE, TRUE); |
| 3152 |
break; |
| 3153 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 3154 |
if (strcmp(opt->fast_desc->name, "PageSize") == 0) |
| 3155 |
build_page_size_combo(opt); |
| 3156 |
else if (stp_check_string_parameter(pv->v, opt->fast_desc->name, |
| 3157 |
STP_PARAMETER_INACTIVE)) |
| 3158 |
plist_build_combo(opt->info.list.combo, opt->info.list.label, |
| 3159 |
opt->info.list.params, opt->is_active, |
| 3160 |
(stp_get_string_parameter |
| 3161 |
(pv->v, opt->fast_desc->name)), |
| 3162 |
opt->info.list.default_val, |
| 3163 |
G_CALLBACK(combo_callback), |
| 3164 |
&(opt->info.list.callback_id), |
| 3165 |
NULL, opt); |
| 3166 |
if (stp_check_string_parameter(pv->v, opt->fast_desc->name, |
| 3167 |
STP_PARAMETER_ACTIVE) || |
| 3168 |
opt->fast_desc->is_mandatory) |
| 3169 |
set_combo_active(opt, TRUE, TRUE); |
| 3170 |
else |
| 3171 |
set_combo_active(opt, FALSE, TRUE); |
| 3172 |
break; |
| 3173 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 3174 |
if (stp_check_boolean_parameter(pv->v, opt->fast_desc->name, |
| 3175 |
STP_PARAMETER_INACTIVE)) |
| 3176 |
gtk_toggle_button_set_active |
| 3177 |
(GTK_TOGGLE_BUTTON(opt->info.bool.checkbox), |
| 3178 |
stp_get_boolean_parameter(pv->v, opt->fast_desc->name)); |
| 3179 |
if (stp_check_boolean_parameter(pv->v, opt->fast_desc->name, |
| 3180 |
STP_PARAMETER_ACTIVE) || |
| 3181 |
opt->fast_desc->is_mandatory) |
| 3182 |
set_bool_active(opt, TRUE, TRUE); |
| 3183 |
else |
| 3184 |
set_bool_active(opt, FALSE, TRUE); |
| 3185 |
break; |
| 3186 |
case STP_PARAMETER_TYPE_FILE: |
| 3187 |
if (stp_check_file_parameter(pv->v, opt->fast_desc->name, |
| 3188 |
STP_PARAMETER_ACTIVE) || |
| 3189 |
opt->fast_desc->is_mandatory) |
| 3190 |
set_file_active(opt, TRUE, TRUE); |
| 3191 |
else |
| 3192 |
set_file_active(opt, FALSE, TRUE); |
| 3193 |
break; |
| 3194 |
default: |
| 3195 |
break; |
| 3196 |
} |
| 3197 |
} |
| 3198 |
} |
| 3199 |
update_adjusted_thumbnail (TRUE); |
| 3200 |
} |
| 3201 |
|
| 3202 |
static void |
| 3203 |
update_options(void) |
| 3204 |
{ |
| 3205 |
gtk_widget_hide(page_size_table); |
| 3206 |
gtk_widget_hide(printer_features_table); |
| 3207 |
gtk_widget_hide(color_adjustment_table); |
| 3208 |
populate_options(pv->v); |
| 3209 |
populate_option_table(page_size_table, STP_PARAMETER_CLASS_CORE); |
| 3210 |
populate_option_table(printer_features_table, STP_PARAMETER_CLASS_FEATURE); |
| 3211 |
populate_option_table(color_adjustment_table, STP_PARAMETER_CLASS_OUTPUT); |
| 3212 |
gtk_widget_show(page_size_table); |
| 3213 |
gtk_widget_show(printer_features_table); |
| 3214 |
gtk_widget_show(color_adjustment_table); |
| 3215 |
set_options_active(NULL); |
| 3216 |
} |
| 3217 |
|
| 3218 |
static void |
| 3219 |
update_standard_print_command(void) |
| 3220 |
{ |
| 3221 |
char *label_text = |
| 3222 |
stpui_build_standard_print_command(pv, stp_get_printer(pv->v)); |
| 3223 |
gtk_entry_set_text(GTK_ENTRY(standard_cmd_entry), label_text); |
| 3224 |
stp_free(label_text); |
| 3225 |
} |
| 3226 |
|
| 3227 |
static void |
| 3228 |
set_color_options(void) |
| 3229 |
{ |
| 3230 |
stp_parameter_t desc; |
| 3231 |
stp_describe_parameter(pv->v, "PrintingMode", &desc); |
| 3232 |
if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST) |
| 3233 |
{ |
| 3234 |
if (!stp_string_list_is_present(desc.bounds.str, "Color")) |
| 3235 |
{ |
| 3236 |
gtk_widget_set_sensitive (output_types[1].button, TRUE); |
| 3237 |
if (gtk_toggle_button_get_active |
| 3238 |
(GTK_TOGGLE_BUTTON (output_types[0].button)) == TRUE) |
| 3239 |
gtk_toggle_button_set_active |
| 3240 |
(GTK_TOGGLE_BUTTON (output_types[1].button), TRUE); |
| 3241 |
gtk_widget_set_sensitive (output_types[0].button, FALSE); |
| 3242 |
} |
| 3243 |
else if (!stp_string_list_is_present(desc.bounds.str, "BW")) |
| 3244 |
{ |
| 3245 |
gtk_widget_set_sensitive (output_types[0].button, TRUE); |
| 3246 |
if (gtk_toggle_button_get_active |
| 3247 |
(GTK_TOGGLE_BUTTON (output_types[1].button)) == TRUE) |
| 3248 |
gtk_toggle_button_set_active |
| 3249 |
(GTK_TOGGLE_BUTTON (output_types[0].button), TRUE); |
| 3250 |
gtk_widget_set_sensitive (output_types[1].button, FALSE); |
| 3251 |
} |
| 3252 |
else |
| 3253 |
{ |
| 3254 |
gtk_widget_set_sensitive (output_types[0].button, TRUE); |
| 3255 |
gtk_widget_set_sensitive (output_types[1].button, TRUE); |
| 3256 |
} |
| 3257 |
} |
| 3258 |
stp_parameter_description_destroy(&desc); |
| 3259 |
} |
| 3260 |
|
| 3261 |
static void |
| 3262 |
do_all_updates(void) |
| 3263 |
{ |
| 3264 |
gint i; |
| 3265 |
suppress_preview_update++; |
| 3266 |
set_orientation(pv->orientation); |
| 3267 |
invalidate_preview_thumbnail (); |
| 3268 |
preview_update (); |
| 3269 |
update_standard_print_command(); |
| 3270 |
|
| 3271 |
if (pv->scaling < 0) |
| 3272 |
{ |
| 3273 |
gdouble tmp = -pv->scaling; |
| 3274 |
gdouble max_ppi_scaling; |
| 3275 |
gdouble min_ppi_scaling; |
| 3276 |
|
| 3277 |
compute_scaling_limits(&min_ppi_scaling, &max_ppi_scaling); |
| 3278 |
|
| 3279 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scaling_ppi), TRUE); |
| 3280 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = min_ppi_scaling; |
| 3281 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = max_ppi_scaling; |
| 3282 |
GTK_ADJUSTMENT (scaling_adjustment)->value = tmp; |
| 3283 |
gtk_adjustment_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 3284 |
gtk_adjustment_value_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 3285 |
} |
| 3286 |
else |
| 3287 |
{ |
| 3288 |
gdouble tmp = pv->scaling; |
| 3289 |
|
| 3290 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scaling_percent), TRUE); |
| 3291 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = minimum_image_percent; |
| 3292 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = 100.0; |
| 3293 |
GTK_ADJUSTMENT (scaling_adjustment)->value = tmp; |
| 3294 |
g_signal_emit_by_name (G_OBJECT(scaling_adjustment), "changed"); |
| 3295 |
g_signal_emit_by_name (G_OBJECT(scaling_adjustment), "value_changed"); |
| 3296 |
} |
| 3297 |
|
| 3298 |
set_color_options(); |
| 3299 |
for (i = 0; i < output_type_count; i++) |
| 3300 |
{ |
| 3301 |
if (stp_get_string_parameter(pv->v, "PrintingMode") && |
| 3302 |
strcmp(output_types[i].value, |
| 3303 |
stp_get_string_parameter(pv->v, "PrintingMode")) == 0) |
| 3304 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(output_types[i].button), |
| 3305 |
TRUE); |
| 3306 |
} |
| 3307 |
|
| 3308 |
|
| 3309 |
|
| 3310 |
|
| 3311 |
|
| 3312 |
update_options(); |
| 3313 |
do_color_updates (); |
| 3314 |
|
| 3315 |
gtk_option_menu_set_history (GTK_OPTION_MENU (orientation_menu), |
| 3316 |
pv->orientation + 1); |
| 3317 |
|
| 3318 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(units[pv->unit].checkbox), |
| 3319 |
TRUE); |
| 3320 |
gtk_label_set_text(GTK_LABEL(units_label), units[pv->unit].name); |
| 3321 |
suppress_preview_update--; |
| 3322 |
preview_update (); |
| 3323 |
} |
| 3324 |
|
| 3325 |
static void |
| 3326 |
copy_count_callback(GtkAdjustment *adjustment, gpointer data) |
| 3327 |
{ |
| 3328 |
(void)data; |
| 3329 |
gint copy_count = adjustment->value; |
| 3330 |
stpui_plist_set_copy_count(pv, copy_count); |
| 3331 |
update_standard_print_command(); |
| 3332 |
} |
| 3333 |
|
| 3334 |
static void |
| 3335 |
auto_paper_size_callback(GtkWidget *widget, gpointer data) |
| 3336 |
{ |
| 3337 |
(void)widget; |
| 3338 |
(void)data; |
| 3339 |
auto_paper_size = |
| 3340 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(auto_paper_size_button)); |
| 3341 |
pv->auto_size_roll_feed_paper = auto_paper_size; |
| 3342 |
set_orientation(pv->orientation); |
| 3343 |
do_all_updates(); |
| 3344 |
} |
| 3345 |
|
| 3346 |
static void |
| 3347 |
setup_auto_paper_size(void) |
| 3348 |
{ |
| 3349 |
const stp_papersize_t *ps = |
| 3350 |
stp_describe_papersize(pv->v, stp_get_string_parameter(pv->v, "PageSize")); |
| 3351 |
if (ps->height == 0 && ps->width != 0) |
| 3352 |
{ |
| 3353 |
g_signal_handlers_block_matched (G_OBJECT(auto_paper_size_button), |
| 3354 |
G_SIGNAL_MATCH_DATA, |
| 3355 |
0, |
| 3356 |
0, |
| 3357 |
NULL, |
| 3358 |
NULL, |
| 3359 |
NULL); |
| 3360 |
|
| 3361 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(auto_paper_size_button), |
| 3362 |
pv->auto_size_roll_feed_paper); |
| 3363 |
gtk_widget_show(auto_paper_size_button); |
| 3364 |
g_signal_handlers_unblock_matched (G_OBJECT(auto_paper_size_button), |
| 3365 |
G_SIGNAL_MATCH_DATA, |
| 3366 |
0, |
| 3367 |
0, |
| 3368 |
NULL, |
| 3369 |
NULL, |
| 3370 |
NULL); |
| 3371 |
} |
| 3372 |
else |
| 3373 |
{ |
| 3374 |
gtk_widget_hide(auto_paper_size_button); |
| 3375 |
auto_paper_size = 0; |
| 3376 |
} |
| 3377 |
} |
| 3378 |
|
| 3379 |
static void |
| 3380 |
queue_callback (GtkWidget *widget, |
| 3381 |
gpointer data) |
| 3382 |
{ |
| 3383 |
(void)widget; |
| 3384 |
(void)data; |
| 3385 |
int i; |
| 3386 |
int count = stp_string_list_count(stpui_system_print_queues); |
| 3387 |
const gchar *result = |
| 3388 |
gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(queue_combo)->entry)); |
| 3389 |
for (i = 0; i < count; i++) |
| 3390 |
{ |
| 3391 |
const stp_param_string_t *s = |
| 3392 |
stp_string_list_param(stpui_system_print_queues, i); |
| 3393 |
if (!strcmp(result, s->text)) |
| 3394 |
{ |
| 3395 |
stpui_plist_set_queue_name(pv, s->name); |
| 3396 |
do_all_updates(); |
| 3397 |
return; |
| 3398 |
} |
| 3399 |
} |
| 3400 |
} |
| 3401 |
|
| 3402 |
static void |
| 3403 |
setup_callback (GtkWidget *widget) |
| 3404 |
{ |
| 3405 |
const gchar *new_value = gtk_entry_get_text (GTK_ENTRY (widget)); |
| 3406 |
|
| 3407 |
if (widget == custom_command_entry) |
| 3408 |
stpui_plist_set_custom_command(pv, new_value); |
| 3409 |
else if (widget == file_entry) |
| 3410 |
{ |
| 3411 |
stpui_plist_set_output_filename(pv, new_value); |
| 3412 |
gtk_file_selection_set_filename |
| 3413 |
(GTK_FILE_SELECTION (file_browser), |
| 3414 |
gtk_entry_get_text (GTK_ENTRY (file_entry))); |
| 3415 |
} |
| 3416 |
} |
| 3417 |
|
| 3418 |
|
| 3419 |
|
| 3420 |
|
| 3421 |
static void |
| 3422 |
plist_callback (GtkWidget *widget, |
| 3423 |
gpointer data) |
| 3424 |
{ |
| 3425 |
gint i; |
| 3426 |
char *tmp; |
| 3427 |
|
| 3428 |
suppress_preview_update++; |
| 3429 |
invalidate_frame (); |
| 3430 |
invalidate_preview_thumbnail (); |
| 3431 |
reset_preview (); |
| 3432 |
|
| 3433 |
if (widget) |
| 3434 |
{ |
| 3435 |
const gchar *result = |
| 3436 |
gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(printer_combo)->entry)); |
| 3437 |
|
| 3438 |
for (i = 0; i < stpui_plist_count; i++) |
| 3439 |
{ |
| 3440 |
if (! strcmp (result, stp_string_list_param(printer_list, i)->text)) |
| 3441 |
{ |
| 3442 |
stpui_plist_current = i; |
| 3443 |
break; |
| 3444 |
} |
| 3445 |
} |
| 3446 |
} |
| 3447 |
else |
| 3448 |
{ |
| 3449 |
stpui_plist_current = p2gint(data); |
| 3450 |
} |
| 3451 |
|
| 3452 |
set_current_printer(); |
| 3453 |
build_queue_combo(); |
| 3454 |
manufacturer = stp_printer_get_manufacturer(stp_get_printer(pv->v)); |
| 3455 |
build_printer_driver_clist(); |
| 3456 |
|
| 3457 |
if (strcmp(stp_get_driver(pv->v), "") != 0) |
| 3458 |
tmp_printer = stp_get_printer(pv->v); |
| 3459 |
|
| 3460 |
gtk_entry_set_text(GTK_ENTRY(file_entry), |
| 3461 |
stpui_plist_get_output_filename(pv)); |
| 3462 |
tmp = stpui_build_standard_print_command(pv, stp_get_printer(pv->v)); |
| 3463 |
gtk_entry_set_text(GTK_ENTRY(standard_cmd_entry), tmp); |
| 3464 |
stp_free(tmp); |
| 3465 |
gtk_entry_set_text(GTK_ENTRY(custom_command_entry), |
| 3466 |
stpui_plist_get_custom_command(pv)); |
| 3467 |
gtk_spin_button_set_value(GTK_SPIN_BUTTON(copy_count_spin_button), |
| 3468 |
(gfloat) stpui_plist_get_copy_count(pv)); |
| 3469 |
do_all_updates(); |
| 3470 |
|
| 3471 |
setup_update (); |
| 3472 |
do_all_updates(); |
| 3473 |
suppress_preview_update--; |
| 3474 |
update_adjusted_thumbnail(TRUE); |
| 3475 |
preview_update (); |
| 3476 |
} |
| 3477 |
|
| 3478 |
static void |
| 3479 |
show_all_paper_sizes_callback(GtkWidget *widget, gpointer data) |
| 3480 |
{ |
| 3481 |
unsigned int i; |
| 3482 |
(void)data; |
| 3483 |
stpui_show_all_paper_sizes = |
| 3484 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); |
| 3485 |
for (i = 0; i < current_option_count; i++) |
| 3486 |
{ |
| 3487 |
option_t *option = &(current_options[i]); |
| 3488 |
if (option->fast_desc && |
| 3489 |
strcmp(option->fast_desc->name, "PageSize") == 0) |
| 3490 |
{ |
| 3491 |
build_a_combo(option); |
| 3492 |
break; |
| 3493 |
} |
| 3494 |
} |
| 3495 |
} |
| 3496 |
|
| 3497 |
static void |
| 3498 |
custom_media_size_callback(GtkWidget *widget, |
| 3499 |
gpointer data) |
| 3500 |
{ |
| 3501 |
gdouble width_limit, height_limit; |
| 3502 |
gdouble min_width_limit, min_height_limit; |
| 3503 |
gdouble new_printed_value = atof(gtk_entry_get_text(GTK_ENTRY(widget))); |
| 3504 |
gdouble new_value = SCALE(new_printed_value, units[pv->unit].scale); |
| 3505 |
(void)data; |
| 3506 |
invalidate_frame (); |
| 3507 |
invalidate_preview_thumbnail (); |
| 3508 |
reset_preview (); |
| 3509 |
|
| 3510 |
stp_get_size_limit(pv->v, &width_limit, &height_limit, |
| 3511 |
&min_width_limit, &min_height_limit); |
| 3512 |
if (widget == custom_size_width) |
| 3513 |
{ |
| 3514 |
if (new_value < min_width_limit) |
| 3515 |
new_value = min_width_limit; |
| 3516 |
else if (new_value > width_limit) |
| 3517 |
new_value = width_limit; |
| 3518 |
stp_set_page_width (pv->v, new_value); |
| 3519 |
} |
| 3520 |
else |
| 3521 |
{ |
| 3522 |
if (new_value < min_height_limit) |
| 3523 |
new_value = min_height_limit; |
| 3524 |
else if (new_value > height_limit) |
| 3525 |
new_value = height_limit; |
| 3526 |
stp_set_page_height (pv->v, new_value); |
| 3527 |
} |
| 3528 |
set_entry_value (widget, new_value, 0); |
| 3529 |
preview_update (); |
| 3530 |
} |
| 3531 |
|
| 3532 |
|
| 3533 |
|
| 3534 |
|
| 3535 |
|
| 3536 |
static void |
| 3537 |
set_media_size(const gchar *new_media_size) |
| 3538 |
{ |
| 3539 |
static int setting_media_size = 0; |
| 3540 |
const stp_papersize_t *pap = stp_describe_papersize (pv->v, new_media_size); |
| 3541 |
|
| 3542 |
if (setting_media_size) |
| 3543 |
return; |
| 3544 |
setting_media_size++; |
| 3545 |
|
| 3546 |
if (pap) |
| 3547 |
{ |
| 3548 |
gdouble size; |
| 3549 |
gdouble old_width = stp_get_page_width(pv->v); |
| 3550 |
gdouble old_height = stp_get_page_height(pv->v); |
| 3551 |
int need_preview_update = 0; |
| 3552 |
|
| 3553 |
if (! stpui_show_all_paper_sizes && |
| 3554 |
(pap->paper_unit == PAPERSIZE_METRIC_EXTENDED || |
| 3555 |
pap->paper_unit == PAPERSIZE_ENGLISH_EXTENDED)) |
| 3556 |
{ |
| 3557 |
unsigned int i; |
| 3558 |
stp_parameter_t desc; |
| 3559 |
stp_describe_parameter(pv->v, "PageSize", &desc); |
| 3560 |
stp_set_string_parameter(pv->v, "PageSize", desc.deflt.str); |
| 3561 |
pap = stp_describe_papersize(pv->v, desc.deflt.str); |
| 3562 |
stp_parameter_description_destroy(&desc); |
| 3563 |
for (i = 0; i < current_option_count; i++) |
| 3564 |
{ |
| 3565 |
option_t *option = &(current_options[i]); |
| 3566 |
if (option->fast_desc && |
| 3567 |
strcmp(option->fast_desc->name, "PageSize") == 0) |
| 3568 |
{ |
| 3569 |
build_a_combo(option); |
| 3570 |
break; |
| 3571 |
} |
| 3572 |
} |
| 3573 |
} |
| 3574 |
|
| 3575 |
if (pap->width == 0) |
| 3576 |
{ |
| 3577 |
gdouble max_w, max_h, min_w, min_h; |
| 3578 |
stp_get_size_limit(pv->v, &max_w, &max_h, &min_w, &min_h); |
| 3579 |
size = old_width; |
| 3580 |
if (size < min_w) |
| 3581 |
size = min_w; |
| 3582 |
else if (size > max_w) |
| 3583 |
size = max_w; |
| 3584 |
gtk_widget_set_sensitive (GTK_WIDGET (custom_size_width), TRUE); |
| 3585 |
gtk_entry_set_editable (GTK_ENTRY (custom_size_width), TRUE); |
| 3586 |
} |
| 3587 |
else |
| 3588 |
{ |
| 3589 |
size = pap->width; |
| 3590 |
gtk_widget_set_sensitive (GTK_WIDGET (custom_size_width), FALSE); |
| 3591 |
gtk_entry_set_editable (GTK_ENTRY (custom_size_width), FALSE); |
| 3592 |
} |
| 3593 |
if (size != old_width) |
| 3594 |
{ |
| 3595 |
need_preview_update = 1; |
| 3596 |
set_entry_value (custom_size_width, size, 0); |
| 3597 |
stp_set_page_width (pv->v, size); |
| 3598 |
} |
| 3599 |
|
| 3600 |
setup_auto_paper_size(); |
| 3601 |
if (pap->height == 0) |
| 3602 |
{ |
| 3603 |
gdouble max_w, max_h, min_w, min_h; |
| 3604 |
stp_get_size_limit(pv->v, &max_w, &max_h, &min_w, &min_h); |
| 3605 |
if (auto_paper_size) |
| 3606 |
{ |
| 3607 |
gdouble l, r, b, t; |
| 3608 |
stp_set_page_height(pv->v, 0); |
| 3609 |
old_height = 0; |
| 3610 |
stp_get_imageable_area(pv->v, &l, &r, &b, &t); |
| 3611 |
gtk_widget_set_sensitive(GTK_WIDGET(custom_size_height), FALSE); |
| 3612 |
gtk_entry_set_editable(GTK_ENTRY(custom_size_height), FALSE); |
| 3613 |
size = print_height; |
| 3614 |
} |
| 3615 |
else |
| 3616 |
{ |
| 3617 |
gtk_widget_set_sensitive (GTK_WIDGET (custom_size_height), TRUE); |
| 3618 |
gtk_entry_set_editable (GTK_ENTRY (custom_size_height), TRUE); |
| 3619 |
size = old_height; |
| 3620 |
} |
| 3621 |
if (size < min_h) |
| 3622 |
size = min_h; |
| 3623 |
else if (size > max_h) |
| 3624 |
size = max_h; |
| 3625 |
} |
| 3626 |
else |
| 3627 |
{ |
| 3628 |
size = pap->height; |
| 3629 |
gtk_widget_set_sensitive(GTK_WIDGET (custom_size_height), FALSE); |
| 3630 |
gtk_entry_set_editable (GTK_ENTRY (custom_size_height), FALSE); |
| 3631 |
} |
| 3632 |
if (size != old_height) |
| 3633 |
{ |
| 3634 |
need_preview_update = 1; |
| 3635 |
set_entry_value (custom_size_height, size, 0); |
| 3636 |
stp_set_page_height (pv->v, size); |
| 3637 |
} |
| 3638 |
if (need_preview_update) |
| 3639 |
{ |
| 3640 |
invalidate_preview_thumbnail(); |
| 3641 |
invalidate_frame(); |
| 3642 |
preview_update(); |
| 3643 |
} |
| 3644 |
} |
| 3645 |
setting_media_size--; |
| 3646 |
} |
| 3647 |
|
| 3648 |
static gboolean |
| 3649 |
refresh_all_options(gpointer data) |
| 3650 |
{ |
| 3651 |
(void)data; |
| 3652 |
do_all_updates(); |
| 3653 |
do_all_updates(); |
| 3654 |
return FALSE; |
| 3655 |
} |
| 3656 |
|
| 3657 |
static void |
| 3658 |
combo_callback(GtkWidget *widget, gpointer data) |
| 3659 |
{ |
| 3660 |
(void)widget; |
| 3661 |
option_t *option = (option_t *)data; |
| 3662 |
const gchar *new_value = |
| 3663 |
stpui_combo_get_name(option->info.list.combo, option->info.list.params); |
| 3664 |
const gchar *value = |
| 3665 |
stp_get_string_parameter(pv->v, option->fast_desc->name); |
| 3666 |
if (value && new_value) |
| 3667 |
{ |
| 3668 |
reset_preview(); |
| 3669 |
if (!value || strcmp(value, new_value) != 0) |
| 3670 |
{ |
| 3671 |
invalidate_frame(); |
| 3672 |
invalidate_preview_thumbnail(); |
| 3673 |
stp_set_string_parameter(pv->v, option->fast_desc->name, new_value); |
| 3674 |
if (strcmp(option->fast_desc->name, "PageSize") == 0) |
| 3675 |
set_media_size(new_value); |
| 3676 |
g_idle_add(refresh_all_options, NULL); |
| 3677 |
if (option->fast_desc->p_class == STP_PARAMETER_CLASS_OUTPUT) |
| 3678 |
update_adjusted_thumbnail(TRUE); |
| 3679 |
preview_update(); |
| 3680 |
} |
| 3681 |
} |
| 3682 |
} |
| 3683 |
|
| 3684 |
|
| 3685 |
|
| 3686 |
|
| 3687 |
#pragma GCC diagnostic push |
| 3688 |
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" |
| 3689 |
static void |
| 3690 |
orientation_callback (GtkWidget *widget, |
| 3691 |
gpointer data) |
| 3692 |
{ |
| 3693 |
(void)widget; |
| 3694 |
reset_preview (); |
| 3695 |
|
| 3696 |
if (pv->orientation != p2gint(data)) |
| 3697 |
{ |
| 3698 |
invalidate_preview_thumbnail (); |
| 3699 |
set_orientation(p2gint(data)); |
| 3700 |
update_adjusted_thumbnail(TRUE); |
| 3701 |
preview_update (); |
| 3702 |
} |
| 3703 |
} |
| 3704 |
#pragma GCC diagnostic pop |
| 3705 |
|
| 3706 |
|
| 3707 |
|
| 3708 |
|
| 3709 |
static void |
| 3710 |
output_type_callback (GtkWidget *widget, |
| 3711 |
gpointer data) |
| 3712 |
{ |
| 3713 |
reset_preview (); |
| 3714 |
|
| 3715 |
if (GTK_TOGGLE_BUTTON (widget)->active) |
| 3716 |
{ |
| 3717 |
if (strcmp((const char *) data, "BW") == 0) |
| 3718 |
gtk_widget_hide(output_color_vbox); |
| 3719 |
else |
| 3720 |
gtk_widget_show(output_color_vbox); |
| 3721 |
stp_set_string_parameter(pv->v, "PrintingMode", (const char *) data); |
| 3722 |
invalidate_preview_thumbnail (); |
| 3723 |
update_adjusted_thumbnail (TRUE); |
| 3724 |
set_options_active(NULL); |
| 3725 |
preview_update (); |
| 3726 |
do_all_updates(); |
| 3727 |
} |
| 3728 |
} |
| 3729 |
|
| 3730 |
static void |
| 3731 |
command_type_callback(GtkWidget *widget, gpointer data) |
| 3732 |
{ |
| 3733 |
(void)widget; |
| 3734 |
if (strcmp((const char *) data, "Standard") == 0) |
| 3735 |
{ |
| 3736 |
gtk_widget_set_sensitive(standard_cmd_entry, TRUE); |
| 3737 |
gtk_widget_set_sensitive(queue_combo, TRUE); |
| 3738 |
gtk_widget_set_sensitive(file_entry, FALSE); |
| 3739 |
gtk_entry_set_editable(GTK_ENTRY(file_entry), FALSE); |
| 3740 |
gtk_widget_set_sensitive(custom_command_entry, FALSE); |
| 3741 |
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), FALSE); |
| 3742 |
gtk_widget_hide(GTK_WIDGET(file_browser)); |
| 3743 |
gtk_widget_set_sensitive(file_button, FALSE); |
| 3744 |
gtk_widget_set_sensitive(copy_count_spin_button, TRUE); |
| 3745 |
stpui_plist_set_command_type(pv, COMMAND_TYPE_DEFAULT); |
| 3746 |
} |
| 3747 |
else if (strcmp((const char *) data, "Custom") == 0) |
| 3748 |
{ |
| 3749 |
gtk_widget_set_sensitive(standard_cmd_entry, FALSE); |
| 3750 |
gtk_widget_set_sensitive(queue_combo, FALSE); |
| 3751 |
gtk_widget_set_sensitive(file_entry, FALSE); |
| 3752 |
gtk_entry_set_editable(GTK_ENTRY(file_entry), FALSE); |
| 3753 |
gtk_widget_set_sensitive(custom_command_entry, TRUE); |
| 3754 |
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), TRUE); |
| 3755 |
gtk_widget_hide(GTK_WIDGET(file_browser)); |
| 3756 |
gtk_widget_set_sensitive(file_button, FALSE); |
| 3757 |
gtk_widget_set_sensitive(copy_count_spin_button, FALSE); |
| 3758 |
stpui_plist_set_command_type(pv, COMMAND_TYPE_CUSTOM); |
| 3759 |
} |
| 3760 |
else if (strcmp((const char *) data, "File") == 0) |
| 3761 |
{ |
| 3762 |
gtk_widget_set_sensitive(standard_cmd_entry, FALSE); |
| 3763 |
gtk_widget_set_sensitive(queue_combo, FALSE); |
| 3764 |
gtk_widget_set_sensitive(file_entry, TRUE); |
| 3765 |
gtk_entry_set_editable(GTK_ENTRY(file_entry), TRUE); |
| 3766 |
gtk_widget_set_sensitive(custom_command_entry, FALSE); |
| 3767 |
gtk_entry_set_editable(GTK_ENTRY(custom_command_entry), FALSE); |
| 3768 |
gtk_widget_set_sensitive(file_button, TRUE); |
| 3769 |
gtk_widget_set_sensitive(copy_count_spin_button, FALSE); |
| 3770 |
stpui_plist_set_command_type(pv, COMMAND_TYPE_FILE); |
| 3771 |
} |
| 3772 |
} |
| 3773 |
|
| 3774 |
static void |
| 3775 |
set_all_entry_values(void) |
| 3776 |
{ |
| 3777 |
set_entry_value (top_entry, (stp_get_top (pv->v)), 1); |
| 3778 |
set_entry_value (left_entry, (stp_get_left (pv->v)), 1); |
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
set_entry_value (bottom_border_entry, |
| 3783 |
(paper_height - (stp_get_top (pv->v) + print_height)), 1); |
| 3784 |
|
| 3785 |
|
| 3786 |
|
| 3787 |
set_entry_value (right_border_entry, |
| 3788 |
(paper_width - (stp_get_left (pv->v) + print_width)), 1); |
| 3789 |
set_entry_value (width_entry, print_width, 1); |
| 3790 |
set_entry_value (height_entry, print_height, 1); |
| 3791 |
set_entry_value (custom_size_width, stp_get_page_width (pv->v), 1); |
| 3792 |
set_entry_value (custom_size_height, stp_get_page_height (pv->v), 1); |
| 3793 |
} |
| 3794 |
|
| 3795 |
|
| 3796 |
|
| 3797 |
|
| 3798 |
static void |
| 3799 |
unit_callback (GtkWidget *widget, |
| 3800 |
gpointer data) |
| 3801 |
{ |
| 3802 |
reset_preview (); |
| 3803 |
|
| 3804 |
if (GTK_TOGGLE_BUTTON (widget)->active) |
| 3805 |
{ |
| 3806 |
pv->unit = p2gint(data); |
| 3807 |
gtk_label_set_text(GTK_LABEL(units_label), units[pv->unit].name); |
| 3808 |
set_all_entry_values(); |
| 3809 |
update_options(); |
| 3810 |
do_color_updates(); |
| 3811 |
} |
| 3812 |
} |
| 3813 |
|
| 3814 |
static void |
| 3815 |
destroy_dialogs (void) |
| 3816 |
{ |
| 3817 |
unsigned int i; |
| 3818 |
gtk_widget_destroy (color_adjust_dialog); |
| 3819 |
gtk_widget_destroy (setup_dialog); |
| 3820 |
gtk_widget_destroy (print_dialog); |
| 3821 |
gtk_widget_destroy (new_printer_dialog); |
| 3822 |
gtk_widget_destroy (about_dialog); |
| 3823 |
for (i = 0; i < current_option_count; i++) |
| 3824 |
{ |
| 3825 |
if (current_options[i].fast_desc->p_type == STP_PARAMETER_TYPE_CURVE && |
| 3826 |
current_options[i].info.curve.dialog) |
| 3827 |
gtk_widget_destroy(current_options[i].info.curve.dialog); |
| 3828 |
} |
| 3829 |
} |
| 3830 |
|
| 3831 |
static void |
| 3832 |
dialogs_set_sensitive (gboolean sensitive) |
| 3833 |
{ |
| 3834 |
unsigned int i; |
| 3835 |
gtk_widget_set_sensitive (color_adjust_dialog, sensitive); |
| 3836 |
gtk_widget_set_sensitive (setup_dialog, sensitive); |
| 3837 |
gtk_widget_set_sensitive (print_dialog, sensitive); |
| 3838 |
gtk_widget_set_sensitive (new_printer_dialog, sensitive); |
| 3839 |
gtk_widget_set_sensitive (about_dialog, sensitive); |
| 3840 |
for (i = 0; i < current_option_count; i++) |
| 3841 |
{ |
| 3842 |
if (current_options[i].fast_desc->p_type == STP_PARAMETER_TYPE_CURVE && |
| 3843 |
current_options[i].info.curve.dialog) |
| 3844 |
gtk_widget_set_sensitive(current_options[i].info.curve.dialog, |
| 3845 |
sensitive); |
| 3846 |
} |
| 3847 |
} |
| 3848 |
|
| 3849 |
|
| 3850 |
|
| 3851 |
|
| 3852 |
static void |
| 3853 |
print_callback (void) |
| 3854 |
{ |
| 3855 |
if (stpui_plist_get_command_type(pv) == COMMAND_TYPE_FILE && |
| 3856 |
strlen(stpui_plist_get_output_filename(pv)) == 0) |
| 3857 |
{ |
| 3858 |
dialogs_set_sensitive (FALSE); |
| 3859 |
exit_after_file_ok = 1; |
| 3860 |
gtk_widget_show (file_browser); |
| 3861 |
} |
| 3862 |
else |
| 3863 |
{ |
| 3864 |
runme = TRUE; |
| 3865 |
destroy_dialogs (); |
| 3866 |
} |
| 3867 |
} |
| 3868 |
|
| 3869 |
|
| 3870 |
|
| 3871 |
|
| 3872 |
static void |
| 3873 |
printandsave_callback (void) |
| 3874 |
{ |
| 3875 |
saveme = TRUE; |
| 3876 |
print_callback(); |
| 3877 |
} |
| 3878 |
|
| 3879 |
static void |
| 3880 |
about_callback (void) |
| 3881 |
{ |
| 3882 |
gtk_widget_show (about_dialog); |
| 3883 |
} |
| 3884 |
|
| 3885 |
|
| 3886 |
|
| 3887 |
|
| 3888 |
static void |
| 3889 |
save_callback (void) |
| 3890 |
{ |
| 3891 |
reset_preview (); |
| 3892 |
stpui_printrc_save (); |
| 3893 |
} |
| 3894 |
|
| 3895 |
|
| 3896 |
|
| 3897 |
|
| 3898 |
static void |
| 3899 |
setup_update (void) |
| 3900 |
{ |
| 3901 |
GtkAdjustment *adjustment; |
| 3902 |
gint idx = 0; |
| 3903 |
gint i; |
| 3904 |
gchar *tmp; |
| 3905 |
stp_parameter_t desc; |
| 3906 |
const char *ppd_file_name = stp_get_file_parameter(pv->v, "PPDFile"); |
| 3907 |
|
| 3908 |
for (i = 0; i < GTK_CLIST(manufacturer_clist)->rows; i++) |
| 3909 |
{ |
| 3910 |
(void) gtk_clist_get_text(GTK_CLIST(manufacturer_clist), i, 0, &tmp); |
| 3911 |
if (tmp && strcmp(manufacturer, tmp) == 0) |
| 3912 |
{ |
| 3913 |
idx = i; |
| 3914 |
break; |
| 3915 |
} |
| 3916 |
} |
| 3917 |
gtk_clist_select_row(GTK_CLIST(manufacturer_clist), idx, 0); |
| 3918 |
|
| 3919 |
idx = stp_get_printer_index_by_driver (stp_get_driver (pv->v)); |
| 3920 |
|
| 3921 |
idx = gtk_clist_find_row_from_data(GTK_CLIST(printer_driver), |
| 3922 |
gint2p(idx)); |
| 3923 |
|
| 3924 |
|
| 3925 |
|
| 3926 |
|
| 3927 |
gtk_clist_select_row (GTK_CLIST (printer_driver), idx, 0); |
| 3928 |
stp_describe_parameter(pv->v, "ModelName", &desc); |
| 3929 |
if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST && desc.is_active && |
| 3930 |
desc.deflt.str) |
| 3931 |
{ |
| 3932 |
const char *extra_printer_model = desc.deflt.str; |
| 3933 |
char *label_text = |
| 3934 |
g_malloc(strlen(gettext (stp_printer_get_long_name (tmp_printer))) + |
| 3935 |
2 + |
| 3936 |
strlen(extra_printer_model) + |
| 3937 |
2); |
| 3938 |
strcpy(label_text, extra_printer_model); |
| 3939 |
strcat(label_text, " ("); |
| 3940 |
strcat(label_text, gettext (stp_printer_get_long_name (tmp_printer))); |
| 3941 |
strcat(label_text, ")"); |
| 3942 |
gtk_label_set_text (GTK_LABEL (printer_model_label), label_text); |
| 3943 |
g_free(label_text); |
| 3944 |
} |
| 3945 |
else |
| 3946 |
{ |
| 3947 |
gtk_label_set_text (GTK_LABEL (printer_model_label), |
| 3948 |
gettext (stp_printer_get_long_name (tmp_printer))); |
| 3949 |
} |
| 3950 |
stp_parameter_description_destroy(&desc); |
| 3951 |
|
| 3952 |
if (ppd_file_name) |
| 3953 |
gtk_entry_set_text (GTK_ENTRY (ppd_file), ppd_file_name); |
| 3954 |
else |
| 3955 |
gtk_entry_set_text (GTK_ENTRY (ppd_file), ""); |
| 3956 |
ppd_file_callback(ppd_file, NULL); |
| 3957 |
|
| 3958 |
if (stp_parameter_find_in_settings(pv->v, "PPDFile")) |
| 3959 |
{ |
| 3960 |
gtk_widget_show (ppd_box); |
| 3961 |
gtk_widget_show (ppd_label); |
| 3962 |
gtk_widget_show (ppd_model_label); |
| 3963 |
gtk_widget_show (ppd_model); |
| 3964 |
} |
| 3965 |
else |
| 3966 |
{ |
| 3967 |
gtk_widget_hide (ppd_box); |
| 3968 |
gtk_widget_hide (ppd_label); |
| 3969 |
gtk_widget_hide (ppd_model_label); |
| 3970 |
gtk_widget_hide (ppd_model); |
| 3971 |
} |
| 3972 |
gtk_entry_set_text (GTK_ENTRY (custom_command_entry), |
| 3973 |
stpui_plist_get_custom_command (pv)); |
| 3974 |
|
| 3975 |
adjustment = GTK_CLIST (printer_driver)->vadjustment; |
| 3976 |
gtk_adjustment_set_value |
| 3977 |
(adjustment, |
| 3978 |
adjustment->lower + idx * (adjustment->upper - adjustment->lower) / |
| 3979 |
GTK_CLIST (printer_driver)->rows); |
| 3980 |
|
| 3981 |
i = stpui_plist_get_command_type(pv); |
| 3982 |
if (i >= 0 && i < command_options_count) |
| 3983 |
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(command_options[i].button), |
| 3984 |
TRUE); |
| 3985 |
} |
| 3986 |
|
| 3987 |
static void |
| 3988 |
ppd_file_callback(GtkWidget *widget, gpointer data) |
| 3989 |
{ |
| 3990 |
(void)data; |
| 3991 |
const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget)); |
| 3992 |
if (name && pv && pv->v) |
| 3993 |
{ |
| 3994 |
stp_parameter_t desc; |
| 3995 |
stp_vars_t *v = stp_vars_create_copy(pv->v); |
| 3996 |
stp_set_file_parameter(v, "PPDFile", name); |
| 3997 |
stp_describe_parameter(v, "ModelName", &desc); |
| 3998 |
if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST && desc.is_active) |
| 3999 |
gtk_label_set_text(GTK_LABEL(ppd_model), desc.deflt.str); |
| 4000 |
else |
| 4001 |
gtk_label_set_text(GTK_LABEL(ppd_model), ""); |
| 4002 |
stp_parameter_description_destroy(&desc); |
| 4003 |
stp_vars_destroy(v); |
| 4004 |
} |
| 4005 |
else |
| 4006 |
gtk_label_set_text(GTK_LABEL(ppd_model), ""); |
| 4007 |
} |
| 4008 |
|
| 4009 |
|
| 4010 |
|
| 4011 |
|
| 4012 |
static void |
| 4013 |
setup_open_callback (void) |
| 4014 |
{ |
| 4015 |
static gboolean first_time = TRUE; |
| 4016 |
manufacturer = stp_printer_get_manufacturer(stp_get_printer(pv->v)); |
| 4017 |
build_printer_driver_clist(); |
| 4018 |
|
| 4019 |
reset_preview (); |
| 4020 |
setup_update (); |
| 4021 |
|
| 4022 |
|
| 4023 |
gtk_widget_show (setup_dialog); |
| 4024 |
|
| 4025 |
if (first_time) |
| 4026 |
{ |
| 4027 |
|
| 4028 |
setup_update (); |
| 4029 |
first_time = FALSE; |
| 4030 |
} |
| 4031 |
} |
| 4032 |
|
| 4033 |
|
| 4034 |
|
| 4035 |
|
| 4036 |
static void |
| 4037 |
new_printer_open_callback (void) |
| 4038 |
{ |
| 4039 |
reset_preview (); |
| 4040 |
gtk_entry_set_text (GTK_ENTRY (new_printer_entry), ""); |
| 4041 |
gtk_widget_show (new_printer_dialog); |
| 4042 |
} |
| 4043 |
|
| 4044 |
static void |
| 4045 |
set_printer(void) |
| 4046 |
{ |
| 4047 |
manufacturer = stp_printer_get_manufacturer(tmp_printer); |
| 4048 |
build_printer_driver_clist(); |
| 4049 |
build_queue_combo(); |
| 4050 |
stp_set_driver (pv->v, stp_printer_get_driver (tmp_printer)); |
| 4051 |
stpui_plist_set_custom_command |
| 4052 |
(pv, gtk_entry_get_text (GTK_ENTRY (custom_command_entry))); |
| 4053 |
stpui_plist_set_output_filename |
| 4054 |
(pv, gtk_entry_get_text (GTK_ENTRY (file_entry))); |
| 4055 |
stp_set_file_parameter (pv->v, "PPDFile", |
| 4056 |
gtk_entry_get_text (GTK_ENTRY (ppd_file))); |
| 4057 |
gtk_label_set_text (GTK_LABEL (printer_model_label), |
| 4058 |
gettext (stp_printer_get_long_name (tmp_printer))); |
| 4059 |
|
| 4060 |
plist_callback (NULL, gint2p(stpui_plist_current)); |
| 4061 |
} |
| 4062 |
|
| 4063 |
|
| 4064 |
|
| 4065 |
|
| 4066 |
static void |
| 4067 |
setup_ok_callback (void) |
| 4068 |
{ |
| 4069 |
gtk_widget_hide(ppd_browser); |
| 4070 |
gtk_widget_hide(file_browser); |
| 4071 |
gtk_widget_hide(setup_dialog); |
| 4072 |
set_printer(); |
| 4073 |
gtk_widget_set_sensitive(GTK_DIALOG(print_dialog)->action_area, TRUE); |
| 4074 |
} |
| 4075 |
|
| 4076 |
|
| 4077 |
|
| 4078 |
|
| 4079 |
static void |
| 4080 |
setup_cancel_callback (void) |
| 4081 |
{ |
| 4082 |
gtk_widget_hide(ppd_browser); |
| 4083 |
gtk_widget_hide(file_browser); |
| 4084 |
gtk_widget_hide(setup_dialog); |
| 4085 |
manufacturer = stp_printer_get_manufacturer(stp_get_printer(pv->v)); |
| 4086 |
build_printer_driver_clist(); |
| 4087 |
setup_update(); |
| 4088 |
gtk_widget_set_sensitive(GTK_DIALOG(print_dialog)->action_area, TRUE); |
| 4089 |
} |
| 4090 |
|
| 4091 |
|
| 4092 |
|
| 4093 |
|
| 4094 |
static void |
| 4095 |
new_printer_ok_callback (void) |
| 4096 |
{ |
| 4097 |
const gchar *data = gtk_entry_get_text (GTK_ENTRY (new_printer_entry)); |
| 4098 |
stpui_plist_t key; |
| 4099 |
|
| 4100 |
if (strlen(data)) |
| 4101 |
{ |
| 4102 |
memset(&key, 0, sizeof(key)); |
| 4103 |
stpui_printer_initialize (&key); |
| 4104 |
stpui_plist_copy(&key, pv); |
| 4105 |
stpui_plist_set_name(&key, data); |
| 4106 |
|
| 4107 |
if (stpui_plist_add (&key, 1)) |
| 4108 |
{ |
| 4109 |
stp_vars_destroy(key.v); |
| 4110 |
g_free(key.name); |
| 4111 |
stpui_plist_current = stpui_plist_count - 1; |
| 4112 |
set_current_printer(); |
| 4113 |
build_printer_combo (); |
| 4114 |
set_printer(); |
| 4115 |
} |
| 4116 |
} |
| 4117 |
|
| 4118 |
gtk_widget_hide (new_printer_dialog); |
| 4119 |
} |
| 4120 |
|
| 4121 |
static void |
| 4122 |
pop_ppd_box(void) |
| 4123 |
{ |
| 4124 |
const stp_vars_t *v = stp_printer_get_defaults(tmp_printer); |
| 4125 |
if (stp_parameter_find_in_settings(v, "PPDFile")) |
| 4126 |
{ |
| 4127 |
gtk_widget_show (ppd_label); |
| 4128 |
gtk_widget_show (ppd_box); |
| 4129 |
gtk_widget_show (ppd_model_label); |
| 4130 |
gtk_widget_show (ppd_model); |
| 4131 |
} |
| 4132 |
else |
| 4133 |
{ |
| 4134 |
gtk_widget_hide (ppd_label); |
| 4135 |
gtk_widget_hide (ppd_box); |
| 4136 |
gtk_widget_hide (ppd_model_label); |
| 4137 |
gtk_widget_hide (ppd_model); |
| 4138 |
} |
| 4139 |
} |
| 4140 |
|
| 4141 |
static void |
| 4142 |
build_printer_driver_clist(void) |
| 4143 |
{ |
| 4144 |
int i; |
| 4145 |
int current_idx = 0; |
| 4146 |
gtk_clist_clear(GTK_CLIST(printer_driver)); |
| 4147 |
for (i = 0; i < stp_printer_model_count (); i ++) |
| 4148 |
{ |
| 4149 |
const stp_printer_t *the_printer = stp_get_printer_by_index (i); |
| 4150 |
|
| 4151 |
if (strcmp(manufacturer, stp_printer_get_manufacturer(the_printer)) == 0) |
| 4152 |
{ |
| 4153 |
gchar *tmp=g_strdup(gettext(stp_printer_get_long_name(the_printer))); |
| 4154 |
|
| 4155 |
|
| 4156 |
|
| 4157 |
|
| 4158 |
|
| 4159 |
|
| 4160 |
|
| 4161 |
|
| 4162 |
gtk_clist_insert (GTK_CLIST (printer_driver), current_idx, &tmp); |
| 4163 |
gtk_clist_set_row_data (GTK_CLIST (printer_driver), current_idx, |
| 4164 |
gint2p(i)); |
| 4165 |
g_free(tmp); |
| 4166 |
current_idx++; |
| 4167 |
} |
| 4168 |
} |
| 4169 |
} |
| 4170 |
|
| 4171 |
static void |
| 4172 |
manufacturer_callback(GtkWidget *widget, |
| 4173 |
gint row, |
| 4174 |
gint column, |
| 4175 |
GdkEventButton *event, |
| 4176 |
gpointer data) |
| 4177 |
{ |
| 4178 |
(void)event; |
| 4179 |
(void)data; |
| 4180 |
static int calling_manufacturer_callback = 0; |
| 4181 |
gchar *text; |
| 4182 |
if (calling_manufacturer_callback) |
| 4183 |
return; |
| 4184 |
calling_manufacturer_callback++; |
| 4185 |
if (gtk_clist_get_text(GTK_CLIST(widget), row, column, &text)) |
| 4186 |
manufacturer = text; |
| 4187 |
build_printer_driver_clist(); |
| 4188 |
setup_update(); |
| 4189 |
calling_manufacturer_callback--; |
| 4190 |
} |
| 4191 |
|
| 4192 |
|
| 4193 |
|
| 4194 |
|
| 4195 |
#pragma GCC diagnostic push |
| 4196 |
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast" |
| 4197 |
static void |
| 4198 |
print_driver_callback (GtkWidget *widget, |
| 4199 |
gint row, |
| 4200 |
gint column, |
| 4201 |
GdkEventButton *event, |
| 4202 |
gpointer data) |
| 4203 |
{ |
| 4204 |
(void)column; |
| 4205 |
(void)event; |
| 4206 |
char *tmp; |
| 4207 |
static int calling_print_driver_callback = 0; |
| 4208 |
if (calling_print_driver_callback) |
| 4209 |
return; |
| 4210 |
calling_print_driver_callback++; |
| 4211 |
invalidate_frame (); |
| 4212 |
invalidate_preview_thumbnail (); |
| 4213 |
reset_preview (); |
| 4214 |
data = gtk_clist_get_row_data (GTK_CLIST (widget), row); |
| 4215 |
tmp_printer = stp_get_printer_by_index (p2gint(data)); |
| 4216 |
tmp = stpui_build_standard_print_command(pv, tmp_printer); |
| 4217 |
gtk_entry_set_text(GTK_ENTRY(standard_cmd_entry), tmp); |
| 4218 |
stp_free(tmp); |
| 4219 |
|
| 4220 |
pop_ppd_box(); |
| 4221 |
calling_print_driver_callback--; |
| 4222 |
} |
| 4223 |
#pragma GCC diagnostic pop |
| 4224 |
|
| 4225 |
|
| 4226 |
|
| 4227 |
|
| 4228 |
static void |
| 4229 |
ppd_browse_callback (void) |
| 4230 |
{ |
| 4231 |
reset_preview (); |
| 4232 |
gtk_file_selection_set_filename (GTK_FILE_SELECTION (ppd_browser), |
| 4233 |
gtk_entry_get_text (GTK_ENTRY (ppd_file))); |
| 4234 |
gtk_widget_show (ppd_browser); |
| 4235 |
} |
| 4236 |
|
| 4237 |
|
| 4238 |
|
| 4239 |
|
| 4240 |
static void |
| 4241 |
ppd_ok_callback (void) |
| 4242 |
{ |
| 4243 |
reset_preview (); |
| 4244 |
gtk_widget_hide (ppd_browser); |
| 4245 |
gtk_entry_set_text |
| 4246 |
(GTK_ENTRY (ppd_file), |
| 4247 |
gtk_file_selection_get_filename (GTK_FILE_SELECTION (ppd_browser))); |
| 4248 |
ppd_file_callback(ppd_file, NULL); |
| 4249 |
update_options(); |
| 4250 |
} |
| 4251 |
|
| 4252 |
|
| 4253 |
|
| 4254 |
|
| 4255 |
static void |
| 4256 |
file_browse_callback (void) |
| 4257 |
{ |
| 4258 |
reset_preview (); |
| 4259 |
gtk_file_selection_set_filename (GTK_FILE_SELECTION (file_browser), |
| 4260 |
gtk_entry_get_text (GTK_ENTRY (file_entry))); |
| 4261 |
gtk_widget_show (file_browser); |
| 4262 |
} |
| 4263 |
|
| 4264 |
|
| 4265 |
|
| 4266 |
|
| 4267 |
static void |
| 4268 |
file_ok_callback (void) |
| 4269 |
{ |
| 4270 |
const char *filename = |
| 4271 |
gtk_file_selection_get_filename(GTK_FILE_SELECTION(file_browser)); |
| 4272 |
gtk_widget_hide (file_browser); |
| 4273 |
gtk_entry_set_text(GTK_ENTRY(file_entry), filename); |
| 4274 |
stpui_plist_set_output_filename(pv, filename); |
| 4275 |
if (exit_after_file_ok) |
| 4276 |
{ |
| 4277 |
runme = TRUE; |
| 4278 |
destroy_dialogs (); |
| 4279 |
} |
| 4280 |
} |
| 4281 |
|
| 4282 |
|
| 4283 |
|
| 4284 |
|
| 4285 |
static void |
| 4286 |
file_cancel_callback (void) |
| 4287 |
{ |
| 4288 |
exit_after_file_ok = 0; |
| 4289 |
gtk_widget_hide (file_browser); |
| 4290 |
dialogs_set_sensitive (TRUE); |
| 4291 |
} |
| 4292 |
|
| 4293 |
static void |
| 4294 |
fill_buffer_writefunc(void *priv, const char *buffer, size_t bytes) |
| 4295 |
{ |
| 4296 |
int mask = 0; |
| 4297 |
size_t i; |
| 4298 |
|
| 4299 |
priv_t *p = (priv_t *) priv; |
| 4300 |
unsigned char *where = p->base_addr + p->offset; |
| 4301 |
const unsigned char *xbuffer = (const unsigned char *)buffer; |
| 4302 |
|
| 4303 |
if (strcmp(p->output_type, "Whitescale") == 0) |
| 4304 |
{ |
| 4305 |
memcpy(where, xbuffer, bytes); |
| 4306 |
p->offset += bytes; |
| 4307 |
} |
| 4308 |
else if (strcmp(p->output_type, "Grayscale") == 0) |
| 4309 |
{ |
| 4310 |
for (i = 0; i < bytes; i++) |
| 4311 |
where[i] = ~xbuffer[i]; |
| 4312 |
p->offset += bytes; |
| 4313 |
} |
| 4314 |
else if (strcmp(p->output_type, "RGB") == 0) |
| 4315 |
{ |
| 4316 |
unsigned int pixels = bytes / 3; |
| 4317 |
if ((off_t)bytes + p->offset > p->limit) |
| 4318 |
bytes = p->limit - p->offset; |
| 4319 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(red_button))) |
| 4320 |
mask |= 1; |
| 4321 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(green_button))) |
| 4322 |
mask |= 2; |
| 4323 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(blue_button))) |
| 4324 |
mask |= 4; |
| 4325 |
|
| 4326 |
memset(where, 0, pixels * 3); |
| 4327 |
for (i = 0; i < pixels; i++) |
| 4328 |
{ |
| 4329 |
if (mask & 1) |
| 4330 |
where[0] = xbuffer[0]; |
| 4331 |
if (mask & 2) |
| 4332 |
where[1] = xbuffer[1]; |
| 4333 |
if (mask & 4) |
| 4334 |
where[2] = xbuffer[2]; |
| 4335 |
where += 3; |
| 4336 |
xbuffer += 3; |
| 4337 |
} |
| 4338 |
p->offset += pixels * 3; |
| 4339 |
} |
| 4340 |
else if (strcmp(p->output_type, "CMY") == 0) |
| 4341 |
{ |
| 4342 |
unsigned int pixels = bytes / 3; |
| 4343 |
if ((off_t)bytes + p->offset > p->limit) |
| 4344 |
bytes = p->limit - p->offset; |
| 4345 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cyan_button))) |
| 4346 |
mask |= 1; |
| 4347 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(magenta_button))) |
| 4348 |
mask |= 2; |
| 4349 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(yellow_button))) |
| 4350 |
mask |= 4; |
| 4351 |
|
| 4352 |
memset(where, 0xff, pixels * 3); |
| 4353 |
for (i = 0; i < pixels; i++) |
| 4354 |
{ |
| 4355 |
if (mask & 1) |
| 4356 |
where[0] = ~xbuffer[0]; |
| 4357 |
if (mask & 2) |
| 4358 |
where[1] = ~xbuffer[1]; |
| 4359 |
if (mask & 4) |
| 4360 |
where[2] = ~xbuffer[2]; |
| 4361 |
where += 3; |
| 4362 |
xbuffer += 3; |
| 4363 |
} |
| 4364 |
p->offset += pixels * 3; |
| 4365 |
} |
| 4366 |
else |
| 4367 |
{ |
| 4368 |
unsigned int pixels = bytes / 4; |
| 4369 |
if ((off_t)bytes + p->offset > p->limit) |
| 4370 |
bytes = p->limit - p->offset; |
| 4371 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cyan_button))) |
| 4372 |
mask |= 1; |
| 4373 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(magenta_button))) |
| 4374 |
mask |= 2; |
| 4375 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(yellow_button))) |
| 4376 |
mask |= 4; |
| 4377 |
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(black_button))) |
| 4378 |
mask |= 8; |
| 4379 |
|
| 4380 |
memset(where, 0xff, pixels * 3); |
| 4381 |
for (i = 0; i < pixels; i++) |
| 4382 |
{ |
| 4383 |
if (mask & 8) |
| 4384 |
{ |
| 4385 |
where[0] -= xbuffer[3]; |
| 4386 |
where[1] -= xbuffer[3]; |
| 4387 |
where[2] -= xbuffer[3]; |
| 4388 |
} |
| 4389 |
if (mask & 1) |
| 4390 |
{ |
| 4391 |
if (where[0] < xbuffer[0]) |
| 4392 |
where[0] = 0; |
| 4393 |
else |
| 4394 |
where[0] -= xbuffer[0]; |
| 4395 |
} |
| 4396 |
if (mask & 2) |
| 4397 |
{ |
| 4398 |
if (where[1] < xbuffer[1]) |
| 4399 |
where[1] = 0; |
| 4400 |
else |
| 4401 |
where[1] -= xbuffer[1]; |
| 4402 |
} |
| 4403 |
if (mask & 4) |
| 4404 |
{ |
| 4405 |
if (where[2] < xbuffer[2]) |
| 4406 |
where[2] = 0; |
| 4407 |
else |
| 4408 |
where[2] -= xbuffer[2]; |
| 4409 |
} |
| 4410 |
where += 3; |
| 4411 |
xbuffer += 4; |
| 4412 |
} |
| 4413 |
p->offset += pixels * 3; |
| 4414 |
} |
| 4415 |
} |
| 4416 |
|
| 4417 |
|
| 4418 |
|
| 4419 |
|
| 4420 |
|
| 4421 |
static void |
| 4422 |
redraw_color_swatch (void) |
| 4423 |
{ |
| 4424 |
static GdkGC *gc = NULL; |
| 4425 |
|
| 4426 |
if (adjusted_thumbnail_data && swatch && swatch->widget.window) |
| 4427 |
{ |
| 4428 |
if (gc == NULL) |
| 4429 |
{ |
| 4430 |
gc = gdk_gc_new (swatch->widget.window); |
| 4431 |
} |
| 4432 |
|
| 4433 |
if (!print_mode_is_color(pv->v)) |
| 4434 |
gdk_draw_gray_image(swatch->widget.window, gc, 0, 0, |
| 4435 |
thumbnail_w, thumbnail_h, GDK_RGB_DITHER_NORMAL, |
| 4436 |
adjusted_thumbnail_data, thumbnail_w); |
| 4437 |
else |
| 4438 |
gdk_draw_rgb_image(swatch->widget.window, gc, 0, 0, |
| 4439 |
thumbnail_w, thumbnail_h, GDK_RGB_DITHER_NORMAL, |
| 4440 |
adjusted_thumbnail_data, 3 * thumbnail_w); |
| 4441 |
} |
| 4442 |
} |
| 4443 |
|
| 4444 |
static void |
| 4445 |
initialize_thumbnail(void) |
| 4446 |
{ |
| 4447 |
int i; |
| 4448 |
if (stpui_get_thumbnail_func()) |
| 4449 |
{ |
| 4450 |
const guchar *internal_thumbnail_data; |
| 4451 |
|
| 4452 |
|
| 4453 |
|
| 4454 |
|
| 4455 |
|
| 4456 |
|
| 4457 |
|
| 4458 |
thumbnail_w = gdk_screen_width()/4; |
| 4459 |
thumbnail_h = gdk_screen_height()/4; |
| 4460 |
|
| 4461 |
|
| 4462 |
|
| 4463 |
|
| 4464 |
|
| 4465 |
internal_thumbnail_data = |
| 4466 |
(stpui_get_thumbnail_func()) (stpui_get_thumbnail_data(), &thumbnail_w, |
| 4467 |
&thumbnail_h, &thumbnail_bpp, 0); |
| 4468 |
if (adjusted_thumbnail_data) |
| 4469 |
g_free(adjusted_thumbnail_data); |
| 4470 |
if (preview_thumbnail_data) |
| 4471 |
g_free(preview_thumbnail_data); |
| 4472 |
if (thumbnail_data) |
| 4473 |
g_free(thumbnail_data); |
| 4474 |
|
| 4475 |
if (internal_thumbnail_data) |
| 4476 |
{ |
| 4477 |
|
| 4478 |
|
| 4479 |
|
| 4480 |
|
| 4481 |
|
| 4482 |
|
| 4483 |
adjusted_thumbnail_data = g_malloc (3 * thumbnail_w * thumbnail_h); |
| 4484 |
preview_thumbnail_data = g_malloc (3 * thumbnail_w * thumbnail_h); |
| 4485 |
thumbnail_data = g_malloc (3 * thumbnail_w * thumbnail_h); |
| 4486 |
|
| 4487 |
switch (thumbnail_bpp) |
| 4488 |
{ |
| 4489 |
case 1: |
| 4490 |
for (i = 0; i < thumbnail_w * thumbnail_h; i++) |
| 4491 |
{ |
| 4492 |
gint val = internal_thumbnail_data[i]; |
| 4493 |
thumbnail_data[(3 * i) + 0] = val; |
| 4494 |
thumbnail_data[(3 * i) + 1] = val; |
| 4495 |
thumbnail_data[(3 * i) + 2] = val; |
| 4496 |
} |
| 4497 |
break; |
| 4498 |
case 3: |
| 4499 |
memcpy(thumbnail_data, internal_thumbnail_data, |
| 4500 |
3 * thumbnail_w * thumbnail_h); |
| 4501 |
break; |
| 4502 |
case 2: |
| 4503 |
for (i = 0; i < thumbnail_w * thumbnail_h; i++) |
| 4504 |
{ |
| 4505 |
gint val = internal_thumbnail_data[2 * i]; |
| 4506 |
gint alpha = internal_thumbnail_data[(2 * i) + 1]; |
| 4507 |
thumbnail_data[(3 * i) +0] = val * alpha / 255 + 255 - alpha; |
| 4508 |
thumbnail_data[(3 * i) +1] = val * alpha / 255 + 255 - alpha; |
| 4509 |
thumbnail_data[(3 * i) +2] = val * alpha / 255 + 255 - alpha; |
| 4510 |
} |
| 4511 |
break; |
| 4512 |
case 4: |
| 4513 |
for (i = 0; i < thumbnail_w * thumbnail_h; i++) |
| 4514 |
{ |
| 4515 |
gint r = internal_thumbnail_data[(4 * i)]; |
| 4516 |
gint g = internal_thumbnail_data[(4 * i) + 1]; |
| 4517 |
gint b = internal_thumbnail_data[(4 * i) + 2]; |
| 4518 |
gint alpha = internal_thumbnail_data[(4 * i) + 3]; |
| 4519 |
thumbnail_data[(3 * i) + 0] = r * alpha / 255 + 255 - alpha; |
| 4520 |
thumbnail_data[(3 * i) + 1] = g * alpha / 255 + 255 - alpha; |
| 4521 |
thumbnail_data[(3 * i) + 2] = b * alpha / 255 + 255 - alpha; |
| 4522 |
} |
| 4523 |
break; |
| 4524 |
default: |
| 4525 |
break; |
| 4526 |
|
| 4527 |
} |
| 4528 |
thumbnail_bpp = 3; |
| 4529 |
} |
| 4530 |
else |
| 4531 |
{ |
| 4532 |
thumbnail_h = 0; |
| 4533 |
thumbnail_w = 0; |
| 4534 |
} |
| 4535 |
} |
| 4536 |
else |
| 4537 |
{ |
| 4538 |
thumbnail_h = 0; |
| 4539 |
thumbnail_w = 0; |
| 4540 |
} |
| 4541 |
} |
| 4542 |
|
| 4543 |
static int |
| 4544 |
compute_thumbnail(const stp_vars_t *v) |
| 4545 |
{ |
| 4546 |
priv_t priv; |
| 4547 |
int answer = 1; |
| 4548 |
stp_image_t *im = stpui_image_thumbnail_new(thumbnail_data, thumbnail_w, |
| 4549 |
thumbnail_h, thumbnail_bpp); |
| 4550 |
stp_vars_t *nv = stp_vars_create_copy(v); |
| 4551 |
const char *output_type = stp_describe_output(nv); |
| 4552 |
stp_set_top(nv, 0); |
| 4553 |
stp_set_left(nv, 0); |
| 4554 |
stp_set_width(nv, thumbnail_w); |
| 4555 |
stp_set_height(nv, thumbnail_h); |
| 4556 |
stp_set_outfunc(nv, fill_buffer_writefunc); |
| 4557 |
stp_set_outdata(nv, &priv); |
| 4558 |
stp_set_errfunc(nv, stpui_get_errfunc()); |
| 4559 |
stp_set_errdata(nv, stpui_get_errdata()); |
| 4560 |
if (strcmp(output_type, "Whitescale") == 0) |
| 4561 |
{ |
| 4562 |
gtk_widget_hide(output_color_vbox); |
| 4563 |
priv.bpp = 1; |
| 4564 |
priv.output_type = "Whitescale"; |
| 4565 |
stp_set_string_parameter(nv, "InkType", "RGBGray"); |
| 4566 |
} |
| 4567 |
else if (strcmp(output_type, "Grayscale") == 0) |
| 4568 |
{ |
| 4569 |
gtk_widget_hide(output_color_vbox); |
| 4570 |
priv.bpp = 1; |
| 4571 |
priv.output_type = "Grayscale"; |
| 4572 |
stp_set_string_parameter(nv, "InkType", "CMYGray"); |
| 4573 |
} |
| 4574 |
else if (strcmp(output_type, "CMY") == 0) |
| 4575 |
{ |
| 4576 |
gtk_widget_hide(black_button); |
| 4577 |
gtk_widget_hide(red_button); |
| 4578 |
gtk_widget_hide(green_button); |
| 4579 |
gtk_widget_hide(blue_button); |
| 4580 |
gtk_widget_show(cyan_button); |
| 4581 |
gtk_widget_show(magenta_button); |
| 4582 |
gtk_widget_show(yellow_button); |
| 4583 |
gtk_widget_show(output_color_vbox); |
| 4584 |
priv.bpp = 3; |
| 4585 |
priv.output_type = "CMY"; |
| 4586 |
stp_set_string_parameter(nv, "InkType", "CMY"); |
| 4587 |
} |
| 4588 |
else if (strcmp(output_type, "RGB") == 0) |
| 4589 |
{ |
| 4590 |
gtk_widget_hide(cyan_button); |
| 4591 |
gtk_widget_hide(magenta_button); |
| 4592 |
gtk_widget_hide(yellow_button); |
| 4593 |
gtk_widget_hide(black_button); |
| 4594 |
gtk_widget_show(red_button); |
| 4595 |
gtk_widget_show(green_button); |
| 4596 |
gtk_widget_show(blue_button); |
| 4597 |
gtk_widget_show(output_color_vbox); |
| 4598 |
priv.bpp = 3; |
| 4599 |
priv.output_type = "RGB"; |
| 4600 |
stp_set_string_parameter(nv, "InkType", "RGB"); |
| 4601 |
} |
| 4602 |
else |
| 4603 |
{ |
| 4604 |
gtk_widget_hide(red_button); |
| 4605 |
gtk_widget_hide(green_button); |
| 4606 |
gtk_widget_hide(blue_button); |
| 4607 |
gtk_widget_show(cyan_button); |
| 4608 |
gtk_widget_show(magenta_button); |
| 4609 |
gtk_widget_show(yellow_button); |
| 4610 |
gtk_widget_show(black_button); |
| 4611 |
gtk_widget_show(output_color_vbox); |
| 4612 |
priv.bpp = 4; |
| 4613 |
priv.output_type = "CMYK"; |
| 4614 |
stp_set_string_parameter(nv, "InkType", "CMYK"); |
| 4615 |
} |
| 4616 |
stp_set_page_height(nv, thumbnail_h); |
| 4617 |
stp_set_page_width(nv, thumbnail_w); |
| 4618 |
stp_set_driver(nv, "raw-data-8"); |
| 4619 |
stp_set_string_parameter(nv, "PageSize", "Custom"); |
| 4620 |
stp_set_float_parameter(nv, "InkLimit", 0); |
| 4621 |
stp_set_string_parameter(nv, "InputImageType", "RGB"); |
| 4622 |
stp_clear_file_parameter(nv, "LUTDumpFile"); |
| 4623 |
|
| 4624 |
priv.base_addr = adjusted_thumbnail_data; |
| 4625 |
priv.offset = 0; |
| 4626 |
priv.limit = thumbnail_bpp * thumbnail_h * thumbnail_w; |
| 4627 |
|
| 4628 |
if (stp_print(nv, im) != 1) |
| 4629 |
{ |
| 4630 |
answer = 0; |
| 4631 |
fprintf(stderr, "Could not print thumbnail!\n"); |
| 4632 |
} |
| 4633 |
stp_vars_destroy(nv); |
| 4634 |
thumbnail_needs_rebuild = FALSE; |
| 4635 |
return answer; |
| 4636 |
} |
| 4637 |
|
| 4638 |
static void |
| 4639 |
set_thumbnail_orientation(void) |
| 4640 |
{ |
| 4641 |
gint x, y; |
| 4642 |
gint preview_limit = (thumbnail_h * thumbnail_w) - 1; |
| 4643 |
gint bpp; |
| 4644 |
if (!print_mode_is_color(pv->v)) |
| 4645 |
bpp = 1; |
| 4646 |
else |
| 4647 |
bpp = 3; |
| 4648 |
switch (physical_orientation) |
| 4649 |
{ |
| 4650 |
case ORIENT_PORTRAIT: |
| 4651 |
memcpy(preview_thumbnail_data, adjusted_thumbnail_data, |
| 4652 |
bpp * thumbnail_h * thumbnail_w); |
| 4653 |
break; |
| 4654 |
case ORIENT_SEASCAPE: |
| 4655 |
for (x = 0; x < thumbnail_w; x++) |
| 4656 |
for (y = 0; y < thumbnail_h; y++) |
| 4657 |
memcpy((preview_thumbnail_data + |
| 4658 |
bpp * (preview_limit - (x * thumbnail_h + y))), |
| 4659 |
(adjusted_thumbnail_data + |
| 4660 |
bpp * ((thumbnail_h - y - 1) * thumbnail_w + x)), bpp); |
| 4661 |
break; |
| 4662 |
|
| 4663 |
case ORIENT_UPSIDEDOWN: |
| 4664 |
for (x = 0; x < thumbnail_h * thumbnail_w; x++) |
| 4665 |
memcpy((preview_thumbnail_data + bpp * (preview_limit - x)), |
| 4666 |
adjusted_thumbnail_data + bpp * x, bpp); |
| 4667 |
break; |
| 4668 |
case ORIENT_LANDSCAPE: |
| 4669 |
for (x = 0; x < thumbnail_w; x++) |
| 4670 |
for (y = 0; y < thumbnail_h; y++) |
| 4671 |
memcpy((preview_thumbnail_data + bpp * (x * thumbnail_h + y)), |
| 4672 |
(adjusted_thumbnail_data + |
| 4673 |
bpp * ((thumbnail_h - y - 1) * thumbnail_w + x)), bpp); |
| 4674 |
break; |
| 4675 |
} |
| 4676 |
} |
| 4677 |
|
| 4678 |
static void |
| 4679 |
draw_arrow (GdkWindow *w, |
| 4680 |
GdkGC *gc, |
| 4681 |
gint paper_left, |
| 4682 |
gint paper_top) |
| 4683 |
{ |
| 4684 |
gint u = preview_ppi/2; |
| 4685 |
gint ox = paper_left + preview_ppi * paper_width / INCH / 2; |
| 4686 |
gint oy = paper_top + preview_ppi * paper_height / INCH / 2; |
| 4687 |
|
| 4688 |
oy -= preview_ppi * paper_height / INCH / 4; |
| 4689 |
if (oy < paper_top + u) |
| 4690 |
oy = paper_top + u; |
| 4691 |
gdk_draw_line (w, gc, ox, oy - u, ox - u, oy); |
| 4692 |
gdk_draw_line (w, gc, ox, oy - u, ox + u, oy); |
| 4693 |
gdk_draw_line (w, gc, ox, oy - u, ox, oy + u); |
| 4694 |
} |
| 4695 |
|
| 4696 |
static void |
| 4697 |
create_valid_preview(guchar **preview_data) |
| 4698 |
{ |
| 4699 |
if (adjusted_thumbnail_data) |
| 4700 |
{ |
| 4701 |
gint bpp = (print_mode_is_color(pv->v)) ? 3 : 1; |
| 4702 |
gint v_denominator = preview_h > 1 ? preview_h - 1 : 1; |
| 4703 |
gint v_numerator = (preview_thumbnail_h - 1) % v_denominator; |
| 4704 |
gint v_whole = (preview_thumbnail_h - 1) / v_denominator; |
| 4705 |
gint h_denominator = preview_w > 1 ? preview_w - 1 : 1; |
| 4706 |
gint h_numerator = (preview_thumbnail_w - 1) % h_denominator; |
| 4707 |
gint h_whole = (preview_thumbnail_w - 1) / h_denominator; |
| 4708 |
gint adjusted_preview_width = bpp * preview_w; |
| 4709 |
gint adjusted_thumbnail_width = bpp * preview_thumbnail_w; |
| 4710 |
gint v_cur = 0; |
| 4711 |
gint v_last = -1; |
| 4712 |
gint v_error = v_denominator / 2; |
| 4713 |
gint y; |
| 4714 |
gint i; |
| 4715 |
|
| 4716 |
if (*preview_data) |
| 4717 |
g_free (*preview_data); |
| 4718 |
*preview_data = g_malloc (bpp * preview_h * preview_w); |
| 4719 |
|
| 4720 |
for (y = 0; y < preview_h; y++) |
| 4721 |
{ |
| 4722 |
guchar *outbuf = *preview_data + adjusted_preview_width * y; |
| 4723 |
|
| 4724 |
if (v_cur == v_last) |
| 4725 |
memcpy (outbuf, outbuf-adjusted_preview_width, |
| 4726 |
adjusted_preview_width); |
| 4727 |
else |
| 4728 |
{ |
| 4729 |
guchar *inbuf = preview_thumbnail_data - bpp |
| 4730 |
+ adjusted_thumbnail_width * v_cur; |
| 4731 |
|
| 4732 |
gint h_cur = 0; |
| 4733 |
gint h_last = -1; |
| 4734 |
gint h_error = h_denominator / 2; |
| 4735 |
gint x; |
| 4736 |
|
| 4737 |
v_last = v_cur; |
| 4738 |
for (x = 0; x < preview_w; x++) |
| 4739 |
{ |
| 4740 |
if (h_cur == h_last) |
| 4741 |
{ |
| 4742 |
for (i = 0; i < bpp; i++) |
| 4743 |
outbuf[i] = outbuf[i - bpp]; |
| 4744 |
} |
| 4745 |
else |
| 4746 |
{ |
| 4747 |
inbuf += bpp * (h_cur - h_last); |
| 4748 |
h_last = h_cur; |
| 4749 |
for (i = 0; i < bpp; i++) |
| 4750 |
outbuf[i] = inbuf[i]; |
| 4751 |
} |
| 4752 |
outbuf += bpp; |
| 4753 |
h_cur += h_whole; |
| 4754 |
h_error += h_numerator; |
| 4755 |
if (h_error >= h_denominator) |
| 4756 |
{ |
| 4757 |
h_error -= h_denominator; |
| 4758 |
h_cur++; |
| 4759 |
} |
| 4760 |
} |
| 4761 |
} |
| 4762 |
v_cur += v_whole; |
| 4763 |
v_error += v_numerator; |
| 4764 |
if (v_error >= v_denominator) |
| 4765 |
{ |
| 4766 |
v_error -= v_denominator; |
| 4767 |
v_cur++; |
| 4768 |
} |
| 4769 |
} |
| 4770 |
preview_valid = TRUE; |
| 4771 |
} |
| 4772 |
} |
| 4773 |
|
| 4774 |
|
| 4775 |
|
| 4776 |
|
| 4777 |
static void |
| 4778 |
do_preview_thumbnail (void) |
| 4779 |
{ |
| 4780 |
static GdkGC *gc = NULL; |
| 4781 |
static GdkGC *gcinv = NULL; |
| 4782 |
static GdkGC *gcset = NULL; |
| 4783 |
static guchar *preview_data = NULL; |
| 4784 |
gint opx = preview_x; |
| 4785 |
gint opy = preview_y; |
| 4786 |
gint oph = preview_h; |
| 4787 |
gint opw = preview_w; |
| 4788 |
gint paper_display_left, paper_display_top; |
| 4789 |
gint printable_display_left, printable_display_top; |
| 4790 |
gint paper_display_width, paper_display_height; |
| 4791 |
gint printable_display_width, printable_display_height; |
| 4792 |
gdouble l_bottom = stp_get_top(pv->v) + stp_get_height(pv->v); |
| 4793 |
gdouble l_right = stp_get_left(pv->v) + stp_get_width(pv->v); |
| 4794 |
|
| 4795 |
preview_ppi = preview_size_horiz * FINCH / (gdouble) paper_width; |
| 4796 |
|
| 4797 |
if (preview_ppi > preview_size_vert * FINCH / (gdouble) paper_height) |
| 4798 |
preview_ppi = preview_size_vert * FINCH / (gdouble) paper_height; |
| 4799 |
if (preview_ppi > MAX_PREVIEW_PPI) |
| 4800 |
preview_ppi = MAX_PREVIEW_PPI; |
| 4801 |
|
| 4802 |
if (preview == NULL || preview->widget.window == NULL) |
| 4803 |
return; |
| 4804 |
|
| 4805 |
|
| 4806 |
|
| 4807 |
paper_display_width = MAX(3, ROUNDUP(preview_ppi * paper_width, INCH)); |
| 4808 |
paper_display_height = MAX(3, ROUNDUP(preview_ppi * paper_height, INCH)); |
| 4809 |
|
| 4810 |
paper_display_left = (preview_size_horiz - paper_display_width) / 2; |
| 4811 |
paper_display_top = (preview_size_vert - paper_display_height) / 2; |
| 4812 |
|
| 4813 |
printable_display_width = |
| 4814 |
MAX(3, ROUNDUP(preview_ppi * printable_width, INCH)); |
| 4815 |
printable_display_height = |
| 4816 |
MAX(3, ROUNDUP(preview_ppi * printable_height, INCH)); |
| 4817 |
|
| 4818 |
printable_display_left = paper_display_left + preview_ppi * left / INCH; |
| 4819 |
printable_display_top = paper_display_top + preview_ppi * top / INCH ; |
| 4820 |
|
| 4821 |
preview_x = |
| 4822 |
1 + paper_display_left + preview_ppi * stp_get_left (pv->v) / INCH; |
| 4823 |
preview_y = |
| 4824 |
1 + paper_display_top + preview_ppi * stp_get_top (pv->v) / INCH; |
| 4825 |
|
| 4826 |
if (!preview_valid) |
| 4827 |
{ |
| 4828 |
gint preview_r = 1 + paper_display_left + preview_ppi * l_right / INCH; |
| 4829 |
gint preview_b = 1 + paper_display_top + preview_ppi * l_bottom / INCH; |
| 4830 |
preview_w = preview_r - preview_x; |
| 4831 |
preview_h = preview_b - preview_y; |
| 4832 |
if (preview_w >= printable_display_width) |
| 4833 |
preview_w = printable_display_width - 1; |
| 4834 |
if (preview_h >= printable_display_height) |
| 4835 |
preview_h = printable_display_height - 1; |
| 4836 |
} |
| 4837 |
|
| 4838 |
if (preview_w + preview_x > printable_display_left + printable_display_width) |
| 4839 |
preview_x--; |
| 4840 |
if (preview_h + preview_y > printable_display_top + printable_display_height) |
| 4841 |
preview_y--; |
| 4842 |
|
| 4843 |
if (gc == NULL) |
| 4844 |
{ |
| 4845 |
gc = gdk_gc_new (preview->widget.window); |
| 4846 |
gcinv = gdk_gc_new (preview->widget.window); |
| 4847 |
gdk_gc_set_function (gcinv, GDK_INVERT); |
| 4848 |
gcset = gdk_gc_new (preview->widget.window); |
| 4849 |
gdk_gc_set_function (gcset, GDK_SET); |
| 4850 |
} |
| 4851 |
|
| 4852 |
if (!preview_valid) |
| 4853 |
create_valid_preview(&preview_data); |
| 4854 |
|
| 4855 |
if (printable_display_left < paper_display_left) |
| 4856 |
printable_display_left = paper_display_left; |
| 4857 |
if (printable_display_top < paper_display_top) |
| 4858 |
printable_display_top = paper_display_top; |
| 4859 |
if (printable_display_left + printable_display_width > |
| 4860 |
paper_display_left + paper_display_width) |
| 4861 |
printable_display_width = |
| 4862 |
paper_display_width - (paper_display_left - printable_display_left); |
| 4863 |
if (printable_display_top + printable_display_height > |
| 4864 |
paper_display_top + paper_display_height) |
| 4865 |
printable_display_height = |
| 4866 |
paper_display_height - (paper_display_top - printable_display_top); |
| 4867 |
if (need_exposure) |
| 4868 |
{ |
| 4869 |
if (!frame_valid) |
| 4870 |
{ |
| 4871 |
gdk_window_clear (preview->widget.window); |
| 4872 |
frame_valid = TRUE; |
| 4873 |
} |
| 4874 |
|
| 4875 |
gdk_draw_rectangle (preview->widget.window, gc, 0, |
| 4876 |
paper_display_left, paper_display_top, |
| 4877 |
paper_display_width, paper_display_height); |
| 4878 |
|
| 4879 |
|
| 4880 |
gdk_draw_rectangle (preview->widget.window, gc, 0, |
| 4881 |
printable_display_left, printable_display_top, |
| 4882 |
printable_display_width, printable_display_height); |
| 4883 |
need_exposure = FALSE; |
| 4884 |
} |
| 4885 |
else if (!frame_valid) |
| 4886 |
{ |
| 4887 |
gdk_window_clear (preview->widget.window); |
| 4888 |
|
| 4889 |
gdk_draw_rectangle (preview->widget.window, gc, 0, |
| 4890 |
paper_display_left, paper_display_top, |
| 4891 |
paper_display_width, paper_display_height); |
| 4892 |
|
| 4893 |
|
| 4894 |
gdk_draw_rectangle (preview->widget.window, gc, 0, |
| 4895 |
printable_display_left, printable_display_top, |
| 4896 |
printable_display_width, printable_display_height); |
| 4897 |
frame_valid = TRUE; |
| 4898 |
} |
| 4899 |
else |
| 4900 |
{ |
| 4901 |
if (opx + opw <= preview_x || opy + oph <= preview_y || |
| 4902 |
preview_x + preview_w <= opx || preview_y + preview_h <= opy) |
| 4903 |
{ |
| 4904 |
gdk_window_clear_area (preview->widget.window, opx, opy, opw, oph); |
| 4905 |
} |
| 4906 |
else |
| 4907 |
{ |
| 4908 |
if (opx < preview_x) |
| 4909 |
gdk_window_clear_area (preview->widget.window, |
| 4910 |
opx, opy, preview_x - opx, oph); |
| 4911 |
if (opy < preview_y) |
| 4912 |
gdk_window_clear_area (preview->widget.window, |
| 4913 |
opx, opy, opw, preview_y - opy); |
| 4914 |
if (opx + opw > preview_x + preview_w) |
| 4915 |
gdk_window_clear_area (preview->widget.window, |
| 4916 |
preview_x + preview_w, opy, |
| 4917 |
(opx + opw) - (preview_x + preview_w), oph); |
| 4918 |
if (opy + oph > preview_y + preview_h) |
| 4919 |
gdk_window_clear_area (preview->widget.window, |
| 4920 |
opx, preview_y + preview_h, |
| 4921 |
opw, (opy + oph) - (preview_y + preview_h)); |
| 4922 |
} |
| 4923 |
} |
| 4924 |
|
| 4925 |
draw_arrow (preview->widget.window, gcset, paper_display_left, |
| 4926 |
paper_display_top); |
| 4927 |
|
| 4928 |
if (!preview_valid) |
| 4929 |
gdk_draw_rectangle (preview->widget.window, gc, 1, |
| 4930 |
preview_x, preview_y, preview_w, preview_h); |
| 4931 |
else if (!print_mode_is_color(pv->v)) |
| 4932 |
gdk_draw_gray_image (preview->widget.window, gc, |
| 4933 |
preview_x, preview_y, preview_w, preview_h, |
| 4934 |
GDK_RGB_DITHER_NORMAL, preview_data, preview_w); |
| 4935 |
else |
| 4936 |
gdk_draw_rgb_image (preview->widget.window, gc, |
| 4937 |
preview_x, preview_y, preview_w, preview_h, |
| 4938 |
GDK_RGB_DITHER_NORMAL, preview_data, 3 * preview_w); |
| 4939 |
|
| 4940 |
|
| 4941 |
if (preview_x <= paper_display_left || opx <= paper_display_left || |
| 4942 |
preview_y <= paper_display_top || opy <= paper_display_top || |
| 4943 |
preview_x + preview_w >= paper_display_left + paper_display_width || |
| 4944 |
opx + opw >= paper_display_left + paper_display_width || |
| 4945 |
preview_y + preview_h >= paper_display_top + paper_display_height || |
| 4946 |
opy + oph >= paper_display_top + paper_display_height) |
| 4947 |
gdk_draw_rectangle (preview->widget.window, gc, 0, |
| 4948 |
paper_display_left, paper_display_top, |
| 4949 |
paper_display_width, paper_display_height); |
| 4950 |
|
| 4951 |
|
| 4952 |
|
| 4953 |
draw_arrow (preview->widget.window, gcinv, paper_display_left, |
| 4954 |
paper_display_top); |
| 4955 |
gdk_flush(); |
| 4956 |
} |
| 4957 |
|
| 4958 |
static gboolean |
| 4959 |
idle_preview_thumbnail(gpointer data) |
| 4960 |
{ |
| 4961 |
(void)data; |
| 4962 |
if (thumbnail_data && adjusted_thumbnail_data && do_update_thumbnail) |
| 4963 |
{ |
| 4964 |
thumbnail_update_pending = TRUE; |
| 4965 |
set_orientation(pv->orientation); |
| 4966 |
if (thumbnail_needs_rebuild && compute_thumbnail(pv->v)) |
| 4967 |
{ |
| 4968 |
set_thumbnail_orientation(); |
| 4969 |
redraw_color_swatch (); |
| 4970 |
} |
| 4971 |
do_preview_thumbnail(); |
| 4972 |
} |
| 4973 |
thumbnail_update_pending = FALSE; |
| 4974 |
return FALSE; |
| 4975 |
} |
| 4976 |
|
| 4977 |
static void |
| 4978 |
update_adjusted_thumbnail (gboolean regenerate_image) |
| 4979 |
{ |
| 4980 |
if (regenerate_image) |
| 4981 |
thumbnail_needs_rebuild = TRUE; |
| 4982 |
preview_update (); |
| 4983 |
} |
| 4984 |
|
| 4985 |
static void |
| 4986 |
preview_expose (void) |
| 4987 |
{ |
| 4988 |
need_exposure = TRUE; |
| 4989 |
preview_update (); |
| 4990 |
} |
| 4991 |
|
| 4992 |
static void |
| 4993 |
preview_update (void) |
| 4994 |
{ |
| 4995 |
gdouble max_ppi_scaling; |
| 4996 |
gdouble min_ppi_scaling; |
| 4997 |
|
| 4998 |
suppress_preview_update++; |
| 4999 |
compute_printable_region(); |
| 5000 |
|
| 5001 |
if (pv->scaling < 0) |
| 5002 |
{ |
| 5003 |
gdouble twidth; |
| 5004 |
|
| 5005 |
compute_scaling_limits(&min_ppi_scaling, &max_ppi_scaling); |
| 5006 |
|
| 5007 |
if (pv->scaling < 0 && pv->scaling > -min_ppi_scaling) |
| 5008 |
pv->scaling = -min_ppi_scaling; |
| 5009 |
|
| 5010 |
twidth = (FINCH * (gdouble) image_width / -pv->scaling); |
| 5011 |
print_width = twidth; |
| 5012 |
print_height = (twidth * (gdouble) image_height / image_width); |
| 5013 |
GTK_ADJUSTMENT (scaling_adjustment)->lower = min_ppi_scaling; |
| 5014 |
GTK_ADJUSTMENT (scaling_adjustment)->upper = max_ppi_scaling; |
| 5015 |
GTK_ADJUSTMENT (scaling_adjustment)->value = -pv->scaling; |
| 5016 |
|
| 5017 |
if (!suppress_scaling_adjustment) |
| 5018 |
{ |
| 5019 |
suppress_preview_reset++; |
| 5020 |
gtk_adjustment_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 5021 |
suppress_scaling_callback = TRUE; |
| 5022 |
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (scaling_ppi), TRUE); |
| 5023 |
suppress_scaling_callback = FALSE; |
| 5024 |
gtk_adjustment_value_changed (GTK_ADJUSTMENT (scaling_adjustment)); |
| 5025 |
suppress_preview_reset--; |
| 5026 |
} |
| 5027 |
} |
| 5028 |
else if (auto_paper_size) |
| 5029 |
{ |
| 5030 |
gdouble twidth = printable_width * pv->scaling / 100; |
| 5031 |
|
| 5032 |
print_width = twidth; |
| 5033 |
print_height = |
| 5034 |
(twidth * (gdouble) image_height / (gdouble) image_width); |
| 5035 |
} |
| 5036 |
else |
| 5037 |
{ |
| 5038 |
|
| 5039 |
|
| 5040 |
if (image_width * printable_height > printable_width * image_height) |
| 5041 |
|
| 5042 |
|
| 5043 |
|
| 5044 |
{ |
| 5045 |
gdouble twidth = printable_width * pv->scaling / 100.0; |
| 5046 |
|
| 5047 |
print_width = twidth; |
| 5048 |
print_height = |
| 5049 |
(twidth * (gdouble) image_height / (gdouble) image_width); |
| 5050 |
} |
| 5051 |
else |
| 5052 |
{ |
| 5053 |
gdouble theight = printable_height * pv->scaling /100.0; |
| 5054 |
|
| 5055 |
print_height = theight; |
| 5056 |
print_width = |
| 5057 |
(theight * (gdouble) image_width / (gdouble) image_height); |
| 5058 |
} |
| 5059 |
} |
| 5060 |
|
| 5061 |
if (auto_paper_size) |
| 5062 |
set_media_size(stp_get_string_parameter(pv->v, "PageSize")); |
| 5063 |
|
| 5064 |
stp_set_width(pv->v, print_width); |
| 5065 |
stp_set_height(pv->v, print_height); |
| 5066 |
|
| 5067 |
if (pv->invalid_mask & INVALID_LEFT) |
| 5068 |
stp_set_left (pv->v, (paper_width - print_width) / 2); |
| 5069 |
|
| 5070 |
if (stp_get_left(pv->v) < left) |
| 5071 |
stp_set_left(pv->v, left); |
| 5072 |
|
| 5073 |
if (stp_get_left (pv->v) > right - print_width) |
| 5074 |
stp_set_left (pv->v, right - print_width); |
| 5075 |
|
| 5076 |
if (pv->invalid_mask & INVALID_TOP) |
| 5077 |
stp_set_top (pv->v, ((paper_height - print_height) / 2)); |
| 5078 |
if (stp_get_top(pv->v) < top) |
| 5079 |
stp_set_top(pv->v, top); |
| 5080 |
|
| 5081 |
if (stp_get_top (pv->v) > bottom - print_height) |
| 5082 |
stp_set_top (pv->v, bottom - print_height); |
| 5083 |
|
| 5084 |
pv->invalid_mask = 0; |
| 5085 |
|
| 5086 |
set_all_entry_values(); |
| 5087 |
suppress_preview_update--; |
| 5088 |
|
| 5089 |
|
| 5090 |
if (! suppress_preview_update && !thumbnail_update_pending) |
| 5091 |
{ |
| 5092 |
thumbnail_update_pending = TRUE; |
| 5093 |
g_idle_add(idle_preview_thumbnail, NULL); |
| 5094 |
} |
| 5095 |
} |
| 5096 |
|
| 5097 |
|
| 5098 |
|
| 5099 |
|
| 5100 |
static void |
| 5101 |
preview_button_callback (GtkWidget *widget, |
| 5102 |
GdkEventButton *event, |
| 5103 |
gpointer data) |
| 5104 |
{ |
| 5105 |
(void)widget; |
| 5106 |
(void)data; |
| 5107 |
if (event->type == GDK_BUTTON_PRESS) |
| 5108 |
{ |
| 5109 |
if (preview_active == 0) |
| 5110 |
{ |
| 5111 |
mouse_x = event->x; |
| 5112 |
mouse_y = event->y; |
| 5113 |
orig_left = stp_get_left (pv->v); |
| 5114 |
orig_top = stp_get_top (pv->v); |
| 5115 |
mouse_button = event->button; |
| 5116 |
buttons_mask = 1 << event->button; |
| 5117 |
buttons_pressed++; |
| 5118 |
preview_active = 1; |
| 5119 |
stpui_disable_help(); |
| 5120 |
move_constraint = |
| 5121 |
(event->state & GDK_SHIFT_MASK) ? MOVE_CONSTRAIN : MOVE_ANY; |
| 5122 |
if (event->state & GDK_CONTROL_MASK) |
| 5123 |
move_constraint |= MOVE_GRID; |
| 5124 |
} |
| 5125 |
else if ((buttons_mask & (1 << event->button)) == 0) |
| 5126 |
{ |
| 5127 |
if (preview_active == 1) |
| 5128 |
{ |
| 5129 |
stpui_enable_help(); |
| 5130 |
preview_active = -1; |
| 5131 |
stp_set_left (pv->v, orig_left); |
| 5132 |
stp_set_top (pv->v, orig_top); |
| 5133 |
preview_update (); |
| 5134 |
} |
| 5135 |
buttons_mask |= 1 << event->button; |
| 5136 |
buttons_pressed++; |
| 5137 |
} |
| 5138 |
} |
| 5139 |
else if (event->type == GDK_BUTTON_RELEASE) |
| 5140 |
{ |
| 5141 |
buttons_pressed--; |
| 5142 |
buttons_mask &= ~(1 << event->button); |
| 5143 |
if (buttons_pressed == 0) |
| 5144 |
{ |
| 5145 |
stpui_enable_help (); |
| 5146 |
preview_active = 0; |
| 5147 |
} |
| 5148 |
} |
| 5149 |
} |
| 5150 |
|
| 5151 |
|
| 5152 |
|
| 5153 |
|
| 5154 |
static void |
| 5155 |
preview_motion_callback (GtkWidget *widget, |
| 5156 |
GdkEventMotion *event, |
| 5157 |
gpointer data) |
| 5158 |
{ |
| 5159 |
(void)widget; |
| 5160 |
(void)data; |
| 5161 |
gdouble old_top = stp_get_top (pv->v); |
| 5162 |
gdouble old_left = stp_get_left (pv->v); |
| 5163 |
gdouble new_top = old_top; |
| 5164 |
gdouble new_left = old_left; |
| 5165 |
gint steps; |
| 5166 |
if (preview_active != 1 || event->type != GDK_MOTION_NOTIFY) |
| 5167 |
return; |
| 5168 |
if (move_constraint == MOVE_CONSTRAIN) |
| 5169 |
{ |
| 5170 |
int dx = STP_DABS(event->x - mouse_x); |
| 5171 |
int dy = STP_DABS(event->y - mouse_y); |
| 5172 |
if (dx > dy && dx > 3) |
| 5173 |
move_constraint = MOVE_HORIZONTAL; |
| 5174 |
else if (dy > dx && dy > 3) |
| 5175 |
move_constraint = MOVE_VERTICAL; |
| 5176 |
else |
| 5177 |
return; |
| 5178 |
} |
| 5179 |
|
| 5180 |
switch (mouse_button) |
| 5181 |
{ |
| 5182 |
case 1: |
| 5183 |
if (move_constraint & MOVE_VERTICAL) |
| 5184 |
new_top = orig_top + INCH * (event->y - mouse_y) / preview_ppi; |
| 5185 |
if (move_constraint & MOVE_HORIZONTAL) |
| 5186 |
new_left = orig_left + INCH * (event->x - mouse_x) / preview_ppi; |
| 5187 |
break; |
| 5188 |
case 3: |
| 5189 |
if (move_constraint & MOVE_VERTICAL) |
| 5190 |
new_top = orig_top + event->y - mouse_y; |
| 5191 |
if (move_constraint & MOVE_HORIZONTAL) |
| 5192 |
new_left = orig_left + event->x - mouse_x; |
| 5193 |
break; |
| 5194 |
case 2: |
| 5195 |
if (move_constraint & MOVE_HORIZONTAL) |
| 5196 |
{ |
| 5197 |
gdouble increment_width = |
| 5198 |
((move_constraint & MOVE_GRID) && pv->scaling > 0) ? |
| 5199 |
printable_width * pv->scaling / 100 : print_width; |
| 5200 |
gdouble x_threshold = MAX (1, (preview_ppi * increment_width) / FINCH); |
| 5201 |
if (event->x > mouse_x) |
| 5202 |
steps = MIN((event->x - mouse_x) / x_threshold, |
| 5203 |
((right - orig_left) / increment_width) - 1); |
| 5204 |
else |
| 5205 |
steps = -(MIN((mouse_x - event->x) / x_threshold, |
| 5206 |
(orig_left - left) / increment_width)); |
| 5207 |
new_left = orig_left + steps * increment_width; |
| 5208 |
} |
| 5209 |
if (move_constraint & MOVE_VERTICAL) |
| 5210 |
{ |
| 5211 |
gdouble increment_height = |
| 5212 |
((move_constraint & MOVE_GRID) && pv->scaling > 0) ? |
| 5213 |
printable_height * pv->scaling / 100 : print_height; |
| 5214 |
gdouble y_threshold = MAX (1, (preview_ppi * increment_height) / FINCH); |
| 5215 |
if (event->y > mouse_y) |
| 5216 |
steps = MIN((event->y - mouse_y) / y_threshold, |
| 5217 |
((bottom - orig_top) / increment_height) - 1); |
| 5218 |
else |
| 5219 |
steps = -(MIN((mouse_y - event->y) / y_threshold, |
| 5220 |
(orig_top - top) / increment_height)); |
| 5221 |
new_top = orig_top + steps * increment_height; |
| 5222 |
} |
| 5223 |
break; |
| 5224 |
} |
| 5225 |
|
| 5226 |
if (new_top < top) |
| 5227 |
new_top = top; |
| 5228 |
if (new_top > bottom - print_height) |
| 5229 |
new_top = bottom - print_height; |
| 5230 |
if (new_left < left) |
| 5231 |
new_left = left; |
| 5232 |
if (new_left > right - print_width) |
| 5233 |
new_left = right - print_width; |
| 5234 |
|
| 5235 |
if (new_top != old_top || new_left != old_left) |
| 5236 |
{ |
| 5237 |
stp_set_top (pv->v, new_top); |
| 5238 |
stp_set_left (pv->v, new_left); |
| 5239 |
preview_update (); |
| 5240 |
} |
| 5241 |
} |
| 5242 |
|
| 5243 |
static void |
| 5244 |
color_update (GtkAdjustment *adjustment) |
| 5245 |
{ |
| 5246 |
unsigned int i; |
| 5247 |
for (i = 0; i < current_option_count; i++) |
| 5248 |
{ |
| 5249 |
option_t *opt = &(current_options[i]); |
| 5250 |
if (opt->fast_desc->p_type == STP_PARAMETER_TYPE_DOUBLE && |
| 5251 |
opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL && |
| 5252 |
opt->info.flt.adjustment && |
| 5253 |
adjustment == GTK_ADJUSTMENT(opt->info.flt.adjustment)) |
| 5254 |
{ |
| 5255 |
invalidate_preview_thumbnail (); |
| 5256 |
if (stp_get_float_parameter(pv->v, opt->fast_desc->name) != |
| 5257 |
adjustment->value) |
| 5258 |
{ |
| 5259 |
stp_set_float_parameter(pv->v, opt->fast_desc->name, |
| 5260 |
adjustment->value); |
| 5261 |
update_adjusted_thumbnail(TRUE); |
| 5262 |
} |
| 5263 |
} |
| 5264 |
} |
| 5265 |
} |
| 5266 |
|
| 5267 |
static void |
| 5268 |
dimension_update (GtkAdjustment *adjustment) |
| 5269 |
{ |
| 5270 |
unsigned int i; |
| 5271 |
gdouble unit_scaler = units[pv->unit].scale; |
| 5272 |
for (i = 0; i < current_option_count; i++) |
| 5273 |
{ |
| 5274 |
option_t *opt = &(current_options[i]); |
| 5275 |
if (opt->fast_desc->p_type == STP_PARAMETER_TYPE_DIMENSION && |
| 5276 |
opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL && |
| 5277 |
opt->info.flt.adjustment && |
| 5278 |
adjustment == GTK_ADJUSTMENT(opt->info.flt.adjustment)) |
| 5279 |
{ |
| 5280 |
gdouble new_value = adjustment->value * unit_scaler; |
| 5281 |
invalidate_preview_thumbnail (); |
| 5282 |
if (stp_get_dimension_parameter(pv->v, opt->fast_desc->name) != |
| 5283 |
new_value) |
| 5284 |
{ |
| 5285 |
stp_set_dimension_parameter(pv->v, opt->fast_desc->name, |
| 5286 |
new_value); |
| 5287 |
update_adjusted_thumbnail(FALSE); |
| 5288 |
} |
| 5289 |
} |
| 5290 |
} |
| 5291 |
} |
| 5292 |
|
| 5293 |
static void |
| 5294 |
integer_update (GtkAdjustment *adjustment) |
| 5295 |
{ |
| 5296 |
unsigned int i; |
| 5297 |
for (i = 0; i < current_option_count; i++) |
| 5298 |
{ |
| 5299 |
option_t *opt = &(current_options[i]); |
| 5300 |
if (opt->fast_desc->p_type == STP_PARAMETER_TYPE_INT && |
| 5301 |
opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL && |
| 5302 |
opt->info.flt.adjustment && |
| 5303 |
adjustment == GTK_ADJUSTMENT(opt->info.flt.adjustment)) |
| 5304 |
{ |
| 5305 |
invalidate_preview_thumbnail (); |
| 5306 |
if (stp_get_int_parameter(pv->v, opt->fast_desc->name) != |
| 5307 |
(int) adjustment->value) |
| 5308 |
{ |
| 5309 |
stp_set_int_parameter(pv->v, opt->fast_desc->name, |
| 5310 |
(int) adjustment->value); |
| 5311 |
update_adjusted_thumbnail(FALSE); |
| 5312 |
} |
| 5313 |
} |
| 5314 |
} |
| 5315 |
} |
| 5316 |
|
| 5317 |
static void |
| 5318 |
set_controls_active (GtkObject *checkbutton, gpointer xopt) |
| 5319 |
{ |
| 5320 |
option_t *opt = (option_t *) xopt; |
| 5321 |
stp_parameter_t desc; |
| 5322 |
gboolean setting = |
| 5323 |
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkbutton)); |
| 5324 |
if (setting && opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL) |
| 5325 |
{ |
| 5326 |
switch (opt->fast_desc->p_type) |
| 5327 |
{ |
| 5328 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 5329 |
set_adjustment_active(opt, TRUE, FALSE); |
| 5330 |
if (! stp_check_float_parameter(pv->v, opt->fast_desc->name, |
| 5331 |
STP_PARAMETER_INACTIVE)) |
| 5332 |
{ |
| 5333 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5334 |
stp_set_float_parameter(pv->v, opt->fast_desc->name, |
| 5335 |
desc.deflt.dbl); |
| 5336 |
stp_parameter_description_destroy(&desc); |
| 5337 |
} |
| 5338 |
stp_set_float_parameter_active(pv->v, opt->fast_desc->name, |
| 5339 |
STP_PARAMETER_ACTIVE); |
| 5340 |
break; |
| 5341 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 5342 |
set_adjustment_active(opt, TRUE, FALSE); |
| 5343 |
if (! stp_check_dimension_parameter(pv->v, opt->fast_desc->name, |
| 5344 |
STP_PARAMETER_INACTIVE)) |
| 5345 |
{ |
| 5346 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5347 |
stp_set_dimension_parameter(pv->v, opt->fast_desc->name, |
| 5348 |
desc.deflt.dimension); |
| 5349 |
stp_parameter_description_destroy(&desc); |
| 5350 |
} |
| 5351 |
stp_set_dimension_parameter_active(pv->v, opt->fast_desc->name, |
| 5352 |
STP_PARAMETER_ACTIVE); |
| 5353 |
break; |
| 5354 |
case STP_PARAMETER_TYPE_INT: |
| 5355 |
set_adjustment_active(opt, TRUE, FALSE); |
| 5356 |
if (! stp_check_int_parameter(pv->v, opt->fast_desc->name, |
| 5357 |
STP_PARAMETER_INACTIVE)) |
| 5358 |
{ |
| 5359 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5360 |
stp_set_int_parameter(pv->v, opt->fast_desc->name, |
| 5361 |
desc.deflt.integer); |
| 5362 |
stp_parameter_description_destroy(&desc); |
| 5363 |
} |
| 5364 |
stp_set_int_parameter_active(pv->v, opt->fast_desc->name, |
| 5365 |
STP_PARAMETER_ACTIVE); |
| 5366 |
break; |
| 5367 |
case STP_PARAMETER_TYPE_CURVE: |
| 5368 |
set_curve_active(opt, TRUE, FALSE); |
| 5369 |
if (! stp_check_curve_parameter(pv->v, opt->fast_desc->name, |
| 5370 |
STP_PARAMETER_INACTIVE)) |
| 5371 |
{ |
| 5372 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5373 |
stp_set_curve_parameter(pv->v, opt->fast_desc->name, |
| 5374 |
desc.deflt.curve); |
| 5375 |
stp_parameter_description_destroy(&desc); |
| 5376 |
} |
| 5377 |
stp_set_curve_parameter_active(pv->v, opt->fast_desc->name, |
| 5378 |
STP_PARAMETER_ACTIVE); |
| 5379 |
break; |
| 5380 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 5381 |
set_combo_active(opt, TRUE, FALSE); |
| 5382 |
if (! stp_check_string_parameter(pv->v, opt->fast_desc->name, |
| 5383 |
STP_PARAMETER_INACTIVE)) |
| 5384 |
{ |
| 5385 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5386 |
stp_set_string_parameter(pv->v, opt->fast_desc->name, |
| 5387 |
desc.deflt.str); |
| 5388 |
stp_parameter_description_destroy(&desc); |
| 5389 |
} |
| 5390 |
stp_set_string_parameter_active(pv->v, opt->fast_desc->name, |
| 5391 |
STP_PARAMETER_ACTIVE); |
| 5392 |
break; |
| 5393 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 5394 |
set_bool_active(opt, TRUE, FALSE); |
| 5395 |
if (! stp_check_boolean_parameter(pv->v, opt->fast_desc->name, |
| 5396 |
STP_PARAMETER_INACTIVE)) |
| 5397 |
{ |
| 5398 |
stp_describe_parameter(pv->v, opt->fast_desc->name, &desc); |
| 5399 |
stp_set_boolean_parameter(pv->v, opt->fast_desc->name, |
| 5400 |
desc.deflt.boolean); |
| 5401 |
stp_parameter_description_destroy(&desc); |
| 5402 |
} |
| 5403 |
stp_set_boolean_parameter_active(pv->v, opt->fast_desc->name, |
| 5404 |
STP_PARAMETER_ACTIVE); |
| 5405 |
break; |
| 5406 |
case STP_PARAMETER_TYPE_FILE: |
| 5407 |
set_file_active(opt, TRUE, FALSE); |
| 5408 |
stp_set_file_parameter_active(pv->v, opt->fast_desc->name, |
| 5409 |
STP_PARAMETER_ACTIVE); |
| 5410 |
break; |
| 5411 |
default: |
| 5412 |
break; |
| 5413 |
} |
| 5414 |
} |
| 5415 |
else |
| 5416 |
{ |
| 5417 |
switch (opt->fast_desc->p_type) |
| 5418 |
{ |
| 5419 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 5420 |
set_adjustment_active(opt, FALSE, FALSE); |
| 5421 |
stp_set_float_parameter_active(pv->v, opt->fast_desc->name, |
| 5422 |
STP_PARAMETER_INACTIVE); |
| 5423 |
break; |
| 5424 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 5425 |
set_adjustment_active(opt, FALSE, FALSE); |
| 5426 |
stp_set_dimension_parameter_active(pv->v, opt->fast_desc->name, |
| 5427 |
STP_PARAMETER_INACTIVE); |
| 5428 |
break; |
| 5429 |
case STP_PARAMETER_TYPE_INT: |
| 5430 |
set_adjustment_active(opt, FALSE, FALSE); |
| 5431 |
stp_set_int_parameter_active(pv->v, opt->fast_desc->name, |
| 5432 |
STP_PARAMETER_INACTIVE); |
| 5433 |
break; |
| 5434 |
case STP_PARAMETER_TYPE_CURVE: |
| 5435 |
set_curve_active(opt, FALSE, FALSE); |
| 5436 |
stp_set_curve_parameter_active(pv->v, opt->fast_desc->name, |
| 5437 |
STP_PARAMETER_INACTIVE); |
| 5438 |
break; |
| 5439 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 5440 |
set_combo_active(opt, FALSE, FALSE); |
| 5441 |
stp_set_string_parameter_active(pv->v, opt->fast_desc->name, |
| 5442 |
STP_PARAMETER_INACTIVE); |
| 5443 |
break; |
| 5444 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 5445 |
set_bool_active(opt, FALSE, FALSE); |
| 5446 |
stp_set_boolean_parameter_active(pv->v, opt->fast_desc->name, |
| 5447 |
STP_PARAMETER_INACTIVE); |
| 5448 |
break; |
| 5449 |
case STP_PARAMETER_TYPE_FILE: |
| 5450 |
set_file_active(opt, FALSE, FALSE); |
| 5451 |
stp_set_file_parameter_active(pv->v, opt->fast_desc->name, |
| 5452 |
STP_PARAMETER_INACTIVE); |
| 5453 |
break; |
| 5454 |
default: |
| 5455 |
break; |
| 5456 |
} |
| 5457 |
} |
| 5458 |
invalidate_preview_thumbnail(); |
| 5459 |
update_adjusted_thumbnail(TRUE); |
| 5460 |
} |
| 5461 |
|
| 5462 |
static void |
| 5463 |
set_one_default(option_t *opt) |
| 5464 |
{ |
| 5465 |
stp_parameter_activity_t active; |
| 5466 |
gdouble unit_scaler; |
| 5467 |
switch (opt->fast_desc->p_type) |
| 5468 |
{ |
| 5469 |
case STP_PARAMETER_TYPE_DOUBLE: |
| 5470 |
active = stp_get_float_parameter_active(pv->v, opt->fast_desc->name); |
| 5471 |
stp_set_float_parameter(pv->v, opt->fast_desc->name, opt->info.flt.deflt); |
| 5472 |
stp_set_float_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5473 |
break; |
| 5474 |
case STP_PARAMETER_TYPE_DIMENSION: |
| 5475 |
unit_scaler = units[pv->unit].scale; |
| 5476 |
active = stp_get_dimension_parameter_active(pv->v, opt->fast_desc->name); |
| 5477 |
stp_set_dimension_parameter(pv->v, opt->fast_desc->name, |
| 5478 |
opt->info.flt.deflt * unit_scaler); |
| 5479 |
stp_set_dimension_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5480 |
break; |
| 5481 |
case STP_PARAMETER_TYPE_INT: |
| 5482 |
unit_scaler = units[pv->unit].scale; |
| 5483 |
active = stp_get_int_parameter_active(pv->v, opt->fast_desc->name); |
| 5484 |
stp_set_int_parameter(pv->v, opt->fast_desc->name, |
| 5485 |
(int) opt->info.flt.deflt); |
| 5486 |
stp_set_int_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5487 |
break; |
| 5488 |
case STP_PARAMETER_TYPE_BOOLEAN: |
| 5489 |
active = stp_get_boolean_parameter_active(pv->v, opt->fast_desc->name); |
| 5490 |
stp_set_boolean_parameter(pv->v, opt->fast_desc->name, |
| 5491 |
opt->info.bool.deflt); |
| 5492 |
stp_set_boolean_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5493 |
break; |
| 5494 |
case STP_PARAMETER_TYPE_STRING_LIST: |
| 5495 |
active = stp_get_string_parameter_active(pv->v, opt->fast_desc->name); |
| 5496 |
stp_set_string_parameter(pv->v, opt->fast_desc->name, |
| 5497 |
opt->info.list.default_val); |
| 5498 |
stp_set_string_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5499 |
break; |
| 5500 |
case STP_PARAMETER_TYPE_FILE: |
| 5501 |
active = stp_get_file_parameter_active(pv->v, opt->fast_desc->name); |
| 5502 |
stp_set_file_parameter(pv->v, opt->fast_desc->name, ""); |
| 5503 |
stp_set_file_parameter_active(pv->v, opt->fast_desc->name, active); |
| 5504 |
break; |
| 5505 |
default: |
| 5506 |
break; |
| 5507 |
} |
| 5508 |
} |
| 5509 |
|
| 5510 |
static void |
| 5511 |
reset_callback(GtkObject *button, gpointer xopt) |
| 5512 |
{ |
| 5513 |
(void)button; |
| 5514 |
option_t *opt = (option_t *)xopt; |
| 5515 |
if (opt) |
| 5516 |
{ |
| 5517 |
set_one_default(opt); |
| 5518 |
if (opt->reset_all) |
| 5519 |
do_all_updates (); |
| 5520 |
else |
| 5521 |
do_color_updates (); |
| 5522 |
} |
| 5523 |
} |
| 5524 |
|
| 5525 |
static void |
| 5526 |
set_printer_defaults (void) |
| 5527 |
{ |
| 5528 |
unsigned int i; |
| 5529 |
for (i = 0; i < current_option_count; i++) |
| 5530 |
{ |
| 5531 |
option_t *opt = &(current_options[i]); |
| 5532 |
if (opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL && |
| 5533 |
opt->fast_desc->p_class == STP_PARAMETER_CLASS_FEATURE && |
| 5534 |
opt->is_active && !opt->fast_desc->read_only) |
| 5535 |
set_one_default(opt); |
| 5536 |
} |
| 5537 |
|
| 5538 |
do_all_updates (); |
| 5539 |
} |
| 5540 |
|
| 5541 |
static void |
| 5542 |
set_color_defaults (void) |
| 5543 |
{ |
| 5544 |
unsigned int i; |
| 5545 |
for (i = 0; i < current_option_count; i++) |
| 5546 |
{ |
| 5547 |
option_t *opt = &(current_options[i]); |
| 5548 |
if (opt->fast_desc->p_level <= MAXIMUM_PARAMETER_LEVEL && |
| 5549 |
opt->fast_desc->p_class == STP_PARAMETER_CLASS_OUTPUT && |
| 5550 |
opt->is_active && !opt->fast_desc->read_only) |
| 5551 |
set_one_default(opt); |
| 5552 |
} |
| 5553 |
|
| 5554 |
do_color_updates (); |
| 5555 |
} |
| 5556 |
|
| 5557 |
gint |
| 5558 |
stpui_do_print_dialog(void) |
| 5559 |
{ |
| 5560 |
|
| 5561 |
|
| 5562 |
|
| 5563 |
stpui_printrc_load (); |
| 5564 |
|
| 5565 |
|
| 5566 |
|
| 5567 |
|
| 5568 |
create_main_window(); |
| 5569 |
|
| 5570 |
gtk_main (); |
| 5571 |
gdk_flush (); |
| 5572 |
|
| 5573 |
|
| 5574 |
|
| 5575 |
|
| 5576 |
if (saveme) |
| 5577 |
stpui_printrc_save (); |
| 5578 |
|
| 5579 |
|
| 5580 |
|
| 5581 |
|
| 5582 |
return (runme); |
| 5583 |
} |