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