2
* (GBONDS) GNOME based Savings Bond Inventory Program
4
* commands.c: gbonds commands module
6
* Copyright (C) 2001-2003 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>
32
#include "print-dialog.h"
33
#include "prefs-dialog.h"
36
#define LOGO_PIXMAP gnome_program_locate_file (NULL,\
37
GNOME_FILE_DOMAIN_APP_PIXMAP,\
38
"gbonds/gbonds_logo.png",\
42
/****************************************************************************/
43
/* File->New command. */
44
/****************************************************************************/
46
gb_cmd_file_new (BonoboUIComponent *uic,
48
const gchar *verbname)
50
gbWindow *window = GB_WINDOW (user_data);
52
gb_debug (DEBUG_COMMANDS, "");
54
gb_file_new (GTK_WINDOW(window));
57
/****************************************************************************/
58
/* File->Open command. */
59
/****************************************************************************/
61
gb_cmd_file_open (BonoboUIComponent *uic,
63
const gchar *verbname)
65
gbWindow *window = GB_WINDOW (user_data);
67
gb_debug (DEBUG_COMMANDS, "");
69
g_return_if_fail (window && GB_IS_WINDOW(window));
71
gb_file_open (GTK_WINDOW(window));
74
/****************************************************************************/
75
/* File->Import command. */
76
/****************************************************************************/
78
gb_cmd_file_import (BonoboUIComponent *uic,
80
const gchar *verbname)
82
gbWindow *window = GB_WINDOW (user_data);
84
gb_debug (DEBUG_COMMANDS, "");
86
g_return_if_fail (window && GB_IS_WINDOW(window));
88
gb_file_import (GTK_WINDOW(window));
91
/****************************************************************************/
92
/* File->Save command. */
93
/****************************************************************************/
95
gb_cmd_file_save (BonoboUIComponent *uic,
97
const gchar *verbname)
99
gbWindow *window = GB_WINDOW (user_data);
101
gb_debug (DEBUG_COMMANDS, "");
103
g_return_if_fail (window && GB_IS_WINDOW(window));
105
gb_file_save (GB_VIEW(window->view)->doc, GTK_WINDOW(window));
108
/****************************************************************************/
109
/* File->Save_as command. */
110
/****************************************************************************/
112
gb_cmd_file_save_as (BonoboUIComponent *uic,
114
const gchar *verbname)
116
gbWindow *window = GB_WINDOW (user_data);
118
gb_debug (DEBUG_COMMANDS, "");
120
g_return_if_fail (window && GB_IS_WINDOW(window));
122
gb_file_save_as (GB_VIEW(window->view)->doc, GTK_WINDOW(window));
125
/****************************************************************************/
126
/* File->Print command. */
127
/****************************************************************************/
129
gb_cmd_file_print (BonoboUIComponent *uic,
131
const gchar *verbname)
133
gbWindow *window = GB_WINDOW (user_data);
135
gb_debug (DEBUG_COMMANDS, "");
137
g_return_if_fail (window && GB_IS_WINDOW(window));
139
gb_print_dialog (GB_VIEW(window->view), BONOBO_WINDOW(window));
143
/****************************************************************************/
144
/* File->Close command. */
145
/****************************************************************************/
147
gb_cmd_file_close (BonoboUIComponent *uic,
149
const gchar *verbname)
151
gbWindow *window = GB_WINDOW (user_data);
153
gb_debug (DEBUG_COMMANDS, "");
155
g_return_if_fail (window && GB_IS_WINDOW(window));
157
gb_file_close (window);
160
/****************************************************************************/
161
/* File->Exit command. */
162
/****************************************************************************/
164
gb_cmd_file_exit (BonoboUIComponent *uic,
166
const gchar *verbname)
168
gbWindow *window = GB_WINDOW (user_data);
170
gb_debug (DEBUG_COMMANDS, "");
172
g_return_if_fail (window && GB_IS_WINDOW(window));
178
/****************************************************************************/
179
/* Edit->Cut command. */
180
/****************************************************************************/
182
gb_cmd_edit_cut (BonoboUIComponent *uic,
184
const gchar *verbname)
186
gbWindow *window = GB_WINDOW (user_data);
188
gb_debug (DEBUG_COMMANDS, "");
190
g_return_if_fail (window && GB_IS_WINDOW(window));
192
gb_view_cut (GB_VIEW(window->view));
195
/****************************************************************************/
196
/* Edit->Copy command. */
197
/****************************************************************************/
199
gb_cmd_edit_copy (BonoboUIComponent *uic,
201
const gchar *verbname)
203
gbWindow *window = GB_WINDOW (user_data);
205
gb_debug (DEBUG_COMMANDS, "");
207
g_return_if_fail (window && GB_IS_WINDOW(window));
209
gb_view_copy (GB_VIEW(window->view));
212
/****************************************************************************/
213
/* Edit->Paste command. */
214
/****************************************************************************/
216
gb_cmd_edit_paste (BonoboUIComponent *uic,
218
const gchar *verbname)
220
gbWindow *window = GB_WINDOW (user_data);
222
gb_debug (DEBUG_COMMANDS, "");
224
g_return_if_fail (window && GB_IS_WINDOW(window));
226
gb_view_paste (GB_VIEW(window->view));
230
/****************************************************************************/
231
/* Edit->Add command. */
232
/****************************************************************************/
234
gb_cmd_edit_add (BonoboUIComponent *uic,
236
const gchar *verbname)
238
gbWindow *window = GB_WINDOW (user_data);
240
gb_debug (DEBUG_COMMANDS, "");
242
g_return_if_fail (window && GB_IS_WINDOW(window));
244
gb_edit_add_bond (GB_VIEW(window->view), BONOBO_WINDOW(window));
247
/****************************************************************************/
248
/* Edit->Delete command. */
249
/****************************************************************************/
251
gb_cmd_edit_delete (BonoboUIComponent *uic,
253
const gchar *verbname)
255
gbWindow *window = GB_WINDOW (user_data);
257
gb_debug (DEBUG_COMMANDS, "");
259
g_return_if_fail (window && GB_IS_WINDOW(window));
261
gb_edit_delete_bonds (GB_VIEW(window->view), BONOBO_WINDOW(window));
264
/****************************************************************************/
265
/* Edit->Title command. */
266
/****************************************************************************/
268
gb_cmd_edit_title (BonoboUIComponent *uic,
270
const gchar *verbname)
272
gbWindow *window = GB_WINDOW (user_data);
274
gb_debug (DEBUG_COMMANDS, "");
276
g_return_if_fail (window && GB_IS_WINDOW(window));
278
gb_edit_title (GB_VIEW(window->view), BONOBO_WINDOW(window));
281
/****************************************************************************/
282
/* Edit->Select_all command. */
283
/****************************************************************************/
285
gb_cmd_edit_select_all (BonoboUIComponent *uic,
287
const gchar *verbname)
289
gbWindow *window = GB_WINDOW (user_data);
291
gb_debug (DEBUG_COMMANDS, "");
293
g_return_if_fail (window && GB_IS_WINDOW(window));
295
gb_view_select_all (GB_VIEW(window->view));
298
/****************************************************************************/
299
/* Edit->Select_all command. */
300
/****************************************************************************/
302
gb_cmd_edit_unselect_all (BonoboUIComponent *uic,
304
const gchar *verbname)
306
gbWindow *window = GB_WINDOW (user_data);
308
gb_debug (DEBUG_COMMANDS, "");
310
g_return_if_fail (window && GB_IS_WINDOW(window));
312
gb_view_unselect_all (GB_VIEW(window->view));
315
/****************************************************************************/
316
/* Settings->Preferences command. */
317
/****************************************************************************/
319
gb_cmd_settings_preferences (BonoboUIComponent *uic,
321
const gchar *verbname)
323
gbWindow *window = GB_WINDOW (user_data);
324
static GtkWidget *dlg = NULL;
326
gb_debug (DEBUG_COMMANDS, "");
328
g_return_if_fail (window && GB_IS_WINDOW(window));
332
gtk_window_present (GTK_WINDOW (dlg));
333
gtk_window_set_transient_for (GTK_WINDOW (dlg),
339
dlg = gb_prefs_dialog_new (GTK_WINDOW(window));
341
g_signal_connect (G_OBJECT (dlg), "destroy",
342
G_CALLBACK (gtk_widget_destroyed), &dlg);
344
gtk_widget_show (dlg);
347
/****************************************************************************/
348
/* Settings->Update command. */
349
/****************************************************************************/
351
gb_cmd_settings_update (BonoboUIComponent *uic,
353
const gchar *verbname)
355
gbWindow *window = GB_WINDOW (user_data);
357
gb_debug (DEBUG_COMMANDS, "");
359
g_return_if_fail (window && GB_IS_WINDOW(window));
365
/****************************************************************************/
366
/* Help->Contents command. */
367
/****************************************************************************/
369
gb_cmd_help_contents (BonoboUIComponent *uic,
371
const gchar *verbname)
373
gbWindow *window = GB_WINDOW (user_data);
374
GError *error = NULL;
376
gb_debug (DEBUG_COMMANDS, "");
378
g_return_if_fail (window && GB_IS_WINDOW(window));
380
gnome_help_display_with_doc_id (NULL, NULL, "gbonds.xml", NULL, &error);
384
g_warning (error->message);
386
g_error_free (error);
390
/****************************************************************************/
391
/* Help->About command. */
392
/****************************************************************************/
394
gb_cmd_help_about (BonoboUIComponent *uic,
396
const gchar *verbname)
398
gbWindow *window = GB_WINDOW (user_data);
399
static GtkWidget *about = NULL;
400
GdkPixbuf *pixbuf = NULL;
402
gchar *copy_text = "Copyright 2001-2003 Jim Evins";
404
_("A savings bond inventory program for GNOME.\n"
406
"Gbonds is free software; you can redistribute it and/or modify it "
407
"under the terms of the GNU General Public License as published by "
408
"the Free Software Foundation; either version 2 of the License, or "
409
"(at your option) any later version.\n" " \n"
410
"This program is distributed in the hope that it will be useful, but "
411
"WITHOUT ANY WARRANTY; without even the implied warranty of "
412
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU "
413
"General Public License for more details.\n"
415
"DISCLAIMER: GBonds is not affiliated with or endorsed by the "
416
"U.S. Treasury or the U.S. Government.");
419
"Jim Evins <evins@snaught.com>",
421
_("See the file AUTHORS for additional credits,"),
422
_("or visit http://snaught.com/gbonds"),
426
gchar *documenters[] = {
431
gchar *translator_credits = _("");
433
gb_debug (DEBUG_COMMANDS, "");
435
g_return_if_fail (window && GB_IS_WINDOW(window));
439
gdk_window_show (about->window);
440
gdk_window_raise (about->window);
444
pixbuf = gdk_pixbuf_new_from_file ( LOGO_PIXMAP, NULL);
446
about = gnome_about_new (_("gbonds"), VERSION,
449
(const char **)authors,
454
gtk_window_set_transient_for (GTK_WINDOW (about),
455
GTK_WINDOW (window));
457
gtk_window_set_destroy_with_parent (GTK_WINDOW (about), TRUE);
460
g_object_unref (pixbuf);
462
g_signal_connect (G_OBJECT (about), "destroy",
463
G_CALLBACK (gtk_widget_destroyed), &about);
465
gtk_widget_show (about);