1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 * (GLABELS) Label and Business Card Creation program for GNOME
6 * ui-commands.c: GLabels UI commands module
8 * Copyright (C) 2001-2003 Jim Evins <evins@snaught.com>.
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.
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.
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
27 #include "ui-commands.h"
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"
39 #include "template-designer.h"
40 #include "print-dialog.h"
42 #include "prefs-dialog.h"
46 #define LOGO_PIXMAP gnome_program_locate_file (NULL,\
47 GNOME_FILE_DOMAIN_APP_PIXMAP,\
48 "glabels/glabels-about-logo.png",\
52 /****************************************************************************/
53 /** File/New command. */
54 /****************************************************************************/
56 gl_ui_cmd_file_new (GtkAction *action,
59 gl_debug (DEBUG_COMMANDS, "START");
61 g_return_if_fail (action && GTK_IS_ACTION(action));
62 g_return_if_fail (window && GL_IS_WINDOW(window));
66 gl_debug (DEBUG_COMMANDS, "END");
69 /****************************************************************************/
70 /** File/Properties command. */
71 /****************************************************************************/
73 gl_ui_cmd_file_properties (GtkAction *action,
76 gl_debug (DEBUG_COMMANDS, "START");
78 g_return_if_fail (action && GTK_IS_ACTION(action));
79 g_return_if_fail (window && GL_IS_WINDOW(window));
81 gl_file_properties (GL_VIEW(window->view)->label, window);
83 gl_debug (DEBUG_COMMANDS, "END");
86 /****************************************************************************/
87 /** File/Template-Designer command. */
88 /****************************************************************************/
90 gl_ui_cmd_file_template_designer (GtkAction *action,
95 gl_debug (DEBUG_COMMANDS, "START");
97 g_return_if_fail (action && GTK_IS_ACTION(action));
98 g_return_if_fail (window && GL_IS_WINDOW(window));
100 dialog = gl_template_designer_new (GTK_WINDOW(window));
102 gtk_widget_show (dialog);
104 gl_debug (DEBUG_COMMANDS, "END");
107 /****************************************************************************/
108 /** File/Open command. */
109 /****************************************************************************/
111 gl_ui_cmd_file_open (GtkAction *action,
114 gl_debug (DEBUG_COMMANDS, "START");
116 g_return_if_fail (action && GTK_IS_ACTION(action));
117 g_return_if_fail (window && GL_IS_WINDOW(window));
119 gl_file_open (window);
121 gl_debug (DEBUG_COMMANDS, "END");
124 /****************************************************************************/
125 /** File/Open-Recent command. */
126 /****************************************************************************/
128 gl_ui_cmd_file_open_recent (GtkAction *action,
131 EggRecentViewUIManager *recent_view;
133 gchar *utf8_filename;
135 gl_debug (DEBUG_COMMANDS, "START");
137 g_return_if_fail (action && GTK_IS_ACTION(action));
138 g_return_if_fail (window && GL_IS_WINDOW(window));
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));
143 item = egg_recent_view_uimanager_get_item (recent_view, action);
144 utf8_filename = gl_recent_get_filename (item);
146 gl_file_open_recent (utf8_filename, window);
148 gl_debug (DEBUG_COMMANDS, "END");
151 /****************************************************************************/
152 /** File/Save command. */
153 /****************************************************************************/
155 gl_ui_cmd_file_save (GtkAction *action,
158 gl_debug (DEBUG_COMMANDS, "START");
160 g_return_if_fail (action && GTK_IS_ACTION(action));
161 g_return_if_fail (window && GL_IS_WINDOW(window));
163 gl_file_save (GL_VIEW(window->view)->label, window);
165 gl_debug (DEBUG_COMMANDS, "END");
168 /****************************************************************************/
169 /** File/Save-as command. */
170 /****************************************************************************/
172 gl_ui_cmd_file_save_as (GtkAction *action,
175 gl_debug (DEBUG_COMMANDS, "START");
177 g_return_if_fail (action && GTK_IS_ACTION(action));
178 g_return_if_fail (window && GL_IS_WINDOW(window));
180 gl_file_save_as (GL_VIEW(window->view)->label, window);
182 gl_debug (DEBUG_COMMANDS, "END");
185 /****************************************************************************/
186 /** File/Print command. */
187 /****************************************************************************/
189 gl_ui_cmd_file_print (GtkAction *action,
192 gl_debug (DEBUG_COMMANDS, "START");
194 g_return_if_fail (action && GTK_IS_ACTION(action));
195 g_return_if_fail (window && GL_IS_WINDOW(window));
197 if (window->print_dialog) {
199 gtk_window_present (GTK_WINDOW(window->print_dialog));
200 gtk_window_set_transient_for (GTK_WINDOW (window->print_dialog),
201 GTK_WINDOW (window));
205 window->print_dialog =
207 gl_print_dialog_new (GL_VIEW(window->view)->label,
208 GTK_WINDOW(window)) );
210 g_signal_connect (G_OBJECT(window->print_dialog), "destroy",
211 G_CALLBACK (gtk_widget_destroyed),
212 &window->print_dialog);
214 gtk_widget_show (GTK_WIDGET (window->print_dialog));
217 gl_debug (DEBUG_COMMANDS, "END");
220 /****************************************************************************/
221 /** File/Close command. */
222 /****************************************************************************/
224 gl_ui_cmd_file_close (GtkAction *action,
227 gl_debug (DEBUG_COMMANDS, "START");
229 g_return_if_fail (action && GTK_IS_ACTION(action));
230 g_return_if_fail (window && GL_IS_WINDOW(window));
232 gl_file_close (window);
234 gl_debug (DEBUG_COMMANDS, "END");
237 /****************************************************************************/
238 /** File/Quit command. */
239 /****************************************************************************/
241 gl_ui_cmd_file_quit (GtkAction *action,
244 gl_debug (DEBUG_COMMANDS, "START");
246 g_return_if_fail (action && GTK_IS_ACTION(action));
247 g_return_if_fail (window && GL_IS_WINDOW(window));
251 gl_debug (DEBUG_COMMANDS, "END");
255 /****************************************************************************/
256 /** Edit/Cut command. */
257 /****************************************************************************/
259 gl_ui_cmd_edit_cut (GtkAction *action,
262 gl_debug (DEBUG_COMMANDS, "START");
264 g_return_if_fail (action && GTK_IS_ACTION(action));
265 g_return_if_fail (window && GL_IS_WINDOW(window));
267 gl_view_cut (GL_VIEW(window->view));
269 gl_debug (DEBUG_COMMANDS, "END");
272 /****************************************************************************/
273 /** Edit/Copy command. */
274 /****************************************************************************/
276 gl_ui_cmd_edit_copy (GtkAction *action,
279 gl_debug (DEBUG_COMMANDS, "START");
281 g_return_if_fail (action && GTK_IS_ACTION(action));
282 g_return_if_fail (window && GL_IS_WINDOW(window));
284 gl_view_copy (GL_VIEW(window->view));
286 gl_debug (DEBUG_COMMANDS, "END");
289 /****************************************************************************/
290 /** Edit/Paste command. */
291 /****************************************************************************/
293 gl_ui_cmd_edit_paste (GtkAction *action,
296 gl_debug (DEBUG_COMMANDS, "START");
298 g_return_if_fail (action && GTK_IS_ACTION(action));
299 g_return_if_fail (window && GL_IS_WINDOW(window));
301 gl_view_paste (GL_VIEW(window->view));
303 gl_debug (DEBUG_COMMANDS, "END");
307 /****************************************************************************/
308 /** Edit/Delete command. */
309 /****************************************************************************/
311 gl_ui_cmd_edit_delete (GtkAction *action,
314 gl_debug (DEBUG_COMMANDS, "START");
316 g_return_if_fail (action && GTK_IS_ACTION(action));
317 g_return_if_fail (window && GL_IS_WINDOW(window));
319 gl_view_delete_selection (GL_VIEW(window->view));
321 gl_debug (DEBUG_COMMANDS, "END");
325 /****************************************************************************/
326 /** Edit/Select-all command. */
327 /****************************************************************************/
329 gl_ui_cmd_edit_select_all (GtkAction *action,
332 gl_debug (DEBUG_COMMANDS, "START");
334 g_return_if_fail (action && GTK_IS_ACTION(action));
335 g_return_if_fail (window && GL_IS_WINDOW(window));
337 gl_view_select_all (GL_VIEW(window->view));
339 gl_debug (DEBUG_COMMANDS, "END");
342 /****************************************************************************/
343 /** Edit/Unselect-all command. */
344 /****************************************************************************/
346 gl_ui_cmd_edit_unselect_all (GtkAction *action,
349 gl_debug (DEBUG_COMMANDS, "START");
351 g_return_if_fail (action && GTK_IS_ACTION(action));
352 g_return_if_fail (window && GL_IS_WINDOW(window));
354 gl_view_unselect_all (GL_VIEW(window->view));
356 gl_debug (DEBUG_COMMANDS, "END");
359 /****************************************************************************/
360 /** Edit/Preferences command. */
361 /****************************************************************************/
363 gl_ui_cmd_edit_preferences (GtkAction *action,
366 static GtkWidget *dlg = NULL;
368 gl_debug (DEBUG_COMMANDS, "START");
370 g_return_if_fail (action && GTK_IS_ACTION(action));
371 g_return_if_fail (window && GL_IS_WINDOW(window));
375 gtk_window_present (GTK_WINDOW (dlg));
376 gtk_window_set_transient_for (GTK_WINDOW (dlg),
381 dlg = gl_prefs_dialog_new (GTK_WINDOW(window));
383 g_signal_connect (G_OBJECT (dlg), "destroy",
384 G_CALLBACK (gtk_widget_destroyed), &dlg);
386 gtk_widget_show (dlg);
390 gl_debug (DEBUG_COMMANDS, "END");
393 /*****************************************************************************/
394 /** View/Property-bar-toggle command. */
395 /*****************************************************************************/
397 gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action,
402 gl_debug (DEBUG_COMMANDS, "START");
404 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
405 g_return_if_fail (window && GL_IS_WINDOW(window));
407 state = gtk_toggle_action_get_active (action);
409 gl_prefs->property_toolbar_visible = state;
411 gtk_widget_show (GTK_WIDGET (window->property_bar));
413 gtk_widget_hide (GTK_WIDGET (window->property_bar));
415 gl_prefs_model_save_settings (gl_prefs);
417 gl_debug (DEBUG_COMMANDS, "END");
420 /*****************************************************************************/
421 /** View/Property-bar-tooltips-toggle command. */
422 /*****************************************************************************/
424 gl_ui_cmd_view_property_bar_tips_toggle (GtkToggleAction *action,
429 gl_debug (DEBUG_COMMANDS, "START");
431 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
432 g_return_if_fail (window && GL_IS_WINDOW(window));
434 state = gtk_toggle_action_get_active (action);
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);
440 gl_debug (DEBUG_COMMANDS, "END");
443 /*****************************************************************************/
444 /** View/Grid-toggle command. */
445 /*****************************************************************************/
447 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
452 gl_debug (DEBUG_COMMANDS, "START");
454 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
455 g_return_if_fail (window && GL_IS_WINDOW(window));
457 state = gtk_toggle_action_get_active (action);
459 gl_prefs->grid_visible = state;
461 gl_view_show_grid (GL_VIEW(window->view));
463 gl_view_hide_grid (GL_VIEW(window->view));
465 gl_prefs_model_save_settings (gl_prefs);
467 gl_debug (DEBUG_COMMANDS, "END");
470 /*****************************************************************************/
471 /** View/Markup-toggle command. */
472 /*****************************************************************************/
474 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
479 gl_debug (DEBUG_COMMANDS, "START");
481 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
482 g_return_if_fail (window && GL_IS_WINDOW(window));
484 state = gtk_toggle_action_get_active (action);
486 gl_prefs->markup_visible = state;
488 gl_view_show_markup (GL_VIEW(window->view));
490 gl_view_hide_markup (GL_VIEW(window->view));
492 gl_prefs_model_save_settings (gl_prefs);
494 gl_debug (DEBUG_COMMANDS, "END");
497 /*****************************************************************************/
498 /** View/Zoom-in command. */
499 /*****************************************************************************/
501 gl_ui_cmd_view_zoomin (GtkAction *action,
505 gl_debug (DEBUG_COMMANDS, "START");
507 g_return_if_fail (action && GTK_IS_ACTION(action));
508 g_return_if_fail (window && GL_IS_WINDOW(window));
510 if (window->view != NULL) {
511 gl_view_zoom_in (GL_VIEW(window->view));
514 gl_debug (DEBUG_COMMANDS, "END");
517 /*****************************************************************************/
518 /** View/Zoom-out command. */
519 /*****************************************************************************/
521 gl_ui_cmd_view_zoomout (GtkAction *action,
525 gl_debug (DEBUG_COMMANDS, "START");
527 g_return_if_fail (action && GTK_IS_ACTION(action));
528 g_return_if_fail (window && GL_IS_WINDOW(window));
530 if (window->view != NULL) {
531 gl_view_zoom_out (GL_VIEW(window->view));
534 gl_debug (DEBUG_COMMANDS, "END");
537 /*****************************************************************************/
538 /** View/Zoom-1:1 command. */
539 /*****************************************************************************/
541 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
545 gl_debug (DEBUG_COMMANDS, "START");
547 g_return_if_fail (action && GTK_IS_ACTION(action));
548 g_return_if_fail (window && GL_IS_WINDOW(window));
550 if (window->view != NULL) {
551 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
554 gl_debug (DEBUG_COMMANDS, "END");
557 /*****************************************************************************/
558 /** View/Zoom-to-fit command. */
559 /*****************************************************************************/
561 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
565 gl_debug (DEBUG_COMMANDS, "START");
567 g_return_if_fail (action && GTK_IS_ACTION(action));
568 g_return_if_fail (window && GL_IS_WINDOW(window));
570 if (window->view != NULL) {
571 gl_view_zoom_to_fit (GL_VIEW(window->view));
574 gl_debug (DEBUG_COMMANDS, "END");
577 /*****************************************************************************/
578 /** Objects/Arrow-mode command. */
579 /*****************************************************************************/
581 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
584 gl_debug (DEBUG_COMMANDS, "START");
586 g_return_if_fail (action && GTK_IS_ACTION(action));
587 g_return_if_fail (window && GL_IS_WINDOW(window));
589 if (window->view != NULL) {
590 gl_view_arrow_mode (GL_VIEW(window->view));
593 gl_debug (DEBUG_COMMANDS, "END");
596 /*****************************************************************************/
597 /** Objects/Create-text object command. */
598 /*****************************************************************************/
600 gl_ui_cmd_objects_create_text (GtkAction *action,
604 gl_debug (DEBUG_COMMANDS, "START");
606 g_return_if_fail (action && GTK_IS_ACTION(action));
607 g_return_if_fail (window && GL_IS_WINDOW(window));
609 if (window->view != NULL) {
610 gl_view_object_create_mode (GL_VIEW(window->view),
611 GL_LABEL_OBJECT_TEXT);
614 gl_debug (DEBUG_COMMANDS, "END");
617 /*****************************************************************************/
618 /** Objects/Create-box object command. */
619 /*****************************************************************************/
621 gl_ui_cmd_objects_create_box (GtkAction *action,
625 gl_debug (DEBUG_COMMANDS, "START");
627 g_return_if_fail (action && GTK_IS_ACTION(action));
628 g_return_if_fail (window && GL_IS_WINDOW(window));
630 if (window->view != NULL) {
631 gl_view_object_create_mode (GL_VIEW(window->view),
632 GL_LABEL_OBJECT_BOX);
635 gl_debug (DEBUG_COMMANDS, "END");
638 /*****************************************************************************/
639 /** Objects/Create-line object command. */
640 /*****************************************************************************/
642 gl_ui_cmd_objects_create_line (GtkAction *action,
646 gl_debug (DEBUG_COMMANDS, "START");
648 g_return_if_fail (action && GTK_IS_ACTION(action));
649 g_return_if_fail (window && GL_IS_WINDOW(window));
651 if (window->view != NULL) {
652 gl_view_object_create_mode (GL_VIEW(window->view),
653 GL_LABEL_OBJECT_LINE);
656 gl_debug (DEBUG_COMMANDS, "END");
659 /*****************************************************************************/
660 /** Objects/Create-ellipse object command. */
661 /*****************************************************************************/
663 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
667 gl_debug (DEBUG_COMMANDS, "START");
669 g_return_if_fail (action && GTK_IS_ACTION(action));
670 g_return_if_fail (window && GL_IS_WINDOW(window));
672 if (window->view != NULL) {
673 gl_view_object_create_mode (GL_VIEW(window->view),
674 GL_LABEL_OBJECT_ELLIPSE);
677 gl_debug (DEBUG_COMMANDS, "END");
680 /*****************************************************************************/
681 /** Objects/Create-image object command. */
682 /*****************************************************************************/
684 gl_ui_cmd_objects_create_image (GtkAction *action,
688 gl_debug (DEBUG_COMMANDS, "START");
690 g_return_if_fail (action && GTK_IS_ACTION(action));
691 g_return_if_fail (window && GL_IS_WINDOW(window));
693 if (window->view != NULL) {
694 gl_view_object_create_mode (GL_VIEW(window->view),
695 GL_LABEL_OBJECT_IMAGE);
698 gl_debug (DEBUG_COMMANDS, "END");
701 /*****************************************************************************/
702 /** Objects/Create-barcode object command. */
703 /*****************************************************************************/
705 gl_ui_cmd_objects_create_barcode (GtkAction *action,
709 gl_debug (DEBUG_COMMANDS, "START");
711 g_return_if_fail (action && GTK_IS_ACTION(action));
712 g_return_if_fail (window && GL_IS_WINDOW(window));
714 if (window->view != NULL) {
715 gl_view_object_create_mode (GL_VIEW(window->view),
716 GL_LABEL_OBJECT_BARCODE);
719 gl_debug (DEBUG_COMMANDS, "END");
722 /*****************************************************************************/
723 /** Objects/Raise command. */
724 /*****************************************************************************/
726 gl_ui_cmd_objects_raise (GtkAction *action,
730 gl_debug (DEBUG_COMMANDS, "START");
732 g_return_if_fail (action && GTK_IS_ACTION(action));
733 g_return_if_fail (window && GL_IS_WINDOW(window));
735 if (window->view != NULL) {
736 gl_view_raise_selection (GL_VIEW(window->view));
739 gl_debug (DEBUG_COMMANDS, "END");
742 /*****************************************************************************/
743 /** Objects/Lower command. */
744 /*****************************************************************************/
746 gl_ui_cmd_objects_lower (GtkAction *action,
750 gl_debug (DEBUG_COMMANDS, "START");
752 g_return_if_fail (action && GTK_IS_ACTION(action));
753 g_return_if_fail (window && GL_IS_WINDOW(window));
755 if (window->view != NULL) {
756 gl_view_lower_selection (GL_VIEW(window->view));
759 gl_debug (DEBUG_COMMANDS, "END");
762 /*****************************************************************************/
763 /** Objects/Rotate-left-90-degrees command. */
764 /*****************************************************************************/
766 gl_ui_cmd_objects_rotate_left (GtkAction *action,
770 gl_debug (DEBUG_COMMANDS, "START");
772 g_return_if_fail (action && GTK_IS_ACTION(action));
773 g_return_if_fail (window && GL_IS_WINDOW(window));
775 if (window->view != NULL) {
776 gl_view_rotate_selection_left (GL_VIEW(window->view));
779 gl_debug (DEBUG_COMMANDS, "END");
782 /*****************************************************************************/
783 /** Objects/Rotate-right-90-degrees command. */
784 /*****************************************************************************/
786 gl_ui_cmd_objects_rotate_right (GtkAction *action,
790 gl_debug (DEBUG_COMMANDS, "START");
792 g_return_if_fail (action && GTK_IS_ACTION(action));
793 g_return_if_fail (window && GL_IS_WINDOW(window));
795 if (window->view != NULL) {
796 gl_view_rotate_selection_right (GL_VIEW(window->view));
799 gl_debug (DEBUG_COMMANDS, "END");
802 /*****************************************************************************/
803 /** Objects/Flip-horizontally command. */
804 /*****************************************************************************/
806 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
810 gl_debug (DEBUG_COMMANDS, "START");
812 g_return_if_fail (action && GTK_IS_ACTION(action));
813 g_return_if_fail (window && GL_IS_WINDOW(window));
815 if (window->view != NULL) {
816 gl_view_flip_selection_horiz (GL_VIEW(window->view));
819 gl_debug (DEBUG_COMMANDS, "END");
822 /*****************************************************************************/
823 /** Objects/Flip-vertically command. */
824 /*****************************************************************************/
826 gl_ui_cmd_objects_flip_vert (GtkAction *action,
830 gl_debug (DEBUG_COMMANDS, "START");
832 g_return_if_fail (action && GTK_IS_ACTION(action));
833 g_return_if_fail (window && GL_IS_WINDOW(window));
835 if (window->view != NULL) {
836 gl_view_flip_selection_vert (GL_VIEW(window->view));
839 gl_debug (DEBUG_COMMANDS, "END");
842 /*****************************************************************************/
843 /** Objects/Align-left command. */
844 /*****************************************************************************/
846 gl_ui_cmd_objects_align_left (GtkAction *action,
850 gl_debug (DEBUG_COMMANDS, "START");
852 g_return_if_fail (action && GTK_IS_ACTION(action));
853 g_return_if_fail (window && GL_IS_WINDOW(window));
855 if (window->view != NULL) {
856 gl_view_align_selection_left (GL_VIEW(window->view));
859 gl_debug (DEBUG_COMMANDS, "END");
862 /*****************************************************************************/
863 /** Objects/Align-right command. */
864 /*****************************************************************************/
866 gl_ui_cmd_objects_align_right (GtkAction *action,
870 gl_debug (DEBUG_COMMANDS, "START");
872 g_return_if_fail (action && GTK_IS_ACTION(action));
873 g_return_if_fail (window && GL_IS_WINDOW(window));
875 if (window->view != NULL) {
876 gl_view_align_selection_right (GL_VIEW(window->view));
879 gl_debug (DEBUG_COMMANDS, "END");
882 /*****************************************************************************/
883 /** Objects/Align-horizontal-center command. */
884 /*****************************************************************************/
886 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
890 gl_debug (DEBUG_COMMANDS, "START");
892 g_return_if_fail (action && GTK_IS_ACTION(action));
893 g_return_if_fail (window && GL_IS_WINDOW(window));
895 if (window->view != NULL) {
896 gl_view_align_selection_hcenter (GL_VIEW(window->view));
899 gl_debug (DEBUG_COMMANDS, "END");
902 /*****************************************************************************/
903 /** Objects/Align-top command. */
904 /*****************************************************************************/
906 gl_ui_cmd_objects_align_top (GtkAction *action,
910 gl_debug (DEBUG_COMMANDS, "START");
912 g_return_if_fail (action && GTK_IS_ACTION(action));
913 g_return_if_fail (window && GL_IS_WINDOW(window));
915 if (window->view != NULL) {
916 gl_view_align_selection_top (GL_VIEW(window->view));
919 gl_debug (DEBUG_COMMANDS, "END");
922 /*****************************************************************************/
923 /** Objects/Align-bottom command. */
924 /*****************************************************************************/
926 gl_ui_cmd_objects_align_bottom (GtkAction *action,
930 gl_debug (DEBUG_COMMANDS, "START");
932 g_return_if_fail (action && GTK_IS_ACTION(action));
933 g_return_if_fail (window && GL_IS_WINDOW(window));
935 if (window->view != NULL) {
936 gl_view_align_selection_bottom (GL_VIEW(window->view));
939 gl_debug (DEBUG_COMMANDS, "END");
942 /*****************************************************************************/
943 /** Objects/Align-vertical center command. */
944 /*****************************************************************************/
946 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
950 gl_debug (DEBUG_COMMANDS, "START");
952 g_return_if_fail (action && GTK_IS_ACTION(action));
953 g_return_if_fail (window && GL_IS_WINDOW(window));
955 if (window->view != NULL) {
956 gl_view_align_selection_vcenter (GL_VIEW(window->view));
959 gl_debug (DEBUG_COMMANDS, "END");
962 /*****************************************************************************/
963 /** Objects/Center-horizontally command. */
964 /*****************************************************************************/
966 gl_ui_cmd_objects_center_horiz (GtkAction *action,
970 gl_debug (DEBUG_COMMANDS, "START");
972 g_return_if_fail (action && GTK_IS_ACTION(action));
973 g_return_if_fail (window && GL_IS_WINDOW(window));
975 if (window->view != NULL) {
976 gl_view_center_selection_horiz (GL_VIEW(window->view));
979 gl_debug (DEBUG_COMMANDS, "END");
982 /*****************************************************************************/
983 /** Objects/Center-vertically command. */
984 /*****************************************************************************/
986 gl_ui_cmd_objects_center_vert (GtkAction *action,
990 gl_debug (DEBUG_COMMANDS, "START");
992 g_return_if_fail (action && GTK_IS_ACTION(action));
993 g_return_if_fail (window && GL_IS_WINDOW(window));
995 if (window->view != NULL) {
996 gl_view_center_selection_vert (GL_VIEW(window->view));
999 gl_debug (DEBUG_COMMANDS, "END");
1002 /*****************************************************************************/
1003 /** Objects/Edit- merge-properties command. */
1004 /*****************************************************************************/
1006 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1010 gl_debug (DEBUG_COMMANDS, "START");
1012 g_return_if_fail (action && GTK_IS_ACTION(action));
1013 g_return_if_fail (window && GL_IS_WINDOW(window));
1015 if (window->merge_dialog) {
1017 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1018 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1019 GTK_WINDOW (window));
1023 window->merge_dialog =
1025 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1026 GTK_WINDOW(window)) );
1028 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1029 G_CALLBACK (gtk_widget_destroyed),
1030 &window->merge_dialog);
1032 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1036 gl_debug (DEBUG_COMMANDS, "END");
1039 /****************************************************************************/
1040 /** Help/Contents command. */
1041 /****************************************************************************/
1043 gl_ui_cmd_help_contents (GtkAction *action,
1046 GError *error = NULL;
1048 gl_debug (DEBUG_COMMANDS, "START");
1050 g_return_if_fail (action && GTK_IS_ACTION(action));
1051 g_return_if_fail (window && GL_IS_WINDOW(window));
1053 gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error);
1057 g_warning (error->message);
1059 g_error_free (error);
1062 gl_debug (DEBUG_COMMANDS, "END");
1065 /*--------------------------------------------------------------------------*/
1066 /** Private: URL handler. */
1067 /*--------------------------------------------------------------------------*/
1069 activate_url (GtkAboutDialog *about,
1073 gl_debug (DEBUG_COMMANDS, "START");
1075 gnome_url_show (url, NULL);
1077 gl_debug (DEBUG_COMMANDS, "END");
1081 /****************************************************************************/
1082 /** Help/About command. */
1083 /****************************************************************************/
1085 gl_ui_cmd_help_about (GtkAction *action,
1088 static GtkWidget *about = NULL;
1090 GdkPixbuf *pixbuf = NULL;
1092 const gchar *authors[] = {
1095 _("Glabels includes contributions from:"),
1101 _("See the file AUTHORS for additional credits,"),
1102 _("or visit http://glabels.sourceforge.net/"),
1106 const gchar *artists[] = {
1112 const gchar *copy_text = "Copyright \xc2\xa9 2001-2005 Jim Evins";
1114 const gchar *about_text = _("A label and business card creation program.\n");
1116 const gchar *url = "http://glabels.sourceforge.net";
1118 const gchar *translator_credits = _("translator-credits");
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");
1130 gl_debug (DEBUG_COMMANDS, "START");
1132 g_return_if_fail (action && GTK_IS_ACTION(action));
1133 g_return_if_fail (window && GL_IS_WINDOW(window));
1138 gtk_window_present (GTK_WINDOW (about));
1139 gtk_window_set_transient_for (GTK_WINDOW (about),
1140 GTK_WINDOW (window));
1144 pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL);
1146 gtk_about_dialog_set_url_hook (activate_url, NULL, NULL);
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);
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);
1162 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
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);
1169 gtk_window_set_transient_for (GTK_WINDOW (about),
1170 GTK_WINDOW (window));
1172 gtk_window_present (GTK_WINDOW (about));
1175 g_object_unref (pixbuf);
1179 gl_debug (DEBUG_COMMANDS, "END");