3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "ui-commands.h"
25 #include <glib/gi18n.h>
30 #include "template-designer.h"
31 #include "print-op-dialog.h"
33 #include "prefs-dialog.h"
38 /****************************************************************************/
39 /** File/New command. */
40 /****************************************************************************/
42 gl_ui_cmd_file_new (GtkAction *action,
45 gl_debug (DEBUG_COMMANDS, "START");
47 g_return_if_fail (action && GTK_IS_ACTION(action));
48 g_return_if_fail (window && GL_IS_WINDOW(window));
52 gl_debug (DEBUG_COMMANDS, "END");
56 /****************************************************************************/
57 /** File/Properties command. */
58 /****************************************************************************/
60 gl_ui_cmd_file_properties (GtkAction *action,
63 gl_debug (DEBUG_COMMANDS, "START");
65 g_return_if_fail (action && GTK_IS_ACTION(action));
66 g_return_if_fail (window && GL_IS_WINDOW(window));
68 gl_file_properties (GL_VIEW(window->view)->label, window);
70 gl_debug (DEBUG_COMMANDS, "END");
74 /****************************************************************************/
75 /** File/Template-Designer command. */
76 /****************************************************************************/
78 gl_ui_cmd_file_template_designer (GtkAction *action,
83 gl_debug (DEBUG_COMMANDS, "START");
85 g_return_if_fail (action && GTK_IS_ACTION(action));
86 g_return_if_fail (window && GL_IS_WINDOW(window));
88 dialog = gl_template_designer_new (GTK_WINDOW(window));
90 gtk_widget_show (dialog);
92 gl_debug (DEBUG_COMMANDS, "END");
96 /****************************************************************************/
97 /** File/Open command. */
98 /****************************************************************************/
100 gl_ui_cmd_file_open (GtkAction *action,
103 gl_debug (DEBUG_COMMANDS, "START");
105 g_return_if_fail (action && GTK_IS_ACTION(action));
106 g_return_if_fail (window && GL_IS_WINDOW(window));
108 gl_file_open (window);
110 gl_debug (DEBUG_COMMANDS, "END");
114 /****************************************************************************/
115 /** File/Open-Recent command. */
116 /****************************************************************************/
118 gl_ui_cmd_file_open_recent (GtkRecentChooser *chooser,
122 gchar *utf8_filename;
124 gl_debug (DEBUG_COMMANDS, "START");
126 g_return_if_fail (chooser && GTK_IS_RECENT_CHOOSER(chooser));
127 g_return_if_fail (window && GL_IS_WINDOW(window));
129 item = gtk_recent_chooser_get_current_item (chooser);
133 utf8_filename = gl_recent_get_utf8_filename (item);
135 gl_debug (DEBUG_COMMANDS, "Selected %s\n", utf8_filename);
136 gl_file_open_recent (utf8_filename, window);
138 gtk_recent_info_unref (item);
140 gl_debug (DEBUG_COMMANDS, "END");
144 /****************************************************************************/
145 /** File/Save command. */
146 /****************************************************************************/
148 gl_ui_cmd_file_save (GtkAction *action,
151 gl_debug (DEBUG_COMMANDS, "START");
153 g_return_if_fail (action && GTK_IS_ACTION(action));
154 g_return_if_fail (window && GL_IS_WINDOW(window));
156 gl_file_save (GL_VIEW(window->view)->label, window);
158 gl_debug (DEBUG_COMMANDS, "END");
162 /****************************************************************************/
163 /** File/Save-as command. */
164 /****************************************************************************/
166 gl_ui_cmd_file_save_as (GtkAction *action,
169 gl_debug (DEBUG_COMMANDS, "START");
171 g_return_if_fail (action && GTK_IS_ACTION(action));
172 g_return_if_fail (window && GL_IS_WINDOW(window));
174 gl_file_save_as (GL_VIEW(window->view)->label, window);
176 gl_debug (DEBUG_COMMANDS, "END");
180 /****************************************************************************/
181 /** File/Print command. */
182 /****************************************************************************/
184 gl_ui_cmd_file_print (GtkAction *action,
188 GtkPrintOperationResult result;
190 gl_debug (DEBUG_COMMANDS, "START");
192 g_return_if_fail (action && GTK_IS_ACTION(action));
193 g_return_if_fail (window && GL_IS_WINDOW(window));
195 op = gl_print_op_dialog_new (GL_VIEW(window->view)->label);
197 if (window->print_settings)
199 gl_print_op_set_settings (GL_PRINT_OP (op), window->print_settings);
202 result = gtk_print_operation_run (GTK_PRINT_OPERATION (op),
203 GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
207 if ( result == GTK_PRINT_OPERATION_RESULT_APPLY )
209 gl_print_op_free_settings (window->print_settings);
210 window->print_settings = gl_print_op_get_settings (GL_PRINT_OP (op));
213 gl_debug (DEBUG_COMMANDS, "END");
217 /****************************************************************************/
218 /** File/Close command. */
219 /****************************************************************************/
221 gl_ui_cmd_file_close (GtkAction *action,
224 gl_debug (DEBUG_COMMANDS, "START");
226 g_return_if_fail (action && GTK_IS_ACTION(action));
227 g_return_if_fail (window && GL_IS_WINDOW(window));
229 gl_file_close (window);
231 gl_debug (DEBUG_COMMANDS, "END");
235 /****************************************************************************/
236 /** File/Quit command. */
237 /****************************************************************************/
239 gl_ui_cmd_file_quit (GtkAction *action,
242 gl_debug (DEBUG_COMMANDS, "START");
244 g_return_if_fail (action && GTK_IS_ACTION(action));
245 g_return_if_fail (window && GL_IS_WINDOW(window));
249 gl_debug (DEBUG_COMMANDS, "END");
253 /****************************************************************************/
254 /** Edit/Cut command. */
255 /****************************************************************************/
257 gl_ui_cmd_edit_cut (GtkAction *action,
260 gl_debug (DEBUG_COMMANDS, "START");
262 g_return_if_fail (action && GTK_IS_ACTION(action));
263 g_return_if_fail (window && GL_IS_WINDOW(window));
265 gl_view_cut (GL_VIEW(window->view));
267 gl_debug (DEBUG_COMMANDS, "END");
271 /****************************************************************************/
272 /** Edit/Copy command. */
273 /****************************************************************************/
275 gl_ui_cmd_edit_copy (GtkAction *action,
278 gl_debug (DEBUG_COMMANDS, "START");
280 g_return_if_fail (action && GTK_IS_ACTION(action));
281 g_return_if_fail (window && GL_IS_WINDOW(window));
283 gl_view_copy (GL_VIEW(window->view));
285 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");
343 /****************************************************************************/
344 /** Edit/Unselect-all command. */
345 /****************************************************************************/
347 gl_ui_cmd_edit_unselect_all (GtkAction *action,
350 gl_debug (DEBUG_COMMANDS, "START");
352 g_return_if_fail (action && GTK_IS_ACTION(action));
353 g_return_if_fail (window && GL_IS_WINDOW(window));
355 gl_view_unselect_all (GL_VIEW(window->view));
357 gl_debug (DEBUG_COMMANDS, "END");
361 /****************************************************************************/
362 /** Edit/Preferences command. */
363 /****************************************************************************/
365 gl_ui_cmd_edit_preferences (GtkAction *action,
368 static GtkWidget *dialog = NULL;
370 gl_debug (DEBUG_COMMANDS, "START");
372 g_return_if_fail (action && GTK_IS_ACTION(action));
373 g_return_if_fail (window && GL_IS_WINDOW(window));
377 gtk_window_present (GTK_WINDOW (dialog));
378 gtk_window_set_transient_for (GTK_WINDOW (dialog),
383 dialog = gl_prefs_dialog_new (GTK_WINDOW(window));
385 g_signal_connect (G_OBJECT (dialog), "destroy",
386 G_CALLBACK (gtk_widget_destroyed), &dialog);
388 gtk_widget_show (dialog);
392 gl_debug (DEBUG_COMMANDS, "END");
396 /*****************************************************************************/
397 /** View/Property-bar-toggle command. */
398 /*****************************************************************************/
400 gl_ui_cmd_view_property_bar_toggle (GtkToggleAction *action,
405 gl_debug (DEBUG_COMMANDS, "START");
407 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
408 g_return_if_fail (window && GL_IS_WINDOW(window));
410 state = gtk_toggle_action_get_active (action);
412 gl_prefs_model_set_property_toolbar_visible (gl_prefs, state);
414 gtk_widget_show (GTK_WIDGET (window->property_bar));
416 gtk_widget_hide (GTK_WIDGET (window->property_bar));
419 gl_debug (DEBUG_COMMANDS, "END");
423 /*****************************************************************************/
424 /** View/Grid-toggle command. */
425 /*****************************************************************************/
427 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
432 gl_debug (DEBUG_COMMANDS, "START");
434 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
435 g_return_if_fail (window && GL_IS_WINDOW(window));
437 state = gtk_toggle_action_get_active (action);
439 if (window->view != NULL)
442 gl_view_show_grid (GL_VIEW(window->view));
444 gl_view_hide_grid (GL_VIEW(window->view));
448 gl_prefs_model_set_grid_visible (gl_prefs, state);
450 gl_debug (DEBUG_COMMANDS, "END");
454 /*****************************************************************************/
455 /** View/Markup-toggle command. */
456 /*****************************************************************************/
458 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
463 gl_debug (DEBUG_COMMANDS, "START");
465 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
466 g_return_if_fail (window && GL_IS_WINDOW(window));
468 state = gtk_toggle_action_get_active (action);
470 if (window->view != NULL)
473 gl_view_show_markup (GL_VIEW(window->view));
475 gl_view_hide_markup (GL_VIEW(window->view));
479 gl_prefs_model_set_markup_visible (gl_prefs, state);
481 gl_debug (DEBUG_COMMANDS, "END");
485 /*****************************************************************************/
486 /** View/Zoom-in command. */
487 /*****************************************************************************/
489 gl_ui_cmd_view_zoomin (GtkAction *action,
493 gl_debug (DEBUG_COMMANDS, "START");
495 g_return_if_fail (action && GTK_IS_ACTION(action));
496 g_return_if_fail (window && GL_IS_WINDOW(window));
498 if (window->view != NULL) {
499 gl_view_zoom_in (GL_VIEW(window->view));
502 gl_debug (DEBUG_COMMANDS, "END");
506 /*****************************************************************************/
507 /** View/Zoom-out command. */
508 /*****************************************************************************/
510 gl_ui_cmd_view_zoomout (GtkAction *action,
514 gl_debug (DEBUG_COMMANDS, "START");
516 g_return_if_fail (action && GTK_IS_ACTION(action));
517 g_return_if_fail (window && GL_IS_WINDOW(window));
519 if (window->view != NULL) {
520 gl_view_zoom_out (GL_VIEW(window->view));
523 gl_debug (DEBUG_COMMANDS, "END");
527 /*****************************************************************************/
528 /** View/Zoom-1:1 command. */
529 /*****************************************************************************/
531 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
535 gl_debug (DEBUG_COMMANDS, "START");
537 g_return_if_fail (action && GTK_IS_ACTION(action));
538 g_return_if_fail (window && GL_IS_WINDOW(window));
540 if (window->view != NULL) {
541 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
544 gl_debug (DEBUG_COMMANDS, "END");
548 /*****************************************************************************/
549 /** View/Zoom-to-fit command. */
550 /*****************************************************************************/
552 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
556 gl_debug (DEBUG_COMMANDS, "START");
558 g_return_if_fail (action && GTK_IS_ACTION(action));
559 g_return_if_fail (window && GL_IS_WINDOW(window));
561 if (window->view != NULL) {
562 gl_view_zoom_to_fit (GL_VIEW(window->view));
565 gl_debug (DEBUG_COMMANDS, "END");
569 /*****************************************************************************/
570 /** Objects/Arrow-mode command. */
571 /*****************************************************************************/
573 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
576 gl_debug (DEBUG_COMMANDS, "START");
578 g_return_if_fail (action && GTK_IS_ACTION(action));
579 g_return_if_fail (window && GL_IS_WINDOW(window));
581 if (window->view != NULL) {
582 gl_view_arrow_mode (GL_VIEW(window->view));
585 gl_debug (DEBUG_COMMANDS, "END");
589 /*****************************************************************************/
590 /** Objects/Create-text object command. */
591 /*****************************************************************************/
593 gl_ui_cmd_objects_create_text (GtkAction *action,
597 gl_debug (DEBUG_COMMANDS, "START");
599 g_return_if_fail (action && GTK_IS_ACTION(action));
600 g_return_if_fail (window && GL_IS_WINDOW(window));
602 if (window->view != NULL) {
603 gl_view_object_create_mode (GL_VIEW(window->view),
604 GL_LABEL_OBJECT_TEXT);
607 gl_debug (DEBUG_COMMANDS, "END");
611 /*****************************************************************************/
612 /** Objects/Create-box object command. */
613 /*****************************************************************************/
615 gl_ui_cmd_objects_create_box (GtkAction *action,
619 gl_debug (DEBUG_COMMANDS, "START");
621 g_return_if_fail (action && GTK_IS_ACTION(action));
622 g_return_if_fail (window && GL_IS_WINDOW(window));
624 if (window->view != NULL) {
625 gl_view_object_create_mode (GL_VIEW(window->view),
626 GL_LABEL_OBJECT_BOX);
629 gl_debug (DEBUG_COMMANDS, "END");
633 /*****************************************************************************/
634 /** Objects/Create-line object command. */
635 /*****************************************************************************/
637 gl_ui_cmd_objects_create_line (GtkAction *action,
641 gl_debug (DEBUG_COMMANDS, "START");
643 g_return_if_fail (action && GTK_IS_ACTION(action));
644 g_return_if_fail (window && GL_IS_WINDOW(window));
646 if (window->view != NULL) {
647 gl_view_object_create_mode (GL_VIEW(window->view),
648 GL_LABEL_OBJECT_LINE);
651 gl_debug (DEBUG_COMMANDS, "END");
655 /*****************************************************************************/
656 /** Objects/Create-ellipse object command. */
657 /*****************************************************************************/
659 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
663 gl_debug (DEBUG_COMMANDS, "START");
665 g_return_if_fail (action && GTK_IS_ACTION(action));
666 g_return_if_fail (window && GL_IS_WINDOW(window));
668 if (window->view != NULL) {
669 gl_view_object_create_mode (GL_VIEW(window->view),
670 GL_LABEL_OBJECT_ELLIPSE);
673 gl_debug (DEBUG_COMMANDS, "END");
677 /*****************************************************************************/
678 /** Objects/Create-image object command. */
679 /*****************************************************************************/
681 gl_ui_cmd_objects_create_image (GtkAction *action,
685 gl_debug (DEBUG_COMMANDS, "START");
687 g_return_if_fail (action && GTK_IS_ACTION(action));
688 g_return_if_fail (window && GL_IS_WINDOW(window));
690 if (window->view != NULL) {
691 gl_view_object_create_mode (GL_VIEW(window->view),
692 GL_LABEL_OBJECT_IMAGE);
695 gl_debug (DEBUG_COMMANDS, "END");
699 /*****************************************************************************/
700 /** Objects/Create-barcode object command. */
701 /*****************************************************************************/
703 gl_ui_cmd_objects_create_barcode (GtkAction *action,
707 gl_debug (DEBUG_COMMANDS, "START");
709 g_return_if_fail (action && GTK_IS_ACTION(action));
710 g_return_if_fail (window && GL_IS_WINDOW(window));
712 if (window->view != NULL) {
713 gl_view_object_create_mode (GL_VIEW(window->view),
714 GL_LABEL_OBJECT_BARCODE);
717 gl_debug (DEBUG_COMMANDS, "END");
721 /*****************************************************************************/
722 /** Objects/Raise command. */
723 /*****************************************************************************/
725 gl_ui_cmd_objects_raise (GtkAction *action,
729 gl_debug (DEBUG_COMMANDS, "START");
731 g_return_if_fail (action && GTK_IS_ACTION(action));
732 g_return_if_fail (window && GL_IS_WINDOW(window));
734 if (window->view != NULL) {
735 gl_view_raise_selection (GL_VIEW(window->view));
738 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");
763 /*****************************************************************************/
764 /** Objects/Rotate-left-90-degrees command. */
765 /*****************************************************************************/
767 gl_ui_cmd_objects_rotate_left (GtkAction *action,
771 gl_debug (DEBUG_COMMANDS, "START");
773 g_return_if_fail (action && GTK_IS_ACTION(action));
774 g_return_if_fail (window && GL_IS_WINDOW(window));
776 if (window->view != NULL) {
777 gl_view_rotate_selection_left (GL_VIEW(window->view));
780 gl_debug (DEBUG_COMMANDS, "END");
784 /*****************************************************************************/
785 /** Objects/Rotate-right-90-degrees command. */
786 /*****************************************************************************/
788 gl_ui_cmd_objects_rotate_right (GtkAction *action,
792 gl_debug (DEBUG_COMMANDS, "START");
794 g_return_if_fail (action && GTK_IS_ACTION(action));
795 g_return_if_fail (window && GL_IS_WINDOW(window));
797 if (window->view != NULL) {
798 gl_view_rotate_selection_right (GL_VIEW(window->view));
801 gl_debug (DEBUG_COMMANDS, "END");
805 /*****************************************************************************/
806 /** Objects/Flip-horizontally command. */
807 /*****************************************************************************/
809 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
813 gl_debug (DEBUG_COMMANDS, "START");
815 g_return_if_fail (action && GTK_IS_ACTION(action));
816 g_return_if_fail (window && GL_IS_WINDOW(window));
818 if (window->view != NULL) {
819 gl_view_flip_selection_horiz (GL_VIEW(window->view));
822 gl_debug (DEBUG_COMMANDS, "END");
826 /*****************************************************************************/
827 /** Objects/Flip-vertically command. */
828 /*****************************************************************************/
830 gl_ui_cmd_objects_flip_vert (GtkAction *action,
834 gl_debug (DEBUG_COMMANDS, "START");
836 g_return_if_fail (action && GTK_IS_ACTION(action));
837 g_return_if_fail (window && GL_IS_WINDOW(window));
839 if (window->view != NULL) {
840 gl_view_flip_selection_vert (GL_VIEW(window->view));
843 gl_debug (DEBUG_COMMANDS, "END");
847 /*****************************************************************************/
848 /** Objects/Align-left command. */
849 /*****************************************************************************/
851 gl_ui_cmd_objects_align_left (GtkAction *action,
855 gl_debug (DEBUG_COMMANDS, "START");
857 g_return_if_fail (action && GTK_IS_ACTION(action));
858 g_return_if_fail (window && GL_IS_WINDOW(window));
860 if (window->view != NULL) {
861 gl_view_align_selection_left (GL_VIEW(window->view));
864 gl_debug (DEBUG_COMMANDS, "END");
868 /*****************************************************************************/
869 /** Objects/Align-right command. */
870 /*****************************************************************************/
872 gl_ui_cmd_objects_align_right (GtkAction *action,
876 gl_debug (DEBUG_COMMANDS, "START");
878 g_return_if_fail (action && GTK_IS_ACTION(action));
879 g_return_if_fail (window && GL_IS_WINDOW(window));
881 if (window->view != NULL) {
882 gl_view_align_selection_right (GL_VIEW(window->view));
885 gl_debug (DEBUG_COMMANDS, "END");
889 /*****************************************************************************/
890 /** Objects/Align-horizontal-center command. */
891 /*****************************************************************************/
893 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
897 gl_debug (DEBUG_COMMANDS, "START");
899 g_return_if_fail (action && GTK_IS_ACTION(action));
900 g_return_if_fail (window && GL_IS_WINDOW(window));
902 if (window->view != NULL) {
903 gl_view_align_selection_hcenter (GL_VIEW(window->view));
906 gl_debug (DEBUG_COMMANDS, "END");
910 /*****************************************************************************/
911 /** Objects/Align-top command. */
912 /*****************************************************************************/
914 gl_ui_cmd_objects_align_top (GtkAction *action,
918 gl_debug (DEBUG_COMMANDS, "START");
920 g_return_if_fail (action && GTK_IS_ACTION(action));
921 g_return_if_fail (window && GL_IS_WINDOW(window));
923 if (window->view != NULL) {
924 gl_view_align_selection_top (GL_VIEW(window->view));
927 gl_debug (DEBUG_COMMANDS, "END");
931 /*****************************************************************************/
932 /** Objects/Align-bottom command. */
933 /*****************************************************************************/
935 gl_ui_cmd_objects_align_bottom (GtkAction *action,
939 gl_debug (DEBUG_COMMANDS, "START");
941 g_return_if_fail (action && GTK_IS_ACTION(action));
942 g_return_if_fail (window && GL_IS_WINDOW(window));
944 if (window->view != NULL) {
945 gl_view_align_selection_bottom (GL_VIEW(window->view));
948 gl_debug (DEBUG_COMMANDS, "END");
952 /*****************************************************************************/
953 /** Objects/Align-vertical center command. */
954 /*****************************************************************************/
956 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
960 gl_debug (DEBUG_COMMANDS, "START");
962 g_return_if_fail (action && GTK_IS_ACTION(action));
963 g_return_if_fail (window && GL_IS_WINDOW(window));
965 if (window->view != NULL) {
966 gl_view_align_selection_vcenter (GL_VIEW(window->view));
969 gl_debug (DEBUG_COMMANDS, "END");
973 /*****************************************************************************/
974 /** Objects/Center-horizontally command. */
975 /*****************************************************************************/
977 gl_ui_cmd_objects_center_horiz (GtkAction *action,
981 gl_debug (DEBUG_COMMANDS, "START");
983 g_return_if_fail (action && GTK_IS_ACTION(action));
984 g_return_if_fail (window && GL_IS_WINDOW(window));
986 if (window->view != NULL) {
987 gl_view_center_selection_horiz (GL_VIEW(window->view));
990 gl_debug (DEBUG_COMMANDS, "END");
994 /*****************************************************************************/
995 /** Objects/Center-vertically command. */
996 /*****************************************************************************/
998 gl_ui_cmd_objects_center_vert (GtkAction *action,
1002 gl_debug (DEBUG_COMMANDS, "START");
1004 g_return_if_fail (action && GTK_IS_ACTION(action));
1005 g_return_if_fail (window && GL_IS_WINDOW(window));
1007 if (window->view != NULL) {
1008 gl_view_center_selection_vert (GL_VIEW(window->view));
1011 gl_debug (DEBUG_COMMANDS, "END");
1015 /*****************************************************************************/
1016 /** Objects/Edit- merge-properties command. */
1017 /*****************************************************************************/
1019 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1023 gl_debug (DEBUG_COMMANDS, "START");
1025 g_return_if_fail (action && GTK_IS_ACTION(action));
1026 g_return_if_fail (window && GL_IS_WINDOW(window));
1028 if (window->merge_dialog) {
1030 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1031 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1032 GTK_WINDOW (window));
1036 window->merge_dialog =
1038 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1039 GTK_WINDOW(window)) );
1041 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1042 G_CALLBACK (gtk_widget_destroyed),
1043 &window->merge_dialog);
1045 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1049 gl_debug (DEBUG_COMMANDS, "END");
1053 /****************************************************************************/
1054 /** Help/Contents command. */
1055 /****************************************************************************/
1057 gl_ui_cmd_help_contents (GtkAction *action,
1060 GError *error = NULL;
1062 gl_debug (DEBUG_COMMANDS, "START");
1064 g_return_if_fail (action && GTK_IS_ACTION(action));
1065 g_return_if_fail (window && GL_IS_WINDOW(window));
1067 gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (window)),
1074 g_message ("%s", error->message);
1076 g_error_free (error);
1079 gl_debug (DEBUG_COMMANDS, "END");
1083 /****************************************************************************/
1084 /** Help/About command. */
1085 /****************************************************************************/
1087 gl_ui_cmd_help_about (GtkAction *action,
1090 static GtkWidget *about = NULL;
1092 GdkPixbuf *pixbuf = NULL;
1094 const gchar *authors[] = {
1097 _("Glabels includes contributions from:"),
1103 _("See the file AUTHORS for additional credits,"),
1104 _("or visit http://glabels.org/"),
1108 const gchar *artists[] = {
1114 const gchar *copy_text = "Copyright \xc2\xa9 2001-2009 Jim Evins";
1116 const gchar *about_text = _("A label and business card creation program.\n");
1118 const gchar *url = "http://glabels.org";
1120 const gchar *translator_credits = _("translator-credits");
1122 const gchar *license = _(
1123 "gLabels is free software: you can redistribute it and/or modify\n"
1124 "it under the terms of the GNU General Public License as published by\n"
1125 "the Free Software Foundation, either version 3 of the License, or\n"
1126 "(at your option) any later version.\n"
1128 "gLabels is distributed in the hope that it will be useful,\n"
1129 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1130 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1131 "GNU General Public License for more details.\n");
1133 gl_debug (DEBUG_COMMANDS, "START");
1135 g_return_if_fail (action && GTK_IS_ACTION(action));
1136 g_return_if_fail (window && GL_IS_WINDOW(window));
1141 gtk_window_present (GTK_WINDOW (about));
1142 gtk_window_set_transient_for (GTK_WINDOW (about),
1143 GTK_WINDOW (window));
1147 pixbuf = gdk_pixbuf_new_from_file (GLABELS_PIXMAP_DIR "glabels-splash.png", NULL);
1149 about = gtk_about_dialog_new ();
1150 gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(about), _("glabels"));
1151 gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about), VERSION);
1152 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text);
1153 gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about), about_text);
1154 gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), url);
1155 gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(about), pixbuf);
1157 gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
1158 gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG(about), artists);
1159 gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about),
1160 translator_credits);
1161 gtk_about_dialog_set_license (GTK_ABOUT_DIALOG(about), license);
1163 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
1165 g_signal_connect (G_OBJECT (about), "response",
1166 G_CALLBACK (gtk_widget_destroy), NULL);
1167 g_signal_connect (G_OBJECT (about), "destroy",
1168 G_CALLBACK (gtk_widget_destroyed), &about);
1170 gtk_window_set_transient_for (GTK_WINDOW (about),
1171 GTK_WINDOW (window));
1173 gtk_window_present (GTK_WINDOW (about));
1176 g_object_unref (pixbuf);
1180 gl_debug (DEBUG_COMMANDS, "END");
1186 * Local Variables: -- emacs
1188 * c-basic-offset: 8 -- emacs
1189 * tab-width: 8 -- emacs
1190 * indent-tabs-mode: nil -- emacs