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