2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * commands.c: GLabels commands module
6 * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>.
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.
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.
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
26 #include <libgnome/libgnome.h>
27 #include <libgnomeui/libgnomeui.h>
31 #include "mdi-child.h"
36 #include "prefs-dialog.h"
39 #ifdef PACKAGE_DATA_DIR
40 #define LOGO_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-about-logo.png")
42 #define LOGO_PIXMAP gnome_pixmap_file("glabels/glabels-about-logo.png")
46 /****************************************************************************/
47 /* File->New command. */
48 /****************************************************************************/
50 gl_cmd_file_new (BonoboUIComponent *uic,
52 const gchar* verbname)
54 gl_debug (DEBUG_COMMANDS, "verbname: %s", verbname);
59 /****************************************************************************/
60 /* File->Open command. */
61 /****************************************************************************/
63 gl_cmd_file_open (BonoboUIComponent *uic,
65 const gchar* verbname)
67 BonoboMDIChild *active_child;
69 gl_debug (DEBUG_COMMANDS, "");
71 active_child = bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi));
73 gl_file_open ((glMDIChild*) active_child);
76 /****************************************************************************/
77 /* File->Save command. */
78 /****************************************************************************/
80 gl_cmd_file_save (BonoboUIComponent *uic,
82 const gchar* verbname)
84 glMDIChild *active_child;
86 gl_debug (DEBUG_COMMANDS, "");
88 active_child = GL_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)));
89 if (active_child == NULL)
92 gl_file_save (active_child);
95 /****************************************************************************/
96 /* File->Save_as command. */
97 /****************************************************************************/
99 gl_cmd_file_save_as (BonoboUIComponent *uic,
101 const gchar* verbname)
103 glMDIChild *active_child;
105 gl_debug (DEBUG_COMMANDS, "");
107 active_child = GL_MDI_CHILD (bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi)));
108 if (active_child == NULL)
111 gl_file_save_as (active_child);
114 /****************************************************************************/
115 /* File->Print command. */
116 /****************************************************************************/
118 gl_cmd_file_print (BonoboUIComponent *uic,
120 const gchar* verbname)
122 glLabel *label = glabels_get_active_label ();
123 BonoboWindow *win = glabels_get_active_window ();
125 gl_debug (DEBUG_COMMANDS, "");
127 g_return_if_fail (label != NULL);
128 g_return_if_fail (win != NULL);
130 gl_print_dialog (label, win);
134 /****************************************************************************/
135 /* File->Close command. */
136 /****************************************************************************/
138 gl_cmd_file_close (BonoboUIComponent *uic,
140 const gchar* verbname)
142 GtkWidget *active_view;
144 gl_debug (DEBUG_COMMANDS, "");
146 active_view = bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi));
148 if (active_view == NULL)
151 glabels_close_x_button_pressed = TRUE;
153 gl_file_close (active_view);
155 glabels_close_x_button_pressed = FALSE;
158 /****************************************************************************/
159 /* File->Close_all command. */
160 /****************************************************************************/
162 gl_cmd_file_close_all (BonoboUIComponent *uic,
164 const gchar* verbname)
166 gl_debug (DEBUG_COMMANDS, "");
168 glabels_close_x_button_pressed = TRUE;
170 gl_file_close_all ();
172 glabels_close_x_button_pressed = FALSE;
175 /****************************************************************************/
176 /* File->Exit command. */
177 /****************************************************************************/
179 gl_cmd_file_exit (BonoboUIComponent *uic,
181 const gchar* verbname)
183 gl_debug (DEBUG_COMMANDS, "");
185 glabels_exit_button_pressed = TRUE;
189 glabels_exit_button_pressed = FALSE;
193 /****************************************************************************/
194 /* Edit->Cut command. */
195 /****************************************************************************/
197 gl_cmd_edit_cut (BonoboUIComponent *uic,
199 const gchar* verbname)
203 active_view = GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)));
204 g_return_if_fail (active_view);
206 gl_view_cut (active_view);
209 /****************************************************************************/
210 /* Edit->Copy command. */
211 /****************************************************************************/
213 gl_cmd_edit_copy (BonoboUIComponent *uic,
215 const gchar* verbname)
219 active_view = GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)));
220 g_return_if_fail (active_view);
222 gl_view_copy (active_view);
225 /****************************************************************************/
226 /* Edit->Paste command. */
227 /****************************************************************************/
229 gl_cmd_edit_paste (BonoboUIComponent *uic,
231 const gchar* verbname)
235 active_view = GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)));
236 g_return_if_fail (active_view);
238 gl_view_paste (active_view);
242 /****************************************************************************/
243 /* Edit->Delete command. */
244 /****************************************************************************/
246 gl_cmd_edit_delete (BonoboUIComponent *uic,
248 const gchar* verbname)
252 active_view = GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi)));
253 g_return_if_fail (active_view);
255 gl_view_delete_selection (active_view);
259 /****************************************************************************/
260 /* Edit->Select_all command. */
261 /****************************************************************************/
263 gl_cmd_edit_select_all (BonoboUIComponent *uic,
265 const gchar* verbname)
270 GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI(glabels_mdi)));
272 g_return_if_fail (active_view);
274 gl_view_select_all (active_view);
277 /****************************************************************************/
278 /* Edit->Select_all command. */
279 /****************************************************************************/
281 gl_cmd_edit_unselect_all (BonoboUIComponent *uic,
283 const gchar* verbname)
288 GL_VIEW (bonobo_mdi_get_active_view (BONOBO_MDI(glabels_mdi)));
290 g_return_if_fail (active_view);
292 gl_view_unselect_all (active_view);
295 /****************************************************************************/
296 /* Settings->Preferences command. */
297 /****************************************************************************/
299 gl_cmd_settings_preferences (BonoboUIComponent *uic,
301 const gchar* verbname)
303 static GtkWidget *dlg = NULL;
305 gl_debug (DEBUG_COMMANDS, "");
309 gtk_window_present (GTK_WINDOW (dlg));
310 gtk_window_set_transient_for (GTK_WINDOW (dlg),
311 GTK_WINDOW (glabels_get_active_window ()));
316 dlg = gl_prefs_dialog_new (GTK_WINDOW (glabels_get_active_window ()));
318 g_signal_connect (G_OBJECT (dlg), "destroy",
319 G_CALLBACK (gtk_widget_destroyed), &dlg);
321 gtk_widget_show (dlg);
324 /****************************************************************************/
325 /* Help->Contents command. */
326 /****************************************************************************/
328 gl_cmd_help_contents (BonoboUIComponent *uic,
330 const gchar* verbname)
332 GError *error = NULL;
334 gl_debug (DEBUG_COMMANDS, "");
336 gnome_help_display_with_doc_id (NULL, NULL, "glabels.xml", NULL, &error);
340 g_warning (error->message);
342 g_error_free (error);
346 /****************************************************************************/
347 /* Help->About command. */
348 /****************************************************************************/
350 gl_cmd_help_about (BonoboUIComponent *uic,
352 const gchar* verbname)
354 static GtkWidget *about = NULL;
355 GdkPixbuf* pixbuf = NULL;
357 gchar *copy_text = "Copyright 2001-2002 Jim Evins";
359 _("A label and business card creation program for GNOME.\n"
361 "Glabels is free software; you can redistribute it and/or modify it "
362 "under the terms of the GNU General Public License as published by "
363 "the Free Software Foundation; either version 2 of the License, or "
364 "(at your option) any later version.\n" " \n"
365 "This program is distributed in the hope that it will be useful, but "
366 "WITHOUT ANY WARRANTY; without even the implied warranty of "
367 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
368 "General Public License for more details.\n");
372 "\tJim Evins <evins@snaught.com>",
374 _("See the file AUTHORS for additional acknowledgments,"),
375 _("or visit http://snaught.com/glabels"),
379 gchar *documenters[] = {
384 gchar *translator_credits = _("");
386 gl_debug (DEBUG_COMMANDS, "");
390 gdk_window_show (about->window);
391 gdk_window_raise (about->window);
395 pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL);
397 about = gnome_about_new (_("glabels"), VERSION,
400 (const char **)authors,
401 (const char **)documenters,
402 (const char *)translator_credits,
405 gtk_window_set_transient_for (GTK_WINDOW (about),
406 GTK_WINDOW (glabels_get_active_window ()));
408 gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
411 g_object_unref (pixbuf);
413 g_signal_connect (G_OBJECT (about), "destroy",
414 G_CALLBACK (gtk_widget_destroyed), &about);
416 gtk_widget_show (about);