mirror of
https://github.com/irssi/irssi.git
synced 2026-08-11 04:43:34 +02:00
Dependencies finally work correctly in perl libraries (they're each compiled
separately now). Added statusbar code to available to perl, it's now possible to create new statusbar items with perl scripts. statusbar_items_redraw(char *name) can now be used to easily redraw all named statusbar items in screen. Probably several other changes I've already forgotten :) git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1861 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
17f4d6b5de
commit
76c6e9ab83
48 changed files with 430 additions and 126 deletions
|
|
@ -33,7 +33,6 @@
|
|||
#define MAX_LAG_UNKNOWN_TIME 30
|
||||
|
||||
/* activity */
|
||||
static GSList *activity_items;
|
||||
static GList *activity_list;
|
||||
|
||||
static GHashTable *input_entries;
|
||||
|
|
@ -195,7 +194,7 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
|
|||
activity_list = g_list_remove(activity_list, window);
|
||||
if (window->data_level != 0)
|
||||
activity_list = g_list_prepend(activity_list, window);
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -204,12 +203,12 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
|
|||
if (window->data_level == 0) {
|
||||
/* remove from activity list */
|
||||
activity_list = g_list_remove(activity_list, window);
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
} else if (window->data_level != GPOINTER_TO_INT(oldlevel) ||
|
||||
window->hilight_color != 0) {
|
||||
/* different level as last time (or maybe different
|
||||
hilight color?), just redraw it. */
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -231,7 +230,7 @@ static void sig_statusbar_activity_hilight(WINDOW_REC *window, gpointer oldlevel
|
|||
if (tmp == NULL)
|
||||
activity_list = g_list_append(activity_list, window);
|
||||
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
}
|
||||
|
||||
static void sig_statusbar_activity_window_destroyed(WINDOW_REC *window)
|
||||
|
|
@ -240,12 +239,12 @@ static void sig_statusbar_activity_window_destroyed(WINDOW_REC *window)
|
|||
|
||||
if (g_list_find(activity_list, window) != NULL)
|
||||
activity_list = g_list_remove(activity_list, window);
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
}
|
||||
|
||||
static void sig_statusbar_activity_updated(void)
|
||||
{
|
||||
statusbar_items_redraw(activity_items);
|
||||
statusbar_items_redraw("act");
|
||||
}
|
||||
|
||||
static void item_more(SBAR_ITEM_REC *item, int get_size_only)
|
||||
|
|
@ -276,24 +275,14 @@ static void item_input(SBAR_ITEM_REC *item, int get_size_only)
|
|||
}
|
||||
}
|
||||
|
||||
static void sig_statusbar_item_created(SBAR_ITEM_REC *item)
|
||||
{
|
||||
if (item->func == item_act)
|
||||
activity_items = g_slist_prepend(activity_items, item);
|
||||
}
|
||||
|
||||
static void sig_statusbar_item_destroyed(SBAR_ITEM_REC *item)
|
||||
{
|
||||
if (item->func == item_act)
|
||||
activity_items = g_slist_remove(activity_items, item);
|
||||
else {
|
||||
GUI_ENTRY_REC *rec;
|
||||
GUI_ENTRY_REC *rec;
|
||||
|
||||
rec = g_hash_table_lookup(input_entries, item);
|
||||
if (rec != NULL) {
|
||||
gui_entry_destroy(rec);
|
||||
g_hash_table_remove(input_entries, item);
|
||||
}
|
||||
rec = g_hash_table_lookup(input_entries, item);
|
||||
if (rec != NULL) {
|
||||
gui_entry_destroy(rec);
|
||||
g_hash_table_remove(input_entries, item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -319,7 +308,6 @@ void statusbar_items_init(void)
|
|||
signal_add("window destroyed", (SIGNAL_FUNC) sig_statusbar_activity_window_destroyed);
|
||||
signal_add("window refnum changed", (SIGNAL_FUNC) sig_statusbar_activity_updated);
|
||||
|
||||
signal_add("statusbar item created", (SIGNAL_FUNC) sig_statusbar_item_created);
|
||||
signal_add("statusbar item destroyed", (SIGNAL_FUNC) sig_statusbar_item_destroyed);
|
||||
}
|
||||
|
||||
|
|
@ -334,6 +322,5 @@ void statusbar_items_deinit(void)
|
|||
g_list_free(activity_list);
|
||||
activity_list = NULL;
|
||||
|
||||
signal_remove("statusbar item created", (SIGNAL_FUNC) sig_statusbar_item_created);
|
||||
signal_remove("statusbar item destroyed", (SIGNAL_FUNC) sig_statusbar_item_destroyed);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,10 +39,11 @@ STATUSBAR_GROUP_REC *active_statusbar_group;
|
|||
sbar_item_funcs: char *name => STATUSBAR_FUNC func
|
||||
sbar_signal_items: int signal_id => GSList *(SBAR_ITEM_REC *items)
|
||||
sbar_item_signals: SBAR_ITEM_REC *item => GSList *(int *signal_ids)
|
||||
|
||||
named_sbar_items: const char *name => GSList *(SBAR_ITEM_REC *items)
|
||||
*/
|
||||
static GHashTable *sbar_item_defs, *sbar_item_funcs;
|
||||
static GHashTable *sbar_signal_items, *sbar_item_signals;
|
||||
static GHashTable *named_sbar_items;
|
||||
|
||||
void statusbar_item_register(const char *name, const char *value,
|
||||
STATUSBAR_FUNC func)
|
||||
|
|
@ -322,6 +323,12 @@ void statusbar_item_redraw(SBAR_ITEM_REC *item)
|
|||
active_win = old_active_win;
|
||||
}
|
||||
|
||||
void statusbar_items_redraw(const char *name)
|
||||
{
|
||||
g_slist_foreach(g_hash_table_lookup(named_sbar_items, name),
|
||||
(GFunc) statusbar_item_redraw, NULL);
|
||||
}
|
||||
|
||||
static void statusbars_recalc_ypos(STATUSBAR_REC *bar)
|
||||
{
|
||||
GSList *tmp, *bar_group;
|
||||
|
|
@ -532,6 +539,32 @@ void statusbar_destroy(STATUSBAR_REC *bar)
|
|||
g_free(bar);
|
||||
}
|
||||
|
||||
void statusbar_recreate_items(STATUSBAR_REC *bar)
|
||||
{
|
||||
GSList *tmp;
|
||||
|
||||
/* destroy */
|
||||
while (bar->items != NULL)
|
||||
statusbar_item_destroy(bar->items->data);
|
||||
|
||||
/* create */
|
||||
for (tmp = bar->config->items; tmp != NULL; tmp = tmp->next) {
|
||||
SBAR_ITEM_CONFIG_REC *rec = tmp->data;
|
||||
|
||||
statusbar_item_create(bar, rec);
|
||||
}
|
||||
|
||||
statusbar_redraw(bar);
|
||||
}
|
||||
|
||||
void statusbars_recreate_items(void)
|
||||
{
|
||||
if (active_statusbar_group != NULL) {
|
||||
g_slist_foreach(active_statusbar_group->bars,
|
||||
(GFunc) statusbar_recreate_items, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
STATUSBAR_REC *statusbar_find(STATUSBAR_GROUP_REC *group, const char *name,
|
||||
MAIN_WINDOW_REC *window)
|
||||
{
|
||||
|
|
@ -782,6 +815,7 @@ SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
|
|||
SBAR_ITEM_CONFIG_REC *config)
|
||||
{
|
||||
SBAR_ITEM_REC *rec;
|
||||
GSList *items;
|
||||
|
||||
g_return_val_if_fail(bar != NULL, NULL);
|
||||
g_return_val_if_fail(config != NULL, NULL);
|
||||
|
|
@ -797,6 +831,10 @@ SBAR_ITEM_REC *statusbar_item_create(STATUSBAR_REC *bar,
|
|||
rec->func = statusbar_item_default_func;
|
||||
statusbar_item_default_signals(rec);
|
||||
|
||||
items = g_hash_table_lookup(named_sbar_items, config->name);
|
||||
items = g_slist_append(items, rec);
|
||||
g_hash_table_insert(named_sbar_items, config->name, items);
|
||||
|
||||
signal_emit("statusbar item created", 1, rec);
|
||||
return rec;
|
||||
}
|
||||
|
|
@ -834,6 +872,14 @@ void statusbar_item_destroy(SBAR_ITEM_REC *item)
|
|||
g_return_if_fail(item != NULL);
|
||||
|
||||
item->bar->items = g_slist_remove(item->bar->items, item);
|
||||
|
||||
list = g_hash_table_lookup(named_sbar_items, item->config->name);
|
||||
list = g_slist_remove(list, item);
|
||||
if (list == NULL)
|
||||
g_hash_table_remove(named_sbar_items, item->config->name);
|
||||
else
|
||||
g_hash_table_insert(named_sbar_items, item->config->name, list);
|
||||
|
||||
signal_emit("statusbar item destroyed", 1, item);
|
||||
|
||||
list = g_hash_table_lookup(sbar_item_signals, item);
|
||||
|
|
@ -943,13 +989,15 @@ void statusbar_init(void)
|
|||
statusbar_groups = NULL;
|
||||
active_statusbar_group = NULL;
|
||||
sbar_item_defs = g_hash_table_new((GHashFunc) g_str_hash,
|
||||
(GCompareFunc) g_str_equal);
|
||||
(GCompareFunc) g_str_equal);
|
||||
sbar_item_funcs = g_hash_table_new((GHashFunc) g_str_hash,
|
||||
(GCompareFunc) g_str_equal);
|
||||
sbar_signal_items = g_hash_table_new((GHashFunc) g_direct_hash,
|
||||
(GCompareFunc) g_direct_equal);
|
||||
sbar_item_signals = g_hash_table_new((GHashFunc) g_direct_hash,
|
||||
(GCompareFunc) g_direct_equal);
|
||||
named_sbar_items = g_hash_table_new((GHashFunc) g_str_hash,
|
||||
(GCompareFunc) g_str_equal);
|
||||
|
||||
signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
|
||||
signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);
|
||||
|
|
@ -980,6 +1028,7 @@ void statusbar_deinit(void)
|
|||
g_hash_table_foreach(sbar_item_signals,
|
||||
(GHFunc) statusbar_item_signal_destroy, NULL);
|
||||
g_hash_table_destroy(sbar_item_signals);
|
||||
g_hash_table_destroy(named_sbar_items);
|
||||
|
||||
signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized);
|
||||
signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized);
|
||||
|
|
|
|||
|
|
@ -100,8 +100,10 @@ void statusbar_item_default_handler(SBAR_ITEM_REC *item, int get_size_only,
|
|||
/* redraw statusbar, NULL = all */
|
||||
void statusbar_redraw(STATUSBAR_REC *bar);
|
||||
void statusbar_item_redraw(SBAR_ITEM_REC *item);
|
||||
#define statusbar_items_redraw(list) \
|
||||
g_slist_foreach(list, (GFunc) statusbar_item_redraw, NULL);
|
||||
void statusbar_items_redraw(const char *name);
|
||||
|
||||
void statusbar_recreate_items(STATUSBAR_REC *bar);
|
||||
void statusbars_recreate_items(void);
|
||||
|
||||
void statusbar_init(void);
|
||||
void statusbar_deinit(void);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue