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