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