15 #include "pandatoolbase.h"
17 #include "gtkStatsServer.h"
18 #include "config_pstats.h"
21 GtkWidget *main_window;
25 delete_event(GtkWidget *widget,
26 GdkEvent *event, gpointer data) {
33 destroy(GtkWidget *widget, gpointer data) {
38 timer(gpointer data) {
49 gdk_window_process_all_updates();
56 main(
int argc,
char *argv[]) {
60 gtk_init(&argc, &argv);
62 main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
64 gtk_window_set_title(GTK_WINDOW(main_window),
"PStats");
68 g_signal_connect(G_OBJECT(main_window),
"delete_event",
69 G_CALLBACK(delete_event), NULL);
71 g_signal_connect(G_OBJECT(main_window),
"destroy",
72 G_CALLBACK(destroy), NULL);
75 stream <<
"Listening on port " << pstats_port;
76 string str = stream.str();
77 GtkWidget *label = gtk_label_new(str.c_str());
78 gtk_container_add(GTK_CONTAINER(main_window), label);
79 gtk_widget_show(label);
86 <<
"Unable to open port " << pstats_port
87 <<
". Try specifying a different\n"
88 <<
"port number using pstats-port in your Config file.";
89 string str = stream.str();
92 gtk_message_dialog_new(GTK_WINDOW(main_window),
93 GTK_DIALOG_DESTROY_WITH_PARENT,
97 gtk_dialog_run(GTK_DIALOG(dialog));
98 gtk_widget_destroy(dialog);
102 gtk_widget_show(main_window);
105 g_timeout_add(200, timer, NULL);
The class that owns the main loop, waiting for client connections.
void poll()
Checks for any network activity and handles it, if appropriate, and then returns. ...
bool listen(int port=-1)
Establishes a port number that the manager will listen on for TCP connections.