25 #include <glib/gi18n.h>
34 #if !(_WIN32_WINNT >= 0x0500)
35 #error "_WIN32_WINNT must be defined >= 0x0500"
45 {
"unlink-tempfile",
'u', 0, G_OPTION_ARG_NONE, &
unlink_temp_file, N_(
"Delete the temporary file"), NULL },
46 {
"print-settings",
'p', 0, G_OPTION_ARG_FILENAME, &
print_settings, N_(
"Print settings file"), N_(
"FILE") },
53 GFile *file, *tempdir;
55 file = g_file_new_for_path (filename);
56 tempdir = g_file_new_for_path (g_get_tmp_dir ());
58 if (g_file_has_prefix (file, tempdir)) {
59 g_file_delete (file, NULL, NULL);
62 g_object_unref (file);
63 g_object_unref (tempdir);
85 uri = g_file_get_uri (file);
88 g_signal_connect (job,
"finished",
100 gtk_window_present (GTK_WINDOW (window));
116 g_application_quit (application);
126 g_object_unref (model);
129 path = g_file_get_path (file);
133 gtk_window_present (GTK_WINDOW (window));
139 GtkApplication *application;
140 GOptionContext *context;
141 GError *error = NULL;
146 if (fileno (stdout) != -1 &&
147 _get_osfhandle (fileno (stdout)) != -1)
153 typedef BOOL (* WINAPI AttachConsole_t) (DWORD);
155 AttachConsole_t p_AttachConsole =
156 (AttachConsole_t) GetProcAddress (GetModuleHandle (
"kernel32.dll"),
"AttachConsole");
158 if (p_AttachConsole != NULL && p_AttachConsole (ATTACH_PARENT_PROCESS))
160 freopen (
"CONOUT$",
"w", stdout);
161 dup2 (fileno (stdout), 1);
162 freopen (
"CONOUT$",
"w", stderr);
163 dup2 (fileno (stderr), 2);
172 bind_textdomain_codeset (GETTEXT_PACKAGE,
"UTF-8");
173 textdomain (GETTEXT_PACKAGE);
176 context = g_option_context_new (
_(
"GNOME Document Previewer"));
177 g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
178 g_option_context_add_main_entries (context,
goption_options, GETTEXT_PACKAGE);
180 g_option_context_add_group (context, gtk_get_option_group (
TRUE));
182 if (!g_option_context_parse (context, &argc, &argv, &error)) {
183 g_printerr (
"Error parsing command line arguments: %s\n", error->message);
184 g_error_free (error);
185 g_option_context_free (context);
188 g_option_context_free (context);
191 g_printerr (
"File argument is required\n");
193 }
else if (argc > 2) {
194 g_printerr (
"Too many files\n");
198 path = g_filename_from_uri (argv[1], NULL, NULL);
199 if (!g_file_test (argv[1], G_FILE_TEST_IS_REGULAR) && !g_file_test (path, G_FILE_TEST_IS_REGULAR)) {
200 g_printerr (
"Filename \"%s\" does not exist or is not a regular file\n", argv[1]);
210 g_set_application_name (
_(
"GNOME Document Previewer"));
211 gtk_window_set_default_icon_name (
"evince");
213 application = gtk_application_new (NULL,
214 G_APPLICATION_NON_UNIQUE |
215 G_APPLICATION_HANDLES_OPEN);
216 g_signal_connect (application,
"activate", G_CALLBACK (
activate_cb), NULL);
217 g_signal_connect (application,
"open", G_CALLBACK (
open_cb), NULL);
219 status = g_application_run (G_APPLICATION (application), argc, argv);