finch/libgnt/gnttextview.c

changeset 18778
7cf5400593b8
parent 18604
2ff126dbae16
child 18791
12003d1b25bf
equal deleted inserted replaced
18777:3872ae99716a 18778:7cf5400593b8
24 #include "gnttextview.h" 24 #include "gnttextview.h"
25 #include "gntutils.h" 25 #include "gntutils.h"
26 26
27 #include <stdlib.h> 27 #include <stdlib.h>
28 #include <string.h> 28 #include <string.h>
29 #include <unistd.h>
29 30
30 enum 31 enum
31 { 32 {
32 SIGS = 1, 33 SIGS = 1,
33 }; 34 };
793 void gnt_text_view_set_flag(GntTextView *view, GntTextViewFlag flag) 794 void gnt_text_view_set_flag(GntTextView *view, GntTextViewFlag flag)
794 { 795 {
795 view->flags |= flag; 796 view->flags |= flag;
796 } 797 }
797 798
799 static void
800 pager_end_cb(int status, gpointer data)
801 {
802 unlink(data);
803 g_free(data);
804 }
805
798 static gboolean 806 static gboolean
799 check_for_pager_cb(GntWidget *widget, const char *key, GntTextView *view) 807 check_for_pager_cb(GntWidget *widget, const char *key, GntTextView *view)
800 { 808 {
801 static const char *combin = NULL; 809 static const char *combin = NULL;
802 char *argv[] = {NULL, NULL, NULL}; 810 char *argv[] = {NULL, NULL, NULL};
803 static char path[1024]; 811 static char path[1024];
804 static int len = -1; 812 static int len = -1;
805 FILE *file; 813 FILE *file;
814 gboolean ret;
806 815
807 if (combin == NULL) { 816 if (combin == NULL) {
808 combin = gnt_key_translate(gnt_style_get_from_name("pager", "key")); 817 combin = gnt_key_translate(gnt_style_get_from_name("pager", "key"));
809 if (combin == NULL) 818 if (combin == NULL)
810 combin = "\033" "v"; 819 combin = "\033" "v";
824 fprintf(file, "%s", view->string->str); 833 fprintf(file, "%s", view->string->str);
825 fclose(file); 834 fclose(file);
826 argv[0] = gnt_style_get_from_name("pager", "path"); 835 argv[0] = gnt_style_get_from_name("pager", "path");
827 argv[0] = argv[0] ? argv[0] : getenv("PAGER"); 836 argv[0] = argv[0] ? argv[0] : getenv("PAGER");
828 argv[0] = argv[0] ? argv[0] : "less"; 837 argv[0] = argv[0] ? argv[0] : "less";
829 argv[1] = path; 838 argv[1] = g_strdup(path);
830 return gnt_giveup_console(NULL, argv, NULL, NULL, NULL, NULL); 839 ret = gnt_giveup_console(NULL, argv, NULL, NULL, NULL, NULL, pager_end_cb, argv[1]);
840 if (!ret)
841 g_free(argv[1]);
842 return ret;
831 } 843 }
832 844
833 void gnt_text_view_attach_pager_widget(GntTextView *view, GntWidget *pager) 845 void gnt_text_view_attach_pager_widget(GntTextView *view, GntWidget *pager)
834 { 846 {
835 g_signal_connect(pager, "key_pressed", G_CALLBACK(check_for_pager_cb), view); 847 g_signal_connect(pager, "key_pressed", G_CALLBACK(check_for_pager_cb), view);

mercurial