+2002-10-28 Jordi Mallach <jordi@sindominio.net>
+
+ * Finally, GNOME2!
+
+ * configure.in: require GTK 2.0.0 and various GNOME2 libs.
+ * src/Makefile.am: new GNOME2 includes.
+ * src/client.c, src/client.h, src/commands.c, src/dialogs.c,
+ src/fields.c, src/fields.h, src/gtetrinet.c, src/misc.c, src/misc.h,
+ src/partyline.c, src/tetrinet.c, src/tetrinet.h: initial port to
+ GNOME2 by James Antill.
+
2002-10-28 Jordi Mallach <jordi@sindominio.net>
* src/config.c (config_loadconfig): patch from James Antill. Save
AC_PROG_CC
-AM_PATH_GTK(1.2.0,,exit 1)
+AM_PATH_GTK_2_0(2.0.0,,exit 1)
AM_GNU_GETTEXT_VERSION(0.11.5)
ALL_LINGUAS="ca"
-GNOME_INIT
+
+dnl *****************************************
+dnl pkg-config check time
+dnl *****************************************
+
+LIBGNOME_REQUIRED=2.0.0
+LIBGNOMEUI_REQUIRED=2.0.0
+
+dnl *****************************************
+dnl libgnome, libgnomeui needed for all utils
+dnl *****************************************
+
+PKG_CHECK_MODULES(GTET, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED)
+AC_SUBST(GTET_CFLAGS)
+AC_SUBST(GTET_LIBS)
AM_PATH_ESD(0.2.5, AC_DEFINE(HAVE_ESD, 1, [Define this to enable EsounD support.]))
SUBDIRS = images
localedir = $(datadir)/locale
-INCLUDES = -DLOCALEDIR=\"$(localedir)\" $(GTK_CFLAGS) $(GNOME_INCLUDEDIR)
-LDADD = $(GNOME_LIBDIR) $(GNOMEUI_LIBS) $(GTK_LIBS)
+
+GTET_DEBUG = -Wall -W -Wno-unused -g3 -O0
+
+INCLUDES = -DLOCALEDIR=\"$(localedir)\" $(GTET_CFLAGS) $(GTET_DEBUG)
+LDADD = $(GTET_LIBS)
AM_CPPFLAGS = -DGTETRINET_DATA=\"$(pkgdatadir)\"
gamesdir = $(prefix)/games
{
}
-void client_init (char *s, char *n)
+void client_init (const char *s, const char *n)
{
int i;
GTET_O_STRCPY(server, s);
extern void client_destroypipes (void);
/* functions for connecting and disconnecting */
-extern void client_init (char *server, char *nick);
+extern void client_init (const char *server, const char *nick);
extern void client_connectcancel (void);
extern void client_destroy (void);
{
GtkWidget *about;
- const char *authors[] = {N_("Ka-shu Wong <kswong@zip.com.au>"), NULL};
+ const char *authors[] = {N_("Ka-shu Wong <kswong@zip.com.au>"),
+ N_("James Antill <james@and.org>"),
+ NULL};
+ const char *documentors[] = {N_("Ka-shu Wong <kswong@zip.com.au>"),
+ N_("Jordi Mallach <jordi@sindominio.net>"),
+ NULL};
about = gnome_about_new (APPNAME, APPVERSION,
_("(C) 1999, 2000, 2001, 2002 Ka-shu Wong"),
- authors,
_("A Tetrinet client for GNOME.\n"
"Homepage: http://gtetrinet.sourceforge.net/\n"),
- NULL);
+ authors,
+ documentors,
+ NULL, NULL);
gtk_widget_show (about);
}
void prefdialog_apply (GnomePropertyBox *dialog, gint pagenum)
{
int i;
- char *midi;
-
+
if (pagenum == -1) {
for (i = 0; i < K_NUM; i ++) {
keys[i] = newkeys[i];
}
if (midichanged) {
- midi = gtk_entry_get_text (GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY(midientry))));
+ const char *midi = gtk_entry_get_text (GTK_ENTRY(gnome_entry_gtk_entry(GNOME_ENTRY(midientry))));
GTET_O_STRCPY (midicmd, midi);
}
themechanged = midichanged = FALSE;
gtk_signal_connect (GTK_OBJECT(soundcheck), "toggled",
- prefdialog_soundtoggle, NULL);
+ GTK_SIGNAL_FUNC(prefdialog_soundtoggle), NULL);
gtk_signal_connect (GTK_OBJECT(midicheck), "toggled",
- prefdialog_miditoggle, NULL);
+ GTK_SIGNAL_FUNC(prefdialog_miditoggle), NULL);
gtk_signal_connect (GTK_OBJECT(gnome_entry_gtk_entry(GNOME_ENTRY(midientry))),
"changed", GTK_SIGNAL_FUNC(prefdialog_midichanged), NULL);
gtk_signal_connect (GTK_OBJECT(themelist), "select_row",
#include <gtk/gtk.h>
#include <gnome.h>
-#include <gdk_imlib.h>
#include <stdio.h>
#include "config.h"
void fields_init (void)
{
- GdkBitmap *bmap;
GtkWidget *mb;
- if (gdk_imlib_load_file_to_pixmap (blocksfile, &blockpix, &bmap) == 0) {
+ GdkPixbuf *pb = NULL;
+ GError *err = NULL;
+ GdkBitmap *mask = NULL;
+
+ if (!(pb = gdk_pixbuf_new_from_file(blocksfile, &err))) {
mb = gnome_message_box_new (_("Error loading theme: cannot load graphics file\n"
"Falling back to default"),
GNOME_MESSAGE_BOX_ERROR, GNOME_STOCK_BUTTON_OK, NULL);
gnome_dialog_run (GNOME_DIALOG(mb));
config_loadtheme (DEFAULTTHEME);
- if (gdk_imlib_load_file_to_pixmap (blocksfile, &blockpix, &bmap) == 0) {
+ err = NULL;
+ if (!(pb = gdk_pixbuf_new_from_file(blocksfile, &err))) {
/* shouldnt happen */
fprintf (stderr, _("Error loading default theme: Aborting...\n"
"Check for installation errors\n"));
}
}
/* we dont want the bitmap mask */
+ gdk_pixbuf_render_pixmap_and_mask(pb, &blockpix, &mask, 1);
+ gdk_pixbuf_unref(pb);
}
void fields_cleanup (void)
{
- gdk_imlib_free_pixmap (blockpix);
+ gdk_pixmap_unref(blockpix);
}
/* a mess of functions here for creating the fields page */
widget = gtk_label_new (_("Attacks and defenses:"));
gtk_widget_show (widget);
gtk_box_pack_start (GTK_BOX(box), widget, TRUE, TRUE, 0);
- attdefwidget = gtk_text_new (NULL, NULL);
+ attdefwidget = gtk_text_view_new_with_buffer(gtk_text_buffer_new(tag_table));
gtk_widget_set_usize (attdefwidget, MAX(22*12, BLOCKSIZE*12), BLOCKSIZE*10);
- gtk_text_set_word_wrap (GTK_TEXT(attdefwidget), TRUE);
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(attdefwidget), GTK_WRAP_WORD);
GTK_WIDGET_UNSET_FLAGS (attdefwidget, GTK_CAN_FOCUS);
gtk_widget_show (attdefwidget);
scroll = gtk_scrolled_window_new (NULL, NULL);
/* game messages */
table2 = gtk_table_new (1, 2, FALSE);
- gmsgtext = gtk_text_new (NULL, NULL);
+ gmsgtext = gtk_text_view_new_with_buffer(gtk_text_buffer_new(tag_table));
gtk_widget_set_usize (gmsgtext, 0, 48);
gtk_widget_show (gmsgtext);
GTK_WIDGET_UNSET_FLAGS (gmsgtext, GTK_CAN_FOCUS);
void fields_attdefmsg (char *text)
{
- textbox_addtext (GTK_TEXT(attdefwidget), text);
- adjust_bottom (GTK_TEXT(attdefwidget)->vadj);
+ textbox_addtext (GTK_TEXT_VIEW(attdefwidget), text);
+ adjust_bottom (GTK_TEXT_VIEW(attdefwidget)->vadjustment);
}
void fields_attdefclear (void)
{
- gtk_text_freeze (GTK_TEXT(attdefwidget));
- gtk_text_backward_delete (GTK_TEXT(attdefwidget),
- gtk_text_get_point (GTK_TEXT(attdefwidget)));
- gtk_text_thaw (GTK_TEXT(attdefwidget));
+ gtk_text_buffer_set_text(GTK_TEXT_VIEW(attdefwidget)->buffer, "", 0);
}
void fields_setlines (int l)
void fields_gmsgadd (char *str)
{
- textbox_addtext (GTK_TEXT(gmsgtext), str);
- adjust_bottom (GTK_TEXT(gmsgtext)->vadj);
+ textbox_addtext (GTK_TEXT_VIEW(gmsgtext), str);
+ adjust_bottom (GTK_TEXT_VIEW(gmsgtext)->vadjustment);
}
void fields_gmsgclear (void)
{
- gtk_text_freeze (GTK_TEXT(gmsgtext));
- gtk_text_backward_delete (GTK_TEXT(gmsgtext),
- gtk_text_get_point (GTK_TEXT(gmsgtext)));
- gtk_text_thaw (GTK_TEXT(gmsgtext));
+ gtk_text_buffer_set_text(GTK_TEXT_VIEW(gmsgtext)->buffer, "", 0);
}
void fields_gmsginput (int i)
gtk_entry_set_position (GTK_ENTRY(gmsginput), strlen(buf));
}
-char *fields_gmsginputtext (void)
+const char *fields_gmsginputtext (void)
{
return gtk_entry_get_text (GTK_ENTRY(gmsginput));
}
extern void fields_gmsginputactivate (int i);
extern void fields_gmsginputadd (char *c);
extern void fields_gmsginputback (void);
-extern char *fields_gmsginputtext (void);
+extern const char *fields_gmsginputtext (void);
#include <gtk/gtk.h>
#include <gnome.h>
-#include <gdk_imlib.h>
#include <locale.h>
#include <stdlib.h>
#include <time.h>
srand (time(NULL));
gnome_init_with_popt_table (APPID, APPVERSION, argc, argv, options, 0 , NULL);
- gdk_imlib_init ();
+ textbox_setup (); /* needs to be done before text boxes are created */
+
/* load settings */
config_loadconfig ();
gtk_widget_set_usize(winlistwidget, 480, 360);
/* initialise some stuff */
- textbox_setup ();
commands_checkstate ();
/* check command line params */
GtkWidget *pixmapdata_label (char **d, char *str)
{
+ GdkPixbuf *pb;
GdkPixmap *pm;
GdkBitmap *mask;
- gdk_imlib_data_to_pixmap (d, &pm, &mask);
+ pb = gdk_pixbuf_new_from_xpm_data ((const char **)d);
+
+ gdk_pixbuf_render_pixmap_and_mask(pb, &pm, &mask, 1);
+ gdk_pixbuf_unref(pb);
return pixmap_label (pm, mask, str);
}
if (widget == app)
{
- /* Main window - check the notebook */
- game_area = (GTK_NOTEBOOK(notebook)->cur_page->child == pfields);
+ int cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
+ int pfields_page = gtk_notebook_page_num(GTK_NOTEBOOK(notebook),
+ pfields);
+ /* Main window - check the notebook */
+ game_area = (cur_page == pfields_page);
}
else
{
/* Sub-window - find out which */
- GtkArg arg;
+ char *title = NULL;
- arg.name = "title";
- gtk_object_getv( GTK_OBJECT(widget), 1, &arg );
- game_area = !strcmp( GTK_VALUE_STRING(arg), "Playing Fields" ); // FIXME
- g_free( GTK_VALUE_STRING(arg) );
+ title = gtk_object_get_data(GTK_OBJECT(widget), "title");
+ game_area = title && !strcmp( title, "Playing Fields" );
}
if (game_area)
if (widget == app)
{
- /* Main window - check the notebook */
- game_area = (GTK_NOTEBOOK(notebook)->cur_page->child == pfields);
+ int cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));
+ int pfields_page = gtk_notebook_page_num(GTK_NOTEBOOK(notebook),
+ pfields);
+ /* Main window - check the notebook */
+ game_area = (cur_page == pfields_page);
}
else
{
/* Sub-window - find out which */
- GtkArg arg;
+ char *title = NULL;
- arg.name = "title";
- gtk_object_getv( GTK_OBJECT(widget), 1, &arg );
- game_area = !strcmp( GTK_VALUE_STRING(arg), "Playing Fields" );
- g_free( GTK_VALUE_STRING(arg) );
+ title = gtk_object_get_data(GTK_OBJECT(widget), "title");
+ game_area = title && !strcmp( title, "Playing Fields" );
}
if (game_area)
#define COLORNUM 26
-static GdkColor colors[] =
+static struct gtet_text_tags {
+ GdkColor c;
+ GtkTextTag *t_c;
+} gtet_text_tags[] =
{
- {0, 0, 0, 0}, /* ^A */
- {0, 0, 0, 0}, /* ^B */
- {0, 0x0000, 0xFFFF, 0xFFFF}, /* ^C cyan */
- {0, 0x0000, 0x0000, 0x0000}, /* ^D black */
- {0, 0x0000, 0x0000, 0xFFFF}, /* ^E bright blue */
- {0, 0x7FFF, 0x7FFF, 0x7FFF}, /* ^F grey */
- {0, 0, 0, 0}, /* ^G */
- {0, 0xFFFF, 0x0000, 0xFFFF}, /* ^H magenta */
- {0, 0, 0, 0}, /* ^I */
- {0, 0, 0, 0}, /* ^J */
- {0, 0x7FFF, 0x7FFF, 0x7FFF}, /* ^K grey */
- {0, 0x0000, 0x7FFF, 0x0000}, /* ^L dark green */
- {0, 0, 0, 0}, /* ^M */
- {0, 0x0000, 0xFFFF, 0x0000}, /* ^N bright green */
- {0, 0xBFFF, 0xBFFF, 0xBFFF}, /* ^O light grey */
- {0, 0x7FFF, 0x0000, 0x0000}, /* ^P dark red */
- {0, 0x0000, 0x0000, 0x7FFF}, /* ^Q dark blue */
- {0, 0x7FFF, 0x7FFF, 0x0000}, /* ^R brown */
- {0, 0x7FFF, 0x0000, 0x7FFF}, /* ^S purple */
- {0, 0xFFFF, 0x0000, 0x0000}, /* ^T bright red */
- {0, 0xBFFF, 0xBFFF, 0xBFFF}, /* ^U light grey */
- {0, 0, 0, 0}, /* ^V */
- {0, 0x0000, 0x7FFF, 0x7FFF}, /* ^W dark cyan */
- {0, 0xFFFF, 0xFFFF, 0xFFFF}, /* ^X white */
- {0, 0xFFFF, 0xFFFF, 0x0000}, /* ^Y yellow */
- {0, 0, 0, 0} /* ^Z */
+ {{0, 0, 0, 0}, NULL}, /* ^A black */
+ {{0, 0, 0, 0}, NULL}, /* ^B black */
+ {{0, 0x0000, 0xFFFF, 0xFFFF}, NULL}, /* ^C cyan */
+ {{0, 0x0000, 0x0000, 0x0000}, NULL}, /* ^D black */
+ {{0, 0x0000, 0x0000, 0xFFFF}, NULL}, /* ^E bright blue */
+ {{0, 0x7FFF, 0x7FFF, 0x7FFF}, NULL}, /* ^F grey */
+ {{0, 0, 0, 0}, NULL}, /* ^G black */
+ {{0, 0xFFFF, 0x0000, 0xFFFF}, NULL}, /* ^H magenta */
+ {{0, 0, 0, 0}, NULL}, /* ^I black */
+ {{0, 0, 0, 0}, NULL}, /* ^J black */
+ {{0, 0x7FFF, 0x7FFF, 0x7FFF}, NULL}, /* ^K grey */
+ {{0, 0x0000, 0x7FFF, 0x0000}, NULL}, /* ^L dark green */
+ {{0, 0, 0, 0}, NULL}, /* ^M black */
+ {{0, 0x0000, 0xFFFF, 0x0000}, NULL}, /* ^N bright green */
+ {{0, 0xBFFF, 0xBFFF, 0xBFFF}, NULL}, /* ^O light grey */
+ {{0, 0x7FFF, 0x0000, 0x0000}, NULL}, /* ^P dark red */
+ {{0, 0x0000, 0x0000, 0x7FFF}, NULL}, /* ^Q dark blue */
+ {{0, 0x7FFF, 0x7FFF, 0x0000}, NULL}, /* ^R brown */
+ {{0, 0x7FFF, 0x0000, 0x7FFF}, NULL}, /* ^S purple */
+ {{0, 0xFFFF, 0x0000, 0x0000}, NULL}, /* ^T bright red */
+ {{0, 0xBFFF, 0xBFFF, 0xBFFF}, NULL}, /* ^U light grey */
+ {{0, 0, 0, 0}, NULL}, /* ^V black */
+ {{0, 0x0000, 0x7FFF, 0x7FFF}, NULL}, /* ^W dark cyan */
+ {{0, 0xFFFF, 0xFFFF, 0xFFFF}, NULL}, /* ^X white */
+ {{0, 0xFFFF, 0xFFFF, 0x0000}, NULL}, /* ^Y yellow */
+ {{0, 0, 0, 0}, NULL} /* ^Z black */
};
-static GdkFont *fonts[4];
+static GtkTextTag *t_bold = NULL;
+static GtkTextTag *t_italic = NULL;
+static GtkTextTag *t_underline = NULL;
+
+GtkTextTagTable *tag_table = NULL;
void textbox_setup (void)
-{
+{ /* API is shafted, so we need to create a buffer,
+ * to use the nice API for adding tags to tag tables ... then we destroy the
+ * buffer and keep the table for use with new buffers */
int n;
- GdkColormap *colormap = gdk_colormap_get_system ();
+ GtkTextBuffer *buffer = gtk_text_buffer_new(NULL);
+
for (n = 0; n < COLORNUM; n ++)
- gdk_color_alloc (colormap, &colors[n]);
- /* hard coded fonts ?!?!?!? */
- /* normal */
- fonts[0] = gdk_fontset_load("-adobe-helvetica-medium-r-normal--*-120-*-*-*-*-*-*,*--12-*");
- /* bold */
- fonts[1] = gdk_fontset_load("-adobe-helvetica-bold-r-normal--*-120-*-*-*-*-*-*,*--12-*");
- /* italic */
- fonts[2] = gdk_fontset_load("-adobe-helvetica-medium-o-normal--*-120-*-*-*-*-*-*,*--12-*");
- /* bold italic */
- fonts[3] = gdk_fontset_load("-adobe-helvetica-bold-o-normal--*-120-*-*-*-*-*-*,*--12-*");
+ gtet_text_tags[n].t_c = gtk_text_buffer_create_tag (buffer, NULL,
+ "foreground-gdk",
+ >et_text_tags[n].c,
+ "background",
+ "white",
+ NULL);
+
+ t_bold = gtk_text_buffer_create_tag (buffer, NULL,
+ "weight", PANGO_WEIGHT_BOLD, NULL);
+ t_italic = gtk_text_buffer_create_tag (buffer, NULL,
+ "style", PANGO_STYLE_ITALIC, NULL);
+ t_underline = gtk_text_buffer_create_tag (buffer, NULL,
+ "underline", PANGO_UNDERLINE_SINGLE, NULL);
+
+ tag_table = gtk_text_buffer_get_tag_table(buffer);
}
-void textbox_addtext (GtkText *textbox, unsigned char *text)
+void textbox_addtext (GtkTextView *textbox, unsigned char *text)
{
- GdkColor *color, *lastcolor;
+ GtkTextTag *color, *lastcolor;
int attr; /* bits are used as flags: bold, italic */
- int i, bottom;
- char last;
- GtkAdjustment *textboxadj = GTK_TEXT(textbox)->vadj;
-
+ int i;
+ /* int bottom; */
+ char last = 0;
+ gboolean attr_bold = FALSE;
+ gboolean attr_italic = FALSE;
+ gboolean attr_underline = FALSE;
+ /* GtkAdjustment *textboxadj = GTK_TEXT_VIEW(textbox)->vadjustment; */
+ GtkTextIter iter;
+
/* is the scroll bar at the bottom ?? */
- if ((textboxadj->value+10)>(textboxadj->upper-textboxadj->lower-textboxadj->page_size))
- bottom = TRUE;
- else bottom = FALSE;
+ /* if ((textboxadj->value+10)>(textboxadj->upper-textboxadj->lower-textboxadj->page_size))
+ bottom = TRUE;
+ else bottom = FALSE; */
+ /* FIXME: this shouldn't be here ... GtkTextView craps itself if you adjust
+ * constantly ...
+ * plus this function is only used from one place that doesn't call
+ * adjust_bottom always anyway */
+
+ lastcolor = color = gtet_text_tags[0].t_c;
+ /* gtk_text_freeze (textbox); */
- lastcolor = color = >K_WIDGET(textbox)->style->black;
- last = 0; attr = 0;
- gtk_text_freeze (textbox);
-
- if (gtk_text_get_length (textbox)) /* not first line */
- gtk_text_insert (textbox, fonts[attr], color, NULL, "\n", 1);
+ gtk_text_buffer_get_end_iter(textbox->buffer, &iter);
+
+ if (gtk_text_buffer_get_char_count (textbox->buffer)) /* not first line */
+ gtk_text_buffer_insert (textbox->buffer, &iter, "\n", 1);
for (i = 0; text[i]; i ++) {
- if (text[i] == 0xFF) { /* reset */
- lastcolor = color = >K_WIDGET(textbox)->style->black;
- last = 0; attr = 0;
+ if (text[i] == TETRI_TB_RESET) {
+ lastcolor = color = gtet_text_tags[0].t_c;
+ attr_bold = FALSE;
+ attr_italic = FALSE;
+ attr_underline = FALSE;
}
- else if (text[i] < 32) {
+ else if (text[i] <= TETRI_TB_END_OFFSET) {
+ g_assert(TETRI_TB_END_OFFSET < 32); /* ASCII space */
+ g_assert(TETRI_TB_C_END_OFFSET <= TETRI_TB_END_OFFSET);
+
switch (text[i]) {
- case TETRI_TB_BOLD: attr = attr ^ 0x01; break; /* bold */
- case TETRI_TB_ITALIC: attr = attr ^ 0x02; break; /* italics */
- case TETRI_TB_UNDERLINE: break; /* underline not available */
+ case TETRI_TB_BOLD: attr_bold = !!attr_bold; break;
+ case TETRI_TB_ITALIC: attr_italic = !!attr_italic; break;
+ case TETRI_TB_UNDERLINE: attr_underline = !!attr_underline; break;
default: /* it is a color... */
- if (text[i] > 0x1A) goto next; /* bounds checking */
+ if (text[i] > TETRI_TB_C_END_OFFSET) break;
if (text[i] == last) {
/* restore previous color */
color = lastcolor;
lastcolor = color;
last = text[i];
/* get new color */
- color = &colors[text[i]-0x01];
+ color = gtet_text_tags[text[i] - TETRI_TB_C_BEG_OFFSET].t_c;
}
}
- else gtk_text_insert (textbox, fonts[attr], color, NULL, &text[i], 1);
+ else
+ {
+ char *out = g_utf8_normalize(&text[i], 1, G_NORMALIZE_ALL);
+ if (out)
+ {
+ if (0)
+ { /* do nothing */ ; }
+ else if (attr_bold && attr_italic && attr_underline)
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ t_bold, t_italic, t_underline,
+ color, NULL);
+ else if (attr_bold && attr_italic)
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ t_bold, t_italic,
+ color, NULL);
+ else if (attr_bold && attr_underline)
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ t_bold, t_underline,
+ color, NULL);
+ else if (attr_italic && attr_underline)
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ t_italic, t_underline,
+ color, NULL);
+ else if (attr_bold || attr_italic || attr_underline)
+ {
+ GtkTextTag *t_a = NULL;
+
+ if (attr_bold) t_a = t_bold;
+ if (attr_italic) t_a = t_italic;
+ if (attr_underline) t_a = t_underline;
+
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ t_a, color, NULL);
+ }
+ else
+ gtk_text_buffer_insert_with_tags (textbox->buffer, &iter, out, -1,
+ color, NULL);
+
+ }
+
+ g_free(out);
+ }
+
next:
continue;
}
/* scroll to bottom */
- gtk_text_thaw (textbox);
- if (bottom) adjust_bottom (textboxadj);
+ /* gtk_text_thaw (textbox); */
+ /* if (bottom) adjust_bottom (textboxadj); */
}
void adjust_bottom (GtkAdjustment *adj)
-{
- gtk_adjustment_set_value (adj, adj->upper - adj->lower - adj->page_size);
+{ /* FIXME: GtkTextView craps itself */
+ gtk_adjustment_set_value (adj, adj->upper);
}
char *nocolor (char *str)
#include <gtk/gtk.h>
+extern GtkTextTagTable *tag_table;
+
extern GtkWidget *leftlabel_new (char *str);
extern void leftlabel_set (GtkWidget *align, char *str);
extern int randomnum (int n);
extern void fdreadline (int fd, char *buf);
extern void textbox_setup (void);
-extern void textbox_addtext (GtkText *textbox, unsigned char *text);
+extern void textbox_addtext (GtkTextView *textbox, unsigned char *text);
extern void adjust_bottom (GtkAdjustment *adj);
extern char *nocolor (char *str);
extern GtkWidget *pixmap_label (GdkPixmap *pm, GdkBitmap *mask, char *str);
/* textbox codes ... */
#define TETRI_TB_RESET 0xFF
-#define TETRI_TB_BOLD 0x2
-#define TETRI_TB_ITALIC 0x16
-#define TETRI_TB_UNDERLINE 0x1F
+#define TETRI_TB_BOLD 2
+#define TETRI_TB_ITALIC 22
+#define TETRI_TB_UNDERLINE 31
+
+#define TETRI_TB_C_BEG_OFFSET 1 /* in theory 1 and 2 are colors ...
+ * however 2 == bold */
/* colors... see colors[] in misc.c */
-#define TETRI_TB_C_CYAN 3
-#define TETRI_TB_C_BLACK 4
-#define TETRI_TB_C_BRIGHT_BLUE 5
-#define TETRI_TB_C_GREY 6
+#define TETRI_TB_C_CYAN 3
+#define TETRI_TB_C_BLACK 4
+#define TETRI_TB_C_BRIGHT_BLUE 5
+#define TETRI_TB_C_GREY 6
-#define TETRI_TB_C_MAGENTA 8
+#define TETRI_TB_C_MAGENTA 8
-/* #define TETRI_TB_C_GREY 11 -- dup */
-#define TETRI_TB_C_DARK_GREEN 12
+/* #define TETRI_TB_C_GREY 11 -- dup */
+#define TETRI_TB_C_DARK_GREEN 12
-#define TETRI_TB_C_BRIGHT_GREEN 14
-#define TETRI_TB_C_LIGHT_GREY 15
-#define TETRI_TB_C_DARK_RED 16
-#define TETRI_TB_C_DARK_BLUE 17
-#define TETRI_TB_C_BROWN 18
-#define TETRI_TB_C_PURPLE 19
-#define TETRI_TB_C_BRIGHT_RED 20
+#define TETRI_TB_C_BRIGHT_GREEN 14
+#define TETRI_TB_C_LIGHT_GREY 15
+#define TETRI_TB_C_DARK_RED 16
+#define TETRI_TB_C_DARK_BLUE 17
+#define TETRI_TB_C_BROWN 18
+#define TETRI_TB_C_PURPLE 19
+#define TETRI_TB_C_BRIGHT_RED 20
/* #define TETRI_TB_C_LIGHT_GREY 21 -- dup */
-#define TETRI_TB_C_DARK_CYAN 23
-#define TETRI_TB_C_WHITE 24
-#define TETRI_TB_C_YELLOW 25
+#define TETRI_TB_C_DARK_CYAN 23
+#define TETRI_TB_C_WHITE 24
+#define TETRI_TB_C_YELLOW 25
+
+#define TETRI_TB_C_END_OFFSET 25 /* highest color value */
+#define TETRI_TB_END_OFFSET 31 /* highest value - must be less than 32 */
leftbox = gtk_vbox_new (FALSE, 4);
/* chat thingy */
/* textbox with scrollbars */
- textbox = gtk_text_new (NULL, NULL);
- gtk_text_set_word_wrap (GTK_TEXT(textbox), TRUE);
+ textbox = gtk_text_view_new_with_buffer(gtk_text_buffer_new(tag_table));
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(textbox), GTK_WRAP_WORD);
GTK_WIDGET_UNSET_FLAGS(textbox, GTK_CAN_FOCUS);
gtk_signal_connect (GTK_OBJECT(textbox), "button_press_event",
GTK_SIGNAL_FUNC(partyline_entryfocus), NULL);
void partyline_text (char *text)
{
- textbox_addtext (GTK_TEXT(textbox), text);
+ textbox_addtext (GTK_TEXT_VIEW(textbox), text);
+ adjust_bottom (GTK_TEXT_VIEW(textbox)->vadjustment);
}
void partyline_playerlist (int *numbers, char **names, char **teams, int n, char **specs, int sn)
void textentry (GtkWidget *widget, gpointer data)
{
- char *text;
+ const char *text;
text = gtk_entry_get_text (GTK_ENTRY(widget));
if (strlen(text) == 0) return;
if (keyval == GDK_Up || keyval == GDK_Down) {
if (plh_cur == plh_end) {
- char *text;
+ const char *text;
text = gtk_entry_get_text (GTK_ENTRY(widget));
GTET_O_STRCPY (plhistory[plh_end], text);
}
static void partylineupdate_leave (char *name);
static void playerlistupdate (void);
static void fieldslabelupdate (void);
-static void plinemsg (char *name, char *text);
-static void plineact (char *name, char *text);
-static void plinesmsg (char *name, char *text);
-static void plinesact (char *name, char *text);
+static void plinemsg (const char *name, const char *text);
+static void plineact (const char *name, const char *text);
+static void plinesmsg (const char *name, const char *text);
+static void plinesact (const char *name, const char *text);
static char translateblock (char c);
static void clearallfields (void);
static void checkmoderatorstatus (void);
}
}
-void tetrinet_playerline (char *text)
+void tetrinet_playerline (const char *text)
{
- char buf[1024], *p;
+ char buf[1024];
+ const char *p;
if (text[0] == '/') {
p = text+1;
plinemsg (nick, text);
}
-void tetrinet_changeteam (char *newteam)
+void tetrinet_changeteam (const char *newteam)
{
char buf[128];
case S_ADDALL4: /* bad for everyone ... */
g_assert(!to);
if (from == playernum)
- g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
+ g_snprintf (buf, sizeof(buf), "%c%c%s%c",
TETRI_TB_BOLD,
TETRI_TB_C_BLACK,
sbinfo[type].info,
- TETRI_TB_C_BLACK,
- TETRI_TB_BOLD);
+ TETRI_TB_RESET);
else
g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
TETRI_TB_BOLD,
case S_BLOCKQUAKE:
case S_BLOCKBOMB: /* badish stuff for someone */
if (to == playernum)
- g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
+ g_snprintf (buf, sizeof(buf), "%c%c%s%c",
TETRI_TB_BOLD,
TETRI_TB_C_BRIGHT_RED,
sbinfo[type].info,
- TETRI_TB_C_BRIGHT_RED,
- TETRI_TB_BOLD);
+ TETRI_TB_RESET);
else if (from == playernum)
- g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
+ g_snprintf (buf, sizeof(buf), "%c%c%s%c",
TETRI_TB_BOLD,
TETRI_TB_C_BLACK,
sbinfo[type].info,
- TETRI_TB_C_BLACK,
- TETRI_TB_BOLD);
+ TETRI_TB_RESET);
else
g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
TETRI_TB_BOLD,
case S_SWITCH:
case S_GRAVITY: /* goodish stuff for someone */
if (to == playernum)
- g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
+ g_snprintf (buf, sizeof(buf), "%c%c%s%c",
TETRI_TB_BOLD,
TETRI_TB_C_BRIGHT_GREEN,
sbinfo[type].info,
- TETRI_TB_C_BRIGHT_GREEN,
- TETRI_TB_BOLD);
+ TETRI_TB_RESET);
else
g_snprintf (buf, sizeof(buf), "%c%c%s%c%c",
TETRI_TB_BOLD,
switch (keyval) {
case GDK_Return:
{
- char buf[256], *s;
+ char buf[256];
+ const char *s;
s = fields_gmsginputtext ();
if (strlen(s) > 0) {
if (strncmp("/me ", s, 4) == 0) {
}
}
-void plinemsg (char *name, char *text)
+void plinemsg (const char *name, const char *text)
{
char buf[1024];
g_snprintf (buf, sizeof(buf), "%c<%s%c%c>%c %s",
partyline_text (buf);
}
-void plinesmsg (char *name, char *text)
+void plinesmsg (const char *name, const char *text)
{
char buf[1024];
g_snprintf (buf, sizeof(buf), "%c%c<%s%c%c%c>%c %s",
partyline_text (buf);
}
-void plineact (char *name, char *text)
+void plineact (const char *name, const char *text)
{
char buf[1024];
g_snprintf (buf, sizeof(buf), "%c* %c%s%c%c %s",
partyline_text (buf);
}
-void plinesact (char *name, char *text)
+void plinesact (const char *name, const char *text)
{
char buf[1024];
g_snprintf (buf, sizeof(buf), "%c* %c%s%c%c %s",
extern int specialblocknum;
extern void tetrinet_inmessage (enum inmsg_type msgtype, char *data);
-extern void tetrinet_playerline (char *text);
-extern void tetrinet_changeteam (char *newteam);
+extern void tetrinet_playerline (const char *text);
+extern void tetrinet_changeteam (const char *newteam);
extern void tetrinet_updatefield (FIELD field);
extern void tetrinet_sendfield (int reset);
extern void tetrinet_resendfield (void);