Mercurial > geeqie
comparison src/editors.c @ 1402:611c25ef73f4
Cleanup and minor fixes.
author | zas_ |
---|---|
date | Sun, 08 Mar 2009 20:49:48 +0000 |
parents | 67573155210c |
children | 03384485676d |
comparison
equal
deleted
inserted
replaced
1401:e18871df295f | 1402:611c25ef73f4 |
---|---|
273 { | 273 { |
274 editor->ext_list = editor_mime_types_to_extensions(mime_types); | 274 editor->ext_list = editor_mime_types_to_extensions(mime_types); |
275 g_strfreev(mime_types); | 275 g_strfreev(mime_types); |
276 if (!editor->ext_list) editor->hidden = TRUE; | 276 if (!editor->ext_list) editor->hidden = TRUE; |
277 } | 277 } |
278 } | |
278 | 279 |
279 } | |
280 | |
281 | |
282 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Keep-Fullscreen", NULL)) editor->flags |= EDITOR_KEEP_FS; | 280 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Keep-Fullscreen", NULL)) editor->flags |= EDITOR_KEEP_FS; |
283 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose", NULL)) editor->flags |= EDITOR_VERBOSE; | 281 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose", NULL)) editor->flags |= EDITOR_VERBOSE; |
284 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose-Multi", NULL)) editor->flags |= EDITOR_VERBOSE_MULTI; | 282 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Verbose-Multi", NULL)) editor->flags |= EDITOR_VERBOSE_MULTI; |
285 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Filter", NULL)) editor->flags |= EDITOR_DEST; | 283 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "X-Geeqie-Filter", NULL)) editor->flags |= EDITOR_DEST; |
286 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Terminal", NULL)) editor->flags |= EDITOR_TERMINAL; | 284 if (g_key_file_get_boolean(key_file, DESKTOP_GROUP, "Terminal", NULL)) editor->flags |= EDITOR_TERMINAL; |
287 | |
288 | 285 |
289 editor->flags |= editor_command_parse(editor, NULL, NULL); | 286 editor->flags |= editor_command_parse(editor, NULL, NULL); |
290 g_key_file_free(key_file); | 287 g_key_file_free(key_file); |
291 | 288 |
292 return TRUE; | 289 return TRUE; |
313 return; | 310 return; |
314 } | 311 } |
315 while ((dir = readdir(dp)) != NULL) | 312 while ((dir = readdir(dp)) != NULL) |
316 { | 313 { |
317 gchar *namel = dir->d_name; | 314 gchar *namel = dir->d_name; |
318 size_t len = strlen(namel); | |
319 | 315 |
320 if (len > 8 && g_ascii_strncasecmp(namel + len - 8, ".desktop", 8) == 0) | 316 if (g_str_has_suffix(namel, ".desktop")) |
321 { | 317 { |
322 gchar *name = path_to_utf8(namel); | 318 gchar *name = path_to_utf8(namel); |
323 gchar *dpath = g_build_filename(path, name, NULL); | 319 gchar *dpath = g_build_filename(path, name, NULL); |
324 editor_read_desktop_file(dpath); | 320 editor_read_desktop_file(dpath); |
325 g_free(dpath); | 321 g_free(dpath); |
371 static void editor_list_add_cb(gpointer key, gpointer value, gpointer data) | 367 static void editor_list_add_cb(gpointer key, gpointer value, gpointer data) |
372 { | 368 { |
373 GList **listp = data; | 369 GList **listp = data; |
374 EditorDescription *editor = value; | 370 EditorDescription *editor = value; |
375 | 371 |
376 /* do not show the special commands in any list, they are called explicitelly */ | 372 /* do not show the special commands in any list, they are called explicitly */ |
377 if (strcmp(editor->key, CMD_COPY) == 0 || | 373 if (strcmp(editor->key, CMD_COPY) == 0 || |
378 strcmp(editor->key, CMD_MOVE) == 0 || | 374 strcmp(editor->key, CMD_MOVE) == 0 || |
379 strcmp(editor->key, CMD_RENAME) == 0 || | 375 strcmp(editor->key, CMD_RENAME) == 0 || |
380 strcmp(editor->key, CMD_DELETE) == 0 || | 376 strcmp(editor->key, CMD_DELETE) == 0 || |
381 strcmp(editor->key, CMD_FOLDER) == 0) return; | 377 strcmp(editor->key, CMD_FOLDER) == 0) return; |
385 | 381 |
386 static gint editor_sort(gconstpointer a, gconstpointer b) | 382 static gint editor_sort(gconstpointer a, gconstpointer b) |
387 { | 383 { |
388 const EditorDescription *ea = a; | 384 const EditorDescription *ea = a; |
389 const EditorDescription *eb = b; | 385 const EditorDescription *eb = b; |
390 int ret; | 386 gint ret; |
391 | 387 |
392 ret = strcmp(ea->menu_path, eb->menu_path); | 388 ret = strcmp(ea->menu_path, eb->menu_path); |
393 if (ret != 0) return ret; | 389 if (ret != 0) return ret; |
394 | 390 |
395 return g_utf8_collate(ea->name, eb->name); | 391 return g_utf8_collate(ea->name, eb->name); |
572 | 568 |
573 static gchar *editor_command_path_parse(const FileData *fd, PathType type, const EditorDescription *editor) | 569 static gchar *editor_command_path_parse(const FileData *fd, PathType type, const EditorDescription *editor) |
574 { | 570 { |
575 GString *string; | 571 GString *string; |
576 gchar *pathl; | 572 gchar *pathl; |
577 const gchar *p = NULL; | 573 const gchar *p; |
578 | 574 |
579 string = g_string_new(""); | 575 string = g_string_new(""); |
580 | 576 |
581 if (type == PATH_FILE || type == PATH_FILE_URL) | 577 if (type == PATH_FILE || type == PATH_FILE_URL) |
582 { | 578 { |
622 p = fd->change->dest; | 618 p = fd->change->dest; |
623 else | 619 else |
624 p = ""; | 620 p = ""; |
625 } | 621 } |
626 | 622 |
623 g_assert(p); | |
627 while (*p != '\0') | 624 while (*p != '\0') |
628 { | 625 { |
629 /* must escape \, ", `, and $ to avoid problems, | 626 /* must escape \, ", `, and $ to avoid problems, |
630 * we assume system shell supports bash-like escaping | 627 * we assume system shell supports bash-like escaping |
631 */ | 628 */ |
638 } | 635 } |
639 | 636 |
640 if (type == PATH_FILE_URL) g_string_prepend(string, "file://"); | 637 if (type == PATH_FILE_URL) g_string_prepend(string, "file://"); |
641 pathl = path_from_utf8(string->str); | 638 pathl = path_from_utf8(string->str); |
642 g_string_free(string, TRUE); | 639 g_string_free(string, TRUE); |
640 | |
641 if (pathl && !pathl[0]) /* empty string case */ | |
642 { | |
643 g_free(pathl); | |
644 pathl = NULL; | |
645 } | |
643 | 646 |
644 return pathl; | 647 return pathl; |
645 } | 648 } |
646 | 649 |
647 | 650 |
859 args[n++] = command; | 862 args[n++] = command; |
860 args[n] = NULL; | 863 args[n] = NULL; |
861 | 864 |
862 if ((ed->flags & EDITOR_DEST) && fd->change && fd->change->dest) /* FIXME: error handling */ | 865 if ((ed->flags & EDITOR_DEST) && fd->change && fd->change->dest) /* FIXME: error handling */ |
863 { | 866 { |
864 setenv("GEEQIE_DESTINATION", fd->change->dest, TRUE); | 867 g_setenv("GEEQIE_DESTINATION", fd->change->dest, TRUE); |
865 } | 868 } |
866 else | 869 else |
867 { | 870 { |
868 unsetenv("GEEQIE_DESTINATION"); | 871 g_unsetenv("GEEQIE_DESTINATION"); |
869 } | 872 } |
870 | 873 |
871 ok = g_spawn_async_with_pipes(working_directory, args, NULL, | 874 ok = g_spawn_async_with_pipes(working_directory, args, NULL, |
872 G_SPAWN_DO_NOT_REAP_CHILD, /* GSpawnFlags */ | 875 G_SPAWN_DO_NOT_REAP_CHILD, /* GSpawnFlags */ |
873 NULL, NULL, | 876 NULL, NULL, |
938 | 941 |
939 fd = ed->list->data; | 942 fd = ed->list->data; |
940 | 943 |
941 if (ed->vd) | 944 if (ed->vd) |
942 { | 945 { |
943 editor_verbose_window_progress(ed, (ed->flags & EDITOR_FOR_EACH) ? fd->path : _("running...")); | 946 if (ed->flags & EDITOR_FOR_EACH) |
947 editor_verbose_window_progress(ed, fd->path); | |
948 else | |
949 editor_verbose_window_progress(ed, _("running...")); | |
944 } | 950 } |
945 ed->count++; | 951 ed->count++; |
946 | 952 |
947 error = editor_command_one(ed->editor, ed->list, ed); | 953 error = editor_command_one(ed->editor, ed->list, ed); |
948 if (!error && ed->vd) | 954 if (!error && ed->vd) |
955 } | 961 } |
956 } | 962 } |
957 | 963 |
958 if (!error) | 964 if (!error) |
959 return 0; | 965 return 0; |
960 else | 966 |
961 /* command was not started, call the finish immediately */ | 967 /* command was not started, call the finish immediately */ |
962 return editor_command_next_finish(ed, 0); | 968 return editor_command_next_finish(ed, 0); |
963 } | 969 } |
964 | 970 |
965 /* everything is done */ | 971 /* everything is done */ |
966 return editor_command_done(ed); | 972 return editor_command_done(ed); |
967 } | 973 } |
1010 { | 1016 { |
1011 gint flags; | 1017 gint flags; |
1012 | 1018 |
1013 if (ed->vd) | 1019 if (ed->vd) |
1014 { | 1020 { |
1015 const gchar *text; | |
1016 | |
1017 if (ed->count == ed->total) | 1021 if (ed->count == ed->total) |
1018 { | 1022 { |
1019 text = _("done"); | 1023 editor_verbose_window_progress(ed, _("done")); |
1020 } | 1024 } |
1021 else | 1025 else |
1022 { | 1026 { |
1023 text = _("stopped by user"); | 1027 editor_verbose_window_progress(ed, _("stopped by user")); |
1024 } | 1028 } |
1025 editor_verbose_window_progress(ed, text); | |
1026 editor_verbose_window_enable_close(ed->vd); | 1029 editor_verbose_window_enable_close(ed->vd); |
1027 } | 1030 } |
1028 | 1031 |
1029 /* free the not-handled items */ | 1032 /* free the not-handled items */ |
1030 if (ed->list) | 1033 if (ed->list) |