You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

589 lines
20KB

  1. //
  2. // "$Id$"
  3. //
  4. // FLUID print panel for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-2010 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems on the following page:
  24. //
  25. // http://www.fltk.org/str.php
  26. //
  27. // generated by Fast Light User Interface Designer (fluid) version 1.0300
  28. #include "print_panel.h"
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include "../src/flstring.h"
  32. #include <FL/Fl_Preferences.H>
  33. extern Fl_Preferences fluid_prefs;
  34. Fl_Double_Window *print_panel=(Fl_Double_Window *)0;
  35. Fl_Group *print_panel_controls=(Fl_Group *)0;
  36. Fl_Choice *print_choice=(Fl_Choice *)0;
  37. static void cb_print_choice(Fl_Choice*, void*) {
  38. print_update_status();
  39. }
  40. Fl_Button *print_properties=(Fl_Button *)0;
  41. static void cb_print_properties(Fl_Button*, void*) {
  42. print_properties_panel->show();
  43. }
  44. Fl_Box *print_status=(Fl_Box *)0;
  45. Fl_Round_Button *print_all=(Fl_Round_Button *)0;
  46. static void cb_print_all(Fl_Round_Button*, void*) {
  47. print_from->deactivate();
  48. print_to->deactivate();
  49. }
  50. Fl_Round_Button *print_pages=(Fl_Round_Button *)0;
  51. static void cb_print_pages(Fl_Round_Button*, void*) {
  52. print_from->activate();
  53. print_to->activate();
  54. }
  55. Fl_Round_Button *print_selection=(Fl_Round_Button *)0;
  56. static void cb_print_selection(Fl_Round_Button*, void*) {
  57. print_from->deactivate();
  58. print_to->deactivate();
  59. }
  60. Fl_Int_Input *print_from=(Fl_Int_Input *)0;
  61. Fl_Int_Input *print_to=(Fl_Int_Input *)0;
  62. Fl_Spinner *print_copies=(Fl_Spinner *)0;
  63. static void cb_print_copies(Fl_Spinner*, void*) {
  64. if (print_copies->value() == 1) {
  65. print_collate_button->deactivate();
  66. print_collate_group[0]->deactivate();
  67. print_collate_group[1]->deactivate();
  68. } else {
  69. print_collate_button->activate();
  70. print_collate_group[0]->activate();
  71. print_collate_group[1]->activate();
  72. };
  73. }
  74. Fl_Check_Button *print_collate_button=(Fl_Check_Button *)0;
  75. static void cb_print_collate_button(Fl_Check_Button*, void*) {
  76. int i = print_collate_button->value() != 0;
  77. print_collate_group[i]->show();
  78. print_collate_group[1 - i]->hide();
  79. }
  80. Fl_Group *print_collate_group[2]={(Fl_Group *)0};
  81. static void cb_Cancel(Fl_Button*, void*) {
  82. print_panel->hide();
  83. }
  84. Fl_Progress *print_progress=(Fl_Progress *)0;
  85. Fl_Double_Window *print_properties_panel=(Fl_Double_Window *)0;
  86. static void cb_print_properties_panel(Fl_Double_Window*, void*) {
  87. print_properties_panel->hide();
  88. print_update_status();
  89. }
  90. Fl_Choice *print_page_size=(Fl_Choice *)0;
  91. Fl_Menu_Item menu_print_page_size[] = {
  92. {"Letter", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
  93. {"A4", 0, 0, 0, 0, FL_NORMAL_LABEL, 0, 14, 0},
  94. {0,0,0,0,0,0,0,0,0}
  95. };
  96. #include <FL/Fl_Pixmap.H>
  97. static const char *idata_print_color[] = {
  98. "24 24 17 1",
  99. " \tc None",
  100. ".\tc #FFFF00",
  101. "+\tc #C8FF00",
  102. "@\tc #00FF00",
  103. "#\tc #FFC800",
  104. "$\tc #FF0000",
  105. "%\tc #00FFFF",
  106. "&\tc #000000",
  107. "*\tc #FF00FF",
  108. "=\tc #00FFC8",
  109. "-\tc #FF00C8",
  110. ";\tc #00C800",
  111. ">\tc #C80000",
  112. ",\tc #0000C8",
  113. "\'\tc #0000FF",
  114. ")\tc #00C8FF",
  115. "!\tc #C800FF",
  116. " ...... ",
  117. " .......... ",
  118. " ............ ",
  119. " .............. ",
  120. " .............. ",
  121. " ................ ",
  122. " ................ ",
  123. " ................ ",
  124. " +@@@@@@+#$$$$$$# ",
  125. " %@@@@@@@&&$$$$$$$* ",
  126. " %%@@@@@@&&&&$$$$$$** ",
  127. " %%%=@@@@&&&&&&$$$$-*** ",
  128. " %%%%@@@;&&&&&&>$$$**** ",
  129. "%%%%%%@@&&&&&&&&$$******",
  130. "%%%%%%%@&&&&&&&&$*******",
  131. "%%%%%%%%,&&&&&&,********",
  132. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  133. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  134. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  135. " %%%%%%%)\'\'\'\'\'\'!******* ",
  136. " %%%%%%%%\'\'\'\'\'\'******** ",
  137. " %%%%%%%%\'\'\'\'******** ",
  138. " %%%%%%%%\'\'******** ",
  139. " %%%%%% ****** "
  140. };
  141. static Fl_Pixmap image_print_color(idata_print_color);
  142. static const char *idata_print_gray[] = {
  143. "24 24 17 1",
  144. " \tc None",
  145. ".\tc #E3E3E3",
  146. "+\tc #D2D2D2",
  147. "@\tc #969696",
  148. "#\tc #C2C2C2",
  149. "$\tc #4C4C4C",
  150. "%\tc #B2B2B2",
  151. "&\tc #000000",
  152. "*\tc #696969",
  153. "=\tc #ACACAC",
  154. "-\tc #626262",
  155. ";\tc #767676",
  156. ">\tc #3C3C3C",
  157. ",\tc #161616",
  158. "\'\tc #1C1C1C",
  159. ")\tc #929292",
  160. "!\tc #585858",
  161. " ...... ",
  162. " .......... ",
  163. " ............ ",
  164. " .............. ",
  165. " .............. ",
  166. " ................ ",
  167. " ................ ",
  168. " ................ ",
  169. " +@@@@@@+#$$$$$$# ",
  170. " %@@@@@@@&&$$$$$$$* ",
  171. " %%@@@@@@&&&&$$$$$$** ",
  172. " %%%=@@@@&&&&&&$$$$-*** ",
  173. " %%%%@@@;&&&&&&>$$$**** ",
  174. "%%%%%%@@&&&&&&&&$$******",
  175. "%%%%%%%@&&&&&&&&$*******",
  176. "%%%%%%%%,&&&&&&,********",
  177. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  178. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  179. "%%%%%%%%\'\'\'\'\'\'\'\'********",
  180. " %%%%%%%)\'\'\'\'\'\'!******* ",
  181. " %%%%%%%%\'\'\'\'\'\'******** ",
  182. " %%%%%%%%\'\'\'\'******** ",
  183. " %%%%%%%%\'\'******** ",
  184. " %%%%%% ****** "
  185. };
  186. static Fl_Pixmap image_print_gray(idata_print_gray);
  187. Fl_Button *print_output_mode[4]={(Fl_Button *)0};
  188. static void cb_Save(Fl_Return_Button*, void*) {
  189. print_properties_panel->hide();
  190. char name[1024];
  191. int val;
  192. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  193. snprintf(name, sizeof(name), "%s/page_size", printer);
  194. fluid_prefs.set(name, print_page_size->value());
  195. snprintf(name, sizeof(name), "%s/output_mode", printer);
  196. for (val = 0; val < 4; val ++) {
  197. if (print_output_mode[val]->value()) break;
  198. }
  199. fluid_prefs.set(name, val);
  200. }
  201. static void cb_Cancel1(Fl_Button*, void*) {
  202. print_properties_panel->hide();
  203. print_update_status();
  204. }
  205. static void cb_Use(Fl_Button*, void*) {
  206. print_properties_panel->hide();
  207. }
  208. Fl_Double_Window* make_print_panel() {
  209. { print_panel = new Fl_Double_Window(465, 235, "Print");
  210. { print_panel_controls = new Fl_Group(10, 10, 447, 216);
  211. { print_choice = new Fl_Choice(113, 10, 181, 25, "Printer:");
  212. print_choice->down_box(FL_BORDER_BOX);
  213. print_choice->labelfont(1);
  214. print_choice->callback((Fl_Callback*)cb_print_choice);
  215. print_choice->when(FL_WHEN_CHANGED);
  216. } // Fl_Choice* print_choice
  217. { print_properties = new Fl_Button(294, 10, 105, 25, "Properties...");
  218. print_properties->callback((Fl_Callback*)cb_print_properties);
  219. } // Fl_Button* print_properties
  220. { print_status = new Fl_Box(111, 41, 288, 17, "printer/job status");
  221. print_status->align(Fl_Align(68|FL_ALIGN_INSIDE));
  222. } // Fl_Box* print_status
  223. { Fl_Group* o = new Fl_Group(10, 86, 227, 105, "Print Range");
  224. o->box(FL_THIN_DOWN_BOX);
  225. o->labelfont(1);
  226. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  227. { print_all = new Fl_Round_Button(20, 96, 38, 25, "All");
  228. print_all->type(102);
  229. print_all->down_box(FL_ROUND_DOWN_BOX);
  230. print_all->value(1);
  231. print_all->callback((Fl_Callback*)cb_print_all);
  232. } // Fl_Round_Button* print_all
  233. { print_pages = new Fl_Round_Button(20, 126, 64, 25, "Pages");
  234. print_pages->type(102);
  235. print_pages->down_box(FL_ROUND_DOWN_BOX);
  236. print_pages->callback((Fl_Callback*)cb_print_pages);
  237. } // Fl_Round_Button* print_pages
  238. { print_selection = new Fl_Round_Button(20, 156, 82, 25, "Selection");
  239. print_selection->type(102);
  240. print_selection->down_box(FL_ROUND_DOWN_BOX);
  241. print_selection->callback((Fl_Callback*)cb_print_selection);
  242. } // Fl_Round_Button* print_selection
  243. { print_from = new Fl_Int_Input(136, 126, 28, 25, "From:");
  244. print_from->type(2);
  245. print_from->textfont(4);
  246. print_from->deactivate();
  247. } // Fl_Int_Input* print_from
  248. { print_to = new Fl_Int_Input(199, 126, 28, 25, "To:");
  249. print_to->type(2);
  250. print_to->textfont(4);
  251. print_to->deactivate();
  252. } // Fl_Int_Input* print_to
  253. o->end();
  254. } // Fl_Group* o
  255. { Fl_Group* o = new Fl_Group(247, 86, 210, 105, "Copies");
  256. o->box(FL_THIN_DOWN_BOX);
  257. o->labelfont(1);
  258. o->align(Fl_Align(FL_ALIGN_TOP_LEFT));
  259. { print_copies = new Fl_Spinner(321, 96, 45, 25, "# Copies:");
  260. print_copies->callback((Fl_Callback*)cb_print_copies);
  261. print_copies->when(FL_WHEN_CHANGED);
  262. } // Fl_Spinner* print_copies
  263. { print_collate_button = new Fl_Check_Button(376, 96, 64, 25, "Collate");
  264. print_collate_button->down_box(FL_DOWN_BOX);
  265. print_collate_button->callback((Fl_Callback*)cb_print_collate_button);
  266. print_collate_button->when(FL_WHEN_CHANGED);
  267. print_collate_button->deactivate();
  268. } // Fl_Check_Button* print_collate_button
  269. { print_collate_group[0] = new Fl_Group(257, 131, 191, 50);
  270. print_collate_group[0]->deactivate();
  271. { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "1");
  272. o->box(FL_BORDER_BOX);
  273. o->color(FL_BACKGROUND2_COLOR);
  274. o->labelsize(11);
  275. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  276. o->deactivate();
  277. } // Fl_Box* o
  278. { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "1");
  279. o->box(FL_BORDER_BOX);
  280. o->color(FL_BACKGROUND2_COLOR);
  281. o->labelsize(11);
  282. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  283. o->deactivate();
  284. } // Fl_Box* o
  285. { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
  286. o->box(FL_BORDER_BOX);
  287. o->color(FL_BACKGROUND2_COLOR);
  288. o->labelsize(11);
  289. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  290. o->deactivate();
  291. } // Fl_Box* o
  292. { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "2");
  293. o->box(FL_BORDER_BOX);
  294. o->color(FL_BACKGROUND2_COLOR);
  295. o->labelsize(11);
  296. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  297. o->deactivate();
  298. } // Fl_Box* o
  299. { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
  300. o->box(FL_BORDER_BOX);
  301. o->color(FL_BACKGROUND2_COLOR);
  302. o->labelsize(11);
  303. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  304. o->deactivate();
  305. } // Fl_Box* o
  306. { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "2");
  307. o->box(FL_BORDER_BOX);
  308. o->color(FL_BACKGROUND2_COLOR);
  309. o->labelsize(11);
  310. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  311. o->deactivate();
  312. } // Fl_Box* o
  313. { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
  314. o->box(FL_BORDER_BOX);
  315. o->color(FL_BACKGROUND2_COLOR);
  316. o->labelsize(11);
  317. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  318. o->deactivate();
  319. } // Fl_Box* o
  320. { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "3");
  321. o->box(FL_BORDER_BOX);
  322. o->color(FL_BACKGROUND2_COLOR);
  323. o->labelsize(11);
  324. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  325. o->deactivate();
  326. } // Fl_Box* o
  327. { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "3");
  328. o->box(FL_BORDER_BOX);
  329. o->color(FL_BACKGROUND2_COLOR);
  330. o->labelsize(11);
  331. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  332. o->deactivate();
  333. } // Fl_Box* o
  334. print_collate_group[0]->end();
  335. } // Fl_Group* print_collate_group[0]
  336. { print_collate_group[1] = new Fl_Group(257, 131, 191, 50);
  337. print_collate_group[1]->hide();
  338. print_collate_group[1]->deactivate();
  339. { Fl_Box* o = new Fl_Box(287, 141, 30, 40, "3");
  340. o->box(FL_BORDER_BOX);
  341. o->color(FL_BACKGROUND2_COLOR);
  342. o->labelsize(11);
  343. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  344. } // Fl_Box* o
  345. { Fl_Box* o = new Fl_Box(272, 136, 30, 40, "2");
  346. o->box(FL_BORDER_BOX);
  347. o->color(FL_BACKGROUND2_COLOR);
  348. o->labelsize(11);
  349. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  350. } // Fl_Box* o
  351. { Fl_Box* o = new Fl_Box(257, 131, 30, 40, "1");
  352. o->box(FL_BORDER_BOX);
  353. o->color(FL_BACKGROUND2_COLOR);
  354. o->labelsize(11);
  355. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  356. } // Fl_Box* o
  357. { Fl_Box* o = new Fl_Box(352, 141, 30, 40, "3");
  358. o->box(FL_BORDER_BOX);
  359. o->color(FL_BACKGROUND2_COLOR);
  360. o->labelsize(11);
  361. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  362. } // Fl_Box* o
  363. { Fl_Box* o = new Fl_Box(337, 136, 30, 40, "2");
  364. o->box(FL_BORDER_BOX);
  365. o->color(FL_BACKGROUND2_COLOR);
  366. o->labelsize(11);
  367. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  368. } // Fl_Box* o
  369. { Fl_Box* o = new Fl_Box(322, 131, 30, 40, "1");
  370. o->box(FL_BORDER_BOX);
  371. o->color(FL_BACKGROUND2_COLOR);
  372. o->labelsize(11);
  373. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  374. } // Fl_Box* o
  375. { Fl_Box* o = new Fl_Box(417, 141, 30, 40, "3");
  376. o->box(FL_BORDER_BOX);
  377. o->color(FL_BACKGROUND2_COLOR);
  378. o->labelsize(11);
  379. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  380. } // Fl_Box* o
  381. { Fl_Box* o = new Fl_Box(402, 136, 30, 40, "2");
  382. o->box(FL_BORDER_BOX);
  383. o->color(FL_BACKGROUND2_COLOR);
  384. o->labelsize(11);
  385. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  386. } // Fl_Box* o
  387. { Fl_Box* o = new Fl_Box(387, 131, 30, 40, "1");
  388. o->box(FL_BORDER_BOX);
  389. o->color(FL_BACKGROUND2_COLOR);
  390. o->labelsize(11);
  391. o->align(Fl_Align(FL_ALIGN_BOTTOM_RIGHT|FL_ALIGN_INSIDE));
  392. } // Fl_Box* o
  393. print_collate_group[1]->end();
  394. } // Fl_Group* print_collate_group[1]
  395. o->end();
  396. } // Fl_Group* o
  397. { Fl_Return_Button* o = new Fl_Return_Button(309, 201, 70, 25, "Print");
  398. o->callback((Fl_Callback*)print_cb);
  399. } // Fl_Return_Button* o
  400. { Fl_Button* o = new Fl_Button(389, 201, 68, 25, "Cancel");
  401. o->callback((Fl_Callback*)cb_Cancel);
  402. } // Fl_Button* o
  403. print_panel_controls->end();
  404. } // Fl_Group* print_panel_controls
  405. { print_progress = new Fl_Progress(10, 203, 289, 21);
  406. print_progress->selection_color((Fl_Color)4);
  407. print_progress->hide();
  408. } // Fl_Progress* print_progress
  409. print_panel->set_modal();
  410. print_panel->end();
  411. } // Fl_Double_Window* print_panel
  412. { print_properties_panel = new Fl_Double_Window(290, 130, "Printer Properties");
  413. print_properties_panel->callback((Fl_Callback*)cb_print_properties_panel);
  414. { print_page_size = new Fl_Choice(110, 10, 80, 25, "Page Size:");
  415. print_page_size->down_box(FL_BORDER_BOX);
  416. print_page_size->labelfont(1);
  417. print_page_size->menu(menu_print_page_size);
  418. } // Fl_Choice* print_page_size
  419. { Fl_Group* o = new Fl_Group(110, 45, 170, 40, "Output Mode:");
  420. o->labelfont(1);
  421. o->align(Fl_Align(FL_ALIGN_LEFT));
  422. { print_output_mode[0] = new Fl_Button(110, 45, 30, 40);
  423. print_output_mode[0]->type(102);
  424. print_output_mode[0]->box(FL_BORDER_BOX);
  425. print_output_mode[0]->down_box(FL_BORDER_BOX);
  426. print_output_mode[0]->value(1);
  427. print_output_mode[0]->color(FL_BACKGROUND2_COLOR);
  428. print_output_mode[0]->selection_color(FL_FOREGROUND_COLOR);
  429. print_output_mode[0]->image(image_print_color);
  430. } // Fl_Button* print_output_mode[0]
  431. { print_output_mode[1] = new Fl_Button(150, 50, 40, 30);
  432. print_output_mode[1]->type(102);
  433. print_output_mode[1]->box(FL_BORDER_BOX);
  434. print_output_mode[1]->down_box(FL_BORDER_BOX);
  435. print_output_mode[1]->color(FL_BACKGROUND2_COLOR);
  436. print_output_mode[1]->selection_color(FL_FOREGROUND_COLOR);
  437. print_output_mode[1]->image(image_print_color);
  438. } // Fl_Button* print_output_mode[1]
  439. { print_output_mode[2] = new Fl_Button(200, 45, 30, 40);
  440. print_output_mode[2]->type(102);
  441. print_output_mode[2]->box(FL_BORDER_BOX);
  442. print_output_mode[2]->down_box(FL_BORDER_BOX);
  443. print_output_mode[2]->color(FL_BACKGROUND2_COLOR);
  444. print_output_mode[2]->selection_color(FL_FOREGROUND_COLOR);
  445. print_output_mode[2]->image(image_print_gray);
  446. } // Fl_Button* print_output_mode[2]
  447. { print_output_mode[3] = new Fl_Button(240, 50, 40, 30);
  448. print_output_mode[3]->type(102);
  449. print_output_mode[3]->box(FL_BORDER_BOX);
  450. print_output_mode[3]->down_box(FL_BORDER_BOX);
  451. print_output_mode[3]->color(FL_BACKGROUND2_COLOR);
  452. print_output_mode[3]->selection_color(FL_FOREGROUND_COLOR);
  453. print_output_mode[3]->image(image_print_gray);
  454. } // Fl_Button* print_output_mode[3]
  455. o->end();
  456. } // Fl_Group* o
  457. { Fl_Return_Button* o = new Fl_Return_Button(123, 95, 79, 25, "Save");
  458. o->callback((Fl_Callback*)cb_Save);
  459. } // Fl_Return_Button* o
  460. { Fl_Button* o = new Fl_Button(212, 95, 68, 25, "Cancel");
  461. o->callback((Fl_Callback*)cb_Cancel1);
  462. } // Fl_Button* o
  463. { Fl_Button* o = new Fl_Button(60, 95, 53, 25, "Use");
  464. o->callback((Fl_Callback*)cb_Use);
  465. } // Fl_Button* o
  466. print_properties_panel->set_modal();
  467. print_properties_panel->end();
  468. } // Fl_Double_Window* print_properties_panel
  469. return print_properties_panel;
  470. }
  471. void print_cb(Fl_Return_Button *, void *);
  472. void print_load() {
  473. FILE *lpstat;
  474. char line[1024], name[1024], *nptr, qname[2048], *qptr, defname[1024];
  475. int i;
  476. if (print_choice->size() > 1) {
  477. for (i = 1; print_choice->text(i); i ++) {
  478. free(print_choice->menu()[i].user_data());
  479. }
  480. }
  481. print_choice->clear();
  482. print_choice->add("Print To File", 0, 0, 0, FL_MENU_DIVIDER);
  483. print_choice->value(0);
  484. defname[0] = '\0';
  485. if ((lpstat = popen("LC_MESSAGES=C LANG=C lpstat -p -d", "r")) != NULL) {
  486. while (fgets(line, sizeof(line), lpstat)) {
  487. if (!strncmp(line, "printer ", 8) &&
  488. sscanf(line + 8, "%s", name) == 1) {
  489. for (nptr = name, qptr = qname; *nptr; *qptr++ = *nptr++) {
  490. if (*nptr == '/') *qptr++ = '\\';
  491. }
  492. *qptr = '\0';
  493. print_choice->add(qname, 0, 0, (void *)strdup(name), 0);
  494. } else if (!strncmp(line, "system default destination: ", 28)) {
  495. if (sscanf(line + 28, "%s", defname) != 1) defname[0] = '\0';
  496. }
  497. }
  498. pclose(lpstat);
  499. }
  500. if (defname[0]) {
  501. for (i = 1; print_choice->text(i); i ++) {
  502. if (!strcmp((char *)print_choice->menu()[i].user_data(), defname)) {
  503. print_choice->value(i);
  504. break;
  505. }
  506. }
  507. } else if (print_choice->size() > 2) print_choice->value(1);
  508. print_update_status();
  509. }
  510. void print_update_status() {
  511. FILE *lpstat;
  512. char command[1024];
  513. static char status[1024];
  514. const char *printer = (const char *)print_choice->menu()[print_choice->value()].user_data();
  515. if (print_choice->value()) {
  516. snprintf(command, sizeof(command), "lpstat -p '%s'", printer);
  517. if ((lpstat = popen(command, "r")) != NULL) {
  518. if (fgets(status, sizeof(status), lpstat)==0) { /* ignore */ }
  519. pclose(lpstat);
  520. } else strcpy(status, "printer status unavailable");
  521. } else status[0] = '\0';
  522. print_status->label(status);
  523. char name[1024];
  524. int val;
  525. snprintf(name, sizeof(name), "%s/page_size", printer);
  526. fluid_prefs.get(name, val, 0);
  527. print_page_size->value(val);
  528. snprintf(name, sizeof(name), "%s/output_mode", printer);
  529. fluid_prefs.get(name, val, 0);
  530. print_output_mode[val]->setonly();
  531. }
  532. //
  533. // End of "$Id$".
  534. //