comparison src/editors.c @ 1397:a0bd58a6535f

In various Edit context menus, only display editors that match the file types in the selection.
author zas_
date Sun, 08 Mar 2009 13:23:25 +0000
parents fe4da037be21
children 7dfa34e4de15
comparison
equal deleted inserted replaced
1396:58f0b4586c8c 1397:a0bd58a6535f
57 57
58 static void editor_verbose_window_progress(EditorData *ed, const gchar *text); 58 static void editor_verbose_window_progress(EditorData *ed, const gchar *text);
59 static gint editor_command_next_start(EditorData *ed); 59 static gint editor_command_next_start(EditorData *ed);
60 static gint editor_command_next_finish(EditorData *ed, gint status); 60 static gint editor_command_next_finish(EditorData *ed, gint status);
61 static gint editor_command_done(EditorData *ed); 61 static gint editor_command_done(EditorData *ed);
62 static gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output);
63 62
64 /* 63 /*
65 *----------------------------------------------------------------------------- 64 *-----------------------------------------------------------------------------
66 * external editor routines 65 * external editor routines
67 *----------------------------------------------------------------------------- 66 *-----------------------------------------------------------------------------
644 643
645 return pathl; 644 return pathl;
646 } 645 }
647 646
648 647
649 static gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output) 648 gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output)
650 { 649 {
651 gint flags = 0; 650 gint flags = 0;
652 const gchar *p; 651 const gchar *p;
653 GString *result = NULL; 652 GString *result = NULL;
654 653
687 if (flags & EDITOR_SINGLE_COMMAND) 686 if (flags & EDITOR_SINGLE_COMMAND)
688 { 687 {
689 flags |= EDITOR_ERROR_INCOMPATIBLE; 688 flags |= EDITOR_ERROR_INCOMPATIBLE;
690 goto err; 689 goto err;
691 } 690 }
691 /* use the first file from the list */
692 if (!list || !list->data)
693 {
694 flags |= EDITOR_ERROR_NO_FILE;
695 goto err;
696 }
697 pathl = editor_command_path_parse((FileData *)list->data,
698 (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
699 editor);
700 if (!pathl)
701 {
702 flags |= EDITOR_ERROR_NO_FILE;
703 goto err;
704 }
692 if (output) 705 if (output)
693 { 706 {
694 /* use the first file from the list */
695 if (!list || !list->data)
696 {
697 flags |= EDITOR_ERROR_NO_FILE;
698 goto err;
699 }
700 pathl = editor_command_path_parse((FileData *)list->data,
701 (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
702 editor);
703 if (!pathl)
704 {
705 flags |= EDITOR_ERROR_NO_FILE;
706 goto err;
707 }
708 result = g_string_append_c(result, '"'); 707 result = g_string_append_c(result, '"');
709 result = g_string_append(result, pathl); 708 result = g_string_append(result, pathl);
710 g_free(pathl);
711 result = g_string_append_c(result, '"'); 709 result = g_string_append_c(result, '"');
712 } 710 }
711 g_free(pathl);
712
713 break; 713 break;
714 714
715 case 'F': 715 case 'F':
716 case 'U': 716 case 'U':
717 flags |= EDITOR_SINGLE_COMMAND; 717 flags |= EDITOR_SINGLE_COMMAND;
719 { 719 {
720 flags |= EDITOR_ERROR_INCOMPATIBLE; 720 flags |= EDITOR_ERROR_INCOMPATIBLE;
721 goto err; 721 goto err;
722 } 722 }
723 723
724 if (output)
725 { 724 {
726 /* use whole list */ 725 /* use whole list */
727 GList *work = list; 726 GList *work = list;
728 gboolean ok = FALSE; 727 gboolean ok = FALSE;
729 728
730 while (work) 729 while (work)
731 { 730 {
732 FileData *fd = work->data; 731 FileData *fd = work->data;
733 pathl = editor_command_path_parse(fd, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor); 732 pathl = editor_command_path_parse(fd, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor);
734
735 if (pathl) 733 if (pathl)
736 { 734 {
737 ok = TRUE; 735 ok = TRUE;
738 if (work != list) g_string_append_c(result, ' '); 736
739 result = g_string_append_c(result, '"'); 737 if (output)
740 result = g_string_append(result, pathl); 738 {
739 ok = TRUE;
740 if (work != list) g_string_append_c(result, ' ');
741 result = g_string_append_c(result, '"');
742 result = g_string_append(result, pathl);
743 result = g_string_append_c(result, '"');
744 }
741 g_free(pathl); 745 g_free(pathl);
742 result = g_string_append_c(result, '"');
743 } 746 }
744 work = work->next; 747 work = work->next;
745 } 748 }
746 if (!ok) 749 if (!ok)
747 { 750 {
800 } 803 }
801 return flags; 804 return flags;
802 } 805 }
803 806
804 807
805 static void editor_child_exit_cb (GPid pid, gint status, gpointer data) 808 static void editor_child_exit_cb(GPid pid, gint status, gpointer data)
806 { 809 {
807 EditorData *ed = data; 810 EditorData *ed = data;
808 g_spawn_close_pid(pid); 811 g_spawn_close_pid(pid);
809 ed->pid = -1; 812 ed->pid = -1;
810 813