]> git.sur5r.net Git - glabels/blob - glabels2/src/ui-commands.c
2007-01-16 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-op.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         glPrintOp *op;
195
196         gl_debug (DEBUG_COMMANDS, "START");
197
198         g_return_if_fail (action && GTK_IS_ACTION(action));
199         g_return_if_fail (window && GL_IS_WINDOW(window));
200
201         op = gl_print_op_new (GL_VIEW(window->view)->label);
202
203         gtk_print_operation_run (GTK_PRINT_OPERATION (op),
204                                  GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
205                                  GTK_WINDOW (window),
206                                  NULL);
207
208         gl_debug (DEBUG_COMMANDS, "END");
209 }
210
211 /****************************************************************************/
212 /** File/Close command.                                                     */
213 /****************************************************************************/
214 void 
215 gl_ui_cmd_file_close (GtkAction *action,
216                       glWindow  *window)
217 {
218         gl_debug (DEBUG_COMMANDS, "START");
219
220         g_return_if_fail (action && GTK_IS_ACTION(action));
221         g_return_if_fail (window && GL_IS_WINDOW(window));
222
223         gl_file_close (window);
224
225         gl_debug (DEBUG_COMMANDS, "END");
226 }
227
228 /****************************************************************************/
229 /** File/Quit command.                                                      */
230 /****************************************************************************/
231 void 
232 gl_ui_cmd_file_quit (GtkAction *action,
233                      glWindow  *window)
234 {
235         gl_debug (DEBUG_COMMANDS, "START");
236
237         g_return_if_fail (action && GTK_IS_ACTION(action));
238         g_return_if_fail (window && GL_IS_WINDOW(window));
239
240         gl_file_exit ();
241
242         gl_debug (DEBUG_COMMANDS, "END");
243 }
244
245
246 /****************************************************************************/
247 /** Edit/Cut command.                                                       */
248 /****************************************************************************/
249 void 
250 gl_ui_cmd_edit_cut (GtkAction *action,
251                     glWindow  *window)
252 {
253         gl_debug (DEBUG_COMMANDS, "START");
254
255         g_return_if_fail (action && GTK_IS_ACTION(action));
256         g_return_if_fail (window && GL_IS_WINDOW(window));
257
258         gl_view_cut (GL_VIEW(window->view)); 
259
260         gl_debug (DEBUG_COMMANDS, "END");
261 }
262
263 /****************************************************************************/
264 /** Edit/Copy command.                                                      */
265 /****************************************************************************/
266 void 
267 gl_ui_cmd_edit_copy (GtkAction *action,
268                      glWindow  *window)
269 {
270         gl_debug (DEBUG_COMMANDS, "START");
271
272         g_return_if_fail (action && GTK_IS_ACTION(action));
273         g_return_if_fail (window && GL_IS_WINDOW(window));
274
275         gl_view_copy (GL_VIEW(window->view)); 
276
277         gl_debug (DEBUG_COMMANDS, "END");
278 }
279
280 /****************************************************************************/
281 /** Edit/Paste command.                                                     */
282 /****************************************************************************/
283 void 
284 gl_ui_cmd_edit_paste (GtkAction *action,
285                       glWindow  *window)
286 {
287         gl_debug (DEBUG_COMMANDS, "START");
288
289         g_return_if_fail (action && GTK_IS_ACTION(action));
290         g_return_if_fail (window && GL_IS_WINDOW(window));
291
292         gl_view_paste (GL_VIEW(window->view)); 
293
294         gl_debug (DEBUG_COMMANDS, "END");
295 }
296
297
298 /****************************************************************************/
299 /** Edit/Delete command.                                                    */
300 /****************************************************************************/
301 void 
302 gl_ui_cmd_edit_delete (GtkAction *action,
303                        glWindow  *window)
304 {
305         gl_debug (DEBUG_COMMANDS, "START");
306
307         g_return_if_fail (action && GTK_IS_ACTION(action));
308         g_return_if_fail (window && GL_IS_WINDOW(window));
309
310         gl_view_delete_selection (GL_VIEW(window->view)); 
311
312         gl_debug (DEBUG_COMMANDS, "END");
313 }
314
315
316 /****************************************************************************/
317 /** Edit/Select-all command.                                                */
318 /****************************************************************************/
319 void
320 gl_ui_cmd_edit_select_all (GtkAction *action,
321                            glWindow  *window)
322 {
323         gl_debug (DEBUG_COMMANDS, "START");
324
325         g_return_if_fail (action && GTK_IS_ACTION(action));
326         g_return_if_fail (window && GL_IS_WINDOW(window));
327
328         gl_view_select_all (GL_VIEW(window->view)); 
329
330         gl_debug (DEBUG_COMMANDS, "END");
331 }
332
333 /****************************************************************************/
334 /** Edit/Unselect-all command.                                              */
335 /****************************************************************************/
336 void
337 gl_ui_cmd_edit_unselect_all (GtkAction *action,
338                              glWindow  *window)
339 {
340         gl_debug (DEBUG_COMMANDS, "START");
341
342         g_return_if_fail (action && GTK_IS_ACTION(action));
343         g_return_if_fail (window && GL_IS_WINDOW(window));
344
345         gl_view_unselect_all (GL_VIEW(window->view)); 
346
347         gl_debug (DEBUG_COMMANDS, "END");
348 }
349
350 /****************************************************************************/
351 /** Edit/Preferences command.                                               */
352 /****************************************************************************/
353 void
354 gl_ui_cmd_edit_preferences (GtkAction *action,
355                             glWindow  *window)
356 {
357         static GtkWidget *dlg = NULL;
358
359         gl_debug (DEBUG_COMMANDS, "START");
360
361         g_return_if_fail (action && GTK_IS_ACTION(action));
362         g_return_if_fail (window && GL_IS_WINDOW(window));
363
364         if (dlg != NULL)
365         {
366                 gtk_window_present (GTK_WINDOW (dlg));
367                 gtk_window_set_transient_for (GTK_WINDOW (dlg),        
368                                               GTK_WINDOW(window));
369
370         } else {
371                 
372                 dlg = gl_prefs_dialog_new (GTK_WINDOW(window));
373
374                 g_signal_connect (G_OBJECT (dlg), "destroy",
375                                   G_CALLBACK (gtk_widget_destroyed), &dlg);
376         
377                 gtk_widget_show (dlg);
378
379         }
380
381         gl_debug (DEBUG_COMMANDS, "END");
382 }
383
384 /*****************************************************************************/
385 /** View/Property-bar-toggle command.                                        */
386 /*****************************************************************************/
387 void
388 gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action,
389                                     glWindow        *window)
390 {
391         gboolean     state;
392
393         gl_debug (DEBUG_COMMANDS, "START");
394
395         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
396         g_return_if_fail (window && GL_IS_WINDOW(window));
397
398         state =  gtk_toggle_action_get_active (action);
399
400         gl_prefs->property_toolbar_visible = state;
401         if (state) {
402                 gtk_widget_show (GTK_WIDGET (window->property_bar));
403         } else {
404                 gtk_widget_hide (GTK_WIDGET (window->property_bar));
405         }
406         gl_prefs_model_save_settings (gl_prefs);
407
408         gl_debug (DEBUG_COMMANDS, "END");
409 }
410
411 /*****************************************************************************/
412 /** View/Property-bar-tooltips-toggle command.                               */
413 /*****************************************************************************/
414 void
415 gl_ui_cmd_view_property_bar_tips_toggle (GtkToggleAction *action,
416                                          glWindow        *window)
417 {
418         gboolean     state;
419
420         gl_debug (DEBUG_COMMANDS, "START");
421
422         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
423         g_return_if_fail (window && GL_IS_WINDOW(window));
424
425         state =  gtk_toggle_action_get_active (action);
426
427         gl_prefs->property_toolbar_view_tooltips = state;
428         gl_ui_property_bar_set_tooltips (window->property_bar, state);
429         gl_prefs_model_save_settings (gl_prefs);
430
431         gl_debug (DEBUG_COMMANDS, "END");
432 }
433
434 /*****************************************************************************/
435 /** View/Grid-toggle command.                                                */
436 /*****************************************************************************/
437 void
438 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
439                             glWindow        *window)
440 {
441         gboolean     state;
442
443         gl_debug (DEBUG_COMMANDS, "START");
444
445         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
446         g_return_if_fail (window && GL_IS_WINDOW(window));
447
448         state =  gtk_toggle_action_get_active (action);
449
450         if (window->view != NULL)
451         {
452                 if (state) {
453                         gl_view_show_grid (GL_VIEW(window->view));
454                 } else {
455                         gl_view_hide_grid (GL_VIEW(window->view));
456                 }
457         }
458
459         gl_prefs->grid_visible = state;
460         gl_prefs_model_save_settings (gl_prefs);
461
462         gl_debug (DEBUG_COMMANDS, "END");
463 }
464
465 /*****************************************************************************/
466 /** View/Markup-toggle command.                                              */
467 /*****************************************************************************/
468 void
469 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
470                               glWindow        *window)
471 {
472         gboolean     state;
473
474         gl_debug (DEBUG_COMMANDS, "START");
475
476         g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
477         g_return_if_fail (window && GL_IS_WINDOW(window));
478
479         state =  gtk_toggle_action_get_active (action);
480
481         if (window->view != NULL)
482         {
483                 if (state) {
484                         gl_view_show_markup (GL_VIEW(window->view));
485                 } else {
486                         gl_view_hide_markup (GL_VIEW(window->view));
487                 }
488         }
489
490         gl_prefs->markup_visible = state;
491         gl_prefs_model_save_settings (gl_prefs);
492
493         gl_debug (DEBUG_COMMANDS, "END");
494 }
495
496 /*****************************************************************************/
497 /** View/Zoom-in command.                                                    */
498 /*****************************************************************************/
499 void
500 gl_ui_cmd_view_zoomin (GtkAction *action,
501                        glWindow  *window)
502
503 {
504         gl_debug (DEBUG_COMMANDS, "START");
505         
506         g_return_if_fail (action && GTK_IS_ACTION(action));
507         g_return_if_fail (window && GL_IS_WINDOW(window));
508
509         if (window->view != NULL) {
510                 gl_view_zoom_in (GL_VIEW(window->view));
511         }
512
513         gl_debug (DEBUG_COMMANDS, "END");
514 }
515
516 /*****************************************************************************/
517 /** View/Zoom-out command.                                                   */
518 /*****************************************************************************/
519 void
520 gl_ui_cmd_view_zoomout (GtkAction *action,
521                         glWindow  *window)
522
523 {
524         gl_debug (DEBUG_COMMANDS, "START");
525         
526         g_return_if_fail (action && GTK_IS_ACTION(action));
527         g_return_if_fail (window && GL_IS_WINDOW(window));
528
529         if (window->view != NULL) {
530                 gl_view_zoom_out (GL_VIEW(window->view));
531         }
532
533         gl_debug (DEBUG_COMMANDS, "END");
534 }
535
536 /*****************************************************************************/
537 /** View/Zoom-1:1 command.                                                   */
538 /*****************************************************************************/
539 void
540 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
541                          glWindow  *window)
542
543 {
544         gl_debug (DEBUG_COMMANDS, "START");
545         
546         g_return_if_fail (action && GTK_IS_ACTION(action));
547         g_return_if_fail (window && GL_IS_WINDOW(window));
548
549         if (window->view != NULL) {
550                 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
551         }
552
553         gl_debug (DEBUG_COMMANDS, "END");
554 }
555
556 /*****************************************************************************/
557 /** View/Zoom-to-fit command.                                                */
558 /*****************************************************************************/
559 void
560 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
561                             glWindow  *window)
562
563 {
564         gl_debug (DEBUG_COMMANDS, "START");
565         
566         g_return_if_fail (action && GTK_IS_ACTION(action));
567         g_return_if_fail (window && GL_IS_WINDOW(window));
568
569         if (window->view != NULL) {
570                 gl_view_zoom_to_fit (GL_VIEW(window->view));
571         }
572
573         gl_debug (DEBUG_COMMANDS, "END");
574 }
575
576 /*****************************************************************************/
577 /** Objects/Arrow-mode command.                                              */
578 /*****************************************************************************/
579 void
580 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
581                               glWindow  *window)
582 {
583         gl_debug (DEBUG_COMMANDS, "START");
584         
585         g_return_if_fail (action && GTK_IS_ACTION(action));
586         g_return_if_fail (window && GL_IS_WINDOW(window));
587
588         if (window->view != NULL) {
589                 gl_view_arrow_mode (GL_VIEW(window->view));
590         }
591
592         gl_debug (DEBUG_COMMANDS, "END");
593 }
594
595 /*****************************************************************************/
596 /** Objects/Create-text object command.                                      */
597 /*****************************************************************************/
598 void
599 gl_ui_cmd_objects_create_text (GtkAction *action,
600                                glWindow  *window)
601
602 {
603         gl_debug (DEBUG_COMMANDS, "START");
604         
605         g_return_if_fail (action && GTK_IS_ACTION(action));
606         g_return_if_fail (window && GL_IS_WINDOW(window));
607
608         if (window->view != NULL) {
609                 gl_view_object_create_mode (GL_VIEW(window->view),
610                                             GL_LABEL_OBJECT_TEXT);
611         }
612
613         gl_debug (DEBUG_COMMANDS, "END");
614 }
615
616 /*****************************************************************************/
617 /** Objects/Create-box object command.                                       */
618 /*****************************************************************************/
619 void
620 gl_ui_cmd_objects_create_box (GtkAction *action,
621                               glWindow  *window)
622
623 {
624         gl_debug (DEBUG_COMMANDS, "START");
625         
626         g_return_if_fail (action && GTK_IS_ACTION(action));
627         g_return_if_fail (window && GL_IS_WINDOW(window));
628
629         if (window->view != NULL) {
630                 gl_view_object_create_mode (GL_VIEW(window->view),
631                                             GL_LABEL_OBJECT_BOX);
632         }
633
634         gl_debug (DEBUG_COMMANDS, "END");
635 }
636
637 /*****************************************************************************/
638 /** Objects/Create-line object command.                                      */
639 /*****************************************************************************/
640 void
641 gl_ui_cmd_objects_create_line (GtkAction *action,
642                                glWindow  *window)
643
644 {
645         gl_debug (DEBUG_COMMANDS, "START");
646         
647         g_return_if_fail (action && GTK_IS_ACTION(action));
648         g_return_if_fail (window && GL_IS_WINDOW(window));
649
650         if (window->view != NULL) {
651                 gl_view_object_create_mode (GL_VIEW(window->view),
652                                             GL_LABEL_OBJECT_LINE);
653         }
654
655         gl_debug (DEBUG_COMMANDS, "END");
656 }
657
658 /*****************************************************************************/
659 /** Objects/Create-ellipse object command.                                   */
660 /*****************************************************************************/
661 void
662 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
663                                   glWindow  *window)
664
665 {
666         gl_debug (DEBUG_COMMANDS, "START");
667         
668         g_return_if_fail (action && GTK_IS_ACTION(action));
669         g_return_if_fail (window && GL_IS_WINDOW(window));
670
671         if (window->view != NULL) {
672                 gl_view_object_create_mode (GL_VIEW(window->view),
673                                             GL_LABEL_OBJECT_ELLIPSE);
674         }
675
676         gl_debug (DEBUG_COMMANDS, "END");
677 }
678
679 /*****************************************************************************/
680 /** Objects/Create-image object command.                                     */
681 /*****************************************************************************/
682 void
683 gl_ui_cmd_objects_create_image (GtkAction *action,
684                                 glWindow  *window)
685
686 {
687         gl_debug (DEBUG_COMMANDS, "START");
688         
689         g_return_if_fail (action && GTK_IS_ACTION(action));
690         g_return_if_fail (window && GL_IS_WINDOW(window));
691
692         if (window->view != NULL) {
693                 gl_view_object_create_mode (GL_VIEW(window->view),
694                                             GL_LABEL_OBJECT_IMAGE);
695         }
696
697         gl_debug (DEBUG_COMMANDS, "END");
698 }
699
700 /*****************************************************************************/
701 /** Objects/Create-barcode object command.                                   */
702 /*****************************************************************************/
703 void
704 gl_ui_cmd_objects_create_barcode (GtkAction *action,
705                                   glWindow  *window)
706
707 {
708         gl_debug (DEBUG_COMMANDS, "START");
709         
710         g_return_if_fail (action && GTK_IS_ACTION(action));
711         g_return_if_fail (window && GL_IS_WINDOW(window));
712
713         if (window->view != NULL) {
714                 gl_view_object_create_mode (GL_VIEW(window->view),
715                                             GL_LABEL_OBJECT_BARCODE);
716         }
717
718         gl_debug (DEBUG_COMMANDS, "END");
719 }
720
721 /*****************************************************************************/
722 /** Objects/Raise command.                                                   */
723 /*****************************************************************************/
724 void
725 gl_ui_cmd_objects_raise (GtkAction *action,
726                          glWindow  *window)
727
728 {
729         gl_debug (DEBUG_COMMANDS, "START");
730         
731         g_return_if_fail (action && GTK_IS_ACTION(action));
732         g_return_if_fail (window && GL_IS_WINDOW(window));
733
734         if (window->view != NULL) {
735                 gl_view_raise_selection (GL_VIEW(window->view));
736         }
737
738         gl_debug (DEBUG_COMMANDS, "END");
739 }
740
741 /*****************************************************************************/
742 /** Objects/Lower command.                                                   */
743 /*****************************************************************************/
744 void
745 gl_ui_cmd_objects_lower (GtkAction *action,
746                          glWindow  *window)
747
748 {
749         gl_debug (DEBUG_COMMANDS, "START");
750         
751         g_return_if_fail (action && GTK_IS_ACTION(action));
752         g_return_if_fail (window && GL_IS_WINDOW(window));
753
754         if (window->view != NULL) {
755                 gl_view_lower_selection (GL_VIEW(window->view));
756         }
757
758         gl_debug (DEBUG_COMMANDS, "END");
759 }
760
761 /*****************************************************************************/
762 /** Objects/Rotate-left-90-degrees command.                                  */
763 /*****************************************************************************/
764 void
765 gl_ui_cmd_objects_rotate_left (GtkAction *action,
766                                glWindow  *window)
767
768 {
769         gl_debug (DEBUG_COMMANDS, "START");
770         
771         g_return_if_fail (action && GTK_IS_ACTION(action));
772         g_return_if_fail (window && GL_IS_WINDOW(window));
773
774         if (window->view != NULL) {
775                 gl_view_rotate_selection_left (GL_VIEW(window->view));
776         }
777
778         gl_debug (DEBUG_COMMANDS, "END");
779 }
780
781 /*****************************************************************************/
782 /** Objects/Rotate-right-90-degrees command.                                 */
783 /*****************************************************************************/
784 void
785 gl_ui_cmd_objects_rotate_right (GtkAction *action,
786                                 glWindow  *window)
787
788 {
789         gl_debug (DEBUG_COMMANDS, "START");
790         
791         g_return_if_fail (action && GTK_IS_ACTION(action));
792         g_return_if_fail (window && GL_IS_WINDOW(window));
793
794         if (window->view != NULL) {
795                 gl_view_rotate_selection_right (GL_VIEW(window->view));
796         }
797
798         gl_debug (DEBUG_COMMANDS, "END");
799 }
800
801 /*****************************************************************************/
802 /** Objects/Flip-horizontally command.                                       */
803 /*****************************************************************************/
804 void
805 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
806                               glWindow  *window)
807
808 {
809         gl_debug (DEBUG_COMMANDS, "START");
810         
811         g_return_if_fail (action && GTK_IS_ACTION(action));
812         g_return_if_fail (window && GL_IS_WINDOW(window));
813
814         if (window->view != NULL) {
815                 gl_view_flip_selection_horiz (GL_VIEW(window->view));
816         }
817
818         gl_debug (DEBUG_COMMANDS, "END");
819 }
820
821 /*****************************************************************************/
822 /** Objects/Flip-vertically command.                                         */
823 /*****************************************************************************/
824 void
825 gl_ui_cmd_objects_flip_vert (GtkAction *action,
826                              glWindow  *window)
827
828 {
829         gl_debug (DEBUG_COMMANDS, "START");
830         
831         g_return_if_fail (action && GTK_IS_ACTION(action));
832         g_return_if_fail (window && GL_IS_WINDOW(window));
833
834         if (window->view != NULL) {
835                 gl_view_flip_selection_vert (GL_VIEW(window->view));
836         }
837
838         gl_debug (DEBUG_COMMANDS, "END");
839 }
840
841 /*****************************************************************************/
842 /** Objects/Align-left command.                                              */
843 /*****************************************************************************/
844 void
845 gl_ui_cmd_objects_align_left (GtkAction *action,
846                               glWindow  *window)
847
848 {
849         gl_debug (DEBUG_COMMANDS, "START");
850         
851         g_return_if_fail (action && GTK_IS_ACTION(action));
852         g_return_if_fail (window && GL_IS_WINDOW(window));
853
854         if (window->view != NULL) {
855                 gl_view_align_selection_left (GL_VIEW(window->view));
856         }
857
858         gl_debug (DEBUG_COMMANDS, "END");
859 }
860
861 /*****************************************************************************/
862 /** Objects/Align-right command.                                             */
863 /*****************************************************************************/
864 void
865 gl_ui_cmd_objects_align_right (GtkAction *action,
866                                glWindow  *window)
867
868 {
869         gl_debug (DEBUG_COMMANDS, "START");
870         
871         g_return_if_fail (action && GTK_IS_ACTION(action));
872         g_return_if_fail (window && GL_IS_WINDOW(window));
873
874         if (window->view != NULL) {
875                 gl_view_align_selection_right (GL_VIEW(window->view));
876         }
877
878         gl_debug (DEBUG_COMMANDS, "END");
879 }
880
881 /*****************************************************************************/
882 /** Objects/Align-horizontal-center command.                                 */
883 /*****************************************************************************/
884 void
885 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
886                                  glWindow  *window)
887
888 {
889         gl_debug (DEBUG_COMMANDS, "START");
890         
891         g_return_if_fail (action && GTK_IS_ACTION(action));
892         g_return_if_fail (window && GL_IS_WINDOW(window));
893
894         if (window->view != NULL) {
895                 gl_view_align_selection_hcenter (GL_VIEW(window->view));
896         }
897
898         gl_debug (DEBUG_COMMANDS, "END");
899 }
900
901 /*****************************************************************************/
902 /** Objects/Align-top command.                                               */
903 /*****************************************************************************/
904 void
905 gl_ui_cmd_objects_align_top (GtkAction *action,
906                              glWindow  *window)
907
908 {
909         gl_debug (DEBUG_COMMANDS, "START");
910         
911         g_return_if_fail (action && GTK_IS_ACTION(action));
912         g_return_if_fail (window && GL_IS_WINDOW(window));
913
914         if (window->view != NULL) {
915                 gl_view_align_selection_top (GL_VIEW(window->view));
916         }
917
918         gl_debug (DEBUG_COMMANDS, "END");
919 }
920
921 /*****************************************************************************/
922 /** Objects/Align-bottom command.                                            */
923 /*****************************************************************************/
924 void
925 gl_ui_cmd_objects_align_bottom (GtkAction *action,
926                                 glWindow  *window)
927
928 {
929         gl_debug (DEBUG_COMMANDS, "START");
930         
931         g_return_if_fail (action && GTK_IS_ACTION(action));
932         g_return_if_fail (window && GL_IS_WINDOW(window));
933
934         if (window->view != NULL) {
935                 gl_view_align_selection_bottom (GL_VIEW(window->view));
936         }
937
938         gl_debug (DEBUG_COMMANDS, "END");
939 }
940
941 /*****************************************************************************/
942 /** Objects/Align-vertical center command.                                   */
943 /*****************************************************************************/
944 void
945 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
946                                  glWindow  *window)
947
948 {
949         gl_debug (DEBUG_COMMANDS, "START");
950         
951         g_return_if_fail (action && GTK_IS_ACTION(action));
952         g_return_if_fail (window && GL_IS_WINDOW(window));
953
954         if (window->view != NULL) {
955                 gl_view_align_selection_vcenter (GL_VIEW(window->view));
956         }
957
958         gl_debug (DEBUG_COMMANDS, "END");
959 }
960
961 /*****************************************************************************/
962 /** Objects/Center-horizontally command.                                     */
963 /*****************************************************************************/
964 void
965 gl_ui_cmd_objects_center_horiz (GtkAction *action,
966                                 glWindow  *window)
967
968 {
969         gl_debug (DEBUG_COMMANDS, "START");
970         
971         g_return_if_fail (action && GTK_IS_ACTION(action));
972         g_return_if_fail (window && GL_IS_WINDOW(window));
973
974         if (window->view != NULL) {
975                 gl_view_center_selection_horiz (GL_VIEW(window->view));
976         }
977
978         gl_debug (DEBUG_COMMANDS, "END");
979 }
980
981 /*****************************************************************************/
982 /** Objects/Center-vertically command.                                       */
983 /*****************************************************************************/
984 void
985 gl_ui_cmd_objects_center_vert (GtkAction *action,
986                                glWindow  *window)
987
988 {
989         gl_debug (DEBUG_COMMANDS, "START");
990         
991         g_return_if_fail (action && GTK_IS_ACTION(action));
992         g_return_if_fail (window && GL_IS_WINDOW(window));
993
994         if (window->view != NULL) {
995                 gl_view_center_selection_vert (GL_VIEW(window->view));
996         }
997
998         gl_debug (DEBUG_COMMANDS, "END");
999 }
1000
1001 /*****************************************************************************/
1002 /** Objects/Edit- merge-properties command.                                  */
1003 /*****************************************************************************/
1004 void
1005 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1006                                     glWindow  *window)
1007
1008 {
1009         gl_debug (DEBUG_COMMANDS, "START");
1010         
1011         g_return_if_fail (action && GTK_IS_ACTION(action));
1012         g_return_if_fail (window && GL_IS_WINDOW(window));
1013
1014         if (window->merge_dialog) {
1015
1016                 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1017                 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1018                                               GTK_WINDOW (window));
1019
1020         } else {
1021
1022                 window->merge_dialog =
1023                         g_object_ref (
1024                                 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1025                                                                 GTK_WINDOW(window)) );
1026
1027                 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1028                                   G_CALLBACK (gtk_widget_destroyed),
1029                                   &window->merge_dialog);
1030
1031                 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1032
1033         }
1034
1035         gl_debug (DEBUG_COMMANDS, "END");
1036 }
1037
1038 /****************************************************************************/
1039 /** Help/Contents command.                                                  */
1040 /****************************************************************************/
1041 void 
1042 gl_ui_cmd_help_contents (GtkAction *action,
1043                          glWindow  *window)
1044 {
1045         GError *error = NULL;
1046
1047         gl_debug (DEBUG_COMMANDS, "START");
1048
1049         g_return_if_fail (action && GTK_IS_ACTION(action));
1050         g_return_if_fail (window && GL_IS_WINDOW(window));
1051
1052         gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error);
1053         
1054         if (error != NULL)
1055         {
1056                 g_message (error->message);
1057
1058                 g_error_free (error);
1059         }
1060
1061         gl_debug (DEBUG_COMMANDS, "END");
1062 }
1063
1064 /*--------------------------------------------------------------------------*/
1065 /** Private: URL handler.                                                   */
1066 /*--------------------------------------------------------------------------*/
1067 static void
1068 activate_url (GtkAboutDialog *about,
1069               const gchar    *url,
1070               gpointer        data)
1071 {
1072         gl_debug (DEBUG_COMMANDS, "START");
1073
1074         gnome_url_show (url, NULL);
1075
1076         gl_debug (DEBUG_COMMANDS, "END");
1077 }
1078
1079
1080 /****************************************************************************/
1081 /** Help/About command.                                                     */
1082 /****************************************************************************/
1083 void 
1084 gl_ui_cmd_help_about (GtkAction *action,
1085                       glWindow  *window)
1086 {
1087         static GtkWidget *about = NULL;
1088
1089         GdkPixbuf        *pixbuf = NULL;
1090         
1091         const gchar *authors[] = {
1092                 "Jim Evins",
1093                 " ",
1094                 _("Glabels includes contributions from:"),
1095                 "Frederic Ruaudel",
1096                 "Wayne Schuller",
1097                 "Emmanuel Pacaud",
1098                 "Austin Henry",
1099                 " ",
1100                 _("See the file AUTHORS for additional credits,"),
1101                 _("or visit http://glabels.sourceforge.net/"),
1102                 NULL
1103         };
1104         
1105         const gchar *artists[] = {
1106                 "Nestor Di",
1107                 "Jim Evins",
1108                 NULL
1109         };
1110         
1111         const gchar *copy_text = "Copyright \xc2\xa9 2001-2005 Jim Evins";
1112
1113         const gchar *about_text = _("A label and business card creation program.\n");
1114
1115         const gchar *url = "http://glabels.sourceforge.net";
1116
1117         const gchar *translator_credits = _("translator-credits");
1118
1119         const gchar *license = _(
1120               "Glabels is free software; you can redistribute it and/or modify it\n"
1121               "under the terms of the GNU General Public License as published by\n"
1122               "the Free Software Foundation; either version 2 of the License, or\n"
1123               "(at your option) any later version.\n" "\n"
1124               "This program is distributed in the hope that it will be useful, but\n"
1125               "WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1126               "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See\n"
1127               "the GNU General Public License for more details.\n");
1128
1129         gl_debug (DEBUG_COMMANDS, "START");
1130
1131         g_return_if_fail (action && GTK_IS_ACTION(action));
1132         g_return_if_fail (window && GL_IS_WINDOW(window));
1133
1134         if (about != NULL)
1135         {
1136
1137                 gtk_window_present (GTK_WINDOW (about));
1138                 gtk_window_set_transient_for (GTK_WINDOW (about),
1139                                               GTK_WINDOW (window));
1140
1141         } else {
1142         
1143                 pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL);
1144
1145                 gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
1146
1147                 about = gtk_about_dialog_new ();
1148                 gtk_about_dialog_set_name      (GTK_ABOUT_DIALOG(about), _("glabels"));
1149                 gtk_about_dialog_set_version   (GTK_ABOUT_DIALOG(about), VERSION);
1150                 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text);
1151                 gtk_about_dialog_set_comments  (GTK_ABOUT_DIALOG(about), about_text);
1152                 gtk_about_dialog_set_website   (GTK_ABOUT_DIALOG(about), url);
1153                 gtk_about_dialog_set_logo      (GTK_ABOUT_DIALOG(about), pixbuf);
1154
1155                 gtk_about_dialog_set_authors   (GTK_ABOUT_DIALOG(about), authors);
1156                 gtk_about_dialog_set_artists   (GTK_ABOUT_DIALOG(about), artists);
1157                 gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about),
1158                                                          translator_credits);
1159                 gtk_about_dialog_set_license   (GTK_ABOUT_DIALOG(about), license);
1160         
1161                 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
1162
1163                 g_signal_connect (G_OBJECT (about), "response",
1164                                   G_CALLBACK (gtk_widget_destroy), NULL);
1165                 g_signal_connect (G_OBJECT (about), "destroy",
1166                                   G_CALLBACK (gtk_widget_destroyed), &about);
1167
1168                 gtk_window_set_transient_for (GTK_WINDOW (about),
1169                                               GTK_WINDOW (window));
1170
1171                 gtk_window_present (GTK_WINDOW (about));
1172
1173                 if (pixbuf != NULL)
1174                         g_object_unref (pixbuf);
1175
1176         }
1177         
1178         gl_debug (DEBUG_COMMANDS, "END");
1179 }
1180