]> git.sur5r.net Git - glabels/blob - glabels1/src/menu.c
2009-09-22 Jim Evins <evins@snaught.com>
[glabels] / glabels1 / src / menu.c
1 /*
2  *  (GLABELS) Label and Business Card Creation program for GNOME
3  *
4  *  menu.c:  Menu module
5  *
6  *  Copyright (C) 2001-2002  Jim Evins <evins@snaught.com>.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21  */
22
23 #include <config.h>
24
25 #include "menu.h"
26 #include "stock.h"
27 #include "file.h"
28 #include "print_dialog.h"
29 #include "edit.h"
30 #include "prefs.h"
31 #include "tools.h"
32
33 #ifdef PACKAGE_DATA_DIR
34 #define LOGO_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-about-logo.png")
35 #else
36 #define LOGO_PIXMAP gnome_pixmap_file("glabels/glabels-about-logo.png")
37 #endif
38
39 /*===========================================*/
40 /* Private function prototypes.              */
41 /*===========================================*/
42 static void about_cb (GtkWidget * widget, gpointer data);
43 static void nothing_cb (GtkWidget * widget, gpointer data);
44
45 /*===========================================*/
46 /* Menu definitions                          */
47 /*===========================================*/
48
49 static GnomeUIInfo menu_file[] = {
50         GNOMEUIINFO_MENU_NEW_ITEM (N_("_New"),
51                                    N_("Make a new, empty label"),
52                                    gl_file_new_cb, NULL),
53
54         GNOMEUIINFO_MENU_OPEN_ITEM (gl_file_open_cb, NULL),
55
56         GNOMEUIINFO_MENU_SAVE_ITEM (gl_file_save_cb, NULL),
57
58         GNOMEUIINFO_MENU_SAVE_AS_ITEM (gl_file_save_as_cb, NULL),
59
60         GNOMEUIINFO_SEPARATOR,
61
62         GNOMEUIINFO_MENU_PRINT_ITEM (gl_print_dialog_cb, NULL),
63
64         GNOMEUIINFO_SEPARATOR,
65         GNOMEUIINFO_MENU_CLOSE_ITEM (gl_file_close_cb, NULL),
66         GNOMEUIINFO_MENU_EXIT_ITEM (gl_file_exit_cb, NULL),
67         GNOMEUIINFO_END
68 };
69
70 static GnomeUIInfo menu_edit[] = {
71 #ifdef UNDO_REDO
72         GNOMEUIINFO_MENU_UNDO_ITEM (nothing_cb, NULL),
73         GNOMEUIINFO_MENU_REDO_ITEM (nothing_cb, NULL),
74
75         GNOMEUIINFO_SEPARATOR,
76 #endif
77
78         GNOMEUIINFO_MENU_CUT_ITEM (gl_edit_cut_cb, NULL),
79         GNOMEUIINFO_MENU_COPY_ITEM (gl_edit_copy_cb, NULL),
80         GNOMEUIINFO_MENU_PASTE_ITEM (gl_edit_paste_cb, NULL),
81
82         GNOMEUIINFO_SEPARATOR,
83
84         GNOMEUIINFO_MENU_SELECT_ALL_ITEM (gl_edit_select_all_cb, NULL),
85         GNOMEUIINFO_ITEM_NONE (N_("U_nselect All "),
86                                N_("Remove all selections"),
87                                gl_edit_unselect_cb),
88
89         GNOMEUIINFO_END
90 };
91
92 static GnomeUIInfo menu_tools[] = {
93
94         GNOMEUIINFO_ITEM_STOCK (N_("Select"),
95                                 N_("Select, move and modify objects"),
96                                 gl_tools_arrow_cb, GL_STOCK_PIXMAP_ARROW),
97
98         GNOMEUIINFO_SEPARATOR,
99
100         GNOMEUIINFO_ITEM_NONE (N_("Text"), N_("Create text object"),
101                                 gl_tools_text_cb),
102
103         GNOMEUIINFO_ITEM_NONE (N_("Box"), N_("Create box/rectangle object"),
104                                 gl_tools_box_cb),
105
106         GNOMEUIINFO_ITEM_NONE (N_("Line"), N_("Create line object"),
107                                 gl_tools_line_cb),
108
109         GNOMEUIINFO_ITEM_NONE (N_("Ellipse"),
110                                 N_("Create ellipse/circle object"),
111                                 gl_tools_ellipse_cb),
112
113         GNOMEUIINFO_ITEM_NONE (N_("Image"), N_("Create image object"),
114                                 gl_tools_image_cb),
115
116         GNOMEUIINFO_ITEM_NONE (N_("Barcode"), N_("Create barcode object"),
117                                 gl_tools_barcode_cb),
118
119         GNOMEUIINFO_SEPARATOR,
120
121         GNOMEUIINFO_ITEM_NONE (N_("Zoom in"), N_("Zoom in"),
122                                 gl_tools_zoomin_cb),
123
124         GNOMEUIINFO_ITEM_NONE (N_("Zoom out"), N_("Zoom out"),
125                                 gl_tools_zoomout_cb),
126
127         GNOMEUIINFO_ITEM_NONE (N_("Zoom 1:1"), N_("Zoom to 1:1"),
128                                 gl_tools_zoom1to1_cb),
129
130         GNOMEUIINFO_SEPARATOR,
131
132         GNOMEUIINFO_ITEM_NONE (N_("Merge properties"),
133                                 N_("Edit merge properties"),
134                                 gl_tools_merge_properties_cb),
135
136         GNOMEUIINFO_END
137 };
138
139 static GnomeUIInfo menu_settings[] = {
140         GNOMEUIINFO_MENU_PREFERENCES_ITEM (gl_prefs_cb, NULL),
141         GNOMEUIINFO_END
142 };
143
144 static GnomeUIInfo menu_windows[] = {
145         GNOMEUIINFO_END
146 };
147
148 static GnomeUIInfo menu_help[] = {
149         GNOMEUIINFO_HELP ("glabels"),
150         GNOMEUIINFO_MENU_ABOUT_ITEM (about_cb, NULL),
151         GNOMEUIINFO_END
152 };
153
154 static GnomeUIInfo menu_main[] = {
155         GNOMEUIINFO_MENU_FILE_TREE (menu_file),
156         GNOMEUIINFO_MENU_EDIT_TREE (menu_edit),
157         GNOMEUIINFO_SUBTREE (N_("_Tools"), menu_tools),
158         GNOMEUIINFO_MENU_SETTINGS_TREE (menu_settings),
159         GNOMEUIINFO_MENU_WINDOWS_TREE (menu_windows),
160         GNOMEUIINFO_MENU_HELP_TREE (menu_help),
161         GNOMEUIINFO_END
162 };
163
164 /*===========================================*/
165 /* Toolbar definitions                       */
166 /*===========================================*/
167 static GnomeUIInfo toolbar[] = {
168         GNOMEUIINFO_ITEM_STOCK (N_("  New   "), N_("New Label/Card"),
169                                 gl_file_new_cb, GNOME_STOCK_PIXMAP_NEW),
170         GNOMEUIINFO_ITEM_STOCK (N_("  Open  "), N_("Open a file"),
171                                 gl_file_open_cb, GNOME_STOCK_PIXMAP_OPEN),
172         GNOMEUIINFO_ITEM_STOCK (N_("  Save  "), N_("Save current file"),
173                                 gl_file_save_cb, GNOME_STOCK_PIXMAP_SAVE),
174         GNOMEUIINFO_SEPARATOR,
175         GNOMEUIINFO_ITEM_STOCK (N_(" Print  "), N_("Print current file"),
176                                 gl_print_dialog_cb, GNOME_STOCK_PIXMAP_PRINT),
177         GNOMEUIINFO_SEPARATOR,
178         GNOMEUIINFO_END
179 };
180
181 /*****************************************************************************/
182 /* Drawing tools toolbar definitions                                         */
183 /*****************************************************************************/
184 static GnomeUIInfo tools_toolbar[] = {
185
186         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Select, move and modify objects"),
187                                 gl_tools_arrow_cb, GL_STOCK_PIXMAP_ARROW),
188
189         GNOMEUIINFO_SEPARATOR,
190
191         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create text object"),
192                                 gl_tools_text_cb, GL_STOCK_PIXMAP_TEXT),
193
194         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create box/rectangle object"),
195                                 gl_tools_box_cb, GL_STOCK_PIXMAP_BOX),
196
197         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create line object"),
198                                 gl_tools_line_cb, GL_STOCK_PIXMAP_LINE),
199
200         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create ellipse/circle object"),
201                                 gl_tools_ellipse_cb, GL_STOCK_PIXMAP_ELLIPSE),
202
203         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create image object"),
204                                 gl_tools_image_cb, GL_STOCK_PIXMAP_IMAGE),
205
206         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create barcode object"),
207                                 gl_tools_barcode_cb, GL_STOCK_PIXMAP_BARCODE),
208
209         GNOMEUIINFO_SEPARATOR,
210
211         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom in"),
212                                 gl_tools_zoomin_cb, GL_STOCK_PIXMAP_ZOOMIN),
213
214         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom out"),
215                                 gl_tools_zoomout_cb, GL_STOCK_PIXMAP_ZOOMOUT),
216
217         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom to 1:1"),
218                                 gl_tools_zoom1to1_cb,
219                                 GL_STOCK_PIXMAP_ZOOM1TO1),
220
221         GNOMEUIINFO_SEPARATOR,
222
223         GNOMEUIINFO_ITEM_STOCK (NULL, N_("Merge properties"),
224                                 gl_tools_merge_properties_cb,
225                                 GL_STOCK_PIXMAP_MERGE),
226
227         GNOMEUIINFO_END
228 };
229
230 \f
231 /****************************************************************************/
232 /* Install menus templates in mdi.                                          */
233 /****************************************************************************/
234 void
235 gl_menu_install_menus (GnomeMDI * mdi)
236 {
237         gnome_mdi_set_menubar_template (mdi, menu_main);
238         gnome_mdi_set_child_list_path (mdi, GNOME_MENU_WINDOWS_PATH);
239 }
240
241 /****************************************************************************/
242 /* Install toolbar in application window.                                   */
243 /****************************************************************************/
244 void
245 gl_menu_install_toolbar (GnomeMDI * mdi)
246 {
247         gnome_mdi_set_toolbar_template (mdi, toolbar);
248 }
249
250 /*****************************************************************************/
251 /* Install drawing tools toolbar in application window.                      */
252 /*****************************************************************************/
253 void
254 gl_menu_install_tools_toolbar (GnomeMDI * mdi,
255                                GnomeApp * app)
256 {
257         GtkWidget *toolbar;
258
259         toolbar = gtk_toolbar_new (GTK_ORIENTATION_VERTICAL,
260                                    GTK_TOOLBAR_ICONS);
261
262         gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), tools_toolbar,
263                                           NULL, mdi);
264         gnome_app_add_toolbar (GNOME_APP (app), GTK_TOOLBAR (toolbar),
265                                "ToolsToolbar", GNOME_DOCK_ITEM_BEH_NORMAL,
266                                GNOME_DOCK_LEFT, 1, 1, 0);
267 }
268
269 /*--------------------------------------------------------------------------*/
270 /* PRIVATE about menu callback.                                             */
271 /*--------------------------------------------------------------------------*/
272 static void
273 about_cb (GtkWidget * widget,
274           gpointer data)
275 {
276         static GtkWidget *dialog = NULL;
277         GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data));
278
279         if (dialog != NULL) {
280                 g_assert (GTK_WIDGET_REALIZED (dialog));
281                 gdk_window_show (dialog->window);
282                 gdk_window_raise (dialog->window);
283         } else {
284                 const gchar *authors[] = {
285                         "Jim Evins <evins@snaught.com>",
286                         NULL
287                 };
288                 gchar *copy_text = "Copyright 2001 Jim Evins";
289                 gchar *about_text =
290                     _("A label and business card creation program for GNOME.\n"
291                       " \n"
292                       "Glabels is free software; you can redistribute it and/or modify it "
293                       "under the terms of the GNU General Public License as published by "
294                       "the Free Software Foundation; either version 2 of the License, or "
295                       "(at your option) any later version.\n" " \n"
296                       "This program is distributed in the hope that it will be useful, but "
297                       "WITHOUT ANY WARRANTY; without even the implied warranty of "
298                       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU "
299                       "General Public License for more details.\n");
300
301                 dialog = gnome_about_new ("glabels", VERSION,
302                                           copy_text, authors, about_text,
303                                           LOGO_PIXMAP);
304                 gtk_window_set_transient_for (GTK_WINDOW (dialog),
305                                               GTK_WINDOW (app));
306
307                 gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
308                                     GTK_SIGNAL_FUNC (gtk_widget_destroyed),
309                                     &dialog);
310
311                 gtk_widget_show (dialog);
312         }
313
314 }
315
316 /*--------------------------------------------------------------------------*/
317 /* PRIVATE.  place-holder callback.                                         */
318 /*--------------------------------------------------------------------------*/
319 static void
320 nothing_cb (GtkWidget * widget,
321             gpointer data)
322 {
323         GtkWidget *dialog;
324         GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data));
325
326         dialog = gnome_ok_dialog (_("Function is not implemented!"));
327         gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (app));
328 }