Mercurial > pidgin.yaz
changeset 13960:a06f7495af6f
[gaim-migrate @ 16513]
It is possible to have multiple gnt-applications sharing the same screen.
To try this, 'make WM' in console/libgnt/test. It will have a small
'Command' entry. You can give a command like './focus.so' (or one of the
other examples). The applications can also be executed standalone. This
required some tinkering to the Makefile. I am not sure whether there is
an easier way of doing it.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Mon, 17 Jul 2006 22:27:26 +0000 |
parents | 2ae35c0cf616 |
children | b0e37dcb3987 |
files | console/libgnt/test/Makefile console/libgnt/test/combo.c console/libgnt/test/focus.c console/libgnt/test/multiwin.c console/libgnt/test/tv.c console/libgnt/test/wm.c |
diffstat | 6 files changed, 88 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/console/libgnt/test/Makefile Mon Jul 17 21:33:50 2006 +0000 +++ b/console/libgnt/test/Makefile Mon Jul 17 22:27:26 2006 +0000 @@ -1,6 +1,6 @@ CC=gcc -CFLAGS=`pkg-config --cflags gobject-2.0` -g -I../ -LDFLAGS=`pkg-config --libs gobject-2.0` -pg -lgnt -L../ +CFLAGS=`pkg-config --cflags gobject-2.0 gmodule-2.0` -g -I../ -DSTANDALONE +LDFLAGS=`pkg-config --libs gobject-2.0 gmodule-2.0` -pg -lgnt -L../ EXAMPLES=combo focus tv multiwin @@ -8,6 +8,9 @@ make examples clean: - rm -f $(EXAMPLES) + rm -f $(EXAMPLES) *.so wm + +WM: wm + for i in $(EXAMPLES); do gcc -shared $(CFLAGS) -USTANDALONE $(LDFLAGS) $${i}.c -o $${i}.so ; done examples: $(EXAMPLES)
--- a/console/libgnt/test/combo.c Mon Jul 17 21:33:50 2006 +0000 +++ b/console/libgnt/test/combo.c Mon Jul 17 22:27:26 2006 +0000 @@ -20,8 +20,10 @@ GntWidget *box, *combo, *button; GntWidget *hbox; +#ifdef STANDALONE freopen(".error", "w", stderr); gnt_init(); +#endif box = gnt_box_new(FALSE, TRUE); gnt_widget_set_name(box, "box"); @@ -61,9 +63,11 @@ gnt_widget_show(box); +#ifdef STANDALONE gnt_main(); gnt_quit(); +#endif return 0; }
--- a/console/libgnt/test/focus.c Mon Jul 17 21:33:50 2006 +0000 +++ b/console/libgnt/test/focus.c Mon Jul 17 22:27:26 2006 +0000 @@ -20,16 +20,15 @@ int main() { +#ifdef STANDALONE freopen(".error", "w", stderr); gnt_init(); - +#endif + GntWidget *label = gnt_label_new("So wassup dudes and dudettes!!\nSo this is, like,\nthe third line!! \\o/"); GntWidget *vbox, *hbox, *tree, *box, *button; WINDOW *test; - box(stdscr, 0, 0); - wrefresh(stdscr); - vbox = gnt_box_new(FALSE, FALSE); hbox = gnt_box_new(FALSE, TRUE); gnt_box_set_alignment(GNT_BOX(hbox), GNT_ALIGN_MID); @@ -58,7 +57,6 @@ GNT_WIDGET_UNSET_FLAGS(hbox, GNT_WIDGET_NO_BORDER | GNT_WIDGET_NO_SHADOW); gnt_box_set_title(GNT_BOX(hbox), "This is the title …"); - g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(toggled), NULL); button = gnt_button_new("one"); @@ -77,9 +75,11 @@ gnt_widget_show(hbox); +#ifdef STANDALONE gnt_main(); gnt_quit(); +#endif return 0; }
--- a/console/libgnt/test/multiwin.c Mon Jul 17 21:33:50 2006 +0000 +++ b/console/libgnt/test/multiwin.c Mon Jul 17 22:27:26 2006 +0000 @@ -13,14 +13,13 @@ int main() { +#ifdef STANDALONE freopen(".error", "w", stderr); gnt_init(); +#endif GntWidget *hbox, *tree, *box2; - box(stdscr, 0, 0); - wrefresh(stdscr); - hbox = gnt_box_new(FALSE, TRUE); box2 = gnt_box_new(FALSE, TRUE); @@ -64,9 +63,11 @@ g_timeout_add(5000, (GSourceFunc)show, box2); +#ifdef STANDALONE gnt_main(); gnt_quit(); +#endif return 0; }
--- a/console/libgnt/test/tv.c Mon Jul 17 21:33:50 2006 +0000 +++ b/console/libgnt/test/tv.c Mon Jul 17 22:27:26 2006 +0000 @@ -35,12 +35,11 @@ { GntWidget *hbox, *entry, *view; +#ifdef STANDALONE freopen(".error", "w", stderr); gnt_init(); - - box(stdscr, 0, 0); - wrefresh(stdscr); +#endif hbox = gnt_box_new(FALSE, TRUE); gnt_widget_set_name(hbox, "hbox"); @@ -67,9 +66,11 @@ g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), view); +#ifdef STANDALONE gnt_main(); gnt_quit(); +#endif return 0; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/console/libgnt/test/wm.c Mon Jul 17 22:27:26 2006 +0000 @@ -0,0 +1,65 @@ +#include <gmodule.h> + +#include <gnt.h> +#include <gntbox.h> +#include <gntentry.h> +#include <gntlabel.h> + +static gboolean +key_pressed(GntEntry *entry, const char *text, gpointer null) +{ + if (*text != '\r') + return FALSE; + + { + const char *cmd; + void *handle; + void (*func)(); + + cmd = gnt_entry_get_text(entry); + handle = g_module_open(cmd, G_MODULE_BIND_LOCAL); + if (handle && g_module_symbol(handle, "main", (gpointer)&func)) + { + gnt_entry_clear(entry); + func(); + } + else + { + GntWidget *widget = gnt_vbox_new(FALSE); + gnt_box_set_toplevel(GNT_BOX(widget), TRUE); + gnt_box_set_title(GNT_BOX(widget), "Error"); + gnt_box_add_widget(GNT_BOX(widget), gnt_label_new("Could not execute.")); + + gnt_widget_show(widget); + } + } + + return TRUE; +} + +int main() +{ + GntWidget *window, *entry; + + freopen(".error", "w", stderr); + + gnt_init(); + + window = gnt_hbox_new(FALSE); + + gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Command")); + + entry = gnt_entry_new(NULL); + g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), NULL); + gnt_box_add_widget(GNT_BOX(window), entry); + + gnt_widget_set_position(window, 0, getmaxy(stdscr) - 2); + gnt_widget_show(window); + + gnt_main(); + + gnt_quit(); + + return 0; +} +