mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 03:03:12 +02:00
Partial support of bars, with custom items.
Today only root bars are partially working (refresh is not always performed), and bars are not saved in configuration file. To be continued...
This commit is contained in:
@@ -18,10 +18,11 @@ IF(NOT DISABLE_NCURSES)
|
||||
SUBDIRS( curses )
|
||||
ENDIF(NOT DISABLE_NCURSES)
|
||||
|
||||
SET(LIB_GUI_COMMON_SRC gui-action.c gui-action.h gui-buffer.c gui-buffer.h
|
||||
gui-chat.c gui-chat.h gui-color.c gui-color.h gui-completion.c gui-completion.h
|
||||
gui-history.c gui-history.h gui-hotlist.c gui-hotlist.h gui-infobar.c
|
||||
gui-infobar.h gui-input.c gui-input.h gui-keyboard.c gui-keyboard.h gui-main.h
|
||||
SET(LIB_GUI_COMMON_SRC gui-action.c gui-action.h gui-bar.c gui-bar.h
|
||||
gui-bar-item.c gui-bar-item.h gui-buffer.c gui-buffer.h gui-chat.c gui-chat.h
|
||||
gui-color.c gui-color.h gui-completion.c gui-completion.h gui-history.c
|
||||
gui-history.h gui-hotlist.c gui-hotlist.h gui-infobar.c gui-infobar.h
|
||||
gui-input.c gui-input.h gui-keyboard.c gui-keyboard.h gui-main.h
|
||||
gui-nicklist.c gui-nicklist.h gui-status.h gui-window.c gui-window.h)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
|
||||
|
||||
@@ -20,6 +20,10 @@ noinst_LIBRARIES = lib_weechat_gui_common.a
|
||||
|
||||
lib_weechat_gui_common_a_SOURCES = gui-action.c \
|
||||
gui-action.h \
|
||||
gui-bar.c \
|
||||
gui-bar.h \
|
||||
gui-bar-item.c \
|
||||
gui-bar-item.h \
|
||||
gui-buffer.c \
|
||||
gui-buffer.h \
|
||||
gui-chat.c \
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
SET(WEECHAT_CURSES_SRC gui-curses-chat.c gui-curses-color.c gui-curses-infobar.c
|
||||
gui-curses-input.c gui-curses-keyboard.c gui-curses-main.c gui-curses-nicklist.c
|
||||
gui-curses-status.c gui-curses-window.c gui-curses.h)
|
||||
SET(WEECHAT_CURSES_SRC gui-curses-bar.c gui-curses-chat.c gui-curses-color.c
|
||||
gui-curses-infobar.c gui-curses-input.c gui-curses-keyboard.c gui-curses-main.c
|
||||
gui-curses-nicklist.c gui-curses-status.c gui-curses-window.c gui-curses.h)
|
||||
|
||||
SET(EXECUTABLE weechat-curses)
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ weechat_curses_LDADD = ../../core/weechat.o \
|
||||
$(PLUGINS_LFLAGS) \
|
||||
$(NCURSES_LFLAGS)
|
||||
|
||||
weechat_curses_SOURCES = gui-curses-chat.c \
|
||||
weechat_curses_SOURCES = gui-curses-bar.c \
|
||||
gui-curses-chat.c \
|
||||
gui-curses-color.c \
|
||||
gui-curses-infobar.c \
|
||||
gui-curses-input.c \
|
||||
|
||||
@@ -0,0 +1,399 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* gui-curses-bar.c: bar functions for Curses GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-bar-item.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
#include "../gui-window.h"
|
||||
#include "gui-curses.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_bar_window_get_size: get total bar size (window bars) for a position
|
||||
* bar is optional, if not NULL, size is computed
|
||||
* from bar 1 to bar # - 1
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
int position)
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
int total_size;
|
||||
|
||||
total_size = 0;
|
||||
for (ptr_bar_window = GUI_CURSES(window)->bar_windows; ptr_bar_window;
|
||||
ptr_bar_window = ptr_bar_window->next_bar_window)
|
||||
{
|
||||
/* stop before bar */
|
||||
if (bar && (ptr_bar_window->bar == bar))
|
||||
return total_size;
|
||||
|
||||
if ((ptr_bar_window->bar->type != GUI_BAR_TYPE_ROOT)
|
||||
&& (ptr_bar_window->bar->position == position))
|
||||
{
|
||||
switch (position)
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
case GUI_BAR_POSITION_TOP:
|
||||
total_size += ptr_bar_window->height;
|
||||
break;
|
||||
case GUI_BAR_POSITION_LEFT:
|
||||
case GUI_BAR_POSITION_RIGHT:
|
||||
total_size += ptr_bar_window->width;
|
||||
break;
|
||||
}
|
||||
if (ptr_bar_window->bar->separator)
|
||||
total_size++;
|
||||
}
|
||||
}
|
||||
return total_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_calculate_pos_size: calculate position and size of a bar
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window)
|
||||
{
|
||||
int x1, y1, x2, y2;
|
||||
int add_bottom, add_top, add_left, add_right;
|
||||
|
||||
if (window)
|
||||
{
|
||||
x1 = window->win_x;
|
||||
y1 = window->win_y + 1;
|
||||
x2 = x1 + window->win_width - 1;
|
||||
y2 = y1 + window->win_height - 1;
|
||||
add_left = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_RIGHT);
|
||||
add_top = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_TOP);
|
||||
add_bottom = gui_bar_window_get_size (bar_window->bar, window, GUI_BAR_POSITION_BOTTOM);
|
||||
}
|
||||
else
|
||||
{
|
||||
x1 = 0;
|
||||
y1 = 0;
|
||||
x2 = gui_window_get_width () - 1;
|
||||
y2 = gui_window_get_height () - 1;
|
||||
add_bottom = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (bar_window->bar, GUI_BAR_POSITION_RIGHT);
|
||||
}
|
||||
|
||||
switch (bar_window->bar->position)
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
bar_window->x = x1 + add_left;
|
||||
bar_window->y = y2 - add_bottom - bar_window->bar->size + 1;
|
||||
bar_window->width = x2 - add_right - x1 + 1;
|
||||
bar_window->height = bar_window->bar->size - add_top - add_bottom;
|
||||
break;
|
||||
case GUI_BAR_POSITION_TOP:
|
||||
bar_window->x = x1 + add_left;
|
||||
bar_window->y = y1 + add_top;
|
||||
bar_window->width = x2 - x1 + 1;
|
||||
bar_window->height = bar_window->bar->size - add_left - add_right;
|
||||
break;
|
||||
case GUI_BAR_POSITION_LEFT:
|
||||
bar_window->x = x1 + add_left;
|
||||
bar_window->y = y1 + add_top;
|
||||
bar_window->width = bar_window->bar->size - add_left - add_right;
|
||||
bar_window->height = y2 - add_top - add_bottom - y1 + 1;
|
||||
break;
|
||||
case GUI_BAR_POSITION_RIGHT:
|
||||
bar_window->x = x2 - add_right - bar_window->bar->size + 1;
|
||||
bar_window->y = y1 + add_top;
|
||||
bar_window->width = bar_window->bar->size - add_left - add_right;
|
||||
bar_window->height = y2 - y1 + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_new: create a new "window bar" for a bar, in screen or a window
|
||||
* if window is not NULL, bar window will be in this window
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *new_bar_window;
|
||||
|
||||
new_bar_window = (struct t_gui_bar_window *) malloc (sizeof (struct t_gui_bar_window));
|
||||
if (new_bar_window)
|
||||
{
|
||||
new_bar_window->bar = bar;
|
||||
if (window)
|
||||
{
|
||||
bar->bar_window = NULL;
|
||||
new_bar_window->next_bar_window = GUI_CURSES(window)->bar_windows;
|
||||
GUI_CURSES(window)->bar_windows = new_bar_window;
|
||||
}
|
||||
else
|
||||
{
|
||||
bar->bar_window = new_bar_window;
|
||||
new_bar_window->next_bar_window = NULL;
|
||||
}
|
||||
|
||||
gui_bar_window_calculate_pos_size (new_bar_window, window);
|
||||
|
||||
new_bar_window->win_bar = newwin (new_bar_window->height,
|
||||
new_bar_window->width,
|
||||
new_bar_window->y,
|
||||
new_bar_window->x);
|
||||
new_bar_window->win_separator = NULL;
|
||||
if (new_bar_window->bar->separator)
|
||||
{
|
||||
switch (bar->position)
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
new_bar_window->win_separator = newwin (1,
|
||||
new_bar_window->width,
|
||||
new_bar_window->y - 1,
|
||||
new_bar_window->x);
|
||||
break;
|
||||
case GUI_BAR_POSITION_TOP:
|
||||
new_bar_window->win_separator = newwin (1,
|
||||
new_bar_window->width,
|
||||
new_bar_window->y + new_bar_window->height,
|
||||
new_bar_window->x);
|
||||
break;
|
||||
case GUI_BAR_POSITION_LEFT:
|
||||
new_bar_window->win_separator = newwin (new_bar_window->height,
|
||||
1,
|
||||
new_bar_window->y,
|
||||
new_bar_window->x + new_bar_window->width);
|
||||
break;
|
||||
case GUI_BAR_POSITION_RIGHT:
|
||||
new_bar_window->win_separator = newwin (new_bar_window->height,
|
||||
1,
|
||||
new_bar_window->y,
|
||||
new_bar_window->x - 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* failed to create bar window */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_print: print text on a bar window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_print (struct t_gui_bar_window *bar_win, char *text,
|
||||
int *max_width)
|
||||
{
|
||||
int weechat_color;
|
||||
char str_color[3];
|
||||
|
||||
if ((bar_win->bar->position == GUI_BAR_POSITION_LEFT)
|
||||
|| (bar_win->bar->position == GUI_BAR_POSITION_RIGHT))
|
||||
gui_window_set_weechat_color (bar_win->win_bar, GUI_COLOR_CHAT);
|
||||
else
|
||||
gui_window_set_weechat_color (bar_win->win_bar, GUI_COLOR_STATUS);
|
||||
|
||||
while (text && text[0])
|
||||
{
|
||||
if (text[0] == GUI_COLOR_COLOR_CHAR)
|
||||
{
|
||||
text++;
|
||||
if (isdigit (text[0]) && isdigit (text[1]))
|
||||
{
|
||||
str_color[0] = text[0];
|
||||
str_color[1] = text[1];
|
||||
str_color[2] = '\0';
|
||||
text += 2;
|
||||
sscanf (str_color, "%d", &weechat_color);
|
||||
gui_window_set_weechat_color (bar_win->win_bar, weechat_color);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wprintw (bar_win->win_bar, "%c", text[0]);
|
||||
(*max_width)--;
|
||||
text++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_draw: draw a bar for a window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_draw (struct t_gui_window *window,
|
||||
struct t_gui_bar_window *bar_win)
|
||||
{
|
||||
int i, max_width;
|
||||
char *item_value;
|
||||
struct t_gui_bar_item *ptr_item;
|
||||
|
||||
if ((bar_win->bar->position == GUI_BAR_POSITION_LEFT)
|
||||
|| (bar_win->bar->position == GUI_BAR_POSITION_RIGHT))
|
||||
gui_window_curses_clear (bar_win->win_bar, GUI_COLOR_CHAT);
|
||||
else
|
||||
gui_window_curses_clear (bar_win->win_bar, GUI_COLOR_STATUS);
|
||||
|
||||
max_width = bar_win->width;
|
||||
|
||||
for (i = 0; i < bar_win->bar->items_count; i++)
|
||||
{
|
||||
ptr_item = gui_bar_item_search (bar_win->bar->items_array[i]);
|
||||
if (ptr_item && ptr_item->build_callback)
|
||||
{
|
||||
item_value = (ptr_item->build_callback) (ptr_item->build_callback_data,
|
||||
ptr_item, window,
|
||||
max_width);
|
||||
if (item_value)
|
||||
{
|
||||
if (item_value[0])
|
||||
{
|
||||
gui_bar_window_print (bar_win, item_value, &max_width);
|
||||
if (max_width < 0)
|
||||
max_width = 0;
|
||||
}
|
||||
free (item_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wnoutrefresh (bar_win->win_bar);
|
||||
|
||||
if (bar_win->bar->separator)
|
||||
{
|
||||
switch (bar_win->bar->position)
|
||||
{
|
||||
case GUI_BAR_POSITION_BOTTOM:
|
||||
gui_window_set_weechat_color (bar_win->win_separator,
|
||||
GUI_COLOR_SEPARATOR);
|
||||
mvwhline (bar_win->win_separator, 0, 0, ACS_HLINE,
|
||||
bar_win->width);
|
||||
break;
|
||||
case GUI_BAR_POSITION_TOP:
|
||||
gui_window_set_weechat_color (bar_win->win_separator,
|
||||
GUI_COLOR_SEPARATOR);
|
||||
mvwhline (bar_win->win_separator, 0, 0, ACS_HLINE,
|
||||
bar_win->width);
|
||||
break;
|
||||
case GUI_BAR_POSITION_LEFT:
|
||||
gui_window_set_weechat_color (bar_win->win_separator,
|
||||
GUI_COLOR_SEPARATOR);
|
||||
mvwvline (bar_win->win_separator, 0, 0, ACS_VLINE,
|
||||
bar_win->height);
|
||||
break;
|
||||
case GUI_BAR_POSITION_RIGHT:
|
||||
gui_window_set_weechat_color (bar_win->win_separator,
|
||||
GUI_COLOR_SEPARATOR);
|
||||
mvwvline (bar_win->win_separator, 0, 0, ACS_VLINE,
|
||||
bar_win->height);
|
||||
break;
|
||||
}
|
||||
wnoutrefresh (bar_win->win_separator);
|
||||
}
|
||||
|
||||
refresh ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_draw: draw a bar
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_draw (struct t_gui_bar *bar)
|
||||
{
|
||||
struct t_gui_window *ptr_win;
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
if (bar->bar_window)
|
||||
{
|
||||
/* root bar */
|
||||
gui_bar_window_draw (NULL, bar->bar_window);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* bar on each window */
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
{
|
||||
for (ptr_bar_win = GUI_CURSES(ptr_win)->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
{
|
||||
if (ptr_bar_win->bar == bar)
|
||||
{
|
||||
gui_bar_window_draw (ptr_win, ptr_bar_win);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_free: delete a bar window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_free (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
/* delete Curses windows */
|
||||
if (bar_window->win_bar)
|
||||
delwin (bar_window->win_bar);
|
||||
if (bar_window->win_separator)
|
||||
delwin (bar_window->win_separator);
|
||||
|
||||
/* free bar window */
|
||||
free (bar_window);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf (" [window bar (addr:0x%x)]", bar_window);
|
||||
log_printf (" bar . . . . . . . : 0x%x", bar_window->bar);
|
||||
log_printf (" x . . . . . . . . : %d", bar_window->x);
|
||||
log_printf (" y . . . . . . . . : %d", bar_window->y);
|
||||
log_printf (" width . . . . . . : %d", bar_window->width);
|
||||
log_printf (" height. . . . . . : %d", bar_window->height);
|
||||
log_printf (" win_bar . . . . . : 0x%x", bar_window->win_bar);
|
||||
log_printf (" win_separator . . : 0x%x", bar_window->win_separator);
|
||||
}
|
||||
@@ -29,8 +29,10 @@
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-config.h"
|
||||
#include "../../core/wee-hook.h"
|
||||
#include "../../core/wee-string.h"
|
||||
#include "../../core/wee-utf8.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
@@ -963,7 +965,7 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
struct t_gui_line *ptr_line;
|
||||
/*t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc;*/
|
||||
char format_empty[32];
|
||||
int i, line_pos, count;
|
||||
int i, line_pos, count, old_scroll;
|
||||
/*int j, num_bars;
|
||||
unsigned long pct_complete;
|
||||
char *unit_name[] = { N_("bytes"), N_("KB"), N_("MB"), N_("GB") };
|
||||
@@ -1173,6 +1175,8 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
ptr_line = ptr_line->next_line;
|
||||
}
|
||||
|
||||
old_scroll = ptr_win->scroll;
|
||||
|
||||
ptr_win->scroll = (ptr_win->win_chat_cursor_y > ptr_win->win_chat_height - 1);
|
||||
|
||||
/* check if last line of buffer is entirely displayed and scrolling */
|
||||
@@ -1183,6 +1187,12 @@ gui_chat_draw (struct t_gui_buffer *buffer, int erase)
|
||||
ptr_win->scroll = 0;
|
||||
}
|
||||
|
||||
if (ptr_win->scroll != old_scroll)
|
||||
{
|
||||
hook_signal_send ("window_scrolled",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, ptr_win);
|
||||
}
|
||||
|
||||
if (!ptr_win->scroll && (ptr_win->start_line == ptr_win->buffer->lines))
|
||||
{
|
||||
ptr_win->start_line = NULL;
|
||||
|
||||
@@ -345,7 +345,7 @@ gui_color_init_weechat ()
|
||||
{
|
||||
int i;
|
||||
|
||||
gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_separator));
|
||||
gui_color[GUI_COLOR_SEPARATOR] = gui_color_build (GUI_COLOR_SEPARATOR, CONFIG_COLOR(config_color_separator), CONFIG_COLOR(config_color_chat_bg));
|
||||
|
||||
gui_color[GUI_COLOR_TITLE] = gui_color_build (GUI_COLOR_TITLE, CONFIG_COLOR(config_color_title), CONFIG_COLOR(config_color_title_bg));
|
||||
gui_color[GUI_COLOR_TITLE_MORE] = gui_color_build (GUI_COLOR_TITLE_MORE, CONFIG_COLOR(config_color_title_more), CONFIG_COLOR(config_color_title_bg));
|
||||
@@ -378,8 +378,8 @@ gui_color_init_weechat ()
|
||||
|
||||
gui_color[GUI_COLOR_STATUS] = gui_color_build (GUI_COLOR_STATUS, CONFIG_COLOR(config_color_status), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_DELIMITERS] = gui_color_build (GUI_COLOR_STATUS_DELIMITERS, CONFIG_COLOR(config_color_status_delimiters), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_NUMBER] = gui_color_build (GUI_COLOR_STATUS_NAME, CONFIG_COLOR(config_color_status_number), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_CATEGORY] = gui_color_build (GUI_COLOR_STATUS_NAME, CONFIG_COLOR(config_color_status_category), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_NUMBER] = gui_color_build (GUI_COLOR_STATUS_NUMBER, CONFIG_COLOR(config_color_status_number), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_CATEGORY] = gui_color_build (GUI_COLOR_STATUS_CATEGORY, CONFIG_COLOR(config_color_status_category), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_NAME] = gui_color_build (GUI_COLOR_STATUS_NAME, CONFIG_COLOR(config_color_status_name), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_DATA_MSG] = gui_color_build (GUI_COLOR_STATUS_DATA_MSG, CONFIG_COLOR(config_color_status_data_msg), CONFIG_COLOR(config_color_status_bg));
|
||||
gui_color[GUI_COLOR_STATUS_DATA_PRIVATE] = gui_color_build (GUI_COLOR_STATUS_DATA_PRIVATE, CONFIG_COLOR(config_color_status_data_private), CONFIG_COLOR(config_color_status_bg));
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "../../core/wee-util.h"
|
||||
#include "../../plugins/plugin.h"
|
||||
#include "../gui-main.h"
|
||||
#include "../gui-bar-item.h"
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
@@ -97,7 +98,10 @@ gui_main_init ()
|
||||
|
||||
/* get time length */
|
||||
gui_chat_time_length = util_get_time_length (CONFIG_STRING(config_look_buffer_time_format));
|
||||
|
||||
|
||||
/* init bar items */
|
||||
gui_bar_item_init ();
|
||||
|
||||
/* create new window/buffer */
|
||||
if (gui_window_new (NULL, 0, 0, COLS, LINES, 100, 100))
|
||||
{
|
||||
@@ -243,6 +247,9 @@ gui_main_loop ()
|
||||
void
|
||||
gui_main_end ()
|
||||
{
|
||||
/* remove bar items */
|
||||
gui_bar_item_end ();
|
||||
|
||||
/* free clipboard buffer */
|
||||
if (gui_input_clipboard)
|
||||
free (gui_input_clipboard);
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../../core/wee-string.h"
|
||||
#include "../gui-window.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-buffer.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
@@ -82,6 +83,7 @@ gui_window_objects_init (struct t_gui_window *window)
|
||||
GUI_CURSES(window)->win_infobar = NULL;
|
||||
GUI_CURSES(window)->win_input = NULL;
|
||||
GUI_CURSES(window)->win_separator = NULL;
|
||||
GUI_CURSES(window)->bar_windows = NULL;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -192,10 +194,16 @@ int
|
||||
gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
{
|
||||
int max_length, max_height, lines, width_used;
|
||||
int add_top, add_bottom, add_left, add_right;
|
||||
|
||||
if (!gui_ok)
|
||||
return 0;
|
||||
|
||||
add_bottom = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_window_get_size (NULL, window, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
/* init chat & nicklist settings */
|
||||
if (window->buffer->nicklist)
|
||||
{
|
||||
@@ -219,7 +227,8 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
}
|
||||
else
|
||||
{
|
||||
width_used = window->win_width - (window->win_width % (max_length + 2));
|
||||
width_used = (window->win_width - add_left - add_right)
|
||||
- ((window->win_width - add_left - add_right) % (max_length + 2));
|
||||
if (((max_length + 2) * window->buffer->nicklist_visible_count) % width_used == 0)
|
||||
lines = ((max_length + 2) * window->buffer->nicklist_visible_count) / width_used;
|
||||
else
|
||||
@@ -231,8 +240,8 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
&& (lines < CONFIG_INTEGER(config_look_nicklist_min_size)))
|
||||
lines = CONFIG_INTEGER(config_look_nicklist_min_size);
|
||||
max_height = (CONFIG_BOOLEAN(config_look_infobar)) ?
|
||||
window->win_height - 3 - 4 :
|
||||
window->win_height - 2 - 4;
|
||||
window->win_height - add_top - add_bottom - 3 - 4 :
|
||||
window->win_height - add_top - add_bottom - 2 - 4;
|
||||
if (lines > max_height)
|
||||
lines = max_height;
|
||||
if (!force_calculate
|
||||
@@ -244,85 +253,84 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
switch (CONFIG_INTEGER(config_look_nicklist_position))
|
||||
{
|
||||
case CONFIG_LOOK_NICKLIST_LEFT:
|
||||
window->win_chat_x = window->win_x + max_length +
|
||||
window->win_chat_x = window->win_x + add_left + max_length +
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_chat_y = window->win_y + 1;
|
||||
window->win_chat_y = window->win_y + add_top + 1;
|
||||
window->win_chat_width = window->win_width - max_length -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_x = window->win_x + 0;
|
||||
window->win_nick_y = window->win_y + 1;
|
||||
window->win_nick_x = window->win_x + add_left + 0;
|
||||
window->win_nick_y = window->win_y + add_top + 1;
|
||||
window->win_nick_width = max_length +
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
{
|
||||
window->win_chat_height = window->win_height - 4;
|
||||
window->win_nick_height = window->win_height - 4;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 4;
|
||||
window->win_nick_height = window->win_height - add_top - add_bottom - 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->win_chat_height = window->win_height - 3;
|
||||
window->win_nick_height = window->win_height - 3;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
|
||||
window->win_nick_height = window->win_height - add_top - add_bottom - 3;
|
||||
}
|
||||
window->win_nick_num_max = window->win_nick_height;
|
||||
break;
|
||||
case CONFIG_LOOK_NICKLIST_RIGHT:
|
||||
window->win_chat_x = window->win_x;
|
||||
window->win_chat_y = window->win_y + 1;
|
||||
window->win_chat_width = window->win_width - max_length -
|
||||
window->win_chat_x = window->win_x + add_left;
|
||||
window->win_chat_y = window->win_y + add_top + 1;
|
||||
window->win_chat_width = window->win_width - add_left - add_right - max_length -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_x = window->win_x + window->win_width -
|
||||
max_length -
|
||||
window->win_nick_x = window->win_x + window->win_width - add_right - max_length -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_y = window->win_y + 1;
|
||||
window->win_nick_y = window->win_y + add_top + 1;
|
||||
window->win_nick_width = max_length +
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
{
|
||||
window->win_chat_height = window->win_height - 4;
|
||||
window->win_nick_height = window->win_height - 4;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 4;
|
||||
window->win_nick_height = window->win_height - add_top - add_bottom - 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->win_chat_height = window->win_height - 3;
|
||||
window->win_nick_height = window->win_height - 3;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
|
||||
window->win_nick_height = window->win_height - add_top - add_bottom - 3;
|
||||
}
|
||||
window->win_nick_num_max = window->win_nick_height;
|
||||
break;
|
||||
case CONFIG_LOOK_NICKLIST_TOP:
|
||||
window->win_chat_x = window->win_x;
|
||||
window->win_chat_y = window->win_y + 1 + lines +
|
||||
window->win_chat_x = window->win_x + add_left;
|
||||
window->win_chat_y = window->win_y + add_top + 1 + lines +
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_chat_width = window->win_width;
|
||||
window->win_chat_width = window->win_width - add_left - add_right;
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
window->win_chat_height = window->win_height - 3 - lines -
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
|
||||
else
|
||||
window->win_chat_height = window->win_height - 3 - lines -
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_x = window->win_x;
|
||||
window->win_nick_y = window->win_y + 1;
|
||||
window->win_nick_width = window->win_width;
|
||||
window->win_nick_x = window->win_x + add_left;
|
||||
window->win_nick_y = window->win_y + add_top + 1;
|
||||
window->win_nick_width = window->win_width - add_left - add_right;
|
||||
window->win_nick_height = lines +
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_num_max = lines * (window->win_nick_width / (max_length + 1));
|
||||
break;
|
||||
case CONFIG_LOOK_NICKLIST_BOTTOM:
|
||||
window->win_chat_x = window->win_x;
|
||||
window->win_chat_y = window->win_y + 1;
|
||||
window->win_chat_width = window->win_width;
|
||||
window->win_chat_x = window->win_x + add_left;
|
||||
window->win_chat_y = window->win_y + add_top + 1;
|
||||
window->win_chat_width = window->win_width - add_left - add_right;
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
window->win_chat_height = window->win_height - 3 - lines -
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
|
||||
else
|
||||
window->win_chat_height = window->win_height - 3 - lines -
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_x = window->win_x;
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
window->win_nick_y = window->win_y + window->win_height -
|
||||
window->win_nick_y = window->win_y + window->win_height - add_bottom -
|
||||
2 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0) - 1;
|
||||
else
|
||||
window->win_nick_y = window->win_y + window->win_height -
|
||||
window->win_nick_y = window->win_y + window->win_height - add_bottom -
|
||||
2 - lines -
|
||||
((CONFIG_BOOLEAN(config_look_nicklist_separator)) ? 1 : 0);
|
||||
window->win_nick_width = window->win_width;
|
||||
@@ -332,20 +340,20 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
break;
|
||||
}
|
||||
|
||||
window->win_chat_cursor_x = window->win_x;
|
||||
window->win_chat_cursor_y = window->win_y;
|
||||
window->win_chat_cursor_x = window->win_x + add_left;
|
||||
window->win_chat_cursor_y = window->win_y + add_top;
|
||||
}
|
||||
else
|
||||
{
|
||||
window->win_chat_x = window->win_x;
|
||||
window->win_chat_y = window->win_y + 1;
|
||||
window->win_chat_width = window->win_width;
|
||||
window->win_chat_x = window->win_x + add_left;
|
||||
window->win_chat_y = window->win_y + add_top + 1;
|
||||
window->win_chat_width = window->win_width - add_left - add_right;
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
window->win_chat_height = window->win_height - 4;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 4;
|
||||
else
|
||||
window->win_chat_height = window->win_height - 3;
|
||||
window->win_chat_cursor_x = window->win_x;
|
||||
window->win_chat_cursor_y = window->win_y;
|
||||
window->win_chat_height = window->win_height - add_top - add_bottom - 3;
|
||||
window->win_chat_cursor_x = window->win_x + add_left;
|
||||
window->win_chat_cursor_y = window->win_y + add_top;
|
||||
window->win_nick_x = -1;
|
||||
window->win_nick_y = -1;
|
||||
window->win_nick_width = -1;
|
||||
@@ -354,26 +362,26 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
}
|
||||
|
||||
/* title window */
|
||||
window->win_title_x = window->win_x;
|
||||
window->win_title_y = window->win_y;
|
||||
window->win_title_width = window->win_width;
|
||||
window->win_title_x = window->win_x + add_left;
|
||||
window->win_title_y = window->win_y + add_top;
|
||||
window->win_title_width = window->win_width - add_left - add_right;
|
||||
window->win_title_height = 1;
|
||||
|
||||
/* status window */
|
||||
window->win_status_x = window->win_x;
|
||||
window->win_status_x = window->win_x + add_left;
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
window->win_status_y = window->win_y + window->win_height - 3;
|
||||
window->win_status_y = window->win_y + window->win_height - add_bottom - 3;
|
||||
else
|
||||
window->win_status_y = window->win_y + window->win_height - 2;
|
||||
window->win_status_width = window->win_width;
|
||||
window->win_status_y = window->win_y + window->win_height - add_bottom - 2;
|
||||
window->win_status_width = window->win_width - add_left - add_right;
|
||||
window->win_status_height = 1;
|
||||
|
||||
/* infobar window */
|
||||
if (CONFIG_BOOLEAN(config_look_infobar))
|
||||
{
|
||||
window->win_infobar_x = window->win_x;
|
||||
window->win_infobar_y = window->win_y + window->win_height - 2;
|
||||
window->win_infobar_width = window->win_width;
|
||||
window->win_infobar_x = window->win_x + add_left;
|
||||
window->win_infobar_y = window->win_y + window->win_height - add_bottom - 2;
|
||||
window->win_infobar_width = window->win_width - add_left - add_right;
|
||||
window->win_infobar_height = 1;
|
||||
}
|
||||
else
|
||||
@@ -385,9 +393,9 @@ gui_window_calculate_pos_size (struct t_gui_window *window, int force_calculate)
|
||||
}
|
||||
|
||||
/* input window */
|
||||
window->win_input_x = window->win_x;
|
||||
window->win_input_y = window->win_y + window->win_height - 1;
|
||||
window->win_input_width = window->win_width;
|
||||
window->win_input_x = window->win_x + add_left;
|
||||
window->win_input_y = window->win_y + window->win_height - add_bottom - 1;
|
||||
window->win_input_width = window->win_width - add_left - add_right;
|
||||
window->win_input_height = 1;
|
||||
|
||||
return 1;
|
||||
@@ -403,7 +411,7 @@ gui_window_draw_separator (struct t_gui_window *window)
|
||||
if (GUI_CURSES(window)->win_separator)
|
||||
delwin (GUI_CURSES(window)->win_separator);
|
||||
|
||||
if (window->win_x > 0)
|
||||
if (window->win_x > gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT))
|
||||
{
|
||||
GUI_CURSES(window)->win_separator = newwin (window->win_height,
|
||||
1,
|
||||
@@ -411,8 +419,8 @@ gui_window_draw_separator (struct t_gui_window *window)
|
||||
window->win_x - 1);
|
||||
gui_window_set_weechat_color (GUI_CURSES(window)->win_separator,
|
||||
GUI_COLOR_SEPARATOR);
|
||||
wborder (GUI_CURSES(window)->win_separator,
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
|
||||
mvwvline (GUI_CURSES(window)->win_separator, 0, 0, ACS_VLINE,
|
||||
window->win_height);
|
||||
wnoutrefresh (GUI_CURSES(window)->win_separator);
|
||||
refresh ();
|
||||
}
|
||||
@@ -928,15 +936,32 @@ gui_window_refresh_windows ()
|
||||
{
|
||||
struct t_gui_window *ptr_win, *old_current_window;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int add_bottom, add_top, add_left, add_right;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
|
||||
old_current_window = gui_current_window;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (ptr_bar->type == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
gui_bar_window_calculate_pos_size (ptr_bar->bar_window, NULL);
|
||||
gui_bar_draw (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, 0, 0,
|
||||
gui_window_get_width (),
|
||||
gui_window_get_height (), 0) < 0)
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
|
||||
gui_window_get_width () - add_left - add_right,
|
||||
gui_window_get_height () - add_top - add_bottom,
|
||||
0) < 0)
|
||||
gui_window_merge_all (gui_current_window);
|
||||
|
||||
for (ptr_win = gui_windows; ptr_win; ptr_win = ptr_win->next_window)
|
||||
@@ -1048,7 +1073,7 @@ void
|
||||
gui_window_resize (struct t_gui_window *window, int pourcentage)
|
||||
{
|
||||
struct t_gui_window_tree *parent;
|
||||
int old_split_pct;
|
||||
int old_split_pct, add_bottom, add_top, add_left, add_right;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
@@ -1062,9 +1087,16 @@ gui_window_resize (struct t_gui_window *window, int pourcentage)
|
||||
parent->split_pct = pourcentage;
|
||||
else
|
||||
parent->split_pct = 100 - pourcentage;
|
||||
if (gui_window_auto_resize (gui_windows_tree, 0, 0,
|
||||
gui_window_get_width (),
|
||||
gui_window_get_height (), 1) < 0)
|
||||
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
|
||||
if (gui_window_auto_resize (gui_windows_tree, add_left, add_top,
|
||||
gui_window_get_width () - add_left - add_right,
|
||||
gui_window_get_height () - add_top - add_bottom,
|
||||
1) < 0)
|
||||
parent->split_pct = old_split_pct;
|
||||
else
|
||||
gui_window_refresh_windows ();
|
||||
@@ -1126,7 +1158,7 @@ gui_window_merge (struct t_gui_window *window)
|
||||
void
|
||||
gui_window_merge_all (struct t_gui_window *window)
|
||||
{
|
||||
int num_deleted;
|
||||
int num_deleted, add_bottom, add_top, add_left, add_right;
|
||||
|
||||
if (!gui_ok)
|
||||
return;
|
||||
@@ -1143,12 +1175,19 @@ gui_window_merge_all (struct t_gui_window *window)
|
||||
gui_window_tree_free (&gui_windows_tree);
|
||||
gui_window_tree_init (window);
|
||||
window->ptr_tree = gui_windows_tree;
|
||||
window->win_x = 0;
|
||||
window->win_y = 0;
|
||||
window->win_width = gui_window_get_width ();
|
||||
window->win_height = gui_window_get_height ();
|
||||
|
||||
add_bottom = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_BOTTOM);
|
||||
add_top = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_TOP);
|
||||
add_left = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_LEFT);
|
||||
add_right = gui_bar_root_get_size (NULL, GUI_BAR_POSITION_RIGHT);
|
||||
window->win_x = add_left;
|
||||
window->win_y = add_top;
|
||||
window->win_width = gui_window_get_width () - add_left - add_right;
|
||||
window->win_height = gui_window_get_height () - add_top - add_bottom;
|
||||
|
||||
window->win_width_pct = 100;
|
||||
window->win_height_pct = 100;
|
||||
|
||||
gui_current_window = window;
|
||||
gui_window_switch_to_buffer (window, window->buffer);
|
||||
gui_window_redraw_buffer (window->buffer);
|
||||
@@ -1450,6 +1489,9 @@ gui_window_title_reset ()
|
||||
void
|
||||
gui_window_objects_print_log (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
log_printf ("");
|
||||
log_printf (" win_title . . . . . : 0x%x", GUI_CURSES(window)->win_title);
|
||||
log_printf (" win_chat. . . . . . : 0x%x", GUI_CURSES(window)->win_chat);
|
||||
log_printf (" win_nick. . . . . . : 0x%x", GUI_CURSES(window)->win_nick);
|
||||
@@ -1457,4 +1499,10 @@ gui_window_objects_print_log (struct t_gui_window *window)
|
||||
log_printf (" win_infobar . . . . : 0x%x", GUI_CURSES(window)->win_infobar);
|
||||
log_printf (" win_input . . . . . : 0x%x", GUI_CURSES(window)->win_input);
|
||||
log_printf (" win_separator . . . : 0x%x", GUI_CURSES(window)->win_separator);
|
||||
|
||||
for (ptr_bar_win = GUI_CURSES(window)->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
{
|
||||
gui_bar_window_print_log (ptr_bar_win);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,18 @@
|
||||
|
||||
#define GUI_CURSES(window) ((t_gui_curses_objects *)(window->gui_objects))
|
||||
|
||||
struct t_gui_bar_window
|
||||
{
|
||||
struct t_gui_bar *bar; /* pointer to bar */
|
||||
int x, y; /* position of window */
|
||||
int width, height; /* window size */
|
||||
WINDOW *win_bar; /* bar Curses window */
|
||||
WINDOW *win_separator; /* separator (optional) */
|
||||
struct t_gui_bar_window *next_bar_window;
|
||||
/* link to next bar window */
|
||||
/* (only used if bar is in windows) */
|
||||
};
|
||||
|
||||
typedef struct t_gui_curses_objects t_gui_curses_objects;
|
||||
|
||||
struct t_gui_curses_objects
|
||||
@@ -44,6 +56,7 @@ struct t_gui_curses_objects
|
||||
WINDOW *win_infobar; /* info bar window */
|
||||
WINDOW *win_input; /* input window */
|
||||
WINDOW *win_separator; /* separation between 2 splited (V) win */
|
||||
struct t_gui_bar_window *bar_windows; /* bar windows */
|
||||
};
|
||||
|
||||
extern struct t_gui_color gui_weechat_colors[];
|
||||
@@ -52,6 +65,10 @@ extern struct t_gui_color gui_weechat_colors[];
|
||||
extern int gui_color_get_pair (int num_color);
|
||||
extern void gui_color_init ();
|
||||
|
||||
/* bar functions */
|
||||
extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window);
|
||||
|
||||
/* chat functions */
|
||||
extern void gui_chat_calculate_line_diff (struct t_gui_window *window,
|
||||
struct t_gui_line **line,
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
SET(WEECHAT_GTK_SRC gui-gtk-chat.c gui-gtk-color.c gui-gtk-infobar.c
|
||||
gui-gtk-input.c gui-gtk-keyboard.c gui-gtk-main.c gui-gtk-nicklist.c
|
||||
gui-gtk-status.c gui-gtk-window.c gui-gtk.h)
|
||||
SET(WEECHAT_GTK_SRC gui-gtk-bar.c gui-gtk-chat.c gui-gtk-color.c
|
||||
gui-gtk-infobar.c gui-gtk-input.c gui-gtk-keyboard.c gui-gtk-main.c
|
||||
gui-gtk-nicklist.c gui-gtk-status.c gui-gtk-window.c gui-gtk.h)
|
||||
|
||||
SET(EXECUTABLE weechat-gtk)
|
||||
|
||||
|
||||
@@ -37,7 +37,8 @@ weechat_gtk_LDADD = ../../core/weechat.o \
|
||||
$(PLUGINS_LFLAGS) \
|
||||
$(GTK_LFLAGS)
|
||||
|
||||
weechat_gtk_SOURCES = gui-gtk-chat.c \
|
||||
weechat_gtk_SOURCES = gui-gtk-bar.c \
|
||||
gui-gtk-chat.c \
|
||||
gui-gtk-color.c \
|
||||
gui-gtk-infobar.c \
|
||||
gui-gtk-input.c \
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* gui-gtk-bar.c: bar functions for Gtk GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../core/weechat.h"
|
||||
#include "../../core/wee-log.h"
|
||||
#include "../gui-bar.h"
|
||||
#include "../gui-chat.h"
|
||||
#include "../gui-color.h"
|
||||
#include "../gui-window.h"
|
||||
#include "gui-gtk.h"
|
||||
|
||||
|
||||
/*
|
||||
* gui_bar_windows_get_size: get total bar size (window bars) for a position
|
||||
* bar is optional, if not NULL, size is computed
|
||||
* from bar 1 to bar # - 1
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_window_get_size (struct t_gui_bar *bar, struct t_gui_window *window,
|
||||
int position)
|
||||
{
|
||||
(void) bar;
|
||||
(void) window;
|
||||
(void) position;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_new: create a new "window bar" for a bar, in screen or a window
|
||||
* if window is not NULL, bar window will be in this window
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_window_new (struct t_gui_bar *bar, struct t_gui_window *window)
|
||||
{
|
||||
(void) bar;
|
||||
(void) window;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_draw: draw a bar
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_draw (struct t_gui_bar *bar)
|
||||
{
|
||||
(void) bar;
|
||||
|
||||
/* TODO: write this function for Gtk */
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_free: delete an bar window
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_free (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
/* TODO: complete this function for Gtk */
|
||||
|
||||
/* free bar window */
|
||||
free (bar_window);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_window_print_log: print bar window infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_window_print_log (struct t_gui_bar_window *bar_window)
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf (" [window bar (addr:0x%x)]", bar_window);
|
||||
log_printf (" bar . . . . . . . : 0x%x", bar_window->bar);
|
||||
log_printf (" x . . . . . . . . : %d", bar_window->x);
|
||||
log_printf (" y . . . . . . . . : %d", bar_window->y);
|
||||
log_printf (" width . . . . . . : %d", bar_window->width);
|
||||
log_printf (" height. . . . . . : %d", bar_window->height);
|
||||
}
|
||||
@@ -76,6 +76,7 @@ gui_window_objects_init (struct t_gui_window *window)
|
||||
GUI_GTK(window)->texttag_chat = NULL;
|
||||
GUI_GTK(window)->textview_nicklist = NULL;
|
||||
GUI_GTK(window)->textbuffer_nicklist = NULL;
|
||||
GUI_GTK(window)->bar_windows = NULL;
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -919,9 +920,23 @@ gui_window_title_reset ()
|
||||
void
|
||||
gui_window_objects_print_log (struct t_gui_window *window)
|
||||
{
|
||||
struct t_gui_bar_window *ptr_bar_win;
|
||||
|
||||
log_printf (" textview_chat . . . : 0x%x", GUI_GTK(window)->textview_chat);
|
||||
log_printf (" textbuffer_chat . . : 0x%x", GUI_GTK(window)->textbuffer_chat);
|
||||
log_printf (" texttag_chat. . . . : 0x%x", GUI_GTK(window)->texttag_chat);
|
||||
log_printf (" textview_nicklist . : 0x%x", GUI_GTK(window)->textview_nicklist);
|
||||
log_printf (" textbuffer_nicklist : 0x%x", GUI_GTK(window)->textbuffer_nicklist);
|
||||
|
||||
for (ptr_bar_win = GUI_GTK(window)->bar_windows; ptr_bar_win;
|
||||
ptr_bar_win = ptr_bar_win->next_bar_window)
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf (" [window bar (addr:0x%x)]", ptr_bar_win);
|
||||
log_printf (" bar . . . . . . . : 0x%x", ptr_bar_win->bar);
|
||||
log_printf (" x . . . . . . . . : %d", ptr_bar_win->x);
|
||||
log_printf (" y . . . . . . . . : %d", ptr_bar_win->y);
|
||||
log_printf (" width . . . . . . : %d", ptr_bar_win->width);
|
||||
log_printf (" height. . . . . . : %d", ptr_bar_win->height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,16 @@ struct t_gui_line;
|
||||
|
||||
#define GUI_GTK(window) ((t_gui_gtk_objects *)(window->gui_objects))
|
||||
|
||||
struct t_gui_bar_window
|
||||
{
|
||||
struct t_gui_bar *bar; /* pointer to bar */
|
||||
int x, y; /* position of window */
|
||||
int width, height; /* window size */
|
||||
struct t_gui_bar_window *next_bar_window;
|
||||
/* link to next bar window */
|
||||
/* (only used if bar is in windows) */
|
||||
};
|
||||
|
||||
typedef struct t_gui_gtk_objects t_gui_gtk_objects;
|
||||
|
||||
struct t_gui_gtk_objects
|
||||
@@ -63,6 +73,7 @@ struct t_gui_gtk_objects
|
||||
GtkTextTag *texttag_chat; /* texttag widget for chat */
|
||||
GtkWidget *textview_nicklist; /* textview widget for nicklist */
|
||||
GtkTextBuffer *textbuffer_nicklist; /* textbuffer widget for nicklist */
|
||||
struct t_gui_bar_window *bar_windows; /* bar windows */
|
||||
};
|
||||
|
||||
//extern t_gui_color gui_weechat_colors[];
|
||||
|
||||
@@ -0,0 +1,592 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* gui-bar-item.c: bar item functions, used by all GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-hook.h"
|
||||
#include "../core/wee-log.h"
|
||||
#include "../core/wee-string.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-bar-item.h"
|
||||
#include "gui-bar.h"
|
||||
#include "gui-buffer.h"
|
||||
#include "gui-color.h"
|
||||
#include "gui-hotlist.h"
|
||||
#include "gui-window.h"
|
||||
|
||||
|
||||
struct t_gui_bar_item *gui_bar_items = NULL; /* first bar item */
|
||||
struct t_gui_bar_item *last_gui_bar_item = NULL; /* last bar item */
|
||||
char *gui_bar_item_names[GUI_BAR_NUM_ITEMS] =
|
||||
{ "buffer_count", "buffer_plugin", "buffer_name", "nicklist_count", "scroll",
|
||||
"hotlist"
|
||||
};
|
||||
struct t_hook *gui_bar_item_hook1 = NULL;
|
||||
struct t_hook *gui_bar_item_hook2 = NULL;
|
||||
struct t_hook *gui_bar_item_hook3 = NULL;
|
||||
struct t_hook *gui_bar_item_hook4 = NULL;
|
||||
struct t_hook *gui_bar_item_hook5 = NULL;
|
||||
struct t_hook *gui_bar_item_hook6 = NULL;
|
||||
struct t_hook *gui_bar_item_hook7 = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* gui_bar_item_search: search a bar item
|
||||
*/
|
||||
|
||||
struct t_gui_bar_item *
|
||||
gui_bar_item_search (char *name)
|
||||
{
|
||||
struct t_gui_bar_item *ptr_item;
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
for (ptr_item = gui_bar_items; ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
if (strcmp (ptr_item->name, name) == 0)
|
||||
return ptr_item;
|
||||
}
|
||||
|
||||
/* bar item not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_search_with_plugin: search a bar item for a plugin
|
||||
*/
|
||||
|
||||
struct t_gui_bar_item *
|
||||
gui_bar_item_search_with_plugin (struct t_weechat_plugin *plugin, char *name)
|
||||
{
|
||||
struct t_gui_bar_item *ptr_item;
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
for (ptr_item = gui_bar_items; ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
if ((ptr_item->plugin == plugin)
|
||||
&& (strcmp (ptr_item->name, name) == 0))
|
||||
return ptr_item;
|
||||
}
|
||||
|
||||
/* bar item not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_new: create a new bar item
|
||||
*/
|
||||
|
||||
struct t_gui_bar_item *
|
||||
gui_bar_item_new (struct t_weechat_plugin *plugin, char *name,
|
||||
char *(*build_callback)(void *data,
|
||||
struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width),
|
||||
void *build_callback_data)
|
||||
{
|
||||
struct t_gui_bar_item *new_bar_item;
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
/* it's not possible to create 2 bar items with same name for same plugin*/
|
||||
if (gui_bar_item_search_with_plugin (plugin, name))
|
||||
return NULL;
|
||||
|
||||
/* create bar item */
|
||||
new_bar_item = (struct t_gui_bar_item *) malloc (sizeof (struct t_gui_bar_item));
|
||||
if (new_bar_item)
|
||||
{
|
||||
new_bar_item->plugin = plugin;
|
||||
new_bar_item->name = strdup (name);
|
||||
new_bar_item->build_callback = build_callback;
|
||||
new_bar_item->build_callback_data = build_callback_data;
|
||||
|
||||
/* add bar item to bar items queue */
|
||||
new_bar_item->prev_item = last_gui_bar_item;
|
||||
if (gui_bar_items)
|
||||
last_gui_bar_item->next_item = new_bar_item;
|
||||
else
|
||||
gui_bar_items = new_bar_item;
|
||||
last_gui_bar_item = new_bar_item;
|
||||
new_bar_item->next_item = NULL;
|
||||
|
||||
return new_bar_item;
|
||||
}
|
||||
|
||||
/* failed to create bar item */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_contains_item: return 1 if a bar contains item, O otherwise
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_contains_item (struct t_gui_bar *bar, char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!bar || !name || !name[0])
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < bar->items_count; i++)
|
||||
{
|
||||
if (strcmp (bar->items_array[i], name) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* item is not in bar */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_update: update an item on all bars displayed on screen
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_update (char *name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (gui_bar_contains_item (ptr_bar, name))
|
||||
gui_bar_draw (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_free: delete a bar item
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_free (struct t_gui_bar_item *item)
|
||||
{
|
||||
/* remove bar item from bar items list */
|
||||
if (item->prev_item)
|
||||
item->prev_item->next_item = item->next_item;
|
||||
if (item->next_item)
|
||||
item->next_item->prev_item = item->prev_item;
|
||||
if (gui_bar_items == item)
|
||||
gui_bar_items = item->next_item;
|
||||
if (last_gui_bar_item == item)
|
||||
last_gui_bar_item = item->prev_item;
|
||||
|
||||
/* free data */
|
||||
if (item->name)
|
||||
free (item->name);
|
||||
|
||||
free (item);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_free_all: delete all bar items
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_free_all ()
|
||||
{
|
||||
while (gui_bar_items)
|
||||
{
|
||||
gui_bar_item_free (gui_bar_items);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_free_all_plugin: delete all bar items for a plugin
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_gui_bar_item *ptr_item, *next_item;
|
||||
|
||||
ptr_item = gui_bar_items;
|
||||
while (ptr_item)
|
||||
{
|
||||
next_item = ptr_item->next_item;
|
||||
|
||||
if (ptr_item->plugin == plugin)
|
||||
gui_bar_item_free (ptr_item);
|
||||
|
||||
ptr_item = next_item;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_buffer_count: default item for number of buffers
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_buffer_count (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) max_width;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s[%s%d%s] ",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_STATUS),
|
||||
(last_gui_buffer) ? last_gui_buffer->number : 0,
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_buffer_plugin: default item for name of buffer plugin
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_buffer_plugin (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s[%s%s%s] ",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_STATUS),
|
||||
(window->buffer->plugin) ? window->buffer->plugin->name : "core",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_buffer_name: default item for name of buffer
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_buffer_name (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[256];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%d%s:%s%s%s/%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_NUMBER),
|
||||
window->buffer->number,
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_STATUS_CATEGORY),
|
||||
window->buffer->category,
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_STATUS_NAME),
|
||||
window->buffer->name);
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_nicklist_count: default item for number of nicks in
|
||||
* buffer nicklist
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_nicklist_count (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
|
||||
if (!window || !window->buffer->nicklist)
|
||||
return NULL;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s[%s%d%s] ",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS),
|
||||
GUI_COLOR(GUI_COLOR_STATUS),
|
||||
window->buffer->nicklist_visible_count,
|
||||
GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_scroll: default item for scrolling indicator
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_scroll (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) max_width;
|
||||
|
||||
if (!window || !window->scroll)
|
||||
return NULL;
|
||||
|
||||
snprintf (buf, sizeof (buf), "%s%s ",
|
||||
GUI_COLOR(GUI_COLOR_STATUS_MORE),
|
||||
_("(MORE)"));
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_default_hotlist: default item for hotlist
|
||||
*/
|
||||
|
||||
char *
|
||||
gui_bar_item_default_hotlist (void *data, struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width)
|
||||
{
|
||||
char buf[1024], format[32];
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
int names_count, display_name;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
(void) max_width;
|
||||
|
||||
if (!gui_hotlist)
|
||||
return NULL;
|
||||
|
||||
buf[0] = '\0';
|
||||
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
strcat (buf, "[");
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS));
|
||||
strcat (buf, _("Act: "));
|
||||
|
||||
names_count = 0;
|
||||
for (ptr_hotlist = gui_hotlist; ptr_hotlist;
|
||||
ptr_hotlist = ptr_hotlist->next_hotlist)
|
||||
{
|
||||
switch (ptr_hotlist->priority)
|
||||
{
|
||||
case GUI_HOTLIST_LOW:
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_OTHER));
|
||||
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 1) != 0);
|
||||
break;
|
||||
case GUI_HOTLIST_MESSAGE:
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_MSG));
|
||||
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 2) != 0);
|
||||
break;
|
||||
case GUI_HOTLIST_PRIVATE:
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_PRIVATE));
|
||||
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 4) != 0);
|
||||
break;
|
||||
case GUI_HOTLIST_HIGHLIGHT:
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DATA_HIGHLIGHT));
|
||||
display_name = ((CONFIG_INTEGER(config_look_hotlist_names_level) & 8) != 0);
|
||||
break;
|
||||
default:
|
||||
display_name = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf (buf + strlen (buf), "%d", ptr_hotlist->buffer->number);
|
||||
|
||||
if (display_name
|
||||
&& (CONFIG_INTEGER(config_look_hotlist_names_count) != 0)
|
||||
&& (names_count < CONFIG_INTEGER(config_look_hotlist_names_count)))
|
||||
{
|
||||
names_count++;
|
||||
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
strcat (buf, ":");
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS));
|
||||
if (CONFIG_INTEGER(config_look_hotlist_names_length) == 0)
|
||||
snprintf (format, sizeof (format) - 1, "%%s");
|
||||
else
|
||||
snprintf (format, sizeof (format) - 1,
|
||||
"%%.%ds",
|
||||
CONFIG_INTEGER(config_look_hotlist_names_length));
|
||||
sprintf (buf + strlen (buf), format, ptr_hotlist->buffer->name);
|
||||
}
|
||||
|
||||
if (ptr_hotlist->next_hotlist)
|
||||
strcat (buf, ",");
|
||||
|
||||
if (strlen (buf) > sizeof (buf) - 32)
|
||||
break;
|
||||
}
|
||||
strcat (buf, GUI_COLOR(GUI_COLOR_STATUS_DELIMITERS));
|
||||
strcat (buf, "] ");
|
||||
|
||||
return strdup (buf);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_signal_cb: callback when a signal is received, for rebuilding
|
||||
* an item
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_item_signal_cb (void *data, char *signal,
|
||||
char *type_data, void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
(void) signal_data;
|
||||
|
||||
gui_bar_item_update ((char *)data);
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_init: init default items in WeeChat
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_init ()
|
||||
{
|
||||
/* buffer count */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_COUNT],
|
||||
&gui_bar_item_default_buffer_count, NULL);
|
||||
gui_bar_item_hook1 = hook_signal (NULL, "buffer_open",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_COUNT]);
|
||||
gui_bar_item_hook2 = hook_signal (NULL, "buffer_closed",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_COUNT]);
|
||||
|
||||
/* buffer plugin */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_PLUGIN],
|
||||
&gui_bar_item_default_buffer_plugin, NULL);
|
||||
|
||||
/* buffer name */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_NAME],
|
||||
&gui_bar_item_default_buffer_name, NULL);
|
||||
gui_bar_item_hook3 = hook_signal (NULL, "buffer_renamed",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_NAME]);
|
||||
gui_bar_item_hook4 = hook_signal (NULL, "buffer_moved",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_BUFFER_NAME]);
|
||||
|
||||
/* nicklist count */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_NICKLIST_COUNT],
|
||||
&gui_bar_item_default_nicklist_count, NULL);
|
||||
gui_bar_item_hook5 = hook_signal (NULL, "nicklist_changed",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_NICKLIST_COUNT]);
|
||||
|
||||
/* scroll indicator */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_SCROLL],
|
||||
&gui_bar_item_default_scroll, NULL);
|
||||
gui_bar_item_hook6 = hook_signal (NULL, "window_scrolled",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_SCROLL]);
|
||||
|
||||
/* hotlist */
|
||||
gui_bar_item_new (NULL,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_HOTLIST],
|
||||
&gui_bar_item_default_hotlist, NULL);
|
||||
gui_bar_item_hook7 = hook_signal (NULL, "hotlist_changed",
|
||||
&gui_bar_item_signal_cb,
|
||||
gui_bar_item_names[GUI_BAR_ITEM_WEECHAT_HOTLIST]);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_end: remove bar items and hooks
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_end ()
|
||||
{
|
||||
/* remove hooks */
|
||||
unhook (gui_bar_item_hook1);
|
||||
unhook (gui_bar_item_hook2);
|
||||
unhook (gui_bar_item_hook3);
|
||||
unhook (gui_bar_item_hook4);
|
||||
unhook (gui_bar_item_hook5);
|
||||
unhook (gui_bar_item_hook6);
|
||||
unhook (gui_bar_item_hook7);
|
||||
|
||||
/* remove bar items */
|
||||
gui_bar_item_free_all ();
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_item_print_log: print bar items infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_item_print_log ()
|
||||
{
|
||||
struct t_gui_bar_item *ptr_item;
|
||||
|
||||
for (ptr_item = gui_bar_items; ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf ("[bar item (addr:0x%x)]", ptr_item);
|
||||
log_printf (" plugin . . . . . . . . : 0x%x", ptr_item->plugin);
|
||||
log_printf (" name . . . . . . . . . : '%s'", ptr_item->name);
|
||||
log_printf (" build_callback . . . . : 0x%x", ptr_item->build_callback);
|
||||
log_printf (" build_callback_data. . : 0x%x", ptr_item->build_callback_data);
|
||||
log_printf (" prev_item. . . . . . . : 0x%x", ptr_item->prev_item);
|
||||
log_printf (" next_item. . . . . . . : 0x%x", ptr_item->next_item);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_GUI_BAR_ITEM_H
|
||||
#define __WEECHAT_GUI_BAR_ITEM_H 1
|
||||
|
||||
enum t_gui_bar_item_weechat
|
||||
{
|
||||
GUI_BAR_ITEM_WEECHAT_BUFFER_COUNT = 0,
|
||||
GUI_BAR_ITEM_WEECHAT_BUFFER_PLUGIN,
|
||||
GUI_BAR_ITEM_WEECHAT_BUFFER_NAME,
|
||||
GUI_BAR_ITEM_WEECHAT_NICKLIST_COUNT,
|
||||
GUI_BAR_ITEM_WEECHAT_SCROLL,
|
||||
GUI_BAR_ITEM_WEECHAT_HOTLIST,
|
||||
/* number of bar items */
|
||||
GUI_BAR_NUM_ITEMS,
|
||||
};
|
||||
|
||||
struct t_gui_window;
|
||||
|
||||
struct t_gui_bar_item
|
||||
{
|
||||
struct t_weechat_plugin *plugin; /* plugin */
|
||||
char *name; /* bar item name */
|
||||
char *(*build_callback)(void *data,
|
||||
struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width);
|
||||
/* callback called for building item */
|
||||
void *build_callback_data; /* data for callback */
|
||||
struct t_gui_bar_item *prev_item; /* link to previous bar item */
|
||||
struct t_gui_bar_item *next_item; /* link to next bar item */
|
||||
};
|
||||
|
||||
/* variables */
|
||||
|
||||
extern struct t_gui_bar_item *gui_bar_items;
|
||||
extern struct t_gui_bar_item *last_gui_bar_item;
|
||||
|
||||
/* functions */
|
||||
|
||||
extern struct t_gui_bar_item *gui_bar_item_search (char *name);
|
||||
extern struct t_gui_bar_item *gui_bar_item_new (struct t_weechat_plugin *plugin,
|
||||
char *name,
|
||||
char *(*build_callback)(void *data,
|
||||
struct t_gui_bar_item *item,
|
||||
struct t_gui_window *window,
|
||||
int max_width),
|
||||
void *build_callback_data);
|
||||
extern void gui_bar_item_update (char *name);
|
||||
extern void gui_bar_item_free (struct t_gui_bar_item *item);
|
||||
extern void gui_bar_item_free_all ();
|
||||
extern void gui_bar_item_free_all_plugin (struct t_weechat_plugin *plugin);
|
||||
extern void gui_bar_item_init ();
|
||||
extern void gui_bar_item_end ();
|
||||
extern void gui_bar_item_print_log ();
|
||||
|
||||
#endif /* gui-bar-item.h */
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* gui-bar.c: bar functions, used by all GUI */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-log.h"
|
||||
#include "../core/wee-string.h"
|
||||
#include "gui-bar.h"
|
||||
#include "gui-window.h"
|
||||
|
||||
|
||||
char *gui_bar_type_str[GUI_BAR_NUM_TYPES] =
|
||||
{ "root", "window_active", "window_inactive" };
|
||||
char *gui_bar_position_str[GUI_BAR_NUM_POSITIONS] =
|
||||
{ "bottom", "top", "left", "right" };
|
||||
|
||||
struct t_gui_bar *gui_bars = NULL; /* first bar */
|
||||
struct t_gui_bar *last_gui_bar = NULL; /* last bar */
|
||||
|
||||
|
||||
/*
|
||||
* gui_bar_root_get_size: get total bar size ("root" type) for a position
|
||||
*/
|
||||
|
||||
int
|
||||
gui_bar_root_get_size (struct t_gui_bar *bar, int position)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
int total_size;
|
||||
|
||||
total_size = 0;
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (bar && (ptr_bar == bar))
|
||||
return total_size;
|
||||
|
||||
if ((ptr_bar->type == GUI_BAR_TYPE_ROOT)
|
||||
&& (ptr_bar->position == position))
|
||||
{
|
||||
total_size += ptr_bar->size;
|
||||
if (ptr_bar->separator)
|
||||
total_size++;
|
||||
}
|
||||
}
|
||||
return total_size;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_search: search a bar by name
|
||||
*/
|
||||
|
||||
struct t_gui_bar *
|
||||
gui_bar_search (char *name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (strcmp (ptr_bar->name, name) == 0)
|
||||
return ptr_bar;
|
||||
}
|
||||
|
||||
/* bar not found */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_new: create a new bar
|
||||
*/
|
||||
|
||||
struct t_gui_bar *
|
||||
gui_bar_new (struct t_weechat_plugin *plugin, char *name, char *type,
|
||||
char *position, int size, int separator, char *items)
|
||||
{
|
||||
struct t_gui_bar *new_bar;
|
||||
struct t_gui_window *ptr_win;
|
||||
int i, type_value, position_value;
|
||||
|
||||
if (!name || !name[0])
|
||||
return NULL;
|
||||
|
||||
/* it's not possible to create 2 bars with same name */
|
||||
if (gui_bar_search (name))
|
||||
return NULL;
|
||||
|
||||
/* look for type */
|
||||
type_value = -1;
|
||||
for (i = 0; i < GUI_BAR_NUM_TYPES; i++)
|
||||
{
|
||||
if (string_strcasecmp (type, gui_bar_type_str[i]) == 0)
|
||||
{
|
||||
type_value = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type_value < 0)
|
||||
return NULL;
|
||||
|
||||
/* look for position */
|
||||
position_value = -1;
|
||||
for (i = 0; i < GUI_BAR_NUM_POSITIONS; i++)
|
||||
{
|
||||
if (string_strcasecmp (position, gui_bar_position_str[i]) == 0)
|
||||
{
|
||||
position_value = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (position_value < 0)
|
||||
return NULL;
|
||||
|
||||
/* create bar */
|
||||
new_bar = (struct t_gui_bar *) malloc (sizeof (struct t_gui_bar));
|
||||
if (new_bar)
|
||||
{
|
||||
new_bar->plugin = plugin;
|
||||
new_bar->number = (last_gui_bar) ? last_gui_bar->number + 1 : 1;
|
||||
new_bar->name = strdup (name);
|
||||
new_bar->type = type_value;
|
||||
new_bar->position = position_value;
|
||||
new_bar->size = size;
|
||||
new_bar->separator = separator;
|
||||
if (items && items[0])
|
||||
{
|
||||
new_bar->items = strdup (items);
|
||||
new_bar->items_array = string_explode (items, ",", 0, 0,
|
||||
&new_bar->items_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
new_bar->items = NULL;
|
||||
new_bar->items_count = 0;
|
||||
new_bar->items_array = NULL;
|
||||
}
|
||||
|
||||
if (type_value == GUI_BAR_TYPE_ROOT)
|
||||
{
|
||||
/* create only one window for bar */
|
||||
gui_bar_window_new (new_bar, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* create bar window for all opened windows */
|
||||
for (ptr_win = gui_windows; ptr_win;
|
||||
ptr_win = ptr_win->next_window)
|
||||
{
|
||||
gui_bar_window_new (new_bar, ptr_win);
|
||||
}
|
||||
}
|
||||
|
||||
/* add bar to bars queue */
|
||||
new_bar->prev_bar = last_gui_bar;
|
||||
if (gui_bars)
|
||||
last_gui_bar->next_bar = new_bar;
|
||||
else
|
||||
gui_bars = new_bar;
|
||||
last_gui_bar = new_bar;
|
||||
new_bar->next_bar = NULL;
|
||||
|
||||
gui_window_refresh_needed = 1;
|
||||
|
||||
return new_bar;
|
||||
}
|
||||
|
||||
/* failed to create bar */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_update: update a bar on screen
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_update (char *name)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
if (strcmp (ptr_bar->name, name) == 0)
|
||||
gui_bar_draw (ptr_bar);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_free: delete a bar
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_free (struct t_gui_bar *bar)
|
||||
{
|
||||
/* remove bar from bars list */
|
||||
if (bar->prev_bar)
|
||||
bar->prev_bar->next_bar = bar->next_bar;
|
||||
if (bar->next_bar)
|
||||
bar->next_bar->prev_bar = bar->prev_bar;
|
||||
if (gui_bars == bar)
|
||||
gui_bars = bar->next_bar;
|
||||
if (last_gui_bar == bar)
|
||||
last_gui_bar = bar->prev_bar;
|
||||
|
||||
/* free data */
|
||||
if (bar->name)
|
||||
free (bar->name);
|
||||
if (bar->bar_window)
|
||||
gui_bar_window_free (bar->bar_window);
|
||||
if (bar->items)
|
||||
free (bar->items);
|
||||
if (bar->items_array)
|
||||
string_free_exploded (bar->items_array);
|
||||
|
||||
free (bar);
|
||||
|
||||
gui_window_refresh_needed = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_free_all: delete all bars
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_free_all ()
|
||||
{
|
||||
while (gui_bars)
|
||||
{
|
||||
gui_bar_free (gui_bars);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_free_all_plugin: delete all bars for a plugin
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_free_all_plugin (struct t_weechat_plugin *plugin)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar, *next_bar;
|
||||
|
||||
ptr_bar = gui_bars;
|
||||
while (ptr_bar)
|
||||
{
|
||||
next_bar = ptr_bar->next_bar;
|
||||
|
||||
if (ptr_bar->plugin == plugin)
|
||||
gui_bar_free (ptr_bar);
|
||||
|
||||
ptr_bar = next_bar;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_bar_print_log: print bar infos in log (usually for crash dump)
|
||||
*/
|
||||
|
||||
void
|
||||
gui_bar_print_log ()
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
|
||||
for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar)
|
||||
{
|
||||
log_printf ("");
|
||||
log_printf ("[bar (addr:0x%x)]", ptr_bar);
|
||||
log_printf (" plugin . . . . . . . . : 0x%x", ptr_bar->plugin);
|
||||
log_printf (" number . . . . . . . . : %d", ptr_bar->number);
|
||||
log_printf (" name . . . . . . . . . : '%s'", ptr_bar->name);
|
||||
log_printf (" type . . . . . . . . . : %d (%s)",
|
||||
ptr_bar->type,
|
||||
gui_bar_type_str[ptr_bar->type]);
|
||||
log_printf (" position . . . . . . . : %d (%s)",
|
||||
ptr_bar->position,
|
||||
gui_bar_position_str[ptr_bar->position]);
|
||||
log_printf (" size . . . . . . . . . : %d", ptr_bar->size);
|
||||
log_printf (" separator. . . . . . . : %d", ptr_bar->separator);
|
||||
log_printf (" items. . . . . . . . . : '%s'", ptr_bar->items);
|
||||
log_printf (" items_count. . . . . . : %d", ptr_bar->items_count);
|
||||
log_printf (" items_array. . . . . . : 0x%x", ptr_bar->items_array);
|
||||
log_printf (" bar_window . . . . . . : 0x%x", ptr_bar->bar_window);
|
||||
log_printf (" prev_bar . . . . . . . : 0x%x", ptr_bar->prev_bar);
|
||||
log_printf (" next_bar . . . . . . . : 0x%x", ptr_bar->next_bar);
|
||||
|
||||
if (ptr_bar->bar_window)
|
||||
gui_bar_window_print_log (ptr_bar->bar_window);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
|
||||
* See README for License detail, AUTHORS for developers list.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WEECHAT_GUI_BAR_H
|
||||
#define __WEECHAT_GUI_BAR_H 1
|
||||
|
||||
struct t_weechat_plugin;
|
||||
struct t_gui_window;
|
||||
|
||||
enum t_gui_bar_type
|
||||
{
|
||||
GUI_BAR_TYPE_ROOT = 0,
|
||||
GUI_BAR_TYPE_WINDOW_ACTIVE,
|
||||
GUI_BAR_TYPE_WINDOW_INACTIVE,
|
||||
/* number of bar types */
|
||||
GUI_BAR_NUM_TYPES,
|
||||
};
|
||||
|
||||
enum t_gui_bar_position
|
||||
{
|
||||
GUI_BAR_POSITION_BOTTOM = 0,
|
||||
GUI_BAR_POSITION_TOP,
|
||||
GUI_BAR_POSITION_LEFT,
|
||||
GUI_BAR_POSITION_RIGHT,
|
||||
/* number of bar positions */
|
||||
GUI_BAR_NUM_POSITIONS,
|
||||
};
|
||||
|
||||
struct t_gui_bar
|
||||
{
|
||||
/* user choices */
|
||||
struct t_weechat_plugin *plugin; /* plugin */
|
||||
int number; /* bar number */
|
||||
char *name; /* bar name */
|
||||
int type; /* type (root or window) */
|
||||
int position; /* position (bottom, top, left, right) */
|
||||
int size; /* size of bar (in chars) */
|
||||
int separator; /* 1 if separator (line) displayed */
|
||||
char *items; /* bar items */
|
||||
|
||||
/* internal vars */
|
||||
int items_count; /* number of bar items */
|
||||
char **items_array; /* exploded bar items */
|
||||
struct t_gui_bar_window *bar_window; /* pointer to bar window */
|
||||
/* (for type root only) */
|
||||
struct t_gui_bar *prev_bar; /* link to previous bar */
|
||||
struct t_gui_bar *next_bar; /* link to next bar */
|
||||
};
|
||||
|
||||
/* variables */
|
||||
|
||||
extern char *gui_bar_type_str[];
|
||||
extern char *gui_bar_position_str[];
|
||||
extern struct t_gui_bar *gui_bars;
|
||||
extern struct t_gui_bar *last_gui_bar;
|
||||
|
||||
/* functions */
|
||||
|
||||
extern int gui_bar_root_get_size (struct t_gui_bar *bar, int position);
|
||||
extern struct t_gui_bar *gui_bar_search (char *name);
|
||||
extern struct t_gui_bar *gui_bar_new (struct t_weechat_plugin *plugin,
|
||||
char *name, char *type, char *position,
|
||||
int size, int separator, char *items);
|
||||
extern void gui_bar_update (char *name);
|
||||
extern void gui_bar_free (struct t_gui_bar *bar);
|
||||
extern void gui_bar_free_all ();
|
||||
extern void gui_bar_free_all_plugin (struct t_weechat_plugin *plugin);
|
||||
extern void gui_bar_print_log ();
|
||||
|
||||
/* functions (GUI dependent) */
|
||||
|
||||
extern int gui_bar_window_get_size (struct t_gui_bar *bar,
|
||||
struct t_gui_window *window, int position);
|
||||
extern int gui_bar_window_new (struct t_gui_bar *bar,
|
||||
struct t_gui_window *window);
|
||||
extern void gui_bar_window_free (struct t_gui_bar_window *bar_window);
|
||||
extern void gui_bar_draw (struct t_gui_bar *bar);
|
||||
extern void gui_bar_window_print_log (struct t_gui_bar_window *bar_window);
|
||||
|
||||
#endif /* gui-bar.h */
|
||||
+12
-3
@@ -253,6 +253,9 @@ gui_buffer_set_category (struct t_gui_buffer *buffer, char *category)
|
||||
buffer->category = strdup (category);
|
||||
}
|
||||
gui_status_refresh_needed = 1;
|
||||
|
||||
hook_signal_send ("buffer_renamed",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -269,6 +272,9 @@ gui_buffer_set_name (struct t_gui_buffer *buffer, char *name)
|
||||
buffer->name = strdup (name);
|
||||
}
|
||||
gui_status_refresh_needed = 1;
|
||||
|
||||
hook_signal_send ("buffer_renamed",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -625,7 +631,7 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another)
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_line *ptr_line;
|
||||
|
||||
hook_signal_send ("buffer_close",
|
||||
hook_signal_send ("buffer_closing",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
|
||||
if (buffer->close_callback)
|
||||
@@ -708,6 +714,8 @@ gui_buffer_close (struct t_gui_buffer *buffer, int switch_to_another)
|
||||
|
||||
if (gui_windows && gui_current_window && gui_current_window->buffer)
|
||||
gui_status_refresh_needed = 1;
|
||||
|
||||
hook_signal_send ("buffer_closed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -903,8 +911,9 @@ gui_buffer_move_to_number (struct t_gui_buffer *buffer, int number)
|
||||
snprintf (buf1_str, sizeof (buf1_str) - 1, "%d", buffer->number);
|
||||
argv[0] = buf1_str;
|
||||
argv[1] = buf2_str;
|
||||
/* TODO: send buffer_move event */
|
||||
/*plugin_event_handler_exec ("buffer_move", 2, argv);*/
|
||||
|
||||
hook_signal_send ("buffer_moved",
|
||||
WEECHAT_HOOK_SIGNAL_POINTER, buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -28,8 +28,10 @@
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-hook.h"
|
||||
#include "../core/wee-log.h"
|
||||
#include "../core/wee-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-hotlist.h"
|
||||
#include "gui-buffer.h"
|
||||
#include "gui-status.h"
|
||||
@@ -178,6 +180,8 @@ gui_hotlist_add_hotlist (struct t_gui_hotlist **hotlist,
|
||||
*hotlist = new_hotlist;
|
||||
*last_hotlist = new_hotlist;
|
||||
}
|
||||
|
||||
hook_signal_send ("hotlist_changed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -312,6 +316,8 @@ gui_hotlist_free (struct t_gui_hotlist **hotlist,
|
||||
|
||||
free (ptr_hotlist);
|
||||
*hotlist = new_hotlist;
|
||||
|
||||
hook_signal_send ("hotlist_changed", WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user