2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * glabels.c: GLabels main 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
24 * This file is based on gedit2.c from gedit2:
26 * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence
27 * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi
32 #include <libgnome/libgnome.h>
33 #include <libgnomeui/libgnomeui.h>
34 #include <libgnomeui/gnome-window-icon.h>
46 #ifdef PACKAGE_DATA_DIR
47 #define ICON_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-icon.png")
49 #define ICON_PIXMAP gnome_pixmap_file("glabels/glabels-icon.png")
52 glMDI *glabels_mdi = NULL;
53 gboolean glabels_close_x_button_pressed = FALSE;
54 gboolean glabels_exit_button_pressed = FALSE;
56 static const struct poptOption options [] =
58 { "debug-view", '\0', POPT_ARG_NONE, &gl_debug_view, 0,
59 N_("Show view debugging messages."), NULL },
61 { "debug-item", '\0', POPT_ARG_NONE, &gl_debug_item, 0,
62 N_("Show item debugging messages."), NULL },
64 { "debug-print", '\0', POPT_ARG_NONE, &gl_debug_print, 0,
65 N_("Show printing debugging messages."), NULL },
67 { "debug-prefs", '\0', POPT_ARG_NONE, &gl_debug_prefs, 0,
68 N_("Show prefs debugging messages."), NULL },
70 { "debug-file", '\0', POPT_ARG_NONE, &gl_debug_file, 0,
71 N_("Show file debugging messages."), NULL },
73 { "debug-label", '\0', POPT_ARG_NONE, &gl_debug_label, 0,
74 N_("Show document debugging messages."), NULL },
76 { "debug-template", '\0', POPT_ARG_NONE, &gl_debug_template, 0,
77 N_("Show template debugging messages."), NULL },
79 { "debug-xml", '\0', POPT_ARG_NONE, &gl_debug_xml, 0,
80 N_("Show xml debugging messages."), NULL },
82 { "debug-merge", '\0', POPT_ARG_NONE, &gl_debug_merge, 0,
83 N_("Show document merge debugging messages."), NULL },
85 { "debug-commands", '\0', POPT_ARG_NONE, &gl_debug_commands, 0,
86 N_("Show commands debugging messages."), NULL },
88 { "debug-undo", '\0', POPT_ARG_NONE, &gl_debug_undo, 0,
89 N_("Show undo debugging messages."), NULL },
91 { "debug-recent", '\0', POPT_ARG_NONE, &gl_debug_recent, 0,
92 N_("Show recent debugging messages."), NULL },
94 { "debug-mdi", '\0', POPT_ARG_NONE, &gl_debug_mdi, 0,
95 N_("Show mdi debugging messages."), NULL },
97 { "debug-media-select", '\0', POPT_ARG_NONE, &gl_debug_media_select, 0,
98 N_("Show media select widget debugging messages."), NULL },
100 { "debug-mini-preview", '\0', POPT_ARG_NONE, &gl_debug_mini_preview, 0,
101 N_("Show mini preview widget debugging messages."), NULL },
103 { "debug-wdgt", '\0', POPT_ARG_NONE, &gl_debug_wdgt, 0,
104 N_("Show widget debugging messages."), NULL },
106 { "debug", '\0', POPT_ARG_NONE, &gl_debug_all, 0,
107 N_("Turn on all debugging messages."), NULL },
109 {NULL, '\0', 0, NULL, 0}
114 main (int argc, char **argv)
116 GValue value = { 0, };
117 GnomeProgram *program;
120 GList *file_list = NULL, *p;
123 bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALEDIR);
124 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
125 textdomain (GETTEXT_PACKAGE);
127 /* Initialize gnome program */
128 program = gnome_program_init ("glabels", VERSION,
129 LIBGNOMEUI_MODULE, argc, argv,
130 GNOME_PARAM_POPT_TABLE, options,
138 /* Set default icon */
139 if (!g_file_test (ICON_PIXMAP, G_FILE_TEST_EXISTS))
141 g_warning ("Could not find %s", ICON_PIXMAP);
145 gnome_window_icon_set_default_from_file (ICON_PIXMAP);
148 /* Load user preferences */
150 gl_prefs_load_settings ();
157 /* Parse args and build the list of files to be loaded at startup */
158 g_value_init (&value, G_TYPE_POINTER);
159 g_object_get_property (G_OBJECT (program),
160 GNOME_PARAM_POPT_CONTEXT, &value);
161 ctx = g_value_get_pointer (&value);
162 g_value_unset (&value);
163 args = (char**) poptGetArgs(ctx);
164 for (i = 0; args && args[i]; i++)
166 file_list = g_list_append (file_list, args[i]);
169 /* Create glabels_mdi and open the first top level window */
170 glabels_mdi = gl_mdi_new ();
171 bonobo_mdi_open_toplevel (BONOBO_MDI (glabels_mdi), NULL);
173 for (p = file_list; p; p = p->next) {
174 gl_file_open_real (p->data,
175 GTK_WINDOW(glabels_get_active_window()));
177 g_list_free (file_list);
186 glabels_get_active_window (void)
188 g_return_val_if_fail (glabels_mdi != NULL, NULL);
190 return bonobo_mdi_get_active_window (BONOBO_MDI (glabels_mdi));
194 glabels_get_active_label (void)
196 BonoboMDIChild *active_child;
198 g_return_val_if_fail (glabels_mdi != NULL, NULL);
200 active_child = bonobo_mdi_get_active_child (BONOBO_MDI (glabels_mdi));
202 if (active_child == NULL)
205 return GL_MDI_CHILD (active_child)->label;
209 glabels_get_active_view (void)
211 GtkWidget *active_view;
213 g_return_val_if_fail (glabels_mdi != NULL, NULL);
215 active_view = bonobo_mdi_get_active_view (BONOBO_MDI (glabels_mdi));
217 if (active_view == NULL)
220 return GL_VIEW (active_view);
224 glabels_get_top_windows (void)
226 g_return_val_if_fail (glabels_mdi != NULL, NULL);
228 return bonobo_mdi_get_windows (BONOBO_MDI (glabels_mdi));