2 * Copyright (C) 1998 Peter Zelezny.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
27 #include <gtk/gtkbutton.h>
28 #include <gtk/gtkhbbox.h>
29 #include <gtk/gtkhbox.h>
30 #include <gtk/gtkvscrollbar.h>
31 #include <gtk/gtkstock.h>
33 #include "../common/xchat.h"
34 #include "../common/xchatc.h"
35 #include "../common/cfgfiles.h"
36 #include "../common/server.h"
45 close_rawlog (GtkWidget
*wid
, server
*serv
)
48 serv
->gui
->rawlog_window
= 0;
52 rawlog_save (server
*serv
, char *file
)
58 if (serv
->gui
->rawlog_window
)
59 fh
= xchat_open_file (file
, O_TRUNC
| O_WRONLY
| O_CREAT
,
60 0600, XOF_DOMODE
| XOF_FULLPATH
);
63 gtk_xtext_save (GTK_XTEXT (serv
->gui
->rawlog_textlist
), fh
);
70 rawlog_clearbutton (GtkWidget
* wid
, server
*serv
)
72 gtk_xtext_clear (GTK_XTEXT (serv
->gui
->rawlog_textlist
)->buffer
, 0);
77 rawlog_savebutton (GtkWidget
* wid
, server
*serv
)
79 gtkutil_file_req (_("Save As..."), rawlog_save
, serv
, NULL
, FRF_WRITE
);
84 open_rawlog (struct server
*serv
)
86 GtkWidget
*hbox
, *vscrollbar
, *vbox
;
89 if (serv
->gui
->rawlog_window
)
91 mg_bring_tofront (serv
->gui
->rawlog_window
);
95 snprintf (tbuf
, sizeof tbuf
, _("XChat: Rawlog (%s)"), serv
->servername
);
96 serv
->gui
->rawlog_window
=
97 mg_create_generic_tab ("RawLog", tbuf
, FALSE
, TRUE
, close_rawlog
, serv
,
98 640, 320, &vbox
, serv
);
100 hbox
= gtk_hbox_new (FALSE
, 2);
101 gtk_container_add (GTK_CONTAINER (vbox
), hbox
);
102 gtk_container_set_border_width (GTK_CONTAINER (hbox
), 4);
103 gtk_widget_show (hbox
);
105 serv
->gui
->rawlog_textlist
= gtk_xtext_new (colors
, 0);
106 gtk_xtext_set_tint (GTK_XTEXT (serv
->gui
->rawlog_textlist
), prefs
.tint_red
, prefs
.tint_green
, prefs
.tint_blue
);
107 gtk_xtext_set_background (GTK_XTEXT (serv
->gui
->rawlog_textlist
),
108 channelwin_pix
, prefs
.transparent
);
110 gtk_container_add (GTK_CONTAINER (hbox
), serv
->gui
->rawlog_textlist
);
111 gtk_xtext_set_font (GTK_XTEXT (serv
->gui
->rawlog_textlist
), prefs
.font_normal
);
112 GTK_XTEXT (serv
->gui
->rawlog_textlist
)->ignore_hidden
= 1;
113 gtk_widget_show (serv
->gui
->rawlog_textlist
);
115 vscrollbar
= gtk_vscrollbar_new (GTK_XTEXT (serv
->gui
->rawlog_textlist
)->adj
);
116 gtk_box_pack_start (GTK_BOX (hbox
), vscrollbar
, FALSE
, FALSE
, 0);
117 show_and_unfocus (vscrollbar
);
119 hbox
= gtk_hbutton_box_new ();
120 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox
), GTK_BUTTONBOX_SPREAD
);
121 gtk_box_pack_end (GTK_BOX (vbox
), hbox
, 0, 0, 0);
122 gtk_widget_show (hbox
);
124 gtkutil_button (hbox
, GTK_STOCK_CLEAR
, NULL
, rawlog_clearbutton
,
125 serv
, _("Clear rawlog"));
127 gtkutil_button (hbox
, GTK_STOCK_SAVE_AS
, NULL
, rawlog_savebutton
,
128 serv
, _("Save As..."));
130 gtk_widget_show (serv
->gui
->rawlog_window
);
134 fe_add_rawlog (server
*serv
, char *text
, int len
, int outbound
)
138 if (!serv
->gui
->rawlog_window
)
141 new_text
= malloc (len
+ 7);
143 len
= sprintf (new_text
, "\0033>>\017 %s", text
);
150 gtk_xtext_append (GTK_XTEXT (serv
->gui
->rawlog_textlist
)->buffer
, new_text
, len
);