diff --git a/src/ChangeLog b/src/ChangeLog index 90c200911..faa472b0f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -9,6 +9,10 @@ * view.c (save_edit_changes): Changed return type to gboolean. * view.c (view_ok_to_quit): Changed return type to gboolean. Adjusted returned values. + * view.c (view_load): Changed return type to gboolean. Adjusted + returned values. + * view.c (view): Rewrote the code a little bit. + * view.h (view): Rewrote the comment. 2005-04-16 Roland Illig diff --git a/src/view.c b/src/view.c index 52b674af0..826938e35 100644 --- a/src/view.c +++ b/src/view.c @@ -584,8 +584,7 @@ init_growing_view (WView *view, const char *name, const char *filename) return NULL; } -/* Return zero on success, -1 on failure */ -int +gboolean view_load (WView *view, const char *_command, const char *_file, int start_line) { @@ -669,7 +668,7 @@ view_load (WView *view, const char *_command, const char *_file, if (!view_is_in_panel (view)) { message (1, MSG_ERROR, "%s", error); g_free (error); - return -1; + return FALSE; } } @@ -696,7 +695,7 @@ view_load (WView *view, const char *_command, const char *_file, view->hexview_in_text = FALSE; view->change_list = NULL; - return 0; + return TRUE; } static void @@ -2570,7 +2569,7 @@ view_dialog_callback (Dlg_head *h, dlg_msg_t msg, int parm) int view (const char *_command, const char *_file, int *move_dir_p, int start_line) { - int error; + gboolean succeeded; WView *wview; WButtonBar *bar; Dlg_head *view_dlg; @@ -2587,22 +2586,18 @@ view (const char *_command, const char *_file, int *move_dir_p, int start_line) add_widget (view_dlg, bar); add_widget (view_dlg, wview); - error = view_load (wview, _command, _file, start_line); - if (move_dir_p) - *move_dir_p = 0; - - /* Please note that if you add another widget, - * you have to modify view_adjust_size to - * be aware of it - */ - if (!error) { + succeeded = view_load (wview, _command, _file, start_line); + if (succeeded) { run_dlg (view_dlg); if (move_dir_p) *move_dir_p = wview->move_dir; + } else { + if (move_dir_p) + *move_dir_p = 0; } destroy_dlg (view_dlg); - return !error; + return succeeded; } static void diff --git a/src/view.h b/src/view.h index f11eb6b81..09268ffa3 100644 --- a/src/view.h +++ b/src/view.h @@ -9,10 +9,12 @@ WView *view_new (int y, int x, int cols, int lines, int is_panel); int view_load (WView *view, const char *_command, const char *_file, int start_line); -/* Command: view a _file, if _command != NULL we use popen on _command */ -/* move direction should be a pointer that will hold the direction in which */ -/* the user wants to move (-1 previous file, 1 next file, 0 do nothing) */ -int view (const char *_command, const char *_file, int *move_direction, +/* View a ''file'' or the output of a ''command'' in the internal viewer, + * starting in line ''start_line''. ''ret_move_direction'' may be NULL or + * point to a variable that will receive the direction in which the user + * wants to move (-1 = previous file, 1 = next file, 0 = do nothing). + */ +int view (const char *command, const char *file, int *ret_move_direction, int start_line); extern int mouse_move_pages_viewer;