]> git.sur5r.net Git - glabels/blob - glabels2/src/ui-commands.c
2009-09-22 Jim Evins <evins@snaught.com>
[glabels] / glabels2 / 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->property_toolbar_visible = 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         gl_prefs_model_save_settings (gl_prefs);
419
420         gl_debug (DEBUG_COMMANDS, "END");
421 }
422
423
424 /*****************************************************************************/
425 /** View/Grid-toggle command.                                                */
426 /*****************************************************************************/
427 void
428 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
429                             glWindow        *window)
430 {
431         gboolean     state;
432
433         gl_debug (DEBUG_COMMANDS, "START");
434
435         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
436         g_return_if_fail (window && GL_IS_WINDOW(window));
437
438         state =  gtk_toggle_action_get_active (action);
439
440         if (window->view != NULL)
441         {
442                 if (state) {
443                         gl_view_show_grid (GL_VIEW(window->view));
444                 } else {
445                         gl_view_hide_grid (GL_VIEW(window->view));
446                 }
447         }
448
449         gl_prefs->grid_visible = state;
450         gl_prefs_model_save_settings (gl_prefs);
451
452         gl_debug (DEBUG_COMMANDS, "END");
453 }
454
455
456 /*****************************************************************************/
457 /** View/Markup-toggle command.                                              */
458 /*****************************************************************************/
459 void
460 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
461                               glWindow        *window)
462 {
463         gboolean     state;
464
465         gl_debug (DEBUG_COMMANDS, "START");
466
467         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
468         g_return_if_fail (window && GL_IS_WINDOW(window));
469
470         state =  gtk_toggle_action_get_active (action);
471
472         if (window->view != NULL)
473         {
474                 if (state) {
475                         gl_view_show_markup (GL_VIEW(window->view));
476                 } else {
477                         gl_view_hide_markup (GL_VIEW(window->view));
478                 }
479         }
480
481         gl_prefs->markup_visible = state;
482         gl_prefs_model_save_settings (gl_prefs);
483
484         gl_debug (DEBUG_COMMANDS, "END");
485 }
486
487
488 /*****************************************************************************/
489 /** View/Zoom-in command.                                                    */
490 /*****************************************************************************/
491 void
492 gl_ui_cmd_view_zoomin (GtkAction *action,
493                        glWindow  *window)
494
495 {
496         gl_debug (DEBUG_COMMANDS, "START");
497         
498         g_return_if_fail (action && GTK_IS_ACTION(action));
499         g_return_if_fail (window && GL_IS_WINDOW(window));
500
501         if (window->view != NULL) {
502                 gl_view_zoom_in (GL_VIEW(window->view));
503         }
504
505         gl_debug (DEBUG_COMMANDS, "END");
506 }
507
508
509 /*****************************************************************************/
510 /** View/Zoom-out command.                                                   */
511 /*****************************************************************************/
512 void
513 gl_ui_cmd_view_zoomout (GtkAction *action,
514                         glWindow  *window)
515
516 {
517         gl_debug (DEBUG_COMMANDS, "START");
518         
519         g_return_if_fail (action && GTK_IS_ACTION(action));
520         g_return_if_fail (window && GL_IS_WINDOW(window));
521
522         if (window->view != NULL) {
523                 gl_view_zoom_out (GL_VIEW(window->view));
524         }
525
526         gl_debug (DEBUG_COMMANDS, "END");
527 }
528
529
530 /*****************************************************************************/
531 /** View/Zoom-1:1 command.                                                   */
532 /*****************************************************************************/
533 void
534 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
535                          glWindow  *window)
536
537 {
538         gl_debug (DEBUG_COMMANDS, "START");
539         
540         g_return_if_fail (action && GTK_IS_ACTION(action));
541         g_return_if_fail (window && GL_IS_WINDOW(window));
542
543         if (window->view != NULL) {
544                 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
545         }
546
547         gl_debug (DEBUG_COMMANDS, "END");
548 }
549
550
551 /*****************************************************************************/
552 /** View/Zoom-to-fit command.                                                */
553 /*****************************************************************************/
554 void
555 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
556                             glWindow  *window)
557
558 {
559         gl_debug (DEBUG_COMMANDS, "START");
560         
561         g_return_if_fail (action && GTK_IS_ACTION(action));
562         g_return_if_fail (window && GL_IS_WINDOW(window));
563
564         if (window->view != NULL) {
565                 gl_view_zoom_to_fit (GL_VIEW(window->view));
566         }
567
568         gl_debug (DEBUG_COMMANDS, "END");
569 }
570
571
572 /*****************************************************************************/
573 /** Objects/Arrow-mode command.                                              */
574 /*****************************************************************************/
575 void
576 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
577                               glWindow  *window)
578 {
579         gl_debug (DEBUG_COMMANDS, "START");
580         
581         g_return_if_fail (action && GTK_IS_ACTION(action));
582         g_return_if_fail (window && GL_IS_WINDOW(window));
583
584         if (window->view != NULL) {
585                 gl_view_arrow_mode (GL_VIEW(window->view));
586         }
587
588         gl_debug (DEBUG_COMMANDS, "END");
589 }
590
591
592 /*****************************************************************************/
593 /** Objects/Create-text object command.                                      */
594 /*****************************************************************************/
595 void
596 gl_ui_cmd_objects_create_text (GtkAction *action,
597                                glWindow  *window)
598
599 {
600         gl_debug (DEBUG_COMMANDS, "START");
601         
602         g_return_if_fail (action && GTK_IS_ACTION(action));
603         g_return_if_fail (window && GL_IS_WINDOW(window));
604
605         if (window->view != NULL) {
606                 gl_view_object_create_mode (GL_VIEW(window->view),
607                                             GL_LABEL_OBJECT_TEXT);
608         }
609
610         gl_debug (DEBUG_COMMANDS, "END");
611 }
612
613
614 /*****************************************************************************/
615 /** Objects/Create-box object command.                                       */
616 /*****************************************************************************/
617 void
618 gl_ui_cmd_objects_create_box (GtkAction *action,
619                               glWindow  *window)
620
621 {
622         gl_debug (DEBUG_COMMANDS, "START");
623         
624         g_return_if_fail (action && GTK_IS_ACTION(action));
625         g_return_if_fail (window && GL_IS_WINDOW(window));
626
627         if (window->view != NULL) {
628                 gl_view_object_create_mode (GL_VIEW(window->view),
629                                             GL_LABEL_OBJECT_BOX);
630         }
631
632         gl_debug (DEBUG_COMMANDS, "END");
633 }
634
635
636 /*****************************************************************************/
637 /** Objects/Create-line object command.                                      */
638 /*****************************************************************************/
639 void
640 gl_ui_cmd_objects_create_line (GtkAction *action,
641                                glWindow  *window)
642
643 {
644         gl_debug (DEBUG_COMMANDS, "START");
645         
646         g_return_if_fail (action && GTK_IS_ACTION(action));
647         g_return_if_fail (window && GL_IS_WINDOW(window));
648
649         if (window->view != NULL) {
650                 gl_view_object_create_mode (GL_VIEW(window->view),
651                                             GL_LABEL_OBJECT_LINE);
652         }
653
654         gl_debug (DEBUG_COMMANDS, "END");
655 }
656
657
658 /*****************************************************************************/
659 /** Objects/Create-ellipse object command.                                   */
660 /*****************************************************************************/
661 void
662 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
663                                   glWindow  *window)
664
665 {
666         gl_debug (DEBUG_COMMANDS, "START");
667         
668         g_return_if_fail (action && GTK_IS_ACTION(action));
669         g_return_if_fail (window && GL_IS_WINDOW(window));
670
671         if (window->view != NULL) {
672                 gl_view_object_create_mode (GL_VIEW(window->view),
673                                             GL_LABEL_OBJECT_ELLIPSE);
674         }
675
676         gl_debug (DEBUG_COMMANDS, "END");
677 }
678
679
680 /*****************************************************************************/
681 /** Objects/Create-image object command.                                     */
682 /*****************************************************************************/
683 void
684 gl_ui_cmd_objects_create_image (GtkAction *action,
685                                 glWindow  *window)
686
687 {
688         gl_debug (DEBUG_COMMANDS, "START");
689         
690         g_return_if_fail (action && GTK_IS_ACTION(action));
691         g_return_if_fail (window && GL_IS_WINDOW(window));
692
693         if (window->view != NULL) {
694                 gl_view_object_create_mode (GL_VIEW(window->view),
695                                             GL_LABEL_OBJECT_IMAGE);
696         }
697
698         gl_debug (DEBUG_COMMANDS, "END");
699 }
700
701
702 /*****************************************************************************/
703 /** Objects/Create-barcode object command.                                   */
704 /*****************************************************************************/
705 void
706 gl_ui_cmd_objects_create_barcode (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_object_create_mode (GL_VIEW(window->view),
717                                             GL_LABEL_OBJECT_BARCODE);
718         }
719
720         gl_debug (DEBUG_COMMANDS, "END");
721 }
722
723
724 /*****************************************************************************/
725 /** Objects/Raise command.                                                   */
726 /*****************************************************************************/
727 void
728 gl_ui_cmd_objects_raise (GtkAction *action,
729                          glWindow  *window)
730
731 {
732         gl_debug (DEBUG_COMMANDS, "START");
733         
734         g_return_if_fail (action && GTK_IS_ACTION(action));
735         g_return_if_fail (window && GL_IS_WINDOW(window));
736
737         if (window->view != NULL) {
738                 gl_view_raise_selection (GL_VIEW(window->view));
739         }
740
741         gl_debug (DEBUG_COMMANDS, "END");
742 }
743
744
745 /*****************************************************************************/
746 /** Objects/Lower command.                                                   */
747 /*****************************************************************************/
748 void
749 gl_ui_cmd_objects_lower (GtkAction *action,
750                          glWindow  *window)
751
752 {
753         gl_debug (DEBUG_COMMANDS, "START");
754         
755         g_return_if_fail (action && GTK_IS_ACTION(action));
756         g_return_if_fail (window && GL_IS_WINDOW(window));
757
758         if (window->view != NULL) {
759                 gl_view_lower_selection (GL_VIEW(window->view));
760         }
761
762         gl_debug (DEBUG_COMMANDS, "END");
763 }
764
765
766 /*****************************************************************************/
767 /** Objects/Rotate-left-90-degrees command.                                  */
768 /*****************************************************************************/
769 void
770 gl_ui_cmd_objects_rotate_left (GtkAction *action,
771                                glWindow  *window)
772
773 {
774         gl_debug (DEBUG_COMMANDS, "START");
775         
776         g_return_if_fail (action && GTK_IS_ACTION(action));
777         g_return_if_fail (window && GL_IS_WINDOW(window));
778
779         if (window->view != NULL) {
780                 gl_view_rotate_selection_left (GL_VIEW(window->view));
781         }
782
783         gl_debug (DEBUG_COMMANDS, "END");
784 }
785
786
787 /*****************************************************************************/
788 /** Objects/Rotate-right-90-degrees command.                                 */
789 /*****************************************************************************/
790 void
791 gl_ui_cmd_objects_rotate_right (GtkAction *action,
792                                 glWindow  *window)
793
794 {
795         gl_debug (DEBUG_COMMANDS, "START");
796         
797         g_return_if_fail (action && GTK_IS_ACTION(action));
798         g_return_if_fail (window && GL_IS_WINDOW(window));
799
800         if (window->view != NULL) {
801                 gl_view_rotate_selection_right (GL_VIEW(window->view));
802         }
803
804         gl_debug (DEBUG_COMMANDS, "END");
805 }
806
807
808 /*****************************************************************************/
809 /** Objects/Flip-horizontally command.                                       */
810 /*****************************************************************************/
811 void
812 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
813                               glWindow  *window)
814
815 {
816         gl_debug (DEBUG_COMMANDS, "START");
817         
818         g_return_if_fail (action && GTK_IS_ACTION(action));
819         g_return_if_fail (window && GL_IS_WINDOW(window));
820
821         if (window->view != NULL) {
822                 gl_view_flip_selection_horiz (GL_VIEW(window->view));
823         }
824
825         gl_debug (DEBUG_COMMANDS, "END");
826 }
827
828
829 /*****************************************************************************/
830 /** Objects/Flip-vertically command.                                         */
831 /*****************************************************************************/
832 void
833 gl_ui_cmd_objects_flip_vert (GtkAction *action,
834                              glWindow  *window)
835
836 {
837         gl_debug (DEBUG_COMMANDS, "START");
838         
839         g_return_if_fail (action && GTK_IS_ACTION(action));
840         g_return_if_fail (window && GL_IS_WINDOW(window));
841
842         if (window->view != NULL) {
843                 gl_view_flip_selection_vert (GL_VIEW(window->view));
844         }
845
846         gl_debug (DEBUG_COMMANDS, "END");
847 }
848
849
850 /*****************************************************************************/
851 /** Objects/Align-left command.                                              */
852 /*****************************************************************************/
853 void
854 gl_ui_cmd_objects_align_left (GtkAction *action,
855                               glWindow  *window)
856
857 {
858         gl_debug (DEBUG_COMMANDS, "START");
859         
860         g_return_if_fail (action && GTK_IS_ACTION(action));
861         g_return_if_fail (window && GL_IS_WINDOW(window));
862
863         if (window->view != NULL) {
864                 gl_view_align_selection_left (GL_VIEW(window->view));
865         }
866
867         gl_debug (DEBUG_COMMANDS, "END");
868 }
869
870
871 /*****************************************************************************/
872 /** Objects/Align-right command.                                             */
873 /*****************************************************************************/
874 void
875 gl_ui_cmd_objects_align_right (GtkAction *action,
876                                glWindow  *window)
877
878 {
879         gl_debug (DEBUG_COMMANDS, "START");
880         
881         g_return_if_fail (action && GTK_IS_ACTION(action));
882         g_return_if_fail (window && GL_IS_WINDOW(window));
883
884         if (window->view != NULL) {
885                 gl_view_align_selection_right (GL_VIEW(window->view));
886         }
887
888         gl_debug (DEBUG_COMMANDS, "END");
889 }
890
891
892 /*****************************************************************************/
893 /** Objects/Align-horizontal-center command.                                 */
894 /*****************************************************************************/
895 void
896 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
897                                  glWindow  *window)
898
899 {
900         gl_debug (DEBUG_COMMANDS, "START");
901         
902         g_return_if_fail (action && GTK_IS_ACTION(action));
903         g_return_if_fail (window && GL_IS_WINDOW(window));
904
905         if (window->view != NULL) {
906                 gl_view_align_selection_hcenter (GL_VIEW(window->view));
907         }
908
909         gl_debug (DEBUG_COMMANDS, "END");
910 }
911
912
913 /*****************************************************************************/
914 /** Objects/Align-top command.                                               */
915 /*****************************************************************************/
916 void
917 gl_ui_cmd_objects_align_top (GtkAction *action,
918                              glWindow  *window)
919
920 {
921         gl_debug (DEBUG_COMMANDS, "START");
922         
923         g_return_if_fail (action && GTK_IS_ACTION(action));
924         g_return_if_fail (window && GL_IS_WINDOW(window));
925
926         if (window->view != NULL) {
927                 gl_view_align_selection_top (GL_VIEW(window->view));
928         }
929
930         gl_debug (DEBUG_COMMANDS, "END");
931 }
932
933
934 /*****************************************************************************/
935 /** Objects/Align-bottom command.                                            */
936 /*****************************************************************************/
937 void
938 gl_ui_cmd_objects_align_bottom (GtkAction *action,
939                                 glWindow  *window)
940
941 {
942         gl_debug (DEBUG_COMMANDS, "START");
943         
944         g_return_if_fail (action && GTK_IS_ACTION(action));
945         g_return_if_fail (window && GL_IS_WINDOW(window));
946
947         if (window->view != NULL) {
948                 gl_view_align_selection_bottom (GL_VIEW(window->view));
949         }
950
951         gl_debug (DEBUG_COMMANDS, "END");
952 }
953
954
955 /*****************************************************************************/
956 /** Objects/Align-vertical center command.                                   */
957 /*****************************************************************************/
958 void
959 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
960                                  glWindow  *window)
961
962 {
963         gl_debug (DEBUG_COMMANDS, "START");
964         
965         g_return_if_fail (action && GTK_IS_ACTION(action));
966         g_return_if_fail (window && GL_IS_WINDOW(window));
967
968         if (window->view != NULL) {
969                 gl_view_align_selection_vcenter (GL_VIEW(window->view));
970         }
971
972         gl_debug (DEBUG_COMMANDS, "END");
973 }
974
975
976 /*****************************************************************************/
977 /** Objects/Center-horizontally command.                                     */
978 /*****************************************************************************/
979 void
980 gl_ui_cmd_objects_center_horiz (GtkAction *action,
981                                 glWindow  *window)
982
983 {
984         gl_debug (DEBUG_COMMANDS, "START");
985         
986         g_return_if_fail (action && GTK_IS_ACTION(action));
987         g_return_if_fail (window && GL_IS_WINDOW(window));
988
989         if (window->view != NULL) {
990                 gl_view_center_selection_horiz (GL_VIEW(window->view));
991         }
992
993         gl_debug (DEBUG_COMMANDS, "END");
994 }
995
996
997 /*****************************************************************************/
998 /** Objects/Center-vertically command.                                       */
999 /*****************************************************************************/
1000 void
1001 gl_ui_cmd_objects_center_vert (GtkAction *action,
1002                                glWindow  *window)
1003
1004 {
1005         gl_debug (DEBUG_COMMANDS, "START");
1006         
1007         g_return_if_fail (action && GTK_IS_ACTION(action));
1008         g_return_if_fail (window && GL_IS_WINDOW(window));
1009
1010         if (window->view != NULL) {
1011                 gl_view_center_selection_vert (GL_VIEW(window->view));
1012         }
1013
1014         gl_debug (DEBUG_COMMANDS, "END");
1015 }
1016
1017
1018 /*****************************************************************************/
1019 /** Objects/Edit- merge-properties command.                                  */
1020 /*****************************************************************************/
1021 void
1022 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1023                                     glWindow  *window)
1024
1025 {
1026         gl_debug (DEBUG_COMMANDS, "START");
1027         
1028         g_return_if_fail (action && GTK_IS_ACTION(action));
1029         g_return_if_fail (window && GL_IS_WINDOW(window));
1030
1031         if (window->merge_dialog) {
1032
1033                 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1034                 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1035                                               GTK_WINDOW (window));
1036
1037         } else {
1038
1039                 window->merge_dialog =
1040                         g_object_ref (
1041                                 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1042                                                                 GTK_WINDOW(window)) );
1043
1044                 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1045                                   G_CALLBACK (gtk_widget_destroyed),
1046                                   &window->merge_dialog);
1047
1048                 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1049
1050         }
1051
1052         gl_debug (DEBUG_COMMANDS, "END");
1053 }
1054
1055
1056 /****************************************************************************/
1057 /** Help/Contents command.                                                  */
1058 /****************************************************************************/
1059 void 
1060 gl_ui_cmd_help_contents (GtkAction *action,
1061                          glWindow  *window)
1062 {
1063         GError *error = NULL;
1064
1065         gl_debug (DEBUG_COMMANDS, "START");
1066
1067         g_return_if_fail (action && GTK_IS_ACTION(action));
1068         g_return_if_fail (window && GL_IS_WINDOW(window));
1069
1070         gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (window)),
1071                       "ghelp:glabels",
1072                       GDK_CURRENT_TIME, 
1073                       &error);
1074         
1075         if (error != NULL)
1076         {
1077                 g_message ("%s", error->message);
1078
1079                 g_error_free (error);
1080         }
1081
1082         gl_debug (DEBUG_COMMANDS, "END");
1083 }
1084
1085
1086 /****************************************************************************/
1087 /** Help/About command.                                                     */
1088 /****************************************************************************/
1089 void 
1090 gl_ui_cmd_help_about (GtkAction *action,
1091                       glWindow  *window)
1092 {
1093         static GtkWidget *about = NULL;
1094
1095         GdkPixbuf        *pixbuf = NULL;
1096         
1097         const gchar *authors[] = {
1098                 "Jim Evins",
1099                 " ",
1100                 _("Glabels includes contributions from:"),
1101                 "Frederic Ruaudel",
1102                 "Wayne Schuller",
1103                 "Emmanuel Pacaud",
1104                 "Austin Henry",
1105                 " ",
1106                 _("See the file AUTHORS for additional credits,"),
1107                 _("or visit http://glabels.sourceforge.net/"),
1108                 NULL
1109         };
1110         
1111         const gchar *artists[] = {
1112                 "Nestor Di",
1113                 "Jim Evins",
1114                 NULL
1115         };
1116         
1117         const gchar *copy_text = "Copyright \xc2\xa9 2001-2009 Jim Evins";
1118
1119         const gchar *about_text = _("A label and business card creation program.\n");
1120
1121         const gchar *url = "http://glabels.sourceforge.net";
1122
1123         const gchar *translator_credits = _("translator-credits");
1124
1125         const gchar *license = _(
1126                 "gLabels is free software: you can redistribute it and/or modify\n"
1127                 "it under the terms of the GNU General Public License as published by\n"
1128                 "the Free Software Foundation, either version 3 of the License, or\n"
1129                 "(at your option) any later version.\n"
1130                 "\n"
1131                 "gLabels is distributed in the hope that it will be useful,\n"
1132                 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1133                 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
1134                 "GNU General Public License for more details.\n");
1135
1136         gl_debug (DEBUG_COMMANDS, "START");
1137
1138         g_return_if_fail (action && GTK_IS_ACTION(action));
1139         g_return_if_fail (window && GL_IS_WINDOW(window));
1140
1141         if (about != NULL)
1142         {
1143
1144                 gtk_window_present (GTK_WINDOW (about));
1145                 gtk_window_set_transient_for (GTK_WINDOW (about),
1146                                               GTK_WINDOW (window));
1147
1148         } else {
1149         
1150                 pixbuf = gdk_pixbuf_new_from_file (GLABELS_PIXMAP_DIR "glabels-splash.png", NULL);
1151
1152                 about = gtk_about_dialog_new ();
1153                 gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(about), _("glabels"));
1154                 gtk_about_dialog_set_version      (GTK_ABOUT_DIALOG(about), VERSION);
1155                 gtk_about_dialog_set_copyright    (GTK_ABOUT_DIALOG(about), copy_text);
1156                 gtk_about_dialog_set_comments     (GTK_ABOUT_DIALOG(about), about_text);
1157                 gtk_about_dialog_set_website      (GTK_ABOUT_DIALOG(about), url);
1158                 gtk_about_dialog_set_logo         (GTK_ABOUT_DIALOG(about), pixbuf);
1159
1160                 gtk_about_dialog_set_authors      (GTK_ABOUT_DIALOG(about), authors);
1161                 gtk_about_dialog_set_artists      (GTK_ABOUT_DIALOG(about), artists);
1162                 gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about),
1163                                                          translator_credits);
1164                 gtk_about_dialog_set_license   (GTK_ABOUT_DIALOG(about), license);
1165         
1166                 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
1167
1168                 g_signal_connect (G_OBJECT (about), "response",
1169                                   G_CALLBACK (gtk_widget_destroy), NULL);
1170                 g_signal_connect (G_OBJECT (about), "destroy",
1171                                   G_CALLBACK (gtk_widget_destroyed), &about);
1172
1173                 gtk_window_set_transient_for (GTK_WINDOW (about),
1174                                               GTK_WINDOW (window));
1175
1176                 gtk_window_present (GTK_WINDOW (about));
1177
1178                 if (pixbuf != NULL)
1179                         g_object_unref (pixbuf);
1180
1181         }
1182         
1183         gl_debug (DEBUG_COMMANDS, "END");
1184 }
1185
1186
1187
1188 /*
1189  * Local Variables:       -- emacs
1190  * mode: C                -- emacs
1191  * c-basic-offset: 8      -- emacs
1192  * tab-width: 8           -- emacs
1193  * indent-tabs-mode: nil  -- emacs
1194  * End:                   -- emacs
1195  */