From: <sa...@us...> - 2006-07-17 22:27:35
|
Revision: 16513 Author: sadrul Date: 2006-07-17 15:27:26 -0700 (Mon, 17 Jul 2006) ViewCVS: http://svn.sourceforge.net/gaim/?rev=16513&view=rev Log Message: ----------- 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. Modified Paths: -------------- trunk/console/libgnt/test/Makefile trunk/console/libgnt/test/combo.c trunk/console/libgnt/test/focus.c trunk/console/libgnt/test/multiwin.c trunk/console/libgnt/test/tv.c Added Paths: ----------- trunk/console/libgnt/test/wm.c Modified: trunk/console/libgnt/test/Makefile =================================================================== --- trunk/console/libgnt/test/Makefile 2006-07-17 21:53:28 UTC (rev 16512) +++ trunk/console/libgnt/test/Makefile 2006-07-17 22:27:26 UTC (rev 16513) @@ -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) Modified: trunk/console/libgnt/test/combo.c =================================================================== --- trunk/console/libgnt/test/combo.c 2006-07-17 21:53:28 UTC (rev 16512) +++ trunk/console/libgnt/test/combo.c 2006-07-17 22:27:26 UTC (rev 16513) @@ -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; } Modified: trunk/console/libgnt/test/focus.c =================================================================== --- trunk/console/libgnt/test/focus.c 2006-07-17 21:53:28 UTC (rev 16512) +++ trunk/console/libgnt/test/focus.c 2006-07-17 22:27:26 UTC (rev 16513) @@ -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; } Modified: trunk/console/libgnt/test/multiwin.c =================================================================== --- trunk/console/libgnt/test/multiwin.c 2006-07-17 21:53:28 UTC (rev 16512) +++ trunk/console/libgnt/test/multiwin.c 2006-07-17 22:27:26 UTC (rev 16513) @@ -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; } Modified: trunk/console/libgnt/test/tv.c =================================================================== --- trunk/console/libgnt/test/tv.c 2006-07-17 21:53:28 UTC (rev 16512) +++ trunk/console/libgnt/test/tv.c 2006-07-17 22:27:26 UTC (rev 16513) @@ -35,13 +35,12 @@ { GntWidget *hbox, *entry, *view; +#ifdef STANDALONE freopen(".error", "w", stderr); gnt_init(); +#endif - 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); @@ -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; } Added: trunk/console/libgnt/test/wm.c =================================================================== --- trunk/console/libgnt/test/wm.c (rev 0) +++ trunk/console/libgnt/test/wm.c 2006-07-17 22:27:26 UTC (rev 16513) @@ -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; +} + Property changes on: trunk/console/libgnt/test/wm.c ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |