view finch/libgnt/test.c @ 27231:e3907cfaeb02

Don't crash when the seemingly impossible occurs. IOW, try to handle khc's crash, even though I don't see how this is possible. (gdb) f 4 #4 0x00007f268bd61e11 in jabber_caps_ext_iqcb (js=0x2ac4700, from=0x4a3c550 "maiku@jabber.org/Telepathy", type=JABBER_IQ_RESULT, id=0x31b1240 "purpleb9d3d882", packet=0x55e3220, data=0x497d6f0) at caps.c:552 552 g_hash_table_insert(node_exts->exts, g_strdup(userdata->name), features); (gdb) p node_exts $2 = (JabberCapsNodeExts *) 0x0 (gdb) bt #0 0x00007f2693f53fb5 in raise () from /lib/libc.so.6 #1 0x00007f2693f55bc3 in abort () from /lib/libc.so.6 #2 0x000000000049366b in sighandler (sig=11) at gtkmain.c:195 #3 <signal handler called> #4 0x00007f268bd61e11 in jabber_caps_ext_iqcb (js=0x2ac4700, from=0x4a3c550 "maiku@jabber.org/Telepathy", type=JABBER_IQ_RESULT, id=0x31b1240 "purpleb9d3d882", packet=0x55e3220, data=0x497d6f0) at caps.c:552 #10 0x00007f268bd56d3d in jabber_parser_process (js=0x2ac4700, buf=0x7f268bf7a980 "<iq from='maiku@jabber.org/Telepathy' to='khc@hxbc.us/Home' type='result' id='purpleb9d3d882'> <query node='http://telepathy.freedesktop.org/caps#voice-v1' xmlns='http://jabber.org/protocol/disco#info"..., len=279) at parser.c:227 $4 = (JabberCapsClientInfo *) 0x4a8bcd0 p *((ext_iq_data*)data)->data->info $6 = { identities = 0x0, features = 0x4a41580, forms = 0x0, exts = 0x0, tuple = { node = 0x3d2ff20 "http://telepathy.freedesktop.org/caps", ver = 0x31aa850 "0.6.2.1", hash = 0x0 } }
author Paul Aurich <paul@darkrain42.org>
date Mon, 22 Jun 2009 23:36:56 +0000
parents 0e3a8505ebbe
children
line wrap: on
line source

#include "gntbutton.h"
#include "gnt.h"
#include "gntkeys.h"
#include "gnttree.h"
#include "gntbox.h"

static gboolean
key_pressed(GntWidget *widget, const char *text, gpointer null)
{
	GntWidget *w = null;
	GntWidget *box = gnt_box_new(FALSE, FALSE);
	GntWidget *label = gnt_label_new("so wassup!!");

	gnt_box_add_widget(GNT_BOX(box), label);
	GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
	gnt_box_set_title(GNT_BOX(box), "This is a test");

	gnt_widget_show(box);
#if 0

	gnt_widget_set_focus(w, TRUE);

	/* XXX: This is to just test stuff */
	if (text[0] == 27)
	{
		if (strcmp(text+1, GNT_KEY_LEFT) == 0 && w->priv.x)
			(w->priv.x)--;
		else if (strcmp(text+1, GNT_KEY_RIGHT) == 0)
			(w->priv.x)++;
		else if (strcmp(text+1, GNT_KEY_UP) == 0 && w->priv.y)
			(w->priv.y)--;
		else if (strcmp(text+1, GNT_KEY_DOWN) == 0)
			(w->priv.y)++;
	}

	gnt_widget_draw(w);
#endif

	return FALSE;
}

static void
button1(GntWidget *widget, gpointer null)
{
	printf("OLAAA");
	gnt_widget_destroy(null);
}

static void
button2(GntWidget *widget, gpointer null)
{
	printf("BOOYAA");
}

static gboolean
w_scroll(GntWidget *tree)
{
	g_return_val_if_fail(GNT_IS_TREE(tree), FALSE);
	gnt_tree_scroll(GNT_TREE(tree), 1);
	/*wscrl(tree->window, 1);*/
	/*box(tree->window, ACS_VLINE, ACS_HLINE);*/
	/*wrefresh(tree->window);*/
	/*char *s = 0;*/
	/**s = 'a';*/
	return TRUE;
}

int main()
{
	gnt_init();

	GntWidget *widget = gnt_button_new("Button 1");
	GntWidget *widget2 = gnt_button_new("Button 2 has a longish text with a UTF-8 thing …");
	GntWidget *label = gnt_label_new("So wassup dudes and dudettes!!\nSo this is, like,\nthe third line!! \\o/");
	GntWidget *vbox, *hbox, *tree;
	WINDOW *test;

	box(stdscr, 0, 0);
	wrefresh(stdscr);

	vbox = gnt_box_new(FALSE, FALSE);
	hbox = gnt_box_new(FALSE, TRUE);

	gnt_widget_set_name(vbox, "vbox");
	gnt_widget_set_name(hbox, "hbox");
	gnt_widget_set_name(widget, "widget");
	gnt_widget_set_name(widget2, "widget2");

	gnt_box_add_widget(GNT_BOX(vbox), widget);
	gnt_box_add_widget(GNT_BOX(vbox), widget2);

	gnt_box_add_widget(GNT_BOX(hbox), label);
	/*gnt_box_add_widget(GNT_BOX(hbox), vbox);*/

	gnt_box_add_widget(GNT_BOX(hbox), gnt_entry_new("a"));

	tree = gnt_tree_new();
	gnt_box_add_widget(GNT_BOX(hbox), tree);

	gnt_tree_add_row_after(GNT_TREE(tree), "a", "a", NULL, NULL);
	gnt_tree_add_row_after(GNT_TREE(tree), "c", "c", NULL, NULL);
	gnt_tree_add_row_after(GNT_TREE(tree), "d", "d", NULL, NULL);
	gnt_tree_add_row_after(GNT_TREE(tree), "e", "e", "a", NULL);
	gnt_tree_add_row_after(GNT_TREE(tree), "b", "b", "d", NULL);

	GNT_WIDGET_UNSET_FLAGS(hbox, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW);
	gnt_box_set_title(GNT_BOX(hbox), "111111111111111111111111111111111111111111111111111111111111111This is the title …");

	/*gnt_widget_set_take_focus(vbox, TRUE);*/
	/*gnt_widget_set_take_focus(hbox, TRUE);*/
	/*gnt_widget_set_position(hbox, 10, 10);*/

	gnt_widget_show(hbox);

	g_signal_connect(hbox, "key_pressed", G_CALLBACK(key_pressed), tree);
	g_signal_connect(widget, "activate", G_CALLBACK(button1), hbox);
	g_signal_connect(widget2, "activate", G_CALLBACK(button2), hbox);

	/*g_timeout_add(1000, (GSourceFunc)w_scroll, tree);*/

	gnt_main();

	return 0;
}