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->property_toolbar_visible = state;
414 gtk_widget_show (GTK_WIDGET (window->property_bar));
416 gtk_widget_hide (GTK_WIDGET (window->property_bar));
418 gl_prefs_model_save_settings (gl_prefs);
420 gl_debug (DEBUG_COMMANDS, "END");
424 /*****************************************************************************/
425 /** View/Grid-toggle command. */
426 /*****************************************************************************/
428 gl_ui_cmd_view_grid_toggle (GtkToggleAction *action,
433 gl_debug (DEBUG_COMMANDS, "START");
435 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
436 g_return_if_fail (window && GL_IS_WINDOW(window));
438 state = gtk_toggle_action_get_active (action);
440 if (window->view != NULL)
443 gl_view_show_grid (GL_VIEW(window->view));
445 gl_view_hide_grid (GL_VIEW(window->view));
449 gl_prefs->grid_visible = state;
450 gl_prefs_model_save_settings (gl_prefs);
452 gl_debug (DEBUG_COMMANDS, "END");
456 /*****************************************************************************/
457 /** View/Markup-toggle command. */
458 /*****************************************************************************/
460 gl_ui_cmd_view_markup_toggle (GtkToggleAction *action,
465 gl_debug (DEBUG_COMMANDS, "START");
467 g_return_if_fail (action && GTK_IS_TOGGLE_ACTION(action));
468 g_return_if_fail (window && GL_IS_WINDOW(window));
470 state = gtk_toggle_action_get_active (action);
472 if (window->view != NULL)
475 gl_view_show_markup (GL_VIEW(window->view));
477 gl_view_hide_markup (GL_VIEW(window->view));
481 gl_prefs->markup_visible = state;
482 gl_prefs_model_save_settings (gl_prefs);
484 gl_debug (DEBUG_COMMANDS, "END");
488 /*****************************************************************************/
489 /** View/Zoom-in command. */
490 /*****************************************************************************/
492 gl_ui_cmd_view_zoomin (GtkAction *action,
496 gl_debug (DEBUG_COMMANDS, "START");
498 g_return_if_fail (action && GTK_IS_ACTION(action));
499 g_return_if_fail (window && GL_IS_WINDOW(window));
501 if (window->view != NULL) {
502 gl_view_zoom_in (GL_VIEW(window->view));
505 gl_debug (DEBUG_COMMANDS, "END");
509 /*****************************************************************************/
510 /** View/Zoom-out command. */
511 /*****************************************************************************/
513 gl_ui_cmd_view_zoomout (GtkAction *action,
517 gl_debug (DEBUG_COMMANDS, "START");
519 g_return_if_fail (action && GTK_IS_ACTION(action));
520 g_return_if_fail (window && GL_IS_WINDOW(window));
522 if (window->view != NULL) {
523 gl_view_zoom_out (GL_VIEW(window->view));
526 gl_debug (DEBUG_COMMANDS, "END");
530 /*****************************************************************************/
531 /** View/Zoom-1:1 command. */
532 /*****************************************************************************/
534 gl_ui_cmd_view_zoom1to1 (GtkAction *action,
538 gl_debug (DEBUG_COMMANDS, "START");
540 g_return_if_fail (action && GTK_IS_ACTION(action));
541 g_return_if_fail (window && GL_IS_WINDOW(window));
543 if (window->view != NULL) {
544 gl_view_set_zoom (GL_VIEW(window->view), 1.0);
547 gl_debug (DEBUG_COMMANDS, "END");
551 /*****************************************************************************/
552 /** View/Zoom-to-fit command. */
553 /*****************************************************************************/
555 gl_ui_cmd_view_zoom_to_fit (GtkAction *action,
559 gl_debug (DEBUG_COMMANDS, "START");
561 g_return_if_fail (action && GTK_IS_ACTION(action));
562 g_return_if_fail (window && GL_IS_WINDOW(window));
564 if (window->view != NULL) {
565 gl_view_zoom_to_fit (GL_VIEW(window->view));
568 gl_debug (DEBUG_COMMANDS, "END");
572 /*****************************************************************************/
573 /** Objects/Arrow-mode command. */
574 /*****************************************************************************/
576 gl_ui_cmd_objects_arrow_mode (GtkAction *action,
579 gl_debug (DEBUG_COMMANDS, "START");
581 g_return_if_fail (action && GTK_IS_ACTION(action));
582 g_return_if_fail (window && GL_IS_WINDOW(window));
584 if (window->view != NULL) {
585 gl_view_arrow_mode (GL_VIEW(window->view));
588 gl_debug (DEBUG_COMMANDS, "END");
592 /*****************************************************************************/
593 /** Objects/Create-text object command. */
594 /*****************************************************************************/
596 gl_ui_cmd_objects_create_text (GtkAction *action,
600 gl_debug (DEBUG_COMMANDS, "START");
602 g_return_if_fail (action && GTK_IS_ACTION(action));
603 g_return_if_fail (window && GL_IS_WINDOW(window));
605 if (window->view != NULL) {
606 gl_view_object_create_mode (GL_VIEW(window->view),
607 GL_LABEL_OBJECT_TEXT);
610 gl_debug (DEBUG_COMMANDS, "END");
614 /*****************************************************************************/
615 /** Objects/Create-box object command. */
616 /*****************************************************************************/
618 gl_ui_cmd_objects_create_box (GtkAction *action,
622 gl_debug (DEBUG_COMMANDS, "START");
624 g_return_if_fail (action && GTK_IS_ACTION(action));
625 g_return_if_fail (window && GL_IS_WINDOW(window));
627 if (window->view != NULL) {
628 gl_view_object_create_mode (GL_VIEW(window->view),
629 GL_LABEL_OBJECT_BOX);
632 gl_debug (DEBUG_COMMANDS, "END");
636 /*****************************************************************************/
637 /** Objects/Create-line object command. */
638 /*****************************************************************************/
640 gl_ui_cmd_objects_create_line (GtkAction *action,
644 gl_debug (DEBUG_COMMANDS, "START");
646 g_return_if_fail (action && GTK_IS_ACTION(action));
647 g_return_if_fail (window && GL_IS_WINDOW(window));
649 if (window->view != NULL) {
650 gl_view_object_create_mode (GL_VIEW(window->view),
651 GL_LABEL_OBJECT_LINE);
654 gl_debug (DEBUG_COMMANDS, "END");
658 /*****************************************************************************/
659 /** Objects/Create-ellipse object command. */
660 /*****************************************************************************/
662 gl_ui_cmd_objects_create_ellipse (GtkAction *action,
666 gl_debug (DEBUG_COMMANDS, "START");
668 g_return_if_fail (action && GTK_IS_ACTION(action));
669 g_return_if_fail (window && GL_IS_WINDOW(window));
671 if (window->view != NULL) {
672 gl_view_object_create_mode (GL_VIEW(window->view),
673 GL_LABEL_OBJECT_ELLIPSE);
676 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");
702 /*****************************************************************************/
703 /** Objects/Create-barcode object command. */
704 /*****************************************************************************/
706 gl_ui_cmd_objects_create_barcode (GtkAction *action,
710 gl_debug (DEBUG_COMMANDS, "START");
712 g_return_if_fail (action && GTK_IS_ACTION(action));
713 g_return_if_fail (window && GL_IS_WINDOW(window));
715 if (window->view != NULL) {
716 gl_view_object_create_mode (GL_VIEW(window->view),
717 GL_LABEL_OBJECT_BARCODE);
720 gl_debug (DEBUG_COMMANDS, "END");
724 /*****************************************************************************/
725 /** Objects/Raise command. */
726 /*****************************************************************************/
728 gl_ui_cmd_objects_raise (GtkAction *action,
732 gl_debug (DEBUG_COMMANDS, "START");
734 g_return_if_fail (action && GTK_IS_ACTION(action));
735 g_return_if_fail (window && GL_IS_WINDOW(window));
737 if (window->view != NULL) {
738 gl_view_raise_selection (GL_VIEW(window->view));
741 gl_debug (DEBUG_COMMANDS, "END");
745 /*****************************************************************************/
746 /** Objects/Lower command. */
747 /*****************************************************************************/
749 gl_ui_cmd_objects_lower (GtkAction *action,
753 gl_debug (DEBUG_COMMANDS, "START");
755 g_return_if_fail (action && GTK_IS_ACTION(action));
756 g_return_if_fail (window && GL_IS_WINDOW(window));
758 if (window->view != NULL) {
759 gl_view_lower_selection (GL_VIEW(window->view));
762 gl_debug (DEBUG_COMMANDS, "END");
766 /*****************************************************************************/
767 /** Objects/Rotate-left-90-degrees command. */
768 /*****************************************************************************/
770 gl_ui_cmd_objects_rotate_left (GtkAction *action,
774 gl_debug (DEBUG_COMMANDS, "START");
776 g_return_if_fail (action && GTK_IS_ACTION(action));
777 g_return_if_fail (window && GL_IS_WINDOW(window));
779 if (window->view != NULL) {
780 gl_view_rotate_selection_left (GL_VIEW(window->view));
783 gl_debug (DEBUG_COMMANDS, "END");
787 /*****************************************************************************/
788 /** Objects/Rotate-right-90-degrees command. */
789 /*****************************************************************************/
791 gl_ui_cmd_objects_rotate_right (GtkAction *action,
795 gl_debug (DEBUG_COMMANDS, "START");
797 g_return_if_fail (action && GTK_IS_ACTION(action));
798 g_return_if_fail (window && GL_IS_WINDOW(window));
800 if (window->view != NULL) {
801 gl_view_rotate_selection_right (GL_VIEW(window->view));
804 gl_debug (DEBUG_COMMANDS, "END");
808 /*****************************************************************************/
809 /** Objects/Flip-horizontally command. */
810 /*****************************************************************************/
812 gl_ui_cmd_objects_flip_horiz (GtkAction *action,
816 gl_debug (DEBUG_COMMANDS, "START");
818 g_return_if_fail (action && GTK_IS_ACTION(action));
819 g_return_if_fail (window && GL_IS_WINDOW(window));
821 if (window->view != NULL) {
822 gl_view_flip_selection_horiz (GL_VIEW(window->view));
825 gl_debug (DEBUG_COMMANDS, "END");
829 /*****************************************************************************/
830 /** Objects/Flip-vertically command. */
831 /*****************************************************************************/
833 gl_ui_cmd_objects_flip_vert (GtkAction *action,
837 gl_debug (DEBUG_COMMANDS, "START");
839 g_return_if_fail (action && GTK_IS_ACTION(action));
840 g_return_if_fail (window && GL_IS_WINDOW(window));
842 if (window->view != NULL) {
843 gl_view_flip_selection_vert (GL_VIEW(window->view));
846 gl_debug (DEBUG_COMMANDS, "END");
850 /*****************************************************************************/
851 /** Objects/Align-left command. */
852 /*****************************************************************************/
854 gl_ui_cmd_objects_align_left (GtkAction *action,
858 gl_debug (DEBUG_COMMANDS, "START");
860 g_return_if_fail (action && GTK_IS_ACTION(action));
861 g_return_if_fail (window && GL_IS_WINDOW(window));
863 if (window->view != NULL) {
864 gl_view_align_selection_left (GL_VIEW(window->view));
867 gl_debug (DEBUG_COMMANDS, "END");
871 /*****************************************************************************/
872 /** Objects/Align-right command. */
873 /*****************************************************************************/
875 gl_ui_cmd_objects_align_right (GtkAction *action,
879 gl_debug (DEBUG_COMMANDS, "START");
881 g_return_if_fail (action && GTK_IS_ACTION(action));
882 g_return_if_fail (window && GL_IS_WINDOW(window));
884 if (window->view != NULL) {
885 gl_view_align_selection_right (GL_VIEW(window->view));
888 gl_debug (DEBUG_COMMANDS, "END");
892 /*****************************************************************************/
893 /** Objects/Align-horizontal-center command. */
894 /*****************************************************************************/
896 gl_ui_cmd_objects_align_hcenter (GtkAction *action,
900 gl_debug (DEBUG_COMMANDS, "START");
902 g_return_if_fail (action && GTK_IS_ACTION(action));
903 g_return_if_fail (window && GL_IS_WINDOW(window));
905 if (window->view != NULL) {
906 gl_view_align_selection_hcenter (GL_VIEW(window->view));
909 gl_debug (DEBUG_COMMANDS, "END");
913 /*****************************************************************************/
914 /** Objects/Align-top command. */
915 /*****************************************************************************/
917 gl_ui_cmd_objects_align_top (GtkAction *action,
921 gl_debug (DEBUG_COMMANDS, "START");
923 g_return_if_fail (action && GTK_IS_ACTION(action));
924 g_return_if_fail (window && GL_IS_WINDOW(window));
926 if (window->view != NULL) {
927 gl_view_align_selection_top (GL_VIEW(window->view));
930 gl_debug (DEBUG_COMMANDS, "END");
934 /*****************************************************************************/
935 /** Objects/Align-bottom command. */
936 /*****************************************************************************/
938 gl_ui_cmd_objects_align_bottom (GtkAction *action,
942 gl_debug (DEBUG_COMMANDS, "START");
944 g_return_if_fail (action && GTK_IS_ACTION(action));
945 g_return_if_fail (window && GL_IS_WINDOW(window));
947 if (window->view != NULL) {
948 gl_view_align_selection_bottom (GL_VIEW(window->view));
951 gl_debug (DEBUG_COMMANDS, "END");
955 /*****************************************************************************/
956 /** Objects/Align-vertical center command. */
957 /*****************************************************************************/
959 gl_ui_cmd_objects_align_vcenter (GtkAction *action,
963 gl_debug (DEBUG_COMMANDS, "START");
965 g_return_if_fail (action && GTK_IS_ACTION(action));
966 g_return_if_fail (window && GL_IS_WINDOW(window));
968 if (window->view != NULL) {
969 gl_view_align_selection_vcenter (GL_VIEW(window->view));
972 gl_debug (DEBUG_COMMANDS, "END");
976 /*****************************************************************************/
977 /** Objects/Center-horizontally command. */
978 /*****************************************************************************/
980 gl_ui_cmd_objects_center_horiz (GtkAction *action,
984 gl_debug (DEBUG_COMMANDS, "START");
986 g_return_if_fail (action && GTK_IS_ACTION(action));
987 g_return_if_fail (window && GL_IS_WINDOW(window));
989 if (window->view != NULL) {
990 gl_view_center_selection_horiz (GL_VIEW(window->view));
993 gl_debug (DEBUG_COMMANDS, "END");
997 /*****************************************************************************/
998 /** Objects/Center-vertically command. */
999 /*****************************************************************************/
1001 gl_ui_cmd_objects_center_vert (GtkAction *action,
1005 gl_debug (DEBUG_COMMANDS, "START");
1007 g_return_if_fail (action && GTK_IS_ACTION(action));
1008 g_return_if_fail (window && GL_IS_WINDOW(window));
1010 if (window->view != NULL) {
1011 gl_view_center_selection_vert (GL_VIEW(window->view));
1014 gl_debug (DEBUG_COMMANDS, "END");
1018 /*****************************************************************************/
1019 /** Objects/Edit- merge-properties command. */
1020 /*****************************************************************************/
1022 gl_ui_cmd_objects_merge_properties (GtkAction *action,
1026 gl_debug (DEBUG_COMMANDS, "START");
1028 g_return_if_fail (action && GTK_IS_ACTION(action));
1029 g_return_if_fail (window && GL_IS_WINDOW(window));
1031 if (window->merge_dialog) {
1033 gtk_window_present (GTK_WINDOW(window->merge_dialog));
1034 gtk_window_set_transient_for (GTK_WINDOW (window->merge_dialog),
1035 GTK_WINDOW (window));
1039 window->merge_dialog =
1041 gl_merge_properties_dialog_new (GL_VIEW(window->view)->label,
1042 GTK_WINDOW(window)) );
1044 g_signal_connect (G_OBJECT(window->merge_dialog), "destroy",
1045 G_CALLBACK (gtk_widget_destroyed),
1046 &window->merge_dialog);
1048 gtk_widget_show (GTK_WIDGET (window->merge_dialog));
1052 gl_debug (DEBUG_COMMANDS, "END");
1056 /****************************************************************************/
1057 /** Help/Contents command. */
1058 /****************************************************************************/
1060 gl_ui_cmd_help_contents (GtkAction *action,
1063 GError *error = NULL;
1065 gl_debug (DEBUG_COMMANDS, "START");
1067 g_return_if_fail (action && GTK_IS_ACTION(action));
1068 g_return_if_fail (window && GL_IS_WINDOW(window));
1070 gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (window)),
1077 g_message ("%s", error->message);
1079 g_error_free (error);
1082 gl_debug (DEBUG_COMMANDS, "END");
1086 /****************************************************************************/
1087 /** Help/About command. */
1088 /****************************************************************************/
1090 gl_ui_cmd_help_about (GtkAction *action,
1093 static GtkWidget *about = NULL;
1095 GdkPixbuf *pixbuf = NULL;
1097 const gchar *authors[] = {
1100 _("Glabels includes contributions from:"),
1106 _("See the file AUTHORS for additional credits,"),
1107 _("or visit http://glabels.sourceforge.net/"),
1111 const gchar *artists[] = {
1117 const gchar *copy_text = "Copyright \xc2\xa9 2001-2009 Jim Evins";
1119 const gchar *about_text = _("A label and business card creation program.\n");
1121 const gchar *url = "http://glabels.sourceforge.net";
1123 const gchar *translator_credits = _("translator-credits");
1125 const gchar *license = _(
1126 "gLabels is free software: you can redistribute it and/or modify\n"
1127 "it under the terms of the GNU General Public License as published by\n"
1128 "the Free Software Foundation, either version 3 of the License, or\n"
1129 "(at your option) any later version.\n"
1131 "gLabels is distributed in the hope that it will be useful,\n"
1132 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
1133 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
1134 "GNU General Public License for more details.\n");
1136 gl_debug (DEBUG_COMMANDS, "START");
1138 g_return_if_fail (action && GTK_IS_ACTION(action));
1139 g_return_if_fail (window && GL_IS_WINDOW(window));
1144 gtk_window_present (GTK_WINDOW (about));
1145 gtk_window_set_transient_for (GTK_WINDOW (about),
1146 GTK_WINDOW (window));
1150 pixbuf = gdk_pixbuf_new_from_file (GLABELS_PIXMAP_DIR "glabels-splash.png", NULL);
1152 about = gtk_about_dialog_new ();
1153 gtk_about_dialog_set_program_name (GTK_ABOUT_DIALOG(about), _("glabels"));
1154 gtk_about_dialog_set_version (GTK_ABOUT_DIALOG(about), VERSION);
1155 gtk_about_dialog_set_copyright (GTK_ABOUT_DIALOG(about), copy_text);
1156 gtk_about_dialog_set_comments (GTK_ABOUT_DIALOG(about), about_text);
1157 gtk_about_dialog_set_website (GTK_ABOUT_DIALOG(about), url);
1158 gtk_about_dialog_set_logo (GTK_ABOUT_DIALOG(about), pixbuf);
1160 gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG(about), authors);
1161 gtk_about_dialog_set_artists (GTK_ABOUT_DIALOG(about), artists);
1162 gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG(about),
1163 translator_credits);
1164 gtk_about_dialog_set_license (GTK_ABOUT_DIALOG(about), license);
1166 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
1168 g_signal_connect (G_OBJECT (about), "response",
1169 G_CALLBACK (gtk_widget_destroy), NULL);
1170 g_signal_connect (G_OBJECT (about), "destroy",
1171 G_CALLBACK (gtk_widget_destroyed), &about);
1173 gtk_window_set_transient_for (GTK_WINDOW (about),
1174 GTK_WINDOW (window));
1176 gtk_window_present (GTK_WINDOW (about));
1179 g_object_unref (pixbuf);
1183 gl_debug (DEBUG_COMMANDS, "END");
1189 * Local Variables: -- emacs
1191 * c-basic-offset: 8 -- emacs
1192 * tab-width: 8 -- emacs
1193 * indent-tabs-mode: nil -- emacs