| 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); |