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