view finch/libgnt/test/menu.c @ 17284:37499e926a42

Add new MsimMessage element type, MSIM_TYPE_RAW, for fields in incoming protocol messages that don't have any type information associated with them. These elements will be unescaped if used as strings, in msim_msg_get_string(), and won't be escaped if serialized into a protocol message in msim_msg_element_pack(). On the other hand, MSIM_TYPE_STRING will be escaped when packed. Previously, everything was MSIM_TYPE_STRING, leading to more complicated escaping. Now, an instant message "foo/bar\baz" will be represented as follows: bm(raw): 1 f(raw): 180301984 cv(raw): 673 msg(raw): foo/1bar/2baz And it will be interpreted by the receiving client correctly-- msim_msg_get_string(..., "msg") will be "foo/bar\baz".
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Sat, 02 Jun 2007 02:43:43 +0000
parents f00f2e283ffb
children f104e1d45d85
line wrap: on
line source

#include "gnt.h"
#include "gntbox.h"
#include "gntlabel.h"
#include "gntmenu.h"
#include "gntmenuitem.h"
#include "gntwindow.h"

void dothis(GntMenuItem *item, gpointer null)
{
	GntWidget *w = gnt_vbox_new(FALSE);
	gnt_box_set_toplevel(GNT_BOX(w), TRUE);
	gnt_box_add_widget(GNT_BOX(w),
			gnt_label_new("Callback to a menuitem"));
	gnt_widget_show(w);
}

int main()
{
	freopen(".error", "w", stderr);
	gnt_init();

	GntWidget *menu = gnt_menu_new(GNT_MENU_TOPLEVEL);
	GObject *item = gnt_menuitem_new("File");

	gnt_menu_add_item(GNT_MENU(menu), GNT_MENU_ITEM(item));

	item = gnt_menuitem_new("Edit");
	gnt_menu_add_item(GNT_MENU(menu), GNT_MENU_ITEM(item));

	item = gnt_menuitem_new("Help");
	gnt_menu_add_item(GNT_MENU(menu), GNT_MENU_ITEM(item));

	GntWidget *sub = gnt_menu_new(GNT_MENU_POPUP);
	gnt_menuitem_set_submenu(GNT_MENU_ITEM(item), GNT_MENU(sub));

	item = gnt_menuitem_new("Online Help");
	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));

	item = gnt_menuitem_new("About");
	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));

	sub = gnt_menu_new(GNT_MENU_POPUP);
	gnt_menuitem_set_submenu(GNT_MENU_ITEM(item), GNT_MENU(sub));

	item = gnt_menuitem_new("Online Help");
	gnt_menu_add_item(GNT_MENU(sub), GNT_MENU_ITEM(item));
	gnt_menuitem_set_callback(GNT_MENU_ITEM(item), dothis, NULL);

	gnt_screen_menu_show(menu);

	GntWidget *win = gnt_window_new();
	gnt_box_add_widget(GNT_BOX(win),
		gnt_label_new("..."));
	gnt_box_set_title(GNT_BOX(win), "Title");
	gnt_window_set_menu(GNT_WINDOW(win), GNT_MENU(menu));
	gnt_widget_show(win);

	gnt_main();

	gnt_quit();

	return  0;
}