diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-17 15:47:52 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-02-17 15:47:52 +0100 |
commit | 4e4fd3f54d8fcd4aaf95f3aac5357d93de7ea2ff (patch) | |
tree | 2e22289ff0df3de04269cead0145a4c13bf8d3b5 /src/gui | |
parent | bc079b007dbef41db8082f3e668a5e131bd60300 (diff) | |
download | weechat-4e4fd3f54d8fcd4aaf95f3aac5357d93de7ea2ff.zip |
core: remove Gtk interface (obsolete sources not working)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/gui/Makefile.am | 6 | ||||
-rw-r--r-- | src/gui/gtk/CMakeLists.txt | 72 | ||||
-rw-r--r-- | src/gui/gtk/Makefile.am | 46 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-bar-window.c | 122 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-chat.c | 371 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-color.c | 357 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-key.c | 56 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-main.c | 284 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-mouse.c | 104 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-term.c | 35 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk-window.c | 935 | ||||
-rw-r--r-- | src/gui/gtk/gui-gtk.h | 109 |
13 files changed, 1 insertions, 2500 deletions
diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index fadcd6647..e9c2cc22f 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -45,7 +45,3 @@ ADD_LIBRARY(weechat_gui_common STATIC ${LIB_GUI_COMMON_SRC}) IF(ENABLE_NCURSES) SUBDIRS( curses ) ENDIF(ENABLE_NCURSES) - -IF(ENABLE_GTK) - ADD_SUBDIRECTORY( gtk ) -ENDIF(ENABLE_GTK) diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 287f87c2f..63b40effe 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -65,10 +65,6 @@ if GUI_NCURSES curses_dir=curses endif -if GUI_GTK -gtk_dir=gtk -endif - -SUBDIRS = . $(curses_dir) $(gtk_dir) +SUBDIRS = . $(curses_dir) EXTRA_DIST = CMakeLists.txt diff --git a/src/gui/gtk/CMakeLists.txt b/src/gui/gtk/CMakeLists.txt deleted file mode 100644 index c8cf3c582..000000000 --- a/src/gui/gtk/CMakeLists.txt +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> -# Copyright (C) 2007 Julien Louis <ptitlouis@sysif.net> -# -# This file is part of WeeChat, the extensible chat client. -# -# WeeChat 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. -# -# WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. -# - -SET(WEECHAT_GTK_SRC -gui-gtk.h -gui-gtk-bar-window.c -gui-gtk-chat.c -gui-gtk-color.c -gui-gtk-key.c -gui-gtk-main.c -gui-gtk-mouse.c -gui-gtk-term.c -gui-gtk-window.c) - -SET(EXECUTABLE weechat-gtk) - -FIND_PACKAGE(PkgConfig) -IF(PKG_CONFIG_FOUND) - pkg_check_modules(GTK2 gtk+-x11-2.0) - IF(GTK2_FOUND) - INCLUDE_DIRECTORIES( ${GTK2_INCLUDE_DIRS} ) - LIST(APPEND EXTRA_LIBS ${GTK2_LIBRARIES}) - # ELSE(GTK2_FOUND) - # MESSAGE(FATAL_ERROR "Missing dependency, aborting configuration phase") - ENDIF(GTK2_FOUND) -ENDIF(PKG_CONFIG_FOUND) - -IF(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - IF(HAVE_BACKTRACE) - LIST(APPEND EXTRA_LIBS "execinfo") - ENDIF(HAVE_BACKTRACE) -ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - -IF(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") - LIST(APPEND EXTRA_LIBS "pthread") -ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD") - -IF(ICONV_LIBRARY) - LIST(APPEND EXTRA_LIBS ${ICONV_LIBRARY}) -ENDIF(ICONV_LIBRARY) - -IF(LIBINTL_LIBRARY) - LIST(APPEND EXTRA_LIBS ${LIBINTL_LIBRARY}) -ENDIF(LIBINTL_LIBRARY) - -LIST(APPEND EXTRA_LIBS ${CURL_LIBRARIES}) - -ADD_EXECUTABLE(${EXECUTABLE} ${WEECHAT_GTK_SRC}) - -INCLUDE_DIRECTORIES(.. ../../core ../../plugins) - -# Because of a linker bug, we have to link 2 times with libweechat_core.a -TARGET_LINK_LIBRARIES(${EXECUTABLE} ${STATIC_LIBS} ${EXTRA_LIBS} ${STATIC_LIBS}) - -INSTALL(TARGETS ${EXECUTABLE} RUNTIME DESTINATION bin) diff --git a/src/gui/gtk/Makefile.am b/src/gui/gtk/Makefile.am deleted file mode 100644 index c4bcaf08a..000000000 --- a/src/gui/gtk/Makefile.am +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> -# -# This file is part of WeeChat, the extensible chat client. -# -# WeeChat 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. -# -# WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. -# - -INCLUDES = -DLOCALEDIR=\"$(datadir)/locale\" $(GTK_CFLAGS) - -bin_PROGRAMS = weechat-gtk - -# Because of a linker bug, we have to link 2 times with lib_weechat_core.a -# (and it must be 2 different path/names to be kept by linker) -weechat_gtk_LDADD = ./../../core/lib_weechat_core.a \ - ../../plugins/lib_weechat_plugins.a \ - ../lib_weechat_gui_common.a \ - ../../core/lib_weechat_core.a \ - $(PLUGINS_LFLAGS) \ - $(GTK_LFLAGS) \ - $(GCRYPT_LFLAGS) \ - $(GNUTLS_LFLAGS) \ - $(CURL_LFLAGS) - -weechat_gtk_SOURCES = gui-gtk-bar-window.c \ - gui-gtk-chat.c \ - gui-gtk-color.c \ - gui-gtk-key.c \ - gui-gtk-main.c \ - gui-gtk-mouse.c \ - gui-gtk-term.c \ - gui-gtk-window.c \ - gui-gtk.h - -EXTRA_DIST = CMakeLists.txt diff --git a/src/gui/gtk/gui-gtk-bar-window.c b/src/gui/gtk/gui-gtk-bar-window.c deleted file mode 100644 index db377de13..000000000 --- a/src/gui/gtk/gui-gtk-bar-window.c +++ /dev/null @@ -1,122 +0,0 @@ -/* - * gui-gtk-bar-window.c - bar window functions for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> - -#include "../../core/weechat.h" -#include "../../core/wee-config.h" -#include "../../core/wee-log.h" -#include "../gui-bar.h" -#include "../gui-bar-window.h" -#include "../gui-color.h" -#include "../gui-window.h" -#include "gui-gtk.h" - - -/* - * Initializes Gtk windows for bar window. - */ - -int -gui_bar_window_objects_init (struct t_gui_bar_window *bar_window) -{ - struct t_gui_bar_window_gtk_objects *new_objects; - - new_objects = malloc (sizeof (*new_objects)); - if (new_objects) - { - bar_window->gui_objects = new_objects; - /* TODO: init Gtk windows */ - return 1; - } - return 0; -} - -/* - * Frees Gtk windows for a bar window. - */ - -void -gui_bar_window_objects_free (struct t_gui_bar_window *bar_window) -{ - /* TODO: free Gtk windows */ - (void) bar_window; -} - -/* - * Creates curses window for bar. - */ - -void -gui_bar_window_create_win (struct t_gui_bar_window *bar_window) -{ - (void) bar_window; - - /* TODO: write this function for Gtk */ -} - -/* - * Prints a string text on a bar window. - * - * Returns number of chars displayed on screen. - */ - -int -gui_bar_window_print_string (struct t_gui_bar_window *bar_window, - const char *string, int max_chars) -{ - (void) bar_window; - (void) string; - (void) max_chars; - - /* TODO: write this function for Gtk */ - return 0; -} - -/* - * Draws a bar for a window. - */ - -void -gui_bar_window_draw (struct t_gui_bar_window *bar_window, - struct t_gui_window *window) -{ - (void) bar_window; - (void) window; - - /* TODO: write this function for Gtk */ -} - -/* - * Prints bar window infos in WeeChat log file (usually for crash dump). - */ - -void -gui_bar_window_objects_print_log (struct t_gui_bar_window *bar_window) -{ - log_printf (" bar window specific objects for Gtk:"); - /* TODO: add specific objects */ - (void) bar_window; -} diff --git a/src/gui/gtk/gui-gtk-chat.c b/src/gui/gtk/gui-gtk-chat.c deleted file mode 100644 index ca48a2ade..000000000 --- a/src/gui/gtk/gui-gtk-chat.c +++ /dev/null @@ -1,371 +0,0 @@ -/* - * gui-gtk-chat.c - chat display functions for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include "../../core/weechat.h" -#include "../../core/wee-config.h" -#include "../../core/wee-utf8.h" -#include "../gui-buffer.h" -#include "../gui-chat.h" -#include "../gui-color.h" -#include "../gui-main.h" -#include "../gui-line.h" -#include "../gui-window.h" -#include "gui-gtk.h" - - -/* - * Sets style (bold, underline, ..) for a chat window. - */ - -void -gui_chat_set_style (struct t_gui_window *window, int style) -{ - /* TODO: write this function for Gtk */ - /*wattron (window->win_chat, style);*/ - (void) window; - (void) style; -} - -/* - * Removes style (bold, underline, ..) for a chat window. - */ - -void -gui_chat_remove_style (struct t_gui_window *window, int style) -{ - /* TODO: write this function for Gtk */ - /*wattroff (window->win_chat, style);*/ - (void) window; - (void) style; -} - -/* - * Toggles a style (bold, underline, ..) for a chat window. - */ - -void -gui_chat_toggle_style (struct t_gui_window *window, int style) -{ - GUI_WINDOW_OBJECTS(window)->current_style_attr ^= style; - if (GUI_WINDOW_OBJECTS(window)->current_style_attr & style) - gui_chat_set_style (window, style); - else - gui_chat_remove_style (window, style); -} - -/* - * Resets style (color and attr) for a chat window. - */ - -void -gui_chat_reset_style (struct t_gui_window *window) -{ - GUI_WINDOW_OBJECTS(window)->current_style_fg = -1; - GUI_WINDOW_OBJECTS(window)->current_style_bg = -1; - GUI_WINDOW_OBJECTS(window)->current_style_attr = 0; - GUI_WINDOW_OBJECTS(window)->current_color_attr = 0; - - /* TODO: change following function call */ - /*gui_window_set_weechat_color (window->win_chat, COLOR_WIN_CHAT);*/ - gui_chat_remove_style (window, - A_BOLD | A_UNDERLINE | A_REVERSE); -} - -/* - * Sets style for color. - */ - -void -gui_chat_set_color_style (struct t_gui_window *window, int style) -{ - GUI_WINDOW_OBJECTS(window)->current_color_attr |= style; - /* TODO: change following function call */ - /*wattron (window->win_chat, style);*/ -} - -/* - * Removes style for color. - */ - -void -gui_chat_remove_color_style (struct t_gui_window *window, int style) -{ - GUI_WINDOW_OBJECTS(window)->current_color_attr &= !style; - /* TODO: change following function call */ - /*wattroff (window->win_chat, style);*/ -} - -/* - * Resets style for color. - */ - -void -gui_chat_reset_color_style (struct t_gui_window *window) -{ - /* TODO: change following function call */ - /*wattroff (window->win_chat, window->current_color_attr);*/ - GUI_WINDOW_OBJECTS(window)->current_color_attr = 0; -} - -/* - * Sets color for a chat window. - */ - -void -gui_chat_set_color (struct t_gui_window *window, int fg, int bg) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) fg; - (void) bg; -} - -/* - * Sets a WeeChat color for a chat window. - */ - -void -gui_chat_set_weechat_color (struct t_gui_window *window, int weechat_color) -{ - gui_chat_reset_style (window); - gui_chat_set_style (window, - gui_color[weechat_color]->attributes); - gui_chat_set_color (window, - gui_color[weechat_color]->foreground, - gui_color[weechat_color]->background); -} - -/* - * Returns next char of a word (for display), special chars like - * colors/attributes are skipped and optionally applied. - */ - -char * -gui_chat_string_next_char (struct t_gui_window *window, struct t_gui_line *line, - const unsigned char *string, int apply_style, - int apply_style_inactive, - int nick_offline) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) line; - (void) apply_style; - (void) apply_style_inactive; - (void) nick_offline; - - return (char *)string; -} - -/* - * Display word on chat buffer, letter by letter, special chars like - * colors/attributes are interpreted. - */ - -void -gui_chat_display_word_raw (struct t_gui_window *window, const char *string) -{ - /*char *prev_char, *next_char, saved_char;*/ - - /* TODO: write this function for Gtk */ - (void) window; - (void) string; -} - -/* - * Displays a word on chat buffer. - */ - -void -gui_chat_display_word (struct t_gui_window *window, - struct t_gui_line *line, - const char *data, - const char *end_offset, - int num_lines, int count, int *lines_displayed, int simulate) -{ - /*char *end_line, saved_char_end, saved_char; - int pos_saved_char, chars_to_display, num_displayed;*/ - - /* TODO: write this function for Gtk */ - (void) window; - (void) line; - (void) data; - (void) end_offset; - (void) num_lines; - (void) count; - (void) lines_displayed; - (void) simulate; -} - -/* - * Displays a line in the chat window. - * - * If count == 0, display whole line. - * If count > 0, display 'count' lines (beginning from the end). - * If simulate == 1, nothing is displayed (for counting how many lines would - * have been lines displayed). - * - * Returns number of lines displayed (or simulated). - */ - -int -gui_chat_display_line (struct t_gui_window *window, struct t_gui_line *line, int count, - int simulate) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) line; - (void) count; - (void) simulate; - return 1; -} - -/* - * Returns pointer to line & offset for a difference with given line. - */ - -void -gui_chat_calculate_line_diff (struct t_gui_window *window, struct t_gui_line **line, - int *line_pos, int difference) -{ - int backward, current_size; - - if (!line || !line_pos) - return; - - backward = (difference < 0); - - if (!(*line)) - { - /* if looking backward, start at last line of buffer */ - if (backward) - { - *line = window->buffer->lines->last_line; - if (!(*line)) - return; - current_size = gui_chat_display_line (window, *line, 0, 1); - if (current_size == 0) - current_size = 1; - *line_pos = current_size - 1; - } - /* if looking forward, start at first line of buffer */ - else - { - *line = window->buffer->lines->first_line; - if (!(*line)) - return; - *line_pos = 0; - current_size = gui_chat_display_line (window, *line, 0, 1); - } - } - else - current_size = gui_chat_display_line (window, *line, 0, 1); - - while ((*line) && (difference != 0)) - { - /* looking backward */ - if (backward) - { - if (*line_pos > 0) - (*line_pos)--; - else - { - *line = (*line)->prev_line; - if (*line) - { - current_size = gui_chat_display_line (window, *line, 0, 1); - if (current_size == 0) - current_size = 1; - *line_pos = current_size - 1; - } - } - difference++; - } - /* looking forward */ - else - { - if (*line_pos < current_size - 1) - (*line_pos)++; - else - { - *line = (*line)->next_line; - if (*line) - { - current_size = gui_chat_display_line (window, *line, 0, 1); - if (current_size == 0) - current_size = 1; - *line_pos = 0; - } - } - difference--; - } - } - - /* first or last line reached */ - if (!(*line)) - { - if (backward) - { - /* first line reached */ - *line = window->buffer->lines->first_line; - *line_pos = 0; - } - else - { - /* last line reached => consider we'll display all until the end */ - *line_pos = 0; - } - } -} - -/* - * Draws chat window for a buffer. - */ - -void -gui_chat_draw (struct t_gui_buffer *buffer, int clear_chat) -{ - /*struct t_gui_window *ptr_win; - struct t_gui_line *ptr_line; - t_irc_dcc *dcc_first, *dcc_selected, *ptr_dcc; - char format_empty[32]; - int i, j, line_pos, count, num_bars; - char *unit_name[] = { N_("bytes"), N_("Kb"), N_("Mb"), N_("Gb") }; - char *unit_format[] = { "%.0Lf", "%.1Lf", "%.02Lf", "%.02Lf" }; - long unit_divide[] = { 1, 1024, 1024*1024, 1024*1024,1024 }; - int num_unit; - char format[32], date[128], *buf; - struct tm *date_tmp;*/ - - if (!gui_init_ok) - return; - - /* TODO: write this function for Gtk */ - (void) buffer; - (void) clear_chat; -} diff --git a/src/gui/gtk/gui-gtk-color.c b/src/gui/gtk/gui-gtk-color.c deleted file mode 100644 index a98b7a6d9..000000000 --- a/src/gui/gtk/gui-gtk-color.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * gui-gtk-color.c - color functions for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> -#include <ctype.h> - -#include "../../core/weechat.h" -#include "../../core/wee-config.h" -#include "../../core/wee-string.h" -#include "../gui-color.h" -#include "gui-gtk.h" - - -struct t_gui_color gui_weechat_colors[] = -{ { -1, 0, 0, "default" }, - { WEECHAT_COLOR_BLACK, 0, 0, "black" }, - { WEECHAT_COLOR_RED, 0, 0, "red" }, - { WEECHAT_COLOR_RED, 0, A_BOLD, "lightred" }, - { WEECHAT_COLOR_GREEN, 0, 0, "green" }, - { WEECHAT_COLOR_GREEN, 0, A_BOLD, "lightgreen" }, - { WEECHAT_COLOR_YELLOW, 0, 0, "brown" }, - { WEECHAT_COLOR_YELLOW, 0, A_BOLD, "yellow" }, - { WEECHAT_COLOR_BLUE, 0, 0, "blue" }, - { WEECHAT_COLOR_BLUE, 0, A_BOLD, "lightblue" }, - { WEECHAT_COLOR_MAGENTA, 0, 0, "magenta" }, - { WEECHAT_COLOR_MAGENTA, 0, A_BOLD, "lightmagenta" }, - { WEECHAT_COLOR_CYAN, 0, 0, "cyan" }, - { WEECHAT_COLOR_CYAN, 0, A_BOLD, "lightcyan" }, - { WEECHAT_COLOR_WHITE, 0, A_BOLD, "white" }, - { 0, 0, 0, NULL } -}; - - -/* - * Searches for a color by name. - * - * Returns index of color in WeeChat colors table. - */ - -int -gui_color_search (const char *color_name) -{ - int i; - - for (i = 0; gui_weechat_colors[i].string; i++) - { - if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0) - return i; - } - - /* color not found */ - return -1; -} - -/* - * Assigns a WeeChat color (read from configuration). - */ - -int -gui_color_assign (int *color, const char *color_name) -{ - int i; - - /* look for curses colors in table */ - i = 0; - while (gui_weechat_colors[i].string) - { - if (string_strcasecmp (gui_weechat_colors[i].string, color_name) == 0) - { - *color = i; - return 1; - } - i++; - } - - /* color not found */ - return 0; -} - -/* - * Assigns color by difference. - * - * It is called when a color option is set with value ++X or --X, to search - * another color (for example ++1 is next color/alias in list). - * - * Returns: - * 1: OK - * 0: error - */ - -int -gui_color_assign_by_diff (int *color, const char *color_name, int diff) -{ - /* TODO: write this function for Gtk */ - (void) color; - (void) color_name; - (void) diff; - - return 1; -} - -/* - * Gets number of available colors. - */ - -int -gui_color_get_weechat_colors_number () -{ - return 0; -} - -/* - * Gets number of colors supported by terminal. - */ - -int -gui_color_get_term_colors () -{ - return 0; -} - -/* - * Gets a pair with given foreground/background colors. - */ - -int -gui_color_get_pair (int fg, int bg) -{ - (void) fg; - (void) bg; - - return 0; -} - -/* - * Gets color pair with a WeeChat color number. - */ - -int -gui_color_weechat_get_pair (int weechat_color) -{ - (void) weechat_color; - - return 0; -} - -/* - * Gets color name. - */ - -const char * -gui_color_get_name (int num_color) -{ - return gui_weechat_colors[num_color].string; -} - -/* - * Initializes WeeChat colors. - */ - -void -gui_color_init_weechat () -{ - /* TODO: write this function for Gtk */ -} - -/* - * Rebuilds WeeChat colors. - */ - -void -gui_color_rebuild_weechat () -{ - int i; - - for (i = 0; i < GUI_COLOR_NUM_COLORS; i++) - { - if (gui_color[i]) - { - if (gui_color[i]->string) - free (gui_color[i]->string); - free (gui_color[i]); - gui_color[i] = NULL; - } - } - gui_color_init_weechat (); -} - -/* - * Displays terminal colors. - * - * This is called by command line option "-c" / "--colors". - */ - -void -gui_color_display_terminal_colors () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Displays content of color buffer. - */ - -void -gui_color_buffer_display () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Switches between WeeChat and terminal colors. - */ - -void -gui_color_switch_colors () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Resets all color pairs. - */ - -void -gui_color_reset_pairs () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Assigns color buffer to pointer if it is not yet set. - */ - -void -gui_color_buffer_assign () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Opens a buffer to display colors. - */ - -void -gui_color_buffer_open () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Builds aliases for palette. - */ - -void -gui_color_palette_build_aliases () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Creates a new color in palette. - */ - -struct t_gui_color_palette * -gui_color_palette_new (int number, const char *value) -{ - /* This function does nothing in Gtk GUI */ - (void) number; - (void) value; - - return NULL; -} - -/* - * Frees a color in palette. - */ - -void -gui_color_palette_free (struct t_gui_color_palette *color_palette) -{ - /* This function does nothing in Gtk GUI */ - (void) color_palette; -} - -/* - * Pre-initializes colors. - */ - -void -gui_color_pre_init () -{ - int i; - - for (i = 0; i < GUI_COLOR_NUM_COLORS; i++) - { - gui_color[i] = NULL; - } -} - -/* - * Initializes GUI colors. - */ - -void -gui_color_init () -{ - gui_color_init_weechat (); -} - -/* - * Dumps colors. - */ - -void -gui_color_dump () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Ends GUI colors. - */ - -void -gui_color_end () -{ - int i; - - for (i = 0; i < GUI_COLOR_NUM_COLORS; i++) - { - gui_color_free (gui_color[i]); - } -} diff --git a/src/gui/gtk/gui-gtk-key.c b/src/gui/gtk/gui-gtk-key.c deleted file mode 100644 index a482a71d4..000000000 --- a/src/gui/gtk/gui-gtk-key.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * gui-gtk-keyboard.c - keyboard functions for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <string.h> - -#include "../../core/weechat.h" -#include "../../core/wee-utf8.h" -#include "../../plugins/plugin.h" -#include "../gui-key.h" -#include "../gui-buffer.h" -#include "gui-gtk.h" - - -/* - * Creates default key bindings. - */ - -void -gui_key_default_bindings (int context) -{ - /* TODO: write this function for Gtk */ - (void) context; -} - -/* - * Reads keyboard chars. - */ - -void -gui_key_read () -{ - /* TODO: write this function for Gtk */ -} diff --git a/src/gui/gtk/gui-gtk-main.c b/src/gui/gtk/gui-gtk-main.c deleted file mode 100644 index 3dfb9153f..000000000 --- a/src/gui/gtk/gui-gtk-main.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - * gui-gtk-main.c - main loop for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <stdlib.h> -#include <stdio.h> -#include <unistd.h> -#include <string.h> -#include <signal.h> - -#include "../../core/weechat.h" -#include "../../core/wee-config.h" -#include "../../core/wee-utf8.h" -#include "../../core/wee-version.h" -#include "../../plugins/plugin.h" -#include "../gui-bar.h" -#include "../gui-bar-item.h" -#include "../gui-bar-window.h" -#include "../gui-chat.h" -#include "../gui-main.h" -#include "../gui-buffer.h" -#include "../gui-filter.h" -#include "../gui-history.h" -#include "../gui-input.h" -#include "../gui-layout.h" -#include "../gui-window.h" -#include "gui-gtk.h" - - -GtkWidget *gui_gtk_main_window; -GtkWidget *gui_gtk_vbox1; -GtkWidget *gui_gtk_entry_topic; -GtkWidget *gui_gtk_notebook1; -GtkWidget *gui_gtk_vbox2; -GtkWidget *gui_gtk_hbox1; -GtkWidget *gui_gtk_hpaned1; -GtkWidget *gui_gtk_scrolledwindow_chat; -GtkWidget *gui_gtk_scrolledwindow_nick; -GtkWidget *gui_gtk_entry_input; -GtkWidget *gui_gtk_label1; - - -/* - * Pre-initializes GUI (called before gui_init). - */ - -void -gui_main_pre_init (int *argc, char **argv[]) -{ - /* pre-init colors */ - gui_color_pre_init (); - - /* init some variables for chat area */ - gui_chat_init (); - - /* Initialise Gtk */ - gtk_init (argc, argv); -} - -/* - * Initializes GUI. - */ - -void -gui_main_init () -{ - struct t_gui_buffer *ptr_buffer; - struct t_gui_bar *ptr_bar; - struct t_gui_bar_window *ptr_bar_win; - GdkColor color_fg, color_bg; - - gui_color_init (); - - /* build prefixes according to configuration */ - gui_chat_prefix_build (); - - /* init clipboard buffer */ - gui_input_clipboard = NULL; - - /* create Gtk widgets */ - - gdk_color_parse ("white", &color_fg); - gdk_color_parse ("black", &color_bg); - - gui_gtk_main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - gtk_window_set_title (GTK_WINDOW (gui_gtk_main_window), - version_get_name_version ()); - - g_signal_connect (G_OBJECT (gui_gtk_main_window), "destroy", gtk_main_quit, NULL); - - gui_gtk_vbox1 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (gui_gtk_vbox1); - gtk_container_add (GTK_CONTAINER (gui_gtk_main_window), gui_gtk_vbox1); - - gui_gtk_entry_topic = gtk_entry_new (); - gtk_widget_show (gui_gtk_entry_topic); - gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_entry_topic, FALSE, FALSE, 0); - gtk_widget_modify_text (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_fg); - gtk_widget_modify_base (gui_gtk_entry_topic, GTK_STATE_NORMAL, &color_bg); - - gui_gtk_notebook1 = gtk_notebook_new (); - gtk_widget_show (gui_gtk_notebook1); - gtk_box_pack_start (GTK_BOX (gui_gtk_vbox1), gui_gtk_notebook1, TRUE, TRUE, 0); - gtk_notebook_set_tab_pos (GTK_NOTEBOOK (gui_gtk_notebook1), GTK_POS_BOTTOM); - - gui_gtk_vbox2 = gtk_vbox_new (FALSE, 0); - gtk_widget_show (gui_gtk_vbox2); - gtk_container_add (GTK_CONTAINER (gui_gtk_notebook1), gui_gtk_vbox2); - - gui_gtk_hbox1 = gtk_hbox_new (FALSE, 0); - gtk_widget_show (gui_gtk_hbox1); - gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_hbox1, TRUE, TRUE, 0); - - gui_gtk_hpaned1 = gtk_hpaned_new (); - gtk_widget_show (gui_gtk_hpaned1); - gtk_box_pack_start (GTK_BOX (gui_gtk_hbox1), gui_gtk_hpaned1, TRUE, TRUE, 0); - gtk_paned_set_position (GTK_PANED (gui_gtk_hpaned1), 0); - - gui_gtk_scrolledwindow_chat = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (gui_gtk_scrolledwindow_chat); - gtk_paned_pack1 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_chat, - FALSE, TRUE); - /*gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_chat, TRUE, TRUE, 0);*/ - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_chat), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - gtk_widget_modify_text (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_fg); - gtk_widget_modify_base (gui_gtk_scrolledwindow_chat, GTK_STATE_NORMAL, &color_bg); - - gui_gtk_scrolledwindow_nick = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_show (gui_gtk_scrolledwindow_nick); - gtk_paned_pack2 (GTK_PANED (gui_gtk_hpaned1), gui_gtk_scrolledwindow_nick, - FALSE, TRUE); - /*gtk_box_pack_start (GTK_PANED (hpaned1), scrolledwindow_nick, TRUE, TRUE, 0);*/ - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (gui_gtk_scrolledwindow_nick), - GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); - gtk_widget_modify_text (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_fg); - gtk_widget_modify_base (gui_gtk_scrolledwindow_nick, GTK_STATE_NORMAL, &color_bg); - - gui_gtk_entry_input = gtk_entry_new (); - gtk_widget_show (gui_gtk_entry_input); - gtk_box_pack_start (GTK_BOX (gui_gtk_vbox2), gui_gtk_entry_input, FALSE, - FALSE, 0); - gtk_widget_modify_text (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_fg); - gtk_widget_modify_base (gui_gtk_entry_input, GTK_STATE_NORMAL, &color_bg); - - gui_gtk_label1 = gtk_label_new (_("server")); - gtk_widget_show (gui_gtk_label1); - gtk_notebook_set_tab_label (GTK_NOTEBOOK (gui_gtk_notebook1), - gtk_notebook_get_nth_page (GTK_NOTEBOOK (gui_gtk_notebook1), 0), - gui_gtk_label1); - gtk_label_set_justify (GTK_LABEL (gui_gtk_label1), GTK_JUSTIFY_LEFT); - - gtk_widget_show_all (gui_gtk_main_window); - - gui_init_ok = 0; - - /* create core buffer */ - ptr_buffer = gui_buffer_new (NULL, "weechat", NULL, NULL, NULL, NULL); - if (ptr_buffer) - { - gui_init_ok = 1; - - /* set title for core buffer */ - gui_buffer_set_title (ptr_buffer, - "WeeChat " WEECHAT_COPYRIGHT_DATE - " - " WEECHAT_WEBSITE); - - /* create main window (using full space) */ - if (gui_window_new (NULL, ptr_buffer, 0, 0, 0, 0, 100, 100)) - { - gui_current_window = gui_windows; - - if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_set_title (version_get_name_version ()); - } - - /* - * create bar windows for root bars (they were read from config, - * but no window was created (GUI was not initialized) - */ - for (ptr_bar = gui_bars; ptr_bar; ptr_bar = ptr_bar->next_bar) - { - if ((CONFIG_INTEGER(ptr_bar->options[GUI_BAR_OPTION_TYPE]) == GUI_BAR_TYPE_ROOT) - && (!ptr_bar->bar_window)) - { - gui_bar_window_new (ptr_bar, NULL); - } - } - for (ptr_bar_win = gui_windows->bar_windows; - ptr_bar_win; ptr_bar_win = ptr_bar_win->next_bar_window) - { - gui_bar_window_calculate_pos_size (ptr_bar_win, gui_windows); - gui_bar_window_create_win (ptr_bar_win); - } - } -} - -/* - * Main loop for WeeChat with Gtk GUI. - */ - -void -gui_main_loop () -{ - /* TODO: write this function for Gtk */ - gtk_main (); -} - -/* - * Ends GUI. - * - * Argument "clean_exit" is 0 when WeeChat is crashing (we don't clean objects - * because WeeChat can crash again during this cleanup...). - */ - -void -gui_main_end (int clean_exit) -{ - if (clean_exit) - { - /* remove bar items and bars */ - gui_bar_item_end (); - gui_bar_free_all (); - - /* remove filters */ - gui_filter_free_all (); - - /* free clipboard buffer */ - if (gui_input_clipboard) - free(gui_input_clipboard); - - /* delete layout saved */ - gui_layout_window_remove_all (&gui_layout_windows); - gui_layout_buffer_remove_all (&gui_layout_buffers, &last_gui_layout_buffer); - - /* delete all windows */ - while (gui_windows) - { - gui_window_free (gui_windows); - /* TODO: destroy Gtk widgets */ - } - gui_window_tree_free (&gui_windows_tree); - - /* delete all buffers */ - while (gui_buffers) - { - gui_buffer_close (gui_buffers); - } - - /* delete global history */ - gui_history_global_free (); - - /* reset title */ - if (CONFIG_BOOLEAN(config_look_set_title)) - gui_window_set_title (NULL); - - /* end color */ - gui_color_end (); - - /* free some variables used for chat area */ - gui_chat_end (); - } -} diff --git a/src/gui/gtk/gui-gtk-mouse.c b/src/gui/gtk/gui-gtk-mouse.c deleted file mode 100644 index b80fd71ec..000000000 --- a/src/gui/gtk/gui-gtk-mouse.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * gui-gtk-mouse.c - mouse functions for Gtk GUI - * - * Copyright (C) 2011-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "../../core/weechat.h" -#include "../gui-mouse.h" - - -/* - * Enables mouse. - */ - -void -gui_mouse_enable () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Disables mouse. - */ - -void -gui_mouse_disable () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Displays state of mouse. - */ - -void -gui_mouse_display_state () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Initializes "grab mode". - */ - -void -gui_mouse_grab_init (int area) -{ - (void) area; - - /* This function does nothing in Gtk GUI */ -} - -/* - * Initializes mouse event. - */ - -void -gui_mouse_event_init () -{ - /* This function does nothing in Gtk GUI */ -} - -/* - * Gets key name with a mouse code. - */ - -const char * -gui_mouse_event_code2key (const char *code) -{ - (void) code; - - /* This function does nothing in Gtk GUI */ - - return NULL; -} - -/* - * Ends mouse event. - */ - -void -gui_mouse_event_end () -{ - /* This function does nothing in Gtk GUI */ -} diff --git a/src/gui/gtk/gui-gtk-term.c b/src/gui/gtk/gui-gtk-term.c deleted file mode 100644 index 892a9e0a6..000000000 --- a/src/gui/gtk/gui-gtk-term.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * gui-gtk-term.c - terminal functions for Gtk GUI - * - * Copyright (C) 2011-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -/* - * Not used in Gtk GUI. - */ - -void -gui_term_set_eat_newline_glitch (int value) -{ - /* make C compiler happy */ - (void) value; -} diff --git a/src/gui/gtk/gui-gtk-window.c b/src/gui/gtk/gui-gtk-window.c deleted file mode 100644 index ac8dedc0b..000000000 --- a/src/gui/gtk/gui-gtk-window.c +++ /dev/null @@ -1,935 +0,0 @@ -/* - * gui-gtk-window.c - window display functions for Gtk GUI - * - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#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 "../../plugins/plugin.h" -#include "../gui-window.h" -#include "../gui-bar.h" -#include "../gui-buffer.h" -#include "../gui-chat.h" -#include "../gui-hotlist.h" -#include "../gui-line.h" -#include "../gui-nicklist.h" -#include "../gui-main.h" -#include "gui-gtk.h" - - -/* - * Gets screen width. - */ - -int -gui_window_get_width () -{ - return 0; -} - -/* - * Gets screen height. - */ - -int -gui_window_get_height () -{ - return 0; -} - -/* - * Initializes Gtk widgets. - * - * Returns: - * 1: OK - * 0: error - */ - -int -gui_window_objects_init (struct t_gui_window *window) -{ - struct t_gui_window_gtk_objects *new_objects; - - if ((new_objects = malloc (sizeof (*new_objects)))) - { - window->gui_objects = new_objects; - GUI_WINDOW_OBJECTS(window)->textview_chat = NULL; - GUI_WINDOW_OBJECTS(window)->textbuffer_chat = NULL; - GUI_WINDOW_OBJECTS(window)->texttag_chat = NULL; - return 1; - } - return 0; -} - -/* - * Frees Gtk widgets for a window. - */ - -void -gui_window_objects_free (struct t_gui_window *window, int free_separators) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) free_separators; -} - -/* - * Sets WeeChat color for window. - */ - -/* TODO: write this function for Gtk */ -/*void -gui_window_set_weechat_color (WINDOW *window, int num_color) -{ - if ((num_color >= 0) && (num_color <= GUI_NUM_COLORS - 1)) - { - wattroff (window, A_BOLD | A_UNDERLINE | A_REVERSE); - wattron (window, COLOR_PAIR(gui_color_get_pair (num_color)) | - gui_color[num_color]->attributes); - } -}*/ - -/* - * Calculates position and size for a window & sub-win. - */ - -void -gui_window_calculate_pos_size (struct t_gui_window *window) -{ - /* TODO: write this function for Gtk */ - (void) window; -} - -/* - * Draws window separation. - */ - -void -gui_window_draw_separators (struct t_gui_window *window) -{ - /* TODO: write this function for Gtk */ - /*if (window->win_separator) - delwin (window->win_separator); - - if (window->win_x > 0) - { - window->win_separator = newwin (window->win_height, - 1, - window->win_y, - window->win_x - 1); - gui_window_set_weechat_color (window->win_separator, COLOR_WIN_SEPARATOR); - wborder (window->win_separator, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '); - wnoutrefresh (window->win_separator); - refresh (); - }*/ - (void) window; -} - -/* - * Redraws a buffer. - */ - -void -gui_window_redraw_buffer (struct t_gui_buffer *buffer) -{ - /* TODO: write this function for Gtk */ - (void) buffer; -} - -/* - * Redraws all buffers. - */ - -void -gui_window_redraw_all_buffers () -{ - /* TODO: write this function for Gtk */ -} - -/* - * Switches to another window. - */ - -void -gui_window_switch (struct t_gui_window *window) -{ - if (gui_current_window == window) - return; - - /* remove unused bars from current window */ - /* ... */ - - gui_current_window = window; - - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - - gui_window_redraw_buffer (gui_current_window->buffer); - - hook_signal_send ("window_switch", - WEECHAT_HOOK_SIGNAL_POINTER, window); -} - -/* - * Switches to another buffer. - */ - -void -gui_window_switch_to_buffer (struct t_gui_window *window, - struct t_gui_buffer *buffer, - int set_last_read) -{ - GtkTextIter start, end; - - gui_buffer_add_value_num_displayed (window->buffer, -1); - - if (window->buffer != buffer) - { - window->scroll->start_line = NULL; - window->scroll->start_line_pos = 0; - if (!gui_buffers_visited_frozen) - { - gui_buffer_visited_add (window->buffer); - gui_buffer_visited_add (buffer); - } - if (set_last_read) - { - if (window->buffer->num_displayed == 0) - { - window->buffer->lines->last_read_line = window->buffer->lines->last_line; - window->buffer->lines->first_line_not_read = 0; - } - if (buffer->lines->last_read_line == buffer->lines->last_line) - { - buffer->lines->last_read_line = NULL; - buffer->lines->first_line_not_read = 0; - } - } - } - - window->buffer = buffer; - gui_window_calculate_pos_size (window); - - if (!GUI_WINDOW_OBJECTS(window)->textview_chat) - { - GUI_WINDOW_OBJECTS(window)->textview_chat = gtk_text_view_new (); - gtk_widget_show (GUI_WINDOW_OBJECTS(window)->textview_chat); - gtk_container_add (GTK_CONTAINER (gui_gtk_scrolledwindow_chat), GUI_WINDOW_OBJECTS(window)->textview_chat); - gtk_widget_set_size_request (GUI_WINDOW_OBJECTS(window)->textview_chat, 300, -1); - gtk_text_view_set_editable (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE); - gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), FALSE); - - GUI_WINDOW_OBJECTS(window)->textbuffer_chat = gtk_text_buffer_new (NULL); - gtk_text_view_set_buffer (GTK_TEXT_VIEW (GUI_WINDOW_OBJECTS(window)->textview_chat), GUI_WINDOW_OBJECTS(window)->textbuffer_chat); - - /*GUI_WINDOW_OBJECTS(window)->texttag_chat = gtk_text_buffer_create_tag(GUI_WINDOW_OBJECTS(window)->textbuffer_chat, "courier", "font_family", "lucida");*/ - gtk_text_buffer_get_bounds (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, &start, &end); - gtk_text_buffer_apply_tag (GUI_WINDOW_OBJECTS(window)->textbuffer_chat, GUI_WINDOW_OBJECTS(window)->texttag_chat, &start, &end); - } - - window->scroll->start_line = NULL; - window->scroll->start_line_pos = 0; - - gui_buffer_add_value_num_displayed (buffer, 1); - - gui_hotlist_remove_buffer (buffer); -} - -/* - * Displays previous page on buffer. - */ - -void -gui_window_page_up (struct t_gui_window *window) -{ - if (!gui_init_ok) - return; - - if (!window->scroll->first_line_displayed) - { - gui_chat_calculate_line_diff (window, &window->scroll->start_line, - &window->scroll->start_line_pos, - (window->scroll->start_line) ? - (-1) * (window->win_chat_height - 1) : - (-1) * ((window->win_chat_height - 1) * 2)); - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Displays next page on buffer. - */ - -void -gui_window_page_down (struct t_gui_window *window) -{ - struct t_gui_line *ptr_line; - int line_pos; - - if (!gui_init_ok) - return; - - if (window->scroll->start_line) - { - gui_chat_calculate_line_diff (window, &window->scroll->start_line, - &window->scroll->start_line_pos, - window->win_chat_height - 1); - - /* check if we can display all */ - ptr_line = window->scroll->start_line; - line_pos = window->scroll->start_line_pos; - gui_chat_calculate_line_diff (window, &ptr_line, - &line_pos, - window->win_chat_height - 1); - if (!ptr_line) - { - window->scroll->start_line = NULL; - window->scroll->start_line_pos = 0; - } - - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Displays previous few lines in buffer. - */ - -void -gui_window_scroll_up (struct t_gui_window *window) -{ - if (!gui_init_ok) - return; - - if (!window->scroll->first_line_displayed) - { - gui_chat_calculate_line_diff (window, &window->scroll->start_line, - &window->scroll->start_line_pos, - (window->scroll->start_line) ? - (-1) * CONFIG_INTEGER(config_look_scroll_amount) : - (-1) * ( (window->win_chat_height - 1) + - CONFIG_INTEGER(config_look_scroll_amount))); - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Displays next few lines in buffer. - */ - -void -gui_window_scroll_down (struct t_gui_window *window) -{ - struct t_gui_line *ptr_line; - int line_pos; - - if (!gui_init_ok) - return; - - if (window->scroll->start_line) - { - gui_chat_calculate_line_diff (window, &window->scroll->start_line, - &window->scroll->start_line_pos, - CONFIG_INTEGER(config_look_scroll_amount)); - - /* check if we can display all */ - ptr_line = window->scroll->start_line; - line_pos = window->scroll->start_line_pos; - gui_chat_calculate_line_diff (window, &ptr_line, - &line_pos, - window->win_chat_height - 1); - - if (!ptr_line) - { - window->scroll->start_line = NULL; - window->scroll->start_line_pos = 0; - } - - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Scrolls to top of buffer. - */ - -void -gui_window_scroll_top (struct t_gui_window *window) -{ - if (!gui_init_ok) - return; - - if (!window->scroll->first_line_displayed) - { - window->scroll->start_line = window->buffer->lines->first_line; - window->scroll->start_line_pos = 0; - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Scrolls to bottom of buffer. - */ - -void -gui_window_scroll_bottom (struct t_gui_window *window) -{ - if (!gui_init_ok) - return; - - if (window->scroll->start_line) - { - window->scroll->start_line = NULL; - window->scroll->start_line_pos = 0; - gui_chat_draw (window->buffer, 0); - } -} - -/* - * Auto-resizes all windows, according to % of global size. - * - * This function is called after a terminal resize. - * - * Returns: - * 0: OK - * -1: all windows must be merged (not enough space) - */ - -int -gui_window_auto_resize (struct t_gui_window_tree *tree, - int x, int y, int width, int height, - int simulate) -{ - int size1, size2; - - if (tree) - { - if (tree->window) - { - if (!simulate) - { - tree->window->win_x = x; - tree->window->win_y = y; - tree->window->win_width = width; - tree->window->win_height = height; - } - } - else - { - if (tree->split_horizontal) - { - size1 = (height * tree->split_pct) / 100; - size2 = height - size1; - if (gui_window_auto_resize (tree->child1, x, y + size1, - width, size2, simulate) < 0) - return -1; - if (gui_window_auto_resize (tree->child2, x, y, - width, size1, simulate) < 0) - return -1; - } - else - { - size1 = (width * tree->split_pct) / 100; - size2 = width - size1 - 1; - if (gui_window_auto_resize (tree->child1, x, y, - size1, height, simulate) < 0) - return -1; - if (gui_window_auto_resize (tree->child2, x + size1 + 1, y, - size2, height, simulate) < 0) - return -1; - } - } - } - return 0; -} - -/* - * Auto-resizes and refreshes all windows. - */ - -void -gui_window_refresh_windows () -{ - /*struct t_gui_window *ptr_win, *old_current_window;*/ - - if (gui_init_ok) - { - /* TODO: write this function for Gtk */ - } -} - -/* - * Horizontally splits a window. - * - * Returns pointer to new window, NULL if error. - */ - -struct t_gui_window * -gui_window_split_horizontal (struct t_gui_window *window, int percentage) -{ - struct t_gui_window *new_window; - int height1, height2; - - if (!gui_init_ok) - return NULL; - - new_window = NULL; - - height1 = (window->win_height * percentage) / 100; - height2 = window->win_height - height1; - - if ((percentage > 0) && (percentage <= 100)) - { - new_window = gui_window_new (window, window->buffer, - window->win_x, window->win_y, - window->win_width, height1, - 100, percentage); - if (new_window) - { - /* reduce old window height (bottom window) */ - window->win_y = new_window->win_y + new_window->win_height; - window->win_height = height2; - window->win_height_pct = 100 - percentage; - - /* assign same buffer for new window (top window) */ - gui_buffer_add_value_num_displayed (new_window->buffer, 1); - - gui_window_switch_to_buffer (window, window->buffer, 1); - - gui_current_window = new_window; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - } - } - - return new_window; -} - -/* - * Vertically splits a window. - * - * Returns pointer to new window, NULL if error. - */ - -struct t_gui_window * -gui_window_split_vertical (struct t_gui_window *window, int percentage) -{ - struct t_gui_window *new_window; - int width1, width2; - - if (!gui_init_ok) - return NULL; - - new_window = NULL; - - width1 = (window->win_width * percentage) / 100; - width2 = window->win_width - width1 - 1; - - if ((percentage > 0) && (percentage <= 100)) - { - new_window = gui_window_new (window, window->buffer, - window->win_x + width1 + 1, window->win_y, - width2, window->win_height, - percentage, 100); - if (new_window) - { - /* reduce old window height (left window) */ - window->win_width = width1; - window->win_width_pct = 100 - percentage; - - /* assign same buffer for new window (right window) */ - gui_buffer_add_value_num_displayed (new_window->buffer, 1); - - gui_window_switch_to_buffer (window, window->buffer, 1); - - gui_current_window = new_window; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - - /* create & draw separators */ - gui_window_draw_separators (gui_current_window); - } - } - - return new_window; -} - -/* - * Resizes window. - */ - -void -gui_window_resize (struct t_gui_window *window, int percentage) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) percentage; -} - -/* - * Resizes window using delta percentage. - */ - -void -gui_window_resize_delta (struct t_gui_window *window, int delta_percentage) -{ - /* TODO: write this function for Gtk */ - (void) window; - (void) delta_percentage; -} - -/* - * Merges window with its sister. - * - * Returns: - * 1: OK - * 0: error - */ - -int -gui_window_merge (struct t_gui_window *window) -{ - struct t_gui_window_tree *parent, *sister; - - parent = window->ptr_tree->parent_node; - if (parent) - { - sister = (parent->child1->window == window) ? - parent->child2 : parent->child1; - - if (!(sister->window)) - return 0; - - if (window->win_y == sister->window->win_y) - { - /* horizontal merge */ - window->win_width += sister->window->win_width + 1; - window->win_width_pct += sister->window->win_width_pct; - } - else - { - /* vertical merge */ - window->win_height += sister->window->win_height; - window->win_height_pct += sister->window->win_height_pct; - } - if (sister->window->win_x < window->win_x) - window->win_x = sister->window->win_x; - if (sister->window->win_y < window->win_y) - window->win_y = sister->window->win_y; - - gui_window_free (sister->window); - gui_window_tree_node_to_leaf (parent, window); - - gui_window_switch_to_buffer (window, window->buffer, 1); - gui_window_redraw_buffer (window->buffer); - return 1; - } - return 0; -} - -/* - * Merges all windows into only one. - */ - -void -gui_window_merge_all (struct t_gui_window *window) -{ - /* TODO: write this function for Gtk */ - (void) window; -} - -/* - * Returns a code about position of 2 windows: - * 0 = they're not side by side - * 1 = side by side: win2 is over the win1 - * 2 = side by side: win2 on the right - * 3 = side by side: win2 below win1 - * 4 = side by side: win2 on the left - */ - -int -gui_window_side_by_side (struct t_gui_window *win1, struct t_gui_window *win2) -{ - /* win2 over win1 ? */ - if (win2->win_y + win2->win_height == win1->win_y) - { - if (win2->win_x >= win1->win_x + win1->win_width) - return 0; - if (win2->win_x + win2->win_width <= win1->win_x) - return 0; - return 1; - } - - /* win2 on the right ? */ - if (win2->win_x == win1->win_x + win1->win_width + 1) - { - if (win2->win_y >= win1->win_y + win1->win_height) - return 0; - if (win2->win_y + win2->win_height <= win1->win_y) - return 0; - return 2; - } - - /* win2 below win1 ? */ - if (win2->win_y == win1->win_y + win1->win_height) - { - if (win2->win_x >= win1->win_x + win1->win_width) - return 0; - if (win2->win_x + win2->win_width <= win1->win_x) - return 0; - return 3; - } - - /* win2 on the left ? */ - if (win2->win_x + win2->win_width + 1 == win1->win_x) - { - if (win2->win_y >= win1->win_y + win1->win_height) - return 0; - if (win2->win_y + win2->win_height <= win1->win_y) - return 0; - return 4; - } - - return 0; -} - -/* - * Searches and switches to a window over current window. - */ - -void -gui_window_switch_up (struct t_gui_window *window) -{ - struct t_gui_window *ptr_win; - - for (ptr_win = gui_windows; ptr_win; - ptr_win = ptr_win->next_window) - { - if ((ptr_win != window) && - (gui_window_side_by_side (window, ptr_win) == 1)) - { - gui_current_window = ptr_win; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - return; - } - } -} - -/* - * Searches and switches to a window below current window. - */ - -void -gui_window_switch_down (struct t_gui_window *window) -{ - struct t_gui_window *ptr_win; - - for (ptr_win = gui_windows; ptr_win; - ptr_win = ptr_win->next_window) - { - if ((ptr_win != window) && - (gui_window_side_by_side (window, ptr_win) == 3)) - { - gui_current_window = ptr_win; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - return; - } - } -} - -/* - * Searches and switches to a window on the left of current window. - */ - -void -gui_window_switch_left (struct t_gui_window *window) -{ - struct t_gui_window *ptr_win; - - for (ptr_win = gui_windows; ptr_win; - ptr_win = ptr_win->next_window) - { - if ((ptr_win != window) && - (gui_window_side_by_side (window, ptr_win) == 4)) - { - gui_current_window = ptr_win; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - return; - } - } -} - -/* - * Searches and switches to a window on the right of current window. - */ - -void -gui_window_switch_right (struct t_gui_window *window) -{ - struct t_gui_window *ptr_win; - - for (ptr_win = gui_windows; ptr_win; - ptr_win = ptr_win->next_window) - { - if ((ptr_win != window) && - (gui_window_side_by_side (window, ptr_win) == 2)) - { - gui_current_window = ptr_win; - gui_window_switch_to_buffer (gui_current_window, gui_current_window->buffer, 1); - gui_window_redraw_buffer (gui_current_window->buffer); - return; - } - } -} - -/* - * Balance windows (set all splits to 50%). - * - * Returns: - * 1: some windows have been balanced - * 0: nothing was changed - */ - -int -gui_window_balance (struct t_gui_window_tree *tree) -{ - (void) tree; - - /* TODO: write this function for Gtk */ - return 0; -} - -/* - * Swaps buffer of two windows. - * - * Argument "direction" can be: - * 0 = auto (swap with sister) - * 1 = window above - * 2 = window on the right - * 3 = window below - * 4 = window on the left - */ - -void -gui_window_swap (struct t_gui_window *window, int direction) -{ - (void) window; - (void) direction; - - /* TODO: write this function for Gtk */ -} - -/* - * Called when terminal size is modified. - */ - -void -gui_window_refresh_screen (int full_refresh) -{ - (void) full_refresh; - - /* TODO: write this function for Gtk */ -} - -/* - * Sets terminal title. - */ - -void -gui_window_set_title (const char *title) -{ - (void) title; - - /* TODO: write this function for Gtk */ -} - -/* - * Copies text to clipboard (sent to terminal). - */ - -void -gui_window_send_clipboard (const char *storage_unit, const char *text) -{ - (void) storage_unit; - (void) text; - - /* TODO: write this function for Gtk */ -} - -/* - * Enables/disables bracketed paste mode. - */ - -void -gui_window_set_bracketed_paste_mode (int enable) -{ - (void) enable; - - /* TODO: write this function for Gtk */ -} - -/* - * Moves cursor on screen (for cursor mode). - */ - -void -gui_window_move_cursor () -{ - /* TODO: write this function for Gtk */ -} - -/* - * Displays some infos about terminal and colors. - */ - -void -gui_window_term_display_infos () -{ - /* No term info for Gtk */ -} - -/* - * Prints Gtk objects infos in WeeChat log file (usually for crash dump). - */ - -void -gui_window_objects_print_log (struct t_gui_window *window) -{ - log_printf (" window specific objects for Gtk:"); - log_printf (" textview_chat . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->textview_chat); - log_printf (" textbuffer_chat . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->textbuffer_chat); - log_printf (" texttag_chat. . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->texttag_chat); - log_printf (" bar_windows . . . . : 0x%lx", GUI_WINDOW_OBJECTS(window)->bar_windows); - log_printf (" last_bar_windows. . : 0x%lx", GUI_WINDOW_OBJECTS(window)->last_bar_window); - log_printf (" current_style_fg. . : %d", GUI_WINDOW_OBJECTS(window)->current_style_fg); - log_printf (" current_style_bg. . : %d", GUI_WINDOW_OBJECTS(window)->current_style_bg); - log_printf (" current_style_attr. : %d", GUI_WINDOW_OBJECTS(window)->current_style_attr); - log_printf (" current_color_attr. : %d", GUI_WINDOW_OBJECTS(window)->current_color_attr); -} diff --git a/src/gui/gtk/gui-gtk.h b/src/gui/gtk/gui-gtk.h deleted file mode 100644 index e7e37b403..000000000 --- a/src/gui/gtk/gui-gtk.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org> - * - * This file is part of WeeChat, the extensible chat client. - * - * WeeChat 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. - * - * WeeChat 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 WeeChat. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __WEECHAT_GUI_GTK_H -#define __WEECHAT_GUI_GTK_H 1 - -#include <gtk/gtk.h> - -struct t_gui_window; -struct t_gui_buffer; -struct t_gui_line; - -/* TODO: remove these temporary defines */ - -#define A_BOLD 1 -#define A_UNDERLINE 2 -#define A_REVERSE 4 - -#define COLOR_BLACK 0 -#define COLOR_BLUE 1 -#define COLOR_GREEN 2 -#define COLOR_CYAN 3 -#define COLOR_RED 4 -#define COLOR_MAGENTA 5 -#define COLOR_YELLOW 6 -#define COLOR_WHITE 7 - -/* - * shift ncurses colors for compatibility with colors - * in IRC messages (same as other IRC clients) - */ - -#define WEECHAT_COLOR_BLACK COLOR_BLACK -#define WEECHAT_COLOR_RED COLOR_BLUE -#define WEECHAT_COLOR_GREEN COLOR_GREEN -#define WEECHAT_COLOR_YELLOW COLOR_CYAN -#define WEECHAT_COLOR_BLUE COLOR_RED -#define WEECHAT_COLOR_MAGENTA COLOR_MAGENTA -#define WEECHAT_COLOR_CYAN COLOR_YELLOW -#define WEECHAT_COLOR_WHITE COLOR_WHITE - -#define GUI_WINDOW_OBJECTS(window) \ - ((struct t_gui_window_gtk_objects *)(window->gui_objects)) -#define GUI_BAR_WINDOW_OBJECTS(bar_window) \ - ((struct t_gui_bar_window_gtk_objects *)(bar_window->gui_objects)) - -struct t_gui_window_gtk_objects -{ - GtkWidget *textview_chat; /* textview widget for chat */ - GtkTextBuffer *textbuffer_chat; /* textbuffer widget for chat */ - GtkTextTag *texttag_chat; /* texttag widget for chat */ - struct t_gui_bar_window *bar_windows; /* bar windows */ - struct t_gui_bar_window *last_bar_window; /* last bar window */ - int current_style_fg; /* current foreground color */ - int current_style_bg; /* current background color */ - int current_style_attr; /* current attributes (bold, ..) */ - int current_color_attr; /* attr sum of last color(s) used */ -}; - -struct t_gui_bar_window_gtk_objects -{ -}; - -extern GtkWidget *gui_gtk_main_window; -extern GtkWidget *gui_gtk_vbox1; -extern GtkWidget *gui_gtk_notebook1; -extern GtkWidget *gui_gtk_vbox2; -extern GtkWidget *gui_gtk_hbox1; -extern GtkWidget *gui_gtk_hpaned1; -extern GtkWidget *gui_gtk_scrolledwindow_chat; -extern GtkWidget *gui_gtk_entry_input; -extern GtkWidget *gui_gtk_label1; - -/* color functions */ -extern int gui_color_get_pair (int fg, int bg); -extern void gui_color_pre_init (); -extern void gui_color_init (); -extern void gui_color_end (); - -/* chat functions */ -extern void gui_chat_calculate_line_diff (struct t_gui_window *window, - struct t_gui_line **line, - int *line_pos, int difference); - -/* key functions */ -extern void gui_key_default_bindings (int context); -extern void gui_key_read (); - -/* window functions */ -extern void gui_window_redraw_buffer (struct t_gui_buffer *buffer); -extern void gui_window_set_title (const char *title); - -#endif /* __WEECHAT_GUI_GTK_H */ |