1# data file for the Fltk User Interface Designer (fluid) 2version 1.0107 3header_name {.h} 4code_name {.cxx} 5comment {// 6// "$Id$" 7// 8// FLUID print panel for the Fast Light Tool Kit (FLTK). 9// 10// Copyright 1998-2010 by Bill Spitzak and others. 11// 12// This library is free software; you can redistribute it and/or 13// modify it under the terms of the GNU Library General Public 14// License as published by the Free Software Foundation; either 15// version 2 of the License, or (at your option) any later version. 16// 17// This library is distributed in the hope that it will be useful, 18// but WITHOUT ANY WARRANTY; without even the implied warranty of 19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20// Library General Public License for more details. 21// 22// You should have received a copy of the GNU Library General Public 23// License along with this library; if not, write to the Free Software 24// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 25// USA. 26// 27// Please report all bugs and problems on the following page: 28// 29// http://www.fltk.org/str.php 30// 31} {in_source in_header 32} 33 34decl {\#include <stdio.h>} {} 35 36decl {\#include <stdlib.h>} {} 37 38decl {\#include "../src/flstring.h"} {} 39 40decl {\#include <FL/Fl_Preferences.H>} {} 41 42decl {extern Fl_Preferences fluid_prefs;} {} 43 44Function {make_print_panel()} {open 45} { 46 Fl_Window print_panel { 47 label Print open 48 xywh {342 21 465 235} type Double modal visible 49 } { 50 Fl_Group print_panel_controls {open 51 xywh {10 10 447 216} 52 } { 53 Fl_Choice print_choice { 54 label {Printer:} 55 callback {print_update_status();} open 56 xywh {113 10 181 25} down_box BORDER_BOX labelfont 1 when 1 57 } {} 58 Fl_Button print_properties { 59 label {Properties...} 60 callback {print_properties_panel->show();} 61 xywh {294 10 105 25} 62 } 63 Fl_Box print_status { 64 label {printer/job status} 65 xywh {111 41 288 17} align 84 66 } 67 Fl_Group {} { 68 label {Print Range} open 69 xywh {10 86 227 105} box THIN_DOWN_BOX labelfont 1 align 5 70 } { 71 Fl_Round_Button print_all { 72 label All 73 callback {print_from->deactivate(); 74print_to->deactivate();} 75 xywh {20 96 38 25} type Radio down_box ROUND_DOWN_BOX value 1 76 } 77 Fl_Round_Button print_pages { 78 label Pages 79 callback {print_from->activate(); 80print_to->activate();} 81 xywh {20 126 64 25} type Radio down_box ROUND_DOWN_BOX 82 } 83 Fl_Round_Button print_selection { 84 label Selection 85 callback {print_from->deactivate(); 86print_to->deactivate();} 87 xywh {20 156 82 25} type Radio down_box ROUND_DOWN_BOX 88 } 89 Fl_Input print_from { 90 label {From:} 91 xywh {136 126 28 25} type Int textfont 4 deactivate 92 } 93 Fl_Input print_to { 94 label {To:} 95 xywh {199 126 28 25} type Int textfont 4 deactivate 96 } 97 } 98 Fl_Group {} { 99 label Copies open 100 xywh {247 86 210 105} box THIN_DOWN_BOX labelfont 1 align 5 101 } { 102 Fl_Spinner print_copies { 103 label {\# Copies:} 104 callback {if (print_copies->value() == 1) { 105 print_collate_button->deactivate(); 106 print_collate_group[0]->deactivate(); 107 print_collate_group[1]->deactivate(); 108} else { 109 print_collate_button->activate(); 110 print_collate_group[0]->activate(); 111 print_collate_group[1]->activate(); 112}} selected 113 xywh {321 96 45 25} when 1 114 } 115 Fl_Check_Button print_collate_button { 116 label Collate 117 callback {int i = print_collate_button->value() != 0; 118print_collate_group[i]->show(); 119print_collate_group[1 - i]->hide();} 120 xywh {376 96 64 25} down_box DOWN_BOX when 1 deactivate 121 } 122 Fl_Group {print_collate_group[0]} { 123 xywh {257 131 191 50} deactivate 124 } { 125 Fl_Box {} { 126 label 1 127 xywh {287 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 128 } 129 Fl_Box {} { 130 label 1 131 xywh {272 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 132 } 133 Fl_Box {} { 134 label 1 135 xywh {257 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 136 } 137 Fl_Box {} { 138 label 2 139 xywh {352 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 140 } 141 Fl_Box {} { 142 label 2 143 xywh {337 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 144 } 145 Fl_Box {} { 146 label 2 147 xywh {322 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 148 } 149 Fl_Box {} { 150 label 3 151 xywh {417 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 152 } 153 Fl_Box {} { 154 label 3 155 xywh {402 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 156 } 157 Fl_Box {} { 158 label 3 159 xywh {387 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 deactivate 160 } 161 } 162 Fl_Group {print_collate_group[1]} { 163 xywh {257 131 191 50} hide deactivate 164 } { 165 Fl_Box {} { 166 label 3 167 xywh {287 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 168 } 169 Fl_Box {} { 170 label 2 171 xywh {272 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 172 } 173 Fl_Box {} { 174 label 1 175 xywh {257 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 176 } 177 Fl_Box {} { 178 label 3 179 xywh {352 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 180 } 181 Fl_Box {} { 182 label 2 183 xywh {337 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 184 } 185 Fl_Box {} { 186 label 1 187 xywh {322 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 188 } 189 Fl_Box {} { 190 label 3 191 xywh {417 141 30 40} box BORDER_BOX color 7 labelsize 11 align 26 192 } 193 Fl_Box {} { 194 label 2 195 xywh {402 136 30 40} box BORDER_BOX color 7 labelsize 11 align 26 196 } 197 Fl_Box {} { 198 label 1 199 xywh {387 131 30 40} box BORDER_BOX color 7 labelsize 11 align 26 200 } 201 } 202 } 203 Fl_Return_Button {} { 204 label Print 205 callback print_cb 206 xywh {309 201 70 25} 207 } 208 Fl_Button {} { 209 label Cancel 210 callback {print_panel->hide();} 211 xywh {389 201 68 25} 212 } 213 } 214 Fl_Progress print_progress { 215 xywh {10 203 289 21} selection_color 4 hide 216 } 217 } 218 Fl_Window print_properties_panel { 219 label {Printer Properties} 220 callback {print_properties_panel->hide(); 221print_update_status();} open 222 xywh {340 213 290 130} type Double modal visible 223 } { 224 Fl_Choice print_page_size { 225 label {Page Size:} 226 xywh {110 10 80 25} down_box BORDER_BOX labelfont 1 227 } { 228 MenuItem {} { 229 label Letter 230 xywh {0 0 35 25} 231 } 232 MenuItem {} { 233 label A4 234 xywh {0 0 35 25} 235 } 236 } 237 Fl_Group {} { 238 label {Output Mode:} open 239 xywh {110 45 170 40} labelfont 1 align 4 240 } { 241 Fl_Button {print_output_mode[0]} { 242 image {pixmaps/print_color.xpm} xywh {110 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX value 1 color 7 selection_color 0 243 } 244 Fl_Button {print_output_mode[1]} { 245 image {pixmaps/print_color.xpm} xywh {150 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0 246 } 247 Fl_Button {print_output_mode[2]} { 248 image {pixmaps/print_gray.xpm} xywh {200 45 30 40} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0 249 } 250 Fl_Button {print_output_mode[3]} { 251 image {pixmaps/print_gray.xpm} xywh {240 50 40 30} type Radio box BORDER_BOX down_box BORDER_BOX color 7 selection_color 0 252 } 253 } 254 Fl_Return_Button {} { 255 label Save 256 callback {print_properties_panel->hide(); 257 258char name[1024]; 259int val; 260const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data(); 261 262snprintf(name, sizeof(name), "%s/page_size", printer); 263fluid_prefs.set(name, print_page_size->value()); 264 265snprintf(name, sizeof(name), "%s/output_mode", printer); 266for (val = 0; val < 4; val ++) { 267 if (print_output_mode[val]->value()) break; 268} 269fluid_prefs.set(name, val);} 270 xywh {123 95 79 25} 271 } 272 Fl_Button {} { 273 label Cancel 274 callback {print_properties_panel->hide(); 275print_update_status();} 276 xywh {212 95 68 25} 277 } 278 Fl_Button {} { 279 label Use 280 callback {print_properties_panel->hide();} 281 xywh {60 95 53 25} 282 } 283 } 284} 285 286decl {void print_cb(Fl_Return_Button *, void *);} {public 287} 288 289Function {print_load()} {open return_type void 290} { 291 code {FILE *lpstat; 292char line[1024], name[1024], *nptr, qname[2048], *qptr, defname[1024]; 293int i; 294 295if (print_choice->size() > 1) { 296 for (i = 1; print_choice->text(i); i ++) { 297 free(print_choice->menu()[i].user_data()); 298 } 299} 300 301print_choice->clear(); 302print_choice->add("Print To File", 0, 0, 0, FL_MENU_DIVIDER); 303print_choice->value(0); 304 305defname[0] = '\\0'; 306 307if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) { 308 while (fgets(line, sizeof(line), lpstat)) { 309 if (!strncmp(line, "printer ", 8) && 310 sscanf(line + 8, "%s", name) == 1) { 311 for (nptr = name, qptr = qname; *nptr; *qptr++ = *nptr++) { 312 if (*nptr == '/') *qptr++ = '\\\\'; 313 } 314 *qptr = '\\0'; 315 316 print_choice->add(qname, 0, 0, (void *)strdup(name), 0); 317 } else if (!strncmp(line, "system default destination: ", 28)) { 318 if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\\0'; 319 } 320 } 321 pclose(lpstat); 322} 323 324if (defname[0]) { 325 for (i = 1; print_choice->text(i); i ++) { 326 if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) { 327 print_choice->value(i); 328 break; 329 } 330 } 331} else if (print_choice->size() > 2) print_choice->value(1); 332 333 334print_update_status();} {} 335} 336 337Function {print_update_status()} {open return_type void 338} { 339 code {FILE *lpstat; 340char command[1024]; 341static char status[1024]; 342const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data(); 343 344if (print_choice->value()) { 345 snprintf(command, sizeof(command), "lpstat -p '%s'", printer); 346 if ((lpstat = popen(command, "r")) != NULL) { 347 if (fgets(status, sizeof(status), lpstat)==0) { /* ignore */ } 348 pclose(lpstat); 349 } else strcpy(status, "printer status unavailable"); 350} else status[0] = '\\0'; 351 352print_status->label(status); 353 354char name[1024]; 355int val; 356 357snprintf(name, sizeof(name), "%s/page_size", printer); 358fluid_prefs.get(name, val, 0); 359print_page_size->value(val); 360 361snprintf(name, sizeof(name), "%s/output_mode", printer); 362fluid_prefs.get(name, val, 0); 363print_output_mode[val]->setonly();} {} 364} 365 366comment { 367// 368// End of "$Id$". 369//} {in_source in_header 370} 371