3 * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include <glib/gi18n.h>
25 #include <libglabels.h>
26 #include "warning-handler.h"
27 #include "critical-error-handler.h"
28 #include "merge-init.h"
30 #include "mini-preview-pixbuf-cache.h"
32 #include "font-history.h"
33 #include "template-history.h"
39 /*========================================================*/
40 /* Private macros and constants. */
41 /*========================================================*/
44 /*========================================================*/
46 /*========================================================*/
49 /*========================================================*/
50 /* Local function prototypes */
51 /*========================================================*/
54 /****************************************************************************/
56 /****************************************************************************/
58 main (int argc, char **argv)
60 gchar **remaining_args = NULL;
61 GOptionEntry option_entries[] = {
62 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY,
63 &remaining_args, NULL, N_("[FILE...]") },
67 GOptionContext *option_context;
68 GList *file_list = NULL, *p;
73 bindtextdomain (GETTEXT_PACKAGE, GLABELS_LOCALE_DIR);
74 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
75 textdomain (GETTEXT_PACKAGE);
77 option_context = g_option_context_new (NULL);
78 g_option_context_set_summary (option_context,
79 _("Launch gLabels label and business card designer."));
80 g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);
83 /* Initialize program */
84 gtk_init( &argc, &argv );
85 if (!g_option_context_parse (option_context, &argc, &argv, &error))
87 g_print(_("%s\nRun '%s --help' to see a full list of available command line options.\n"),
88 error->message, argv[0]);
94 /* Install GUI handlers for critical error and warning messages */
95 gl_critical_error_handler_init();
96 gl_warning_handler_init();
98 /* Add glabels specific icons to search path */
99 gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
100 GLABELS_DATA_DIR G_DIR_SEPARATOR_S "icons");
102 /* Set default icon */
103 gtk_window_set_default_icon_name (GLABELS_ICON_NAME);
105 /* Initialize subsystems */
109 gl_mini_preview_pixbuf_cache_init ();
112 gl_template_history_init ();
113 gl_font_history_init ();
116 /* Parse args and build the list of files to be loaded at startup */
117 if (remaining_args != NULL) {
120 num_args = g_strv_length (remaining_args);
121 for (i = 0; i < num_args; ++i) {
122 utf8_filename = g_filename_to_utf8 (remaining_args[i], -1, NULL, NULL, NULL);
124 file_list = g_list_append (file_list, utf8_filename);
126 g_strfreev (remaining_args);
127 remaining_args = NULL;
131 /* Open files or create empty top-level window. */
132 for (p = file_list; p; p = p->next) {
133 win = gl_window_new_from_file (p->data);
134 gtk_widget_show_all (win);
137 if ( gl_window_get_window_list() == NULL ) {
138 win = gl_window_new ();
139 gtk_widget_show_all (win);
141 g_list_free (file_list);
144 /* Begin main loop */
153 * Local Variables: -- emacs
155 * c-basic-offset: 8 -- emacs
156 * tab-width: 8 -- emacs
157 * indent-tabs-mode: nil -- emacs