Mercurial > pidgin
annotate finch/libgnt/test/wm.c @ 32047:e21500d61347
merge of '2825cfec5e2f9ce0b43361fdd7bdd21c4ea69b24'
and '4a5d49d94ae44a21c23f7977dd7b6b9f69dfb000'
author | andrew.victor@mxit.com |
---|---|
date | Mon, 05 Sep 2011 18:34:32 +0000 |
parents | a8cc50c2279f |
children |
rev | line source |
---|---|
15817 | 1 #include <gmodule.h> |
2 | |
3 #include <gnt.h> | |
4 #include <gntbox.h> | |
5 #include <gntentry.h> | |
6 #include <gntlabel.h> | |
7 | |
8 static gboolean | |
9 key_pressed(GntEntry *entry, const char *text, gpointer null) | |
10 { | |
11 if (*text != '\r') | |
12 return FALSE; | |
13 | |
14 { | |
15 const char *cmd; | |
16 void *handle; | |
17 void (*func)(); | |
18 | |
19 cmd = gnt_entry_get_text(entry); | |
20 handle = g_module_open(cmd, G_MODULE_BIND_LOCAL); | |
21 if (handle && g_module_symbol(handle, "main", (gpointer)&func)) | |
22 { | |
23 char *argv[] = {cmd, NULL}; | |
24 gnt_entry_clear(entry); | |
25 func(1, argv); | |
26 } | |
27 else | |
28 { | |
29 GntWidget *widget = gnt_vbox_new(FALSE); | |
30 gnt_box_set_toplevel(GNT_BOX(widget), TRUE); | |
31 gnt_box_set_title(GNT_BOX(widget), "Error"); | |
32 gnt_box_add_widget(GNT_BOX(widget), gnt_label_new("Could not execute.")); | |
33 gnt_box_add_widget(GNT_BOX(widget), gnt_label_new(g_module_error())); | |
34 | |
35 gnt_widget_show(widget); | |
36 } | |
37 } | |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
15817
diff
changeset
|
38 |
15817 | 39 return TRUE; |
40 } | |
41 | |
42 int main() | |
43 { | |
44 GntWidget *window, *entry; | |
45 | |
46 freopen(".error", "w", stderr); | |
47 | |
48 gnt_init(); | |
49 | |
50 window = gnt_hbox_new(FALSE); | |
51 | |
52 gnt_box_add_widget(GNT_BOX(window), gnt_label_new("Command")); | |
53 | |
54 entry = gnt_entry_new(NULL); | |
55 g_signal_connect(G_OBJECT(entry), "key_pressed", G_CALLBACK(key_pressed), NULL); | |
56 gnt_box_add_widget(GNT_BOX(window), entry); | |
57 | |
58 gnt_widget_set_position(window, 0, getmaxy(stdscr) - 2); | |
59 gnt_widget_show(window); | |
60 | |
61 gnt_main(); | |
62 | |
63 gnt_quit(); | |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
15817
diff
changeset
|
64 |
15817 | 65 return 0; |
66 } | |
67 |