* cmd.c (get_random_hint): Add "force" argument to ignore

timeout.  Adjust all dependencies.
* main.c (load_hint): Likewise.
* layout.c (setup_panels): Force updating the hint bar.
Original patch by Adam Byrtek <alpha@debian.org>
This commit is contained in:
Pavel Roskin 2003-02-05 08:37:21 +00:00
parent 620bf270aa
commit 0f865bcf8f
6 changed files with 26 additions and 12 deletions

View File

@ -1,3 +1,11 @@
2003-02-04 Pavel Roskin <proski@gnu.org>
* cmd.c (get_random_hint): Add "force" argument to ignore
timeout. Adjust all dependencies.
* main.c (load_hint): Likewise.
* layout.c (setup_panels): Force updating the hint bar.
Original patch by Adam Byrtek <alpha@debian.org>
2003-02-03 Pavel Roskin <proski@gnu.org> 2003-02-03 Pavel Roskin <proski@gnu.org>
* slint.c (getch): If there is EOF on the input, exit * slint.c (getch): If there is EOF on the input, exit

View File

@ -1200,8 +1200,11 @@ char *guess_message_value (void)
return g_strdup (locale); return g_strdup (locale);
} }
/* Returns a random hint */ /*
char *get_random_hint (void) * Return a random hint. If force is not 0, ignore the timeout.
*/
char *
get_random_hint (int force)
{ {
char *data, *result, *eol; char *data, *result, *eol;
int len; int len;
@ -1214,7 +1217,7 @@ char *get_random_hint (void)
time_t now; time_t now;
time (&now); time (&now);
if ((now - last) < 60) if (!force && (now - last) < 60)
return g_strdup (""); return g_strdup ("");
last = now; last = now;
#else #else
@ -1222,7 +1225,7 @@ char *get_random_hint (void)
static struct timeval tv; static struct timeval tv;
gettimeofday (&tv, NULL); gettimeofday (&tv, NULL);
if (!(tv.tv_sec> last_sec+60)) if (!force && !(tv.tv_sec > last_sec + 60))
return g_strdup (""); return g_strdup ("");
last_sec = tv.tv_sec; last_sec = tv.tv_sec;
#endif /* !SCO_FLAVOR */ #endif /* !SCO_FLAVOR */

View File

@ -49,7 +49,7 @@ void swap_cmd (void);
void view_other_cmd (void); void view_other_cmd (void);
void quick_cd_cmd (void); void quick_cd_cmd (void);
void save_setup_cmd (void); void save_setup_cmd (void);
char *get_random_hint (void); char *get_random_hint (int force);
void source_routing (void); void source_routing (void);
void user_file_menu_cmd (void); void user_file_menu_cmd (void);
char *guess_message_value (void); char *guess_message_value (void);

View File

@ -712,7 +712,7 @@ setup_panels (void)
} else } else
widget_set_size (&the_hint->widget, 0, 0, 0, 0); widget_set_size (&the_hint->widget, 0, 0, 0, 0);
load_hint (); load_hint (1);
update_xterm_title_path (); update_xterm_title_path ();
} }

View File

@ -789,7 +789,7 @@ _do_panel_cd (WPanel *panel, char *new_dir, enum cd_enum cd_type)
do_load_dir (&panel->dir, panel->sort_type, panel->reverse, do_load_dir (&panel->dir, panel->sort_type, panel->reverse,
panel->case_sensitive, panel->filter); panel->case_sensitive, panel->filter);
try_to_select (panel, get_parent_dir_name (panel->cwd, olddir)); try_to_select (panel, get_parent_dir_name (panel->cwd, olddir));
load_hint (); load_hint (0);
panel_update_contents (panel); panel_update_contents (panel);
update_xterm_title_path (); update_xterm_title_path ();
@ -1853,9 +1853,12 @@ update_xterm_title_path (void)
} }
} }
/* Load new hint and display it. */ /*
* Load new hint and display it.
* IF force is not 0, ignore the timeout.
*/
void void
load_hint (void) load_hint (int force)
{ {
char *hint; char *hint;
@ -1867,7 +1870,7 @@ load_hint (void)
return; return;
} }
if ((hint = get_random_hint ())) { if ((hint = get_random_hint (force))) {
if (*hint) if (*hint)
set_hintbar (hint); set_hintbar (hint);
g_free (hint); g_free (hint);
@ -1887,7 +1890,7 @@ setup_panels_and_run_mc (void)
xtoolkit_panel_setup (); xtoolkit_panel_setup ();
add_widget (midnight_dlg, the_hint); add_widget (midnight_dlg, the_hint);
load_hint (); load_hint (1);
add_widget (midnight_dlg, cmdline); add_widget (midnight_dlg, cmdline);
add_widget (midnight_dlg, the_prompt); add_widget (midnight_dlg, the_prompt);
add_widget (midnight_dlg, the_bar); add_widget (midnight_dlg, the_bar);

View File

@ -131,7 +131,7 @@ int quiet_quit_cmd (void); /* For cmd.c and command.c */
void untouch_bar (void); void untouch_bar (void);
void touch_bar (void); void touch_bar (void);
void update_xterm_title_path (void); void update_xterm_title_path (void);
void load_hint (void); void load_hint (int force);
void print_vfs_message(char *msg, ...) void print_vfs_message(char *msg, ...)
__attribute__ ((format (printf, 1, 2))); __attribute__ ((format (printf, 1, 2)));