/* This is the implementation of the GUI-file */ /* Horked from Havoc Pennington's book */ #include #include "gui.h" static GtkWidget * glob_dialog_window = NULL; static GtkWidget * glob_button = NULL; static GtkWidget * glob_label = NULL; static void button_clicked_cb(GtkWidget *w, gpointer data) { GtkWidget *label; gchar *text; gchar *tmp; label = GTK_WIDGET(data); gtk_label_get(GTK_LABEL(label), &text); tmp = g_strdup(text); g_strreverse(tmp); gtk_label_set_text(GTK_LABEL(label), tmp); g_free(tmp); } static char *glob_requirements[] = { "GTK+", NULL }; int initgui() { if (!glob_dialog_window) { glob_dialog_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); glob_button = gtk_button_new(); glob_label = gtk_label_new("Hello, host!"); gtk_container_add(GTK_CONTAINER(glob_button), glob_label); gtk_container_add(GTK_CONTAINER(glob_dialog_window), glob_button); gtk_window_set_title(GTK_WINDOW(glob_dialog_window), "Visiting from .so-file"); gtk_signal_connect(GTK_OBJECT(glob_button), "clicked", GTK_SIGNAL_FUNC(button_clicked_cb), glob_label); return 1; } } int opendialog() { gtk_widget_show_all(glob_dialog_window); } int closedialog() { gtk_widget_hide_all(glob_dialog_window); } char ** get_requirements() { return glob_requirements; }