>>>>> "M" == M N S S K Pavan Kumar <[EMAIL PROTECTED]> writes:
M> Hi, I have a gtkhbox of size two packed into a main window. Each
M> block of gtk hbox had a widget, first part of the hbox had a
M> textwidget packed into it and the second part has a drawing area
M> packed into it. If a toggle button is pressed , textwidget is
M> shown in the whole window, if another toggle button is pressed ,
M> drawingarea is completely shown and if both are on , both are
M> shown. Is there a way to do this.
Connect a signal handler to the toggle buttons, and show/hide the text
widget or drawing area there.
I've attached a program that shows the genral idea.
/mailund
===File ~/src/gtk-snippets/show/show-hide.c=================
#include <gtk/gtk.h>
static void
toogle_text (GtkWidget *text)
{
static gboolean b = TRUE;
if (b) {
gtk_widget_hide (text);
b = FALSE;
} else {
gtk_widget_show (text);
b = TRUE;
}
}
static void
toogle_drawing_area (GtkWidget *da)
{
static gboolean b = TRUE;
if (b) {
gtk_widget_hide (da);
b = FALSE;
} else {
gtk_widget_show (da);
b = TRUE;
}
}
int
main (int argc, char *argv[])
{
GtkWidget *win;
GtkWidget *vbox, *hbox;
GtkWidget *toggle;
GtkWidget *text, *drawingarea;
gtk_init (&argc, &argv);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (win), vbox);
hbox = gtk_hbox_new (TRUE, 5);
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
text = gtk_text_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 5);
drawingarea = gtk_drawing_area_new ();
gtk_box_pack_start (GTK_BOX (hbox), drawingarea,
FALSE, FALSE, 5);
hbox = gtk_hbox_new (TRUE, 5);
gtk_box_pack_end (GTK_BOX (vbox), hbox, TRUE, TRUE, 5);
toggle = gtk_toggle_button_new_with_label ("TEXT");
gtk_signal_connect_object (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (toogle_text),
GTK_OBJECT (text));
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 5);
toggle = gtk_toggle_button_new_with_label ("DRAWING AREA");
gtk_signal_connect_object (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (toogle_drawing_area),
GTK_OBJECT (drawingarea));
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 5);
gtk_widget_show_all (win);
gtk_main ();
return 0;
}
============================================================
--
To unsubscribe: mail -s unsubscribe [EMAIL PROTECTED] < /dev/null