1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program; if not, write to the Free Software Foundation, |
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | |
---|
21 | ### File Specific: |
---|
22 | main-programmer: Benjamin Grauer |
---|
23 | co-programmer: |
---|
24 | */ |
---|
25 | |
---|
26 | |
---|
27 | #include "orxonox_console_entry.h" |
---|
28 | |
---|
29 | |
---|
30 | OrxonoxConsoleEntry* OrxonoxConsoleEntry::test = 0; |
---|
31 | |
---|
32 | /* |
---|
33 | OrxonoxConsoleEntry::OrxonoxConsoleEntry(OrxonoxConsoleLog* log, |
---|
34 | OrxonoxConsoleEntry* test) |
---|
35 | { |
---|
36 | consoleLog = log; |
---|
37 | |
---|
38 | } |
---|
39 | */ |
---|
40 | |
---|
41 | GtkWidget* OrxonoxConsoleEntry::createEntry() |
---|
42 | { |
---|
43 | frame = gtk_frame_new ("Console Entry:"); |
---|
44 | |
---|
45 | |
---|
46 | gtk_container_set_border_width (GTK_CONTAINER(frame), 5); |
---|
47 | { |
---|
48 | entrybox = gtk_hbox_new (FALSE, 5); |
---|
49 | { |
---|
50 | entry = gtk_entry_new(); |
---|
51 | g_signal_connect(GTK_ENTRY(entry), "activate", G_CALLBACK(submit), entry); |
---|
52 | gtk_box_pack_start(GTK_BOX(entrybox), entry, TRUE, TRUE, 5); |
---|
53 | |
---|
54 | |
---|
55 | button = gtk_button_new_with_label("Submit"); |
---|
56 | g_signal_connect(GTK_BUTTON(button), "clicked", G_CALLBACK(submit), entry); |
---|
57 | gtk_box_pack_start(GTK_BOX(entrybox), button, FALSE, FALSE, 5); |
---|
58 | } |
---|
59 | gtk_container_add(GTK_CONTAINER(frame), entrybox); |
---|
60 | } |
---|
61 | return (frame); |
---|
62 | } |
---|
63 | |
---|
64 | void OrxonoxConsoleEntry::setLog(OrxonoxConsoleLog* log, OrxonoxConsoleEntry* entry) |
---|
65 | { |
---|
66 | consoleLog = log; |
---|
67 | test = entry; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | void OrxonoxConsoleEntry::submit(GtkWidget *widget, GtkWidget* entry) |
---|
72 | { |
---|
73 | char* entryText = (char*)gtk_entry_get_text(GTK_ENTRY(entry)); |
---|
74 | printf("%s\n", entryText); |
---|
75 | test->sendtoLog(entryText); |
---|
76 | gtk_entry_set_text(GTK_ENTRY(entry),""); |
---|
77 | // freen entryText; |
---|
78 | return; |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | void OrxonoxConsoleEntry::sendtoLog(char* submitText) |
---|
83 | { |
---|
84 | consoleLog->appendText(submitText); |
---|
85 | |
---|
86 | return; |
---|
87 | } |
---|