2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2012 the Claws Mail team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "claws-features.h"
29 #include <glib/gi18n.h>
44 static gboolean claws_initialized
= FALSE
;
45 static gchar
*startup_dir
;
46 static void (*claws_idle_function
)(void) = NULL
;
49 * Parse program parameters and remove all parameters
50 * that have been processed. Arguments are pointers to
51 * original passed programm arguments and these will
52 * be modified leaving only unknown parameters for
55 * \param argc pointer to number of parameters
56 * \param argv pointer to array of parameter strings
58 static void parse_parameter(int *argc
, char ***argv
)
62 cm_return_if_fail(argc
!= NULL
);
63 cm_return_if_fail(argv
!= NULL
);
65 for (i
= 1; i
< *argc
;) {
66 if ((strcmp("--debug", (*argv
)[i
]) == 0) || (strcmp("-d", (*argv
)[i
]) == 0)) {
75 /* Remove NULL args from argv[] for further processing */
76 for (i
= 1; i
< *argc
; i
++) {
77 for (k
= i
; k
< *argc
; k
++)
78 if ((*argv
)[k
] != NULL
)
83 for (j
= i
+ k
; j
< *argc
; j
++)
84 (*argv
)[j
- k
] = (*argv
)[j
];
90 gboolean
claws_init(int *argc
, char ***argv
)
92 if (claws_initialized
)
98 startup_dir
= g_get_current_dir();
100 parse_parameter(argc
, argv
);
102 debug_print("Starting Claws Mail version %s\n", VERSION
);
104 setlocale(LC_ALL
, "");
106 bindtextdomain(PACKAGE
, get_locale_dir () );
107 bind_textdomain_codeset (PACKAGE
, "UTF-8");
109 #endif /*ENABLE_NLS*/
110 putenv("G_BROKEN_FILENAMES=1");
111 putenv("LIBOVERLAY_SCROLLBAR=0");
113 /* Disable GTK's overlay scrollbar feature, unless user has
114 * this environment variable already set. */
115 if (!g_getenv("GTK_OVERLAY_SCROLLING"))
116 putenv("GTK_OVERLAY_SCROLLING=0");
118 /* backup if old rc file exists */
119 if (is_file_exist(RC_DIR
)) {
120 if (g_rename(RC_DIR
, RC_DIR
".bak") < 0) {
121 FILE_OP_ERROR(RC_DIR
, "rename");
126 srand((gint
) time(NULL
));
128 claws_initialized
= TRUE
;
133 void claws_done(void)
141 const gchar
*claws_get_startup_dir(void)
146 guint
claws_get_version(void)
148 return VERSION_NUMERIC
;
151 void claws_register_idle_function (void (*idle_func
)(void))
153 claws_idle_function
= idle_func
;
156 void claws_do_idle(void)
158 if (claws_idle_function
!= NULL
)
159 claws_idle_function();