32 #if !(_WIN32_WINNT >= 0x0500)
33 #error "_WIN32_WINNT must be defined >= 0x0500"
38 #define THUMBNAIL_SIZE 128
39 #define DEFAULT_SLEEP_TIME (15 * G_USEC_PER_SEC)
48 {
"size",
's', 0, G_OPTION_ARG_INT, &
size, NULL,
"SIZE" },
49 {
"no-limit",
'l', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &
time_limit,
"Don't limit the thumbnailing time to 15 seconds", NULL },
50 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &
file_arguments, NULL,
"<input> <ouput>" },
62 G_GNUC_NORETURN
static gpointer
65 const gchar *app_name;
72 app_name = g_get_application_name ();
74 app_name = g_get_prgname ();
75 g_printerr (
"%s couldn't process file: '%s'\n"
76 "Reason: Took too much time to process.\n",
88 g_thread_new (
"ThumbnailerTimer",
time_monitor, (gpointer) input);
101 g_object_unref (file);
110 info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI, G_FILE_QUERY_INFO_NONE, NULL, NULL);
113 target = g_strdup (g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_STANDARD_TARGET_URI));
114 g_object_unref (info);
122 if (g_file_has_uri_scheme (file,
"trash") !=
FALSE ||
123 g_file_has_uri_scheme (file,
"recent") !=
FALSE) {
126 return g_file_get_path (file);
134 GFile *tmp_file = NULL;
135 GError *error = NULL;
140 gchar *base_name, *
template;
142 base_name = g_file_get_basename (file);
143 template = g_strdup_printf (
"document.XXXXXX-%s", base_name);
149 g_printerr (
"Error loading remote document: %s\n", error->message);
150 g_error_free (error);
155 g_file_copy (file, tmp_file, G_FILE_COPY_OVERWRITE,
156 NULL, NULL, NULL, &error);
158 g_printerr (
"Error loading remote document: %s\n", error->message);
159 g_error_free (error);
160 g_object_unref (tmp_file);
164 uri = g_file_get_uri (tmp_file);
166 uri = g_filename_to_uri (path, NULL, NULL);
173 g_object_weak_ref (G_OBJECT (document),
178 g_object_unref (tmp_file);
186 g_error_free (error);
189 g_printerr (
"Error loading document: %s\n", error->message);
190 g_error_free (error);
201 double width, height;
212 g_object_unref (page);
214 if (pixbuf != NULL) {
215 if (gdk_pixbuf_save (pixbuf, thumbnail,
"png", NULL, NULL)) {
216 g_object_unref (pixbuf);
220 g_object_unref (pixbuf);
235 g_idle_add ((GSourceFunc)gtk_main_quit, NULL);
245 help = g_option_context_get_help (context,
TRUE, NULL);
246 g_print (
"%s", help);
254 GOptionContext *context;
258 GError *error = NULL;
260 setlocale (LC_ALL,
"");
262 context = g_option_context_new (
"- GNOME Document Thumbnailer");
265 if (!g_option_context_parse (context, &argc, &argv, &error)) {
266 g_printerr (
"%s\n", error->message);
267 g_error_free (error);
269 g_option_context_free (context);
276 if (!input || !output) {
278 g_option_context_free (context);
283 g_option_context_free (context);
286 g_printerr (
"Size cannot be smaller than 1 pixel\n");
296 file = g_file_new_for_commandline_arg (input);
298 g_object_unref (file);
311 gtk_init (&argc, &argv);
317 g_thread_new (
"ThmbnlrAsyncRndr",
323 g_object_unref (document);
330 g_object_unref (document);
336 g_object_unref (document);