2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * glabels.c: main program module
6 * Copyright (C) 2001 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 <libgnomeui/gnome-window-icon.h>
36 #ifdef PACKAGE_DATA_DIR
37 #define ICON_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-icon.png")
39 #define ICON_PIXMAP gnome_pixmap_file("glabels/glabels-icon.png")
42 /*============================================*/
44 /*============================================*/
45 static struct poptOption options[] = {
46 {NULL, '\0', 0, NULL, 0, NULL, NULL}
49 /*============================================*/
50 /* Private function prototypes */
51 /*============================================*/
52 static void session_die (GnomeClient * client,
53 gpointer client_data);
54 static gint save_session (GnomeClient * client,
56 GnomeSaveStyle save_style,
58 GnomeInteractStyle interact_style,
60 gpointer client_data);
63 /*****************************************************************************/
65 /*****************************************************************************/
74 GSList *p, *file_list = NULL;
77 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
80 gnome_init_with_popt_table (PACKAGE, VERSION,
81 argc, argv, options, 0, &pctx);
86 if (!g_file_exists (ICON_PIXMAP)) {
87 WARN ("Could not find %s", ICON_PIXMAP);
89 gnome_window_icon_set_default_from_file (ICON_PIXMAP);
91 /* argument parsing */
92 args = (char **) poptGetArgs (pctx);
93 for (i = 0; args && args[i]; i++) {
94 file_list = g_slist_append (file_list, args[i]);
96 poptFreeContext (pctx);
98 /* session management */
99 client = gnome_master_client ();
100 gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
101 GTK_SIGNAL_FUNC (save_session), argv[0]);
102 gtk_signal_connect (GTK_OBJECT (client), "die",
103 GTK_SIGNAL_FUNC (session_die), NULL);
110 mdi = gl_mdi_init ();
112 /* Any files on command line? */
114 for (p = file_list; p; p = p->next) {
115 if (gl_mdi_new_child_from_xml_file (p->data))
118 g_slist_free (file_list);
121 gnome_mdi_open_toplevel (mdi);
124 /* Now start main loop */
130 /*---------------------------------------------------------------------------*/
131 /* PRIVATE. Save Session signal callback. */
132 /*---------------------------------------------------------------------------*/
134 save_session (GnomeClient * client,
136 GnomeSaveStyle save_style,
138 GnomeInteractStyle interact_style,
140 gpointer client_data)
145 argv = g_malloc0 (4 * sizeof (gchar *));
148 argv[0] = client_data;
150 gnome_client_set_clone_command (client, argc, argv);
151 gnome_client_set_restart_command (client, argc, argv);
156 /*---------------------------------------------------------------------------*/
157 /* PRIVATE. Session Die signal callback. */
158 /*---------------------------------------------------------------------------*/
160 session_die (GnomeClient * client,
161 gpointer client_data)