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