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