[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Console Button
- From: Carlos Pereira <carlos pehoe civil ist utl pt>
- To: gtk-app-devel-list redhat com
- Subject: Re: Console Button
- Date: Mon, 4 Oct 1999 19:06:22 +0100
Thanks a lot for the code and usefull discussion on the "Console Button" topic.
In case it is usefull for someone else, here is a working example, with two buttons:
1) a console button that shows up and down the console every time is pressed
2) a shell button that fires up a new xterm every time is pressed
I made the top level window really big, of the size of a typical application, so
the console and shell windows don't cover the "application" (i.e. the two buttons).
Carlos Pereira,
Technical University of Lisboa
Portugal
-------------------------iobuttons.c-------------------------------------
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#define x_left_space 50
#define y_left_space 50
typedef struct _my_type {
Display *display;
Window console;
} my_type;
void handle_shell_button (GtkWidget *widget, gpointer data)
{
system ("xterm -geometry 80x20 -bg black -fg white &");
printf ("Open Shell Window\n");
}
void handle_console_button (GtkWidget *widget, gpointer data)
{
static gint flag = 1;
my_type *my_structure = (my_type *) data;
if (flag > 0)
{
XRaiseWindow(my_structure->display, my_structure->console);
printf ("Raise Console Window\n");
}
else
{
XLowerWindow(my_structure->display, my_structure->console);
printf ("Lower Console Window\n");
}
flag *= -1;
}
int main (int argc, char **argv)
{
char *windowid;
GtkWidget *my_window;
GtkWidget *my_hbox;
GtkWidget *my_button;
my_type *my_structure;
gtk_init(&argc, &argv);
my_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (my_window, gdk_screen_width()-x_left_space,
gdk_screen_height()-y_left_space);
my_hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (my_window), my_hbox);
my_button = gtk_button_new_with_label("Console Button");
gtk_box_pack_start(GTK_BOX(my_hbox), my_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (my_button), "clicked",
GTK_SIGNAL_FUNC (handle_console_button), my_structure);
gtk_widget_show(my_button);
my_button = gtk_button_new_with_label("Shell Button");
gtk_box_pack_start(GTK_BOX(my_hbox), my_button, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT (my_button), "clicked",
GTK_SIGNAL_FUNC (handle_shell_button), my_structure);
gtk_widget_show(my_button);
gtk_widget_show(my_hbox);
gtk_widget_show(my_window);
windowid = (char *) getenv("WINDOWID");
my_structure->console = (Window) atoi(windowid);
my_structure->display = GDK_WINDOW_XDISPLAY(my_window->window);
gtk_main();
}
----------------------------------------------------------
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]