Mercurial > pidgin
changeset 13883:ab6376814e73
[gaim-migrate @ 16363]
Some examples so other people can try things out.
I am planning on making the conversation-pane behave like test/tv .. comments?
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 28 Jun 2006 00:21:38 +0000 |
parents | 5c750626eaa5 |
children | eac18261c6f0 |
files | console/libgnt/test/Makefile console/libgnt/test/focus.c console/libgnt/test/multiwin.c console/libgnt/test/tv.c |
diffstat | 4 files changed, 197 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/test/Makefile Wed Jun 28 00:21:38 2006 +0000 @@ -0,0 +1,13 @@ +CFLAGS=`pkg-config --cflags gobject-2.0` -g -I../ +LDFLAGS=`pkg-config --libs gobject-2.0` -lncursesw -pg -lgnt -L../ + +EXAMPLES=focus tv multiwin + +all: + cd .. && make + make examples + +clean: + rm -f $(EXAMPLES) + +examples: $(EXAMPLES)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/test/focus.c Wed Jun 28 00:21:38 2006 +0000 @@ -0,0 +1,49 @@ +#include "gntbutton.h" +#include "gnt.h" +#include "gntkeys.h" +#include "gnttree.h" +#include "gntbox.h" +#include "gntentry.h" +#include "gntlabel.h" + +int main() +{ + gnt_init(); + + 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_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), "This is the title …"); + + gnt_widget_show(hbox); + + gnt_main(); + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/test/multiwin.c Wed Jun 28 00:21:38 2006 +0000 @@ -0,0 +1,64 @@ +#include "gntbutton.h" +#include "gnt.h" +#include "gntkeys.h" +#include "gnttree.h" +#include "gntbox.h" + +gboolean show(GntWidget *w) +{ + gnt_widget_draw(w); + + return TRUE; +} + +int main() +{ + gnt_init(); + + GntWidget *hbox, *tree, *box2; + + box(stdscr, 0, 0); + wrefresh(stdscr); + + hbox = gnt_box_new(FALSE, TRUE); + box2 = gnt_box_new(FALSE, TRUE); + + gnt_widget_set_name(hbox, "hbox"); + gnt_widget_set_name(box2, "box2"); + + tree = gnt_tree_new(); + gnt_widget_set_name(tree, "tree"); + gnt_box_add_widget(GNT_BOX(hbox), tree); + + gnt_box_set_toplevel(GNT_BOX(hbox), TRUE); + gnt_box_set_title(GNT_BOX(hbox), "Testing the tree widget"); + + gnt_box_set_toplevel(GNT_BOX(box2), TRUE); + gnt_box_set_title(GNT_BOX(box2), "On top"); + + gnt_box_add_widget(GNT_BOX(box2), GNT_WIDGET(gnt_label_new("asdasd"))); + + gnt_widget_show(hbox); + gnt_widget_set_position(box2, 5, 5); + gnt_widget_show(box2); + + 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_tree_add_row_after(GNT_TREE(tree), "1", "1", NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "2", "2", NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "3", "3", NULL, NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "4", "4", "a", NULL); + gnt_tree_add_row_after(GNT_TREE(tree), "5", "5", "d", NULL); + + gnt_tree_add_row_after(GNT_TREE(tree), "6", "6", "4", NULL); + g_timeout_add(1000, (GSourceFunc)show, hbox); + + gnt_main(); + + return 0; +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/test/tv.c Wed Jun 28 00:21:38 2006 +0000 @@ -0,0 +1,71 @@ +#include "gntbutton.h" +#include "gnt.h" +#include "gntkeys.h" +#include "gnttree.h" +#include "gntbox.h" +#include "gntentry.h" +#include "gnttextview.h" + +static gboolean +key_pressed(GntWidget *w, const char *key, GntWidget *view) +{ + if (key[0] == '\r' && key[1] == 0) + { + gnt_text_view_next_line(GNT_TEXT_VIEW(view)); + gnt_text_view_append_text_with_flags(GNT_TEXT_VIEW(view), + gnt_entry_get_text(GNT_ENTRY(w)), + GNT_TEXT_FLAG_BOLD); + gnt_entry_clear(GNT_ENTRY(w)); + gnt_text_view_scroll(GNT_TEXT_VIEW(view), 0); + + return TRUE; + } + else if (key[0] == 27) + { + if (strcmp(key+1, GNT_KEY_UP)) + gnt_text_view_scroll(GNT_TEXT_VIEW(view), 1); + else if (strcmp(key+1, GNT_KEY_DOWN)) + gnt_text_view_scroll(GNT_TEXT_VIEW(view), -1); + } + + return FALSE; +} + +int main() +{ + GntWidget *hbox, *entry, *view; + + freopen(".error", "w", stderr); + + gnt_init(); + + box(stdscr, 0, 0); + wrefresh(stdscr); + + hbox = gnt_box_new(FALSE, TRUE); + gnt_widget_set_name(hbox, "hbox"); + gnt_box_set_toplevel(GNT_BOX(hbox), TRUE); + gnt_box_set_title(GNT_BOX(hbox), "Textview test"); + + entry = gnt_entry_new(NULL); + gnt_widget_set_name(entry, "entry"); + GNT_WIDGET_SET_FLAGS(entry, GNT_WIDGET_CAN_TAKE_FOCUS); + + view = gnt_text_view_new(); + gnt_widget_set_name(view, "view"); + + gnt_widget_set_size(view, getmaxx(stdscr) - 3, 15); + gnt_widget_set_size(entry, getmaxx(stdscr) - 3, 1); + + gnt_box_add_widget(GNT_BOX(hbox), view); + gnt_box_add_widget(GNT_BOX(hbox), entry); + + gnt_widget_show(hbox); + + g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); + + gnt_main(); + + return 0; +} +