Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-text / statusbar-items.c
index f8042c5c3eab3718b12f0c0ede4ed90e196358c0..dce98380d089697fc1a3fc287e8e5f5255459314 100644 (file)
@@ -290,15 +290,16 @@ static void item_lag(SBAR_ITEM_REC *item, int get_size_only)
        int lag, lag_unknown;
 
        server = active_win == NULL ? NULL : active_win->active_server;
-       lag = get_lag(server, &lag_unknown)/10;
+       lag = get_lag(server, &lag_unknown);
 
-       if (lag <= 0 || lag < settings_get_int("lag_min_show")) {
+       if (lag <= 0 || lag < settings_get_time("lag_min_show")) {
                /* don't print the lag item */
                if (get_size_only)
                        item->min_size = item->max_size = 0;
                return;
        }
 
+       lag /= 10;
        last_lag = lag;
        last_lag_unknown = lag_unknown;
 
@@ -321,8 +322,10 @@ static void lag_check_update(void)
        server = active_win == NULL ? NULL : active_win->active_server;
        lag = get_lag(server, &lag_unknown)/10;
 
-       if (lag < settings_get_int("lag_min_show"))
-                lag = 0;
+       if (lag < settings_get_time("lag_min_show"))
+               lag = 0;
+       else
+               lag /= 10;
 
        if (lag != last_lag || (lag > 0 && lag_unknown != last_lag_unknown))
                 statusbar_items_redraw("lag");
@@ -344,12 +347,13 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
 {
        GUI_ENTRY_REC *rec;
 
-       rec = g_hash_table_lookup(input_entries, item->bar);
+       rec = g_hash_table_lookup(input_entries, item->bar->config->name);
        if (rec == NULL) {
                rec = gui_entry_create(item->xpos, item->bar->real_ypos,
                                       item->size, term_type == TERM_TYPE_UTF8);
                gui_entry_set_active(rec);
-               g_hash_table_insert(input_entries, item->bar, rec);
+               g_hash_table_insert(input_entries,
+                                   g_strdup(item->bar->config->name), rec);
        }
 
        if (get_size_only) {
@@ -363,17 +367,6 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
        gui_entry_redraw(rec); /* FIXME: this is only necessary with ^L.. */
 }
 
-static void sig_statusbar_destroyed(STATUSBAR_REC *bar)
-{
-       GUI_ENTRY_REC *rec;
-
-       rec = g_hash_table_lookup(input_entries, bar);
-       if (rec != NULL) {
-               gui_entry_destroy(rec);
-               g_hash_table_remove(input_entries, bar);
-       }
-}
-
 static void read_settings(void)
 {
        if (active_entry != NULL)
@@ -382,13 +375,15 @@ static void read_settings(void)
 
 void statusbar_items_init(void)
 {
-       settings_add_int("misc", "lag_min_show", 100);
+       settings_add_time("misc", "lag_min_show", "1sec");
        settings_add_bool("lookandfeel", "actlist_moves", FALSE);
 
        statusbar_item_register("window", NULL, item_window_active);
        statusbar_item_register("window_empty", NULL, item_window_empty);
        statusbar_item_register("prompt", NULL, item_window_active);
        statusbar_item_register("prompt_empty", NULL, item_window_empty);
+       statusbar_item_register("topic", NULL, item_window_active);
+       statusbar_item_register("topic_empty", NULL, item_window_empty);
        statusbar_item_register("lag", NULL, item_lag);
        statusbar_item_register("act", NULL, item_act);
        statusbar_item_register("more", NULL, item_more);
@@ -416,9 +411,8 @@ void statusbar_items_init(void)
         lag_timeout_tag = g_timeout_add(5000, (GSourceFunc) sig_lag_timeout, NULL);
 
         /* input */
-       input_entries = g_hash_table_new((GHashFunc) g_direct_hash,
-                                        (GCompareFunc) g_direct_equal);
-       signal_add("statusbar destroyed", (SIGNAL_FUNC) sig_statusbar_destroyed);
+       input_entries = g_hash_table_new((GHashFunc) g_str_hash,
+                                        (GCompareFunc) g_str_equal);
 
        read_settings();
         signal_add_last("setup changed", (SIGNAL_FUNC) read_settings);
@@ -448,8 +442,8 @@ void statusbar_items_deinit(void)
         g_source_remove(lag_timeout_tag);
 
         /* input */
-       signal_remove("statusbar destroyed", (SIGNAL_FUNC) sig_statusbar_destroyed);
-        g_hash_table_destroy(input_entries);
+        g_hash_table_foreach(input_entries, (GHFunc) g_free, NULL);
+       g_hash_table_destroy(input_entries);
 
         signal_remove("setup changed", (SIGNAL_FUNC) read_settings);
 }