]> git.sur5r.net Git - glabels/blob - glabels2/src/ui-commands.c
2007-02-14 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / src / ui-commands.c
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2
3 /*
4  *  (GLABELS) Label and Business Card Creation program for GNOME
5  *
6  *  ui-commands.c:  GLabels UI commands module
7  *
8  *  Copyright (C) 2001-2003  Jim Evins <evins@snaught.com>.
9  *
10  *  This program is free software; you can redistribute it and/or modify
11  *  it under the terms of the GNU General Public License as published by
12  *  the Free Software Foundation; either version 2 of the License, or
13  *  (at your option) any later version.
14  *
15  *  This program is distributed in the hope that it will be useful,
16  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  *  GNU General Public License for more details.
19  *
20  *  You should have received a copy of the GNU General Public License
21  *  along with this program; if not, write to the Free Software
22  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
23  */
24
25 #include <config.h>
26
27 #include "ui-commands.h"
28
29 #include <glib/gi18n.h>
30 #include <gtk/gtkwindow.h>
31 #include <gtk/gtkaboutdialog.h>
32 #include <libgnome/gnome-help.h>
33
34 #include "view.h"
35 #include "file.h"
36 #include "template-designer.h"
37 #include "print-op.h"
38 #include "prefs.h"
39 #include "prefs-dialog.h"
40 #include "recent.h"
41 #include "debug.h"
42
43
44 \f
45 /****************************************************************************/
46 /** File/New command.                                                       */
47 /****************************************************************************/
48 void 
49 gl_ui_cmd_file_new (GtkAction *action,
50                     glWindow  *window)
51 {
52         gl_debug (DEBUG_COMMANDS, "START");
53         
54         g_return_if_fail (action && GTK_IS_ACTION(action));
55         g_return_if_fail (window && GL_IS_WINDOW(window));
56
57         gl_file_new (window);
58
59         gl_debug (DEBUG_COMMANDS, "END");
60 }
61
62 /****************************************************************************/
63 /** File/Properties command.                                                */
64 /****************************************************************************/
65 void 
66 gl_ui_cmd_file_properties (GtkAction *action,
67                            glWindow  *window)
68 {
69         gl_debug (DEBUG_COMMANDS, "START");
70         
71         g_return_if_fail (action && GTK_IS_ACTION(action));
72         g_return_if_fail (window && GL_IS_WINDOW(window));
73
74         gl_file_properties (GL_VIEW(window->view)->label, window);
75
76         gl_debug (DEBUG_COMMANDS, "END");
77 }
78
79 /****************************************************************************/
80 /** File/Template-Designer command.                                         */
81 /****************************************************************************/
82 void
83 gl_ui_cmd_file_template_designer (GtkAction *action,
84                                   glWindow  *window)
85 {
86         GtkWidget *dialog;
87
88         gl_debug (DEBUG_COMMANDS, "START");
89
90         g_return_if_fail (action && GTK_IS_ACTION(action));
91         g_return_if_fail (window && GL_IS_WINDOW(window));
92
93         dialog = gl_template_designer_new (GTK_WINDOW(window));
94
95         gtk_widget_show (dialog);
96
97         gl_debug (DEBUG_COMMANDS, "END");
98 }
99
100 /****************************************************************************/
101 /** File/Open command.                                                      */
102 /****************************************************************************/
103 void 
104 gl_ui_cmd_file_open (GtkAction *action,
105                      glWindow  *window)
106 {
107         gl_debug (DEBUG_COMMANDS, "START");
108
109         g_return_if_fail (action && GTK_IS_ACTION(action));
110         g_return_if_fail (window && GL_IS_WINDOW(window));
111
112         gl_file_open (window);
113
114         gl_debug (DEBUG_COMMANDS, "END");
115 }
116
117 /****************************************************************************/
118 /** File/Open-Recent command.                                               */
119 /****************************************************************************/
120 void 
121 gl_ui_cmd_file_open_recent (GtkRecentChooser *chooser,
122                             glWindow         *window)
123 {
124         GtkRecentInfo *item;
125         gchar         *utf8_filename;
126
127         gl_debug (DEBUG_COMMANDS, "START");
128
129         g_return_if_fail (chooser && GTK_IS_RECENT_CHOOSER(chooser));
130         g_return_if_fail (window && GL_IS_WINDOW(window));
131
132         item = gtk_recent_chooser_get_current_item (chooser);
133         if (!item)
134                 return;
135
136         utf8_filename = gl_recent_get_utf8_filename (item);
137
138         gl_debug (DEBUG_COMMANDS, "Selected %s\n", utf8_filename);
139 #if 1
140         gl_file_open_recent (utf8_filename, window);
141 #endif
142
143         gtk_recent_info_unref (item);
144         
145         gl_debug (DEBUG_COMMANDS, "END");
146 }
147
148 /****************************************************************************/
149 /** File/Save command.                                                      */
150 /****************************************************************************/
151 void 
152 gl_ui_cmd_file_save (GtkAction *action,
153                      glWindow  *window)
154 {
155         gl_debug (DEBUG_COMMANDS, "START");
156
157         g_return_if_fail (action && GTK_IS_ACTION(action));
158         g_return_if_fail (window && GL_IS_WINDOW(window));
159
160         gl_file_save (GL_VIEW(window->view)->label, window);
161
162         gl_debug (DEBUG_COMMANDS, "END");
163 }
164
165 /****************************************************************************/
166 /** File/Save-as command.                                                   */
167 /****************************************************************************/
168 void 
169 gl_ui_cmd_file_save_as (GtkAction *action,
170                         glWindow  *window)
171 {
172         gl_debug (DEBUG_COMMANDS, "START");
173
174         g_return_if_fail (action && GTK_IS_ACTION(action));
175         g_return_if_fail (window && GL_IS_WINDOW(window));
176
177         gl_file_save_as (GL_VIEW(window->view)->label, window);
178
179         gl_debug (DEBUG_COMMANDS, "END");
180 }
181
182 /****************************************************************************/
183 /** File/Print command.                                                     */
184 /****************************************************************************/
185 void
186 gl_ui_cmd_file_print (GtkAction *action,
187                       glWindow  *window)
188 {
189         glPrintOp *op;
190
191         gl_debug (DEBUG_COMMANDS, "START");
192
193         g_return_if_fail (action && GTK_IS_ACTION(action));
194         g_return_if_fail (window && GL_IS_WINDOW(window));
195
196         op = gl_print_op_new (GL_VIEW(window->view)->label);
197
198         gtk_print_operation_run (GTK_PRINT_OPERATION (op),
199                                  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
200                                  GTK_WINDOW (window),
201                                  NULL);
202
203         gl_debug (DEBUG_COMMANDS, "END");
204 }
205
206 /****************************************************************************/
207 /** File/Close command.                                                     */
208 /****************************************************************************/
209 void 
210 gl_ui_cmd_file_close (GtkAction *action,
211                       glWindow  *window)
212 {
213         gl_debug (DEBUG_COMMANDS, "START");
214
215         g_return_if_fail (action && GTK_IS_ACTION(action));
216         g_return_if_fail (window && GL_IS_WINDOW(window));
217
218         gl_file_close (window);
219
220         gl_debug (DEBUG_COMMANDS, "END");
221 }
222
223 /****************************************************************************/
224 /** File/Quit command.                                                      */
225 /****************************************************************************/
226 void 
227 gl_ui_cmd_file_quit (GtkAction *action,
228                      glWindow  *window)
229 {
230         gl_debug (DEBUG_COMMANDS, "START");
231
232         g_return_if_fail (action && GTK_IS_ACTION(action));
233         g_return_if_fail (window && GL_IS_WINDOW(window));
234
235         gl_file_exit ();
236
237         gl_debug (DEBUG_COMMANDS, "END");
238 }
239
240
241 /****************************************************************************/
242 /** Edit/Cut command.                                                       */
243 /****************************************************************************/
244 void 
245 gl_ui_cmd_edit_cut (GtkAction *action,
246                     glWindow  *window)
247 {
248         gl_debug (DEBUG_COMMANDS, "START");
249
250         g_return_if_fail (action && GTK_IS_ACTION(action));
251         g_return_if_fail (window && GL_IS_WINDOW(window));
252
253         gl_view_cut (GL_VIEW(window->view)); 
254
255         gl_debug (DEBUG_COMMANDS, "END");
256 }
257
258 /****************************************************************************/
259 /** Edit/Copy command.                                                      */
260 /****************************************************************************/
261 void 
262 gl_ui_cmd_edit_copy (GtkAction *action,
263                      glWindow  *window)
264 {
265         gl_debug (DEBUG_COMMANDS, "START");
266
267         g_return_if_fail (action && GTK_IS_ACTION(action));
268         g_return_if_fail (window && GL_IS_WINDOW(window));
269
270         gl_view_copy (GL_VIEW(window->view)); 
271
272         gl_debug (DEBUG_COMMANDS, "END");
273 }
274
275 /****************************************************************************/
276 /** Edit/Paste command.                                                     */
277 /****************************************************************************/
278 void 
279 gl_ui_cmd_edit_paste (GtkAction *action,
280                       glWindow  *window)
281 {
282         gl_debug (DEBUG_COMMANDS, "START");
283
284         g_return_if_fail (action && GTK_IS_ACTION(action));
285         g_return_if_fail (window && GL_IS_WINDOW(window));
286
287         gl_view_paste (GL_VIEW(window->view)); 
288
289         gl_debug (DEBUG_COMMANDS, "END");
290 }
291
292
293 /****************************************************************************/
294 /** Edit/Delete command.                                                    */
295 /****************************************************************************/
296 void 
297 gl_ui_cmd_edit_delete (GtkAction *action,
298                        glWindow  *window)
299 {
300         gl_debug (DEBUG_COMMANDS, "START");
301
302         g_return_if_fail (action && GTK_IS_ACTION(action));
303         g_return_if_fail (window && GL_IS_WINDOW(window));
304
305         gl_view_delete_selection (GL_VIEW(window->view)); 
306
307         gl_debug (DEBUG_COMMANDS, "END");
308 }
309
310
311 /****************************************************************************/
312 /** Edit/Select-all command.                                                */
313 /****************************************************************************/
314 void
315 gl_ui_cmd_edit_select_all (GtkAction *action,
316                            glWindow  *window)
317 {
318         gl_debug (DEBUG_COMMANDS, "START");
319
320         g_return_if_fail (action && GTK_IS_ACTION(action));
321         g_return_if_fail (window && GL_IS_WINDOW(window));
322
323         gl_view_select_all (GL_VIEW(window->view)); 
324
325         gl_debug (DEBUG_COMMANDS, "END");
326 }
327
328 /****************************************************************************/
329 /** Edit/Unselect-all command.                                              */
330 /****************************************************************************/
331 void
332 gl_ui_cmd_edit_unselect_all (GtkAction *action,
333                              glWindow  *window)
334 {
335         gl_debug (DEBUG_COMMANDS, "START");
336
337         g_return_if_fail (action && GTK_IS_ACTION(action));
338         g_return_if_fail (window && GL_IS_WINDOW(window));
339
340         gl_view_unselect_all (GL_VIEW(window->view)); 
341
342         gl_debug (DEBUG_COMMANDS, "END");
343 }
344
345 /****************************************************************************/
346 /** Edit/Preferences command.                                               */
347 /****************************************************************************/
348 void
349 gl_ui_cmd_edit_preferences (GtkAction *action,
350                             glWindow  *window)
351 {
352         static GtkWidget *dialog = NULL;
353
354         gl_debug (DEBUG_COMMANDS, "START");
355
356         g_return_if_fail (action && GTK_IS_ACTION(action));
357         g_return_if_fail (window && GL_IS_WINDOW(window));
358
359         if (dialog != NULL)
360         {
361                 gtk_window_present (GTK_WINDOW (dialog));
362                 gtk_window_set_transient_for (GTK_WINDOW (dialog),        
363                                               GTK_WINDOW(window));
364
365         } else {
366                 
367                 dialog = gl_prefs_dialog_new (GTK_WINDOW(window));
368
369                 g_signal_connect (G_OBJECT (dialog), "destroy",
370                                   G_CALLBACK (gtk_widget_destroyed), &dialog);
371         
372                 gtk_widget_show (dialog);
373
374         }
375
376         gl_debug (DEBUG_COMMANDS, "END");
377 }
378
379 /*****************************************************************************/
380 /** View/Property-bar-toggle command.                                        */
381 /*****************************************************************************/
382 void
383 gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action,
384                                     glWindow        *window)
385 {
386         gboolean     state;
387
388         gl_debug (DEBUG_COMMANDS, "START");
389
390         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
391         g_return_if_fail (window && GL_IS_WINDOW(window));
392
393         state =  gtk_toggle_action_get_active (action);
394
395         gl_prefs->property_toolbar_visible = state;
396         if (state) {
397                 gtk_widget_show (GTK_WIDGET (window->property_bar));
398         } else {
399                 gtk_widget_hide (GTK_WIDGET (window->property_bar));
400         }
401         gl_prefs_model_save_settings (gl_prefs);
402
403         gl_debug (DEBUG_COMMANDS, "END");
404 }
405
406 /*****************************************************************************/
407 /** View/Property-bar-tooltips-toggle command.                               */
408 /*****************************************************************************/
409 void
410 gl_ui_cmd_view_property_bar_tips_toggle (GtkToggleAction *action,
411                                          glWindow        *window)
412 {
413         gboolean     state;
414
415         gl_debug (DEBUG_COMMANDS, "START");
416
417         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
418         g_return_if_fail (window && GL_IS_WINDOW(window));
419
420         state =  gtk_toggle_action_get_active (action);
421
422         gl_prefs->property_toolbar_view_tooltips = state;
423         gl_ui_property_bar_set_tooltips (window->property_bar, state);
424         gl_prefs_model_save_settings (gl_prefs);
425
426         gl_debug (DEBUG_COMMANDS, "END");
427 }
428
429 /*****************************************************************************/
430 /** View/Grid-toggle command.                                                */
431 /*****************************************************************************/
432 void
433 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
434                             glWindow        *window)
435 {
436         gboolean     state;
437
438         gl_debug (DEBUG_COMMANDS, "START");
439
440         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
441         g_return_if_fail (window && GL_IS_WINDOW(window));
442
443         state =  gtk_toggle_action_get_active (action);
444
445         if (window->view != NULL)
446         {
447                 if (state) {
448                         gl_view_show_grid (GL_VIEW(window->view));
449                 } else {
450                         gl_view_hide_grid (GL_VIEW(window->view));
451                 }
452         }
453
454         gl_prefs->grid_visible = state;
455         gl_prefs_model_save_settings (gl_prefs);
456
457         gl_debug (DEBUG_COMMANDS, "END");
458 }
459
460 /*****************************************************************************/
461 /** View/Markup-toggle command.                                              */
462 /*****************************************************************************/
463 void
464 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
465                               glWindow        *window)
466 {
467         gboolean     state;
468
469         gl_debug (DEBUG_COMMANDS, "START");
470
471         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
472         g_return_if_fail (window && GL_IS_WINDOW(window));
473
474         state =  gtk_toggle_action_get_active (action);
475
476         if (window->view != NULL)
477         {
478                 if (state) {
479                         gl_view_show_markup (GL_VIEW(window->view));
480                 } else {
481                         gl_view_hide_markup (GL_VIEW(window->view));
482                 }
483         }
484
485         gl_prefs->markup_visible = state;
486         gl_prefs_model_save_settings (gl_prefs);
487
488         gl_debug (DEBUG_COMMANDS, "END");
489 }
490
491 /*****************************************************************************/
492 /** View/Zoom-in command.                                                    */
493 /*****************************************************************************/
494 void
495 gl_ui_cmd_view_zoomin (GtkAction *action,
496                        glWindow  *window)
497
498 {
499         gl_debug (DEBUG_COMMANDS, "START");
500         
501         g_return_if_fail (action && GTK_IS_ACTION(action));
502         g_return_if_fail (window && GL_IS_WINDOW(window));
503
504         if (window->view != NULL) {
505                 gl_view_zoom_in (GL_VIEW(window->view));
506         }
507
508         gl_debug (DEBUG_COMMANDS, "END");
509 }
510
511 /*****************************************************************************/
512 /** View/Zoom-out command.                                                   */
513 /*****************************************************************************/
514 void
515 gl_ui_cmd_view_zoomout (GtkAction *action,
516                         glWindow  *window)
517
518 {
519         gl_debug (DEBUG_COMMANDS, "START");
520         
521         g_return_if_fail (action && GTK_IS_ACTION(action));
522         g_return_if_fail (window && GL_IS_WINDOW(window));
523
524         if (window->view != NULL) {
525                 gl_view_zoom_out (GL_VIEW(window->view));
526         }
527
528         gl_debug (DEBUG_COMMANDS, "END");
529 }
530
531 /*****************************************************************************/
532 /** View/Zoom-1:1 command.                                                   */
533 /*****************************************************************************/
534 void
535 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
536                          glWindow  *window)
537
538 {
539         gl_debug (DEBUG_COMMANDS, "START");
540         
541         g_return_if_fail (action && GTK_IS_ACTION(action));
542         g_return_if_fail (window && GL_IS_WINDOW(window));
543
544         if (window->view != NULL) {
545                 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
546         }
547
548         gl_debug (DEBUG_COMMANDS, "END");
549 }
550
551 /*****************************************************************************/
552 /** View/Zoom-to-fit command.                                                */
553 /*****************************************************************************/
554 void
555 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
556                             glWindow  *window)
557
558 {
559         gl_debug (DEBUG_COMMANDS, "START");
560         
561         g_return_if_fail (action && GTK_IS_ACTION(action));
562         g_return_if_fail (window && GL_IS_WINDOW(window));
563
564         if (window->view != NULL) {
565                 gl_view_zoom_to_fit (GL_VIEW(window->view));
566         }
567
568         gl_debug (DEBUG_COMMANDS, "END");
569 }
570
571 /*****************************************************************************/
572 /** Objects/Arrow-mode command.                                              */
573 /*****************************************************************************/
574 void
575 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
576                               glWindow  *window)
577 {
578         gl_debug (DEBUG_COMMANDS, "START");
579         
580         g_return_if_fail (action && GTK_IS_ACTION(action));
581         g_return_if_fail (window && GL_IS_WINDOW(window));
582
583         if (window->view != NULL) {
584                 gl_view_arrow_mode (GL_VIEW(window->view));
585         }
586
587         gl_debug (DEBUG_COMMANDS, "END");
588 }
589
590 /*****************************************************************************/
591 /** Objects/Create-text object command.                                      */
592 /*****************************************************************************/
593 void
594 gl_ui_cmd_objects_create_text (GtkAction *action,
595                                glWindow  *window)
596
597 {
598         gl_debug (DEBUG_COMMANDS, "START");
599         
600         g_return_if_fail (action && GTK_IS_ACTION(action));
601         g_return_if_fail (window && GL_IS_WINDOW(window));
602
603         if (window->view != NULL) {
604                 gl_view_object_create_mode (GL_VIEW(window->view),
605                                             GL_LABEL_OBJECT_TEXT);
606         }
607
608         gl_debug (DEBUG_COMMANDS, "END");
609 }
610
611 /*****************************************************************************/
612 /** Objects/Create-box object command.                                       */
613 /*****************************************************************************/
614 void
615 gl_ui_cmd_objects_create_box (GtkAction *action,
616                               glWindow  *window)
617
618 {
619         gl_debug (DEBUG_COMMANDS, "START");
620         
621         g_return_if_fail (action && GTK_IS_ACTION(action));
622         g_return_if_fail (window && GL_IS_WINDOW(window));
623
624         if (window->view != NULL) {
625                 gl_view_object_create_mode (GL_VIEW(window->view),
626                                             GL_LABEL_OBJECT_BOX);
627         }
628
629         gl_debug (DEBUG_COMMANDS, "END");
630 }
631
632 /*****************************************************************************/
633 /** Objects/Create-line object command.                                      */
634 /*****************************************************************************/
635 void
636 gl_ui_cmd_objects_create_line (GtkAction *action,
637                                glWindow  *window)
638
639 {
640         gl_debug (DEBUG_COMMANDS, "START");
641         
642         g_return_if_fail (action && GTK_IS_ACTION(action));
643         g_return_if_fail (window && GL_IS_WINDOW(window));
644
645         if (window->view != NULL) {
646                 gl_view_object_create_mode (GL_VIEW(window->view),
647                                             GL_LABEL_OBJECT_LINE);
648         }
649
650         gl_debug (DEBUG_COMMANDS, "END");
651 }
652
653 /*****************************************************************************/
654 /** Objects/Create-ellipse object command.                                   */
655 /*****************************************************************************/
656 void
657 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
658                                   glWindow  *window)
659
660 {
661         gl_debug (DEBUG_COMMANDS, "START");
662         
663         g_return_if_fail (action && GTK_IS_ACTION(action));
664         g_return_if_fail (window && GL_IS_WINDOW(window));
665
666         if (window->view != NULL) {
667                 gl_view_object_create_mode (GL_VIEW(window->view),
668                                             GL_LABEL_OBJECT_ELLIPSE);
669         }
670
671         gl_debug (DEBUG_COMMANDS, "END");
672 }
673
674 /*****************************************************************************/
675 /** Objects/Create-image object command.                                     */
676 /*****************************************************************************/
677 void
678 gl_ui_cmd_objects_create_image (GtkAction *action,
679                                 glWindow  *window)
680
681 {
682         gl_debug (DEBUG_COMMANDS, "START");
683         
684         g_return_if_fail (action && GTK_IS_ACTION(action));
685         g_return_if_fail (window && GL_IS_WINDOW(window));
686
687         if (window->view != NULL) {
688                 gl_view_object_create_mode (GL_VIEW(window->view),
689                                             GL_LABEL_OBJECT_IMAGE);
690         }
691
692         gl_debug (DEBUG_COMMANDS, "END");
693 }
694
695 /*****************************************************************************/
696 /** Objects/Create-barcode object command.                                   */
697 /*****************************************************************************/
698 void
699 gl_ui_cmd_objects_create_barcode (GtkAction *action,
700                                   glWindow  *window)
701
702 {
703         gl_debug (DEBUG_COMMANDS, "START");
704         
705         g_return_if_fail (action && GTK_IS_ACTION(action));
706         g_return_if_fail (window && GL_IS_WINDOW(window));
707
708         if (window->view != NULL) {
709                 gl_view_object_create_mode (GL_VIEW(window->view),
710                                             GL_LABEL_OBJECT_BARCODE);
711         }
712
713         gl_debug (DEBUG_COMMANDS, "END");
714 }
715
716 /*****************************************************************************/
717 /** Objects/Raise command.                                                   */
718 /*****************************************************************************/
719 void
720 gl_ui_cmd_objects_raise (GtkAction *action,
721                          glWindow  *window)
722
723 {
724         gl_debug (DEBUG_COMMANDS, "START");
725         
726         g_return_if_fail (action && GTK_IS_ACTION(action));
727         g_return_if_fail (window && GL_IS_WINDOW(window));
728
729         if (window->view != NULL) {
730                 gl_view_raise_selection (GL_VIEW(window->view));
731         }
732
733         gl_debug (DEBUG_COMMANDS, "END");
734 }
735
736 /*****************************************************************************/
737 /** Objects/Lower command.                                                   */
738 /*****************************************************************************/
739 void
740 gl_ui_cmd_objects_lower (GtkAction *action,
741                          glWindow  *window)
742
743 {
744         gl_debug (DEBUG_COMMANDS, "START");
745         
746         g_return_if_fail (action && GTK_IS_ACTION(action));
747         g_return_if_fail (window && GL_IS_WINDOW(window));
748
749         if (window->view != NULL) {
750                 gl_view_lower_selection (GL_VIEW(window->view));
751         }
752
753         gl_debug (DEBUG_COMMANDS, "END");
754 }
755
756 /*****************************************************************************/
757 /** Objects/Rotate-left-90-degrees command.                                  */
758 /*****************************************************************************/
759 void
760 gl_ui_cmd_objects_rotate_left (GtkAction *action,
761                                glWindow  *window)
762
763 {
764         gl_debug (DEBUG_COMMANDS, "START");
765         
766         g_return_if_fail (action && GTK_IS_ACTION(action));
767         g_return_if_fail (window && GL_IS_WINDOW(window));
768
769         if (window->view != NULL) {
770                 gl_view_rotate_selection_left (GL_VIEW(window->view));
771         }
772
773         gl_debug (DEBUG_COMMANDS, "END");
774 }
775
776 /*****************************************************************************/
777 /** Objects/Rotate-right-90-degrees command.                                 */
778 /*****************************************************************************/
779 void
780 gl_ui_cmd_objects_rotate_right (GtkAction *action,
781                                 glWindow  *window)
782
783 {
784         gl_debug (DEBUG_COMMANDS, "START");
785         
786         g_return_if_fail (action && GTK_IS_ACTION(action));
787         g_return_if_fail (window && GL_IS_WINDOW(window));
788
789         if (window->view != NULL) {
790                 gl_view_rotate_selection_right (GL_VIEW(window->view));
791         }
792
793         gl_debug (DEBUG_COMMANDS, "END");
794 }
795
796 /*****************************************************************************/
797 /** Objects/Flip-horizontally command.                                       */
798 /*****************************************************************************/
799 void
800 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
801                               glWindow  *window)
802
803 {
804         gl_debug (DEBUG_COMMANDS, "START");
805         
806         g_return_if_fail (action && GTK_IS_ACTION(action));
807         g_return_if_fail (window && GL_IS_WINDOW(window));
808
809         if (window->view != NULL) {
810                 gl_view_flip_selection_horiz (GL_VIEW(window->view));
811         }
812
813         gl_debug (DEBUG_COMMANDS, "END");
814 }
815
816 /*****************************************************************************/
817 /** Objects/Flip-vertically command.                                         */
818 /*****************************************************************************/
819 void
820 gl_ui_cmd_objects_flip_vert (GtkAction *action,
821                              glWindow  *window)
822
823 {
824         gl_debug (DEBUG_COMMANDS, "START");
825         
826         g_return_if_fail (action && GTK_IS_ACTION(action));
827         g_return_if_fail (window && GL_IS_WINDOW(window));
828
829         if (window->view != NULL) {
830                 gl_view_flip_selection_vert (GL_VIEW(window->view));
831         }
832
833         gl_debug (DEBUG_COMMANDS, "END");
834 }
835
836 /*****************************************************************************/
837 /** Objects/Align-left command.                                              */
838 /*****************************************************************************/
839 void
840 gl_ui_cmd_objects_align_left (GtkAction *action,
841                               glWindow  *window)
842
843 {
844         gl_debug (DEBUG_COMMANDS, "START");
845         
846         g_return_if_fail (action && GTK_IS_ACTION(action));
847         g_return_if_fail (window && GL_IS_WINDOW(window));
848
849         if (window->view != NULL) {
850                 gl_view_align_selection_left (GL_VIEW(window->view));
851         }
852
853         gl_debug (DEBUG_COMMANDS, "END");
854 }
855
856 /*****************************************************************************/
857 /** Objects/Align-right command.                                             */
858 /*****************************************************************************/
859 void
860 gl_ui_cmd_objects_align_right (GtkAction *action,
861                                glWindow  *window)
862
863 {
864         gl_debug (DEBUG_COMMANDS, "START");
865         
866         g_return_if_fail (action && GTK_IS_ACTION(action));
867         g_return_if_fail (window && GL_IS_WINDOW(window));
868
869         if (window->view != NULL) {
870                 gl_view_align_selection_right (GL_VIEW(window->view));
871         }
872
873         gl_debug (DEBUG_COMMANDS, "END");
874 }
875
876 /*****************************************************************************/
877 /** Objects/Align-horizontal-center command.                                 */
878 /*****************************************************************************/
879 void
880 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
881                                  glWindow  *window)
882
883 {
884         gl_debug (DEBUG_COMMANDS, "START");
885         
886         g_return_if_fail (action && GTK_IS_ACTION(action));
887         g_return_if_fail (window && GL_IS_WINDOW(window));
888
889         if (window->view != NULL) {
890                 gl_view_align_selection_hcenter (GL_VIEW(window->view));
891         }
892
893         gl_debug (DEBUG_COMMANDS, "END");
894 }
895
896 /*****************************************************************************/
897 /** Objects/Align-top command.                                               */
898 /*****************************************************************************/
899 void
900 gl_ui_cmd_objects_align_top (GtkAction *action,
901                              glWindow  *window)
902
903 {
904         gl_debug (DEBUG_COMMANDS, "START");
905         
906         g_return_if_fail (action && GTK_IS_ACTION(action));
907         g_return_if_fail (window && GL_IS_WINDOW(window));
908
909         if (window->view != NULL) {
910                 gl_view_align_selection_top (GL_VIEW(window->view));
911         }
912
913         gl_debug (DEBUG_COMMANDS, "END");
914 }
915
916 /*****************************************************************************/
917 /** Objects/Align-bottom command.                                            */
918 /*****************************************************************************/
919 void
920 gl_ui_cmd_objects_align_bottom (GtkAction *action,
921                                 glWindow  *window)
922
923 {
924         gl_debug (DEBUG_COMMANDS, "START");
925         
926         g_return_if_fail (action && GTK_IS_ACTION(action));
927         g_return_if_fail (window && GL_IS_WINDOW(window));
928
929         if (window->view != NULL) {
930                 gl_view_align_selection_bottom (GL_VIEW(window->view));
931         }
932
933         gl_debug (DEBUG_COMMANDS, "END");
934 }
935
936 /*****************************************************************************/
937 /** Objects/Align-vertical center command.                                   */
938 /*****************************************************************************/
939 void
940 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
941                                  glWindow  *window)
942
943 {
944         gl_debug (DEBUG_COMMANDS, "START");
945         
946         g_return_if_fail (action && GTK_IS_ACTION(action));
947         g_return_if_fail (window && GL_IS_WINDOW(window));
948
949         if (window->view != NULL) {
950                 gl_view_align_selection_vcenter (GL_VIEW(window->view));
951         }
952
953         gl_debug (DEBUG_COMMANDS, "END");
954 }
955
956 /*****************************************************************************/
957 /** Objects/Center-horizontally command.                                     */
958 /*****************************************************************************/
959 void
960 gl_ui_cmd_objects_center_horiz (GtkAction *action,
961                                 glWindow  *window)
962
963 {
964         gl_debug (DEBUG_COMMANDS, "START");
965         
966         g_return_if_fail (action && GTK_IS_ACTION(action));
967         g_return_if_fail (window && GL_IS_WINDOW(window));
968
969         if (window->view != NULL) {
970                 gl_view_center_selection_horiz (GL_VIEW(window->view));
971         }
972
973         gl_debug (DEBUG_COMMANDS, "END");
974 }
975
976 /*****************************************************************************/
977 /** Objects/Center-vertically command.                                       */
978 /*****************************************************************************/
979 void
980 gl_ui_cmd_objects_center_vert (GtkAction *action,
981                                glWindow  *window)
982
983 {
984         gl_debug (DEBUG_COMMANDS, "START");
985         
986         g_return_if_fail (action && GTK_IS_ACTION(action));
987         g_return_if_fail (window && GL_IS_WINDOW(window));
988
989         if (window->view != NULL) {
990                 gl_view_center_selection_vert (GL_VIEW(window->view));
991         }
992
993         gl_debug (DEBUG_COMMANDS, "END");
994 }
995
996 /*****************************************************************************/
997 /** Objects/Edit- merge-properties command.                                  */
998 /*****************************************************************************/
999 void
1000 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1001                                     glWindow  *window)
1002
1003 {
1004         gl_debug (DEBUG_COMMANDS, "START");
1005         
1006         g_return_if_fail (action && GTK_IS_ACTION(action));
1007         g_return_if_fail (window && GL_IS_WINDOW(window));
1008
1009         if (window->merge_dialog) {
1010
1011                 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1012                 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1013                                               GTK_WINDOW (window));
1014
1015         } else {
1016
1017                 window->merge_dialog =
1018                         g_object_ref (
1019                                 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1020                                                                 GTK_WINDOW(window)) );
1021
1022                 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1023                                   G_CALLBACK (gtk_widget_destroyed),
1024                                   &window->merge_dialog);
1025
1026                 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1027
1028         }
1029
1030         gl_debug (DEBUG_COMMANDS, "END");
1031 }
1032
1033 /****************************************************************************/
1034 /** Help/Contents command.                                                  */
1035 /****************************************************************************/
1036 void 
1037 gl_ui_cmd_help_contents (GtkAction *action,
1038                          glWindow  *window)
1039 {
1040         GError *error = NULL;
1041
1042         gl_debug (DEBUG_COMMANDS, "START");
1043
1044         g_return_if_fail (action && GTK_IS_ACTION(action));
1045         g_return_if_fail (window && GL_IS_WINDOW(window));
1046
1047         gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error);
1048         
1049         if (error != NULL)
1050         {
1051                 g_message (error->message);
1052
1053                 g_error_free (error);
1054         }
1055
1056         gl_debug (DEBUG_COMMANDS, "END");
1057 }
1058
1059
1060 /****************************************************************************/
1061 /** Help/About command.                                                     */
1062 /****************************************************************************/
1063 void 
1064 gl_ui_cmd_help_about (GtkAction *action,
1065                       glWindow  *window)
1066 {
1067         static GtkWidget *about = NULL;
1068
1069         GdkPixbuf        *pixbuf = NULL;
1070         
1071         const gchar *authors[] = {
1072                 "Jim Evins",
1073                 " ",
1074                 _("Glabels includes contributions from:"),
1075                 "Frederic Ruaudel",
1076                 "Wayne Schuller",
1077                 "Emmanuel Pacaud",
1078                 "Austin Henry",
1079                 " ",
1080                 _("See the file AUTHORS for additional credits,"),
1081                 _("or visit http://glabels.sourceforge.net/"),
1082                 NULL
1083         };
1084         
1085         const gchar *artists[] = {
1086                 "Nestor Di",
1087                 "Jim Evins",
1088                 NULL
1089         };
1090         
1091         const gchar *copy_text = "Copyright \xc2\xa9 2001-2005 Jim Evins";
1092
1093         const gchar *about_text = _("A label and business card creation program.\n");
1094
1095         const gchar *url = "http://glabels.sourceforge.net";
1096
1097         const gchar *translator_credits = _("translator-credits");
1098
1099         const gchar *license = _(
1100               "Glabels is free software; you can redistribute it and/or modify it\n"
1101               "under the terms of the GNU General Public License as published by\n"
1102               "the Free Software Foundation; either version 2 of the License, or\n"
1103               "(at your option) any later version.\n" "\n"
1104               "This program is distributed in the hope that it will be useful, but\n"
1105               "WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1106               "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See\n"
1107               "the GNU General Public License for more details.\n");
1108
1109         gl_debug (DEBUG_COMMANDS, "START");
1110
1111         g_return_if_fail (action && GTK_IS_ACTION(action));
1112         g_return_if_fail (window && GL_IS_WINDOW(window));
1113
1114         if (about != NULL)
1115         {
1116
1117                 gtk_window_present (GTK_WINDOW (about));
1118                 gtk_window_set_transient_for (GTK_WINDOW (about),
1119                                               GTK_WINDOW (window));
1120
1121         } else {
1122         
1123                 pixbuf = gdk_pixbuf_new_from_file (GLABELS_PIXMAP_DIR "glabels-splash.png", NULL);
1124
1125                 about = gtk_about_dialog_new ();
1126                 gtk_about_dialog_set_name      (GTK_ABOUT_DIALOG(about), _("glabels"));
1127                 gtk_about_dialog_set_version   (GTK_ABOUT_DIALOG(about), VERSION);
1128                 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text);
1129                 gtk_about_dialog_set_comments  (GTK_ABOUT_DIALOG(about), about_text);
1130                 gtk_about_dialog_set_website   (GTK_ABOUT_DIALOG(about), url);
1131                 gtk_about_dialog_set_logo      (GTK_ABOUT_DIALOG(about), pixbuf);
1132
1133                 gtk_about_dialog_set_authors   (GTK_ABOUT_DIALOG(about), authors);
1134                 gtk_about_dialog_set_artists   (GTK_ABOUT_DIALOG(about), artists);
1135                 gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about),
1136                                                          translator_credits);
1137                 gtk_about_dialog_set_license   (GTK_ABOUT_DIALOG(about), license);
1138         
1139                 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
1140
1141                 g_signal_connect (G_OBJECT (about), "response",
1142                                   G_CALLBACK (gtk_widget_destroy), NULL);
1143                 g_signal_connect (G_OBJECT (about), "destroy",
1144                                   G_CALLBACK (gtk_widget_destroyed), &about);
1145
1146                 gtk_window_set_transient_for (GTK_WINDOW (about),
1147                                               GTK_WINDOW (window));
1148
1149                 gtk_window_present (GTK_WINDOW (about));
1150
1151                 if (pixbuf != NULL)
1152                         g_object_unref (pixbuf);
1153
1154         }
1155         
1156         gl_debug (DEBUG_COMMANDS, "END");
1157 }
1158