void statusbar_destroy(STATUSBAR_REC *bar) { int top; g_return_if_fail(bar != NULL); bar->group->bars = g_slist_remove(bar->group->bars, bar); if (bar->parent_window != NULL) { bar->parent_window->statusbars = g_slist_remove(bar->parent_window->statusbars, bar); } signal_emit("statusbar destroyed", 1, bar); while (bar->items != NULL) statusbar_item_destroy(bar->items->data); g_free(bar->color); if (bar->config->type != STATUSBAR_TYPE_WINDOW || bar->parent_window != NULL) statusbars_recalc_ypos(bar); top = bar->config->placement == STATUSBAR_TOP; if (bar->config->type == STATUSBAR_TYPE_ROOT) { /* top/bottom of the screen */ mainwindows_reserve_lines(top ? -1 : 0, !top ? -1 : 0); } else if (bar->parent_window != NULL) { /* top/bottom of the window */ mainwindow_set_statusbar_lines(bar->parent_window, top ? -1 : 0, !top ? -1 : 0); } g_free(bar); }
/* ypos is used only when pos == STATUSBAR_POS_MIDDLE */ STATUSBAR_REC *statusbar_create(int pos, int ypos) { STATUSBAR_REC *rec; rec = g_new0(STATUSBAR_REC, 1); statusbars = g_slist_append(statusbars, rec); rec->pos = pos; rec->line = pos == STATUSBAR_POS_MIDDLE ? ypos : mainwindows_reserve_lines(1, pos == STATUSBAR_POS_UP); rec->ypos = pos == STATUSBAR_POS_MIDDLE ? ypos : pos == STATUSBAR_POS_UP ? rec->line : LINES-1-rec->line; if (pos == STATUSBAR_POS_UP) { if (sbars_up == 0) sbar_uppest = rec->line; sbars_up++; rec->line -= sbar_uppest; } else if (pos == STATUSBAR_POS_DOWN) { if (sbars_down == 0) sbar_lowest = rec->line; sbars_down++; rec->line -= sbar_lowest; } set_bg(stdscr, settings_get_int("statusbar_background") << 4); move(rec->ypos, 0); clrtoeol(); set_bg(stdscr, 0); return rec; }
void mainwindows_init(void) { mainwindows = NULL; active_mainwin = NULL; reserved_up = reserved_down = 0; /* for entry line */ mainwindows_reserve_lines(1, FALSE); command_bind("window grow", NULL, (SIGNAL_FUNC) cmd_window_grow); command_bind("window shrink", NULL, (SIGNAL_FUNC) cmd_window_shrink); command_bind("window size", NULL, (SIGNAL_FUNC) cmd_window_size); command_bind("window balance", NULL, (SIGNAL_FUNC) cmd_window_balance); command_bind("window hide", NULL, (SIGNAL_FUNC) cmd_window_hide); command_bind("window show", NULL, (SIGNAL_FUNC) cmd_window_show); command_bind("window up", NULL, (SIGNAL_FUNC) cmd_window_up); command_bind("window down", NULL, (SIGNAL_FUNC) cmd_window_down); }
void statusbar_destroy(STATUSBAR_REC *bar) { g_return_if_fail(bar != NULL); if (bar->pos != STATUSBAR_POS_MIDDLE) mainwindows_reserve_lines(-1, bar->pos == STATUSBAR_POS_UP); if (bar->pos == STATUSBAR_POS_UP) sbars_up--; if (bar->pos == STATUSBAR_POS_DOWN) sbars_down--; statusbars = g_slist_remove(statusbars, bar); while (bar->items != NULL) statusbar_item_destroy(bar->items->data); if (bar->pos != STATUSBAR_POS_MIDDLE) statusbars_pack(bar->pos, bar->pos); g_free(bar); if (!quitting) statusbar_redraw_all(); }
STATUSBAR_REC *statusbar_create(STATUSBAR_GROUP_REC *group, STATUSBAR_CONFIG_REC *config, MAIN_WINDOW_REC *parent_window) { STATUSBAR_REC *bar; THEME_REC *theme; GSList *tmp; char *name, *value; g_return_val_if_fail(group != NULL, NULL); g_return_val_if_fail(config != NULL, NULL); g_return_val_if_fail(config->type != STATUSBAR_TYPE_WINDOW || parent_window != NULL, NULL); bar = g_new0(STATUSBAR_REC, 1); group->bars = g_slist_append(group->bars, bar); bar->group = group; bar->config = config; bar->parent_window = parent_window; irssi_set_dirty(); bar->dirty = TRUE; bar->dirty_xpos = 0; signal_remove("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); signal_remove("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); signal_remove("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); if (config->type == STATUSBAR_TYPE_ROOT) { /* top/bottom of the screen */ mainwindows_reserve_lines(config->placement == STATUSBAR_TOP, config->placement == STATUSBAR_BOTTOM); theme = current_theme; } else { /* top/bottom of the window */ parent_window->statusbars = g_slist_append(parent_window->statusbars, bar); mainwindow_set_statusbar_lines(parent_window, config->placement == STATUSBAR_TOP, config->placement == STATUSBAR_BOTTOM); theme = parent_window != NULL && parent_window->active != NULL && parent_window->active->theme != NULL ? parent_window->active->theme : current_theme; } signal_add("terminal resized", (SIGNAL_FUNC) sig_terminal_resized); signal_add("mainwindow resized", (SIGNAL_FUNC) sig_mainwindow_resized); signal_add("mainwindow moved", (SIGNAL_FUNC) sig_mainwindow_resized); /* get background color from sb_background abstract */ name = g_strdup_printf("{sb_%s_bg}", config->name); value = theme_format_expand(theme, name); g_free(name); if (*value == '\0') { /* try with the statusbar group name */ g_free(value); name = g_strdup_printf("{sb_%s_bg}", group->name); value = theme_format_expand(theme, name); g_free(name); if (*value == '\0') { /* fallback to default statusbar background (also provides backwards compatibility..) */ g_free(value); value = theme_format_expand(theme, "{sb_background}"); } } if (*value == '\0') { g_free(value); value = g_strdup("%8"); } bar->color = g_strconcat("%n", value, NULL); g_free(value); statusbars_recalc_ypos(bar); signal_emit("statusbar created", 1, bar); /* create the items to statusbar */ for (tmp = config->items; tmp != NULL; tmp = tmp->next) { SBAR_ITEM_CONFIG_REC *rec = tmp->data; statusbar_item_create(bar, rec); } return bar; }