233 GOptionContext *context;
234 GError *error = NULL;
239 if (fileno (stdout) != -1 &&
240 _get_osfhandle (fileno (stdout)) != -1)
246 typedef BOOL (* WINAPI AttachConsole_t) (DWORD);
248 AttachConsole_t p_AttachConsole =
249 (AttachConsole_t) GetProcAddress (GetModuleHandle (
"kernel32.dll"),
"AttachConsole");
251 if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
253 freopen (
"CONOUT$",
"w", stdout);
254 dup2 (fileno (stdout), 1);
255 freopen (
"CONOUT$",
"w", stderr);
256 dup2 (fileno (stderr), 2);
265 bind_textdomain_codeset (GETTEXT_PACKAGE,
"UTF-8");
266 textdomain (GETTEXT_PACKAGE);
269 context = g_option_context_new (N_(
"GNOME Document Viewer"));
270 g_option_context_set_translation_domain(context, GETTEXT_PACKAGE);
271 g_option_context_add_main_entries (context,
goption_options, GETTEXT_PACKAGE);
273 g_option_context_add_group (context, gtk_get_option_group (
TRUE));
275 if (!g_option_context_parse (context, &argc, &argv, &error)) {
276 g_printerr (
"Cannot parse arguments: %s\n", error->message);
277 g_error_free (error);
278 g_option_context_free (context);
282 g_option_context_free (context);
289 return retval ? 0 : 1;
298 g_set_application_name (
_(
"Document Viewer"));
299 gtk_window_set_default_icon_name (
"evince");
302 if (!g_application_register (G_APPLICATION (application), NULL, &error)) {
303 g_printerr (
"Failed to register: %s\n", error->message);
304 g_error_free (error);
314 g_chdir (g_get_home_dir ());
316 status = g_application_run (G_APPLICATION (application), 0, NULL);
322 g_object_unref (application);