Mercurial > pidgin.yaz
annotate finch/libgnt/test/wm.c @ 32805:064eb5d78946
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 0ba3afb8adb303a77581a7872d674c600979a5a6)
to branch 'im.pidgin.pidgin' (head 7711a4d267e1fe776387496c764fb63227d70aec)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 31 Oct 2011 01:25:36 +0000 |
parents | a8cc50c2279f |
children |
rev | line source |
---|---|
15818 | 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 } | |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
15818
diff
changeset
|
38 |
15818 | 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(); | |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
15818
diff
changeset
|
64 |
15818 | 65 return 0; |
66 } | |
67 |