a question about widgets...



Hi list!

This is my first message, then go there:
Why this code bellow don't function?

I want to substitute one widget for another one in the
same place, then I tryed to equal the old widget to
the new (this code is in the function button_click
inside of switch).

I wait for your reply!
Bye.

Adriano Bonat

-------[ code starts here ]-------------

#include <gtk/gtk.h>

GtkWidget *main_window, *button1, *button2;

GtkWidget *create_main_window(gchar *);
void button_click(GtkWidget *, gpointer);

int main(int argc, char *argv[])
{
  gtk_init(&argc, &argv);

  main_window = create_main_window("testing...");
  gtk_widget_show_all(main_window);

  gtk_main();
  return 0;
}

GtkWidget *create_main_window(gchar *title)
{
  GtkWidget *window, *button;

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect(GTK_OBJECT(window), "destroy",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
  gtk_window_set_title(GTK_WINDOW(window), title);

  button = gtk_button_new_with_label("Click here!");
  gtk_container_add(GTK_CONTAINER(window), button);
  gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(0));

  button1 = gtk_button_new_with_label("Windows");
  gtk_signal_connect(GTK_OBJECT(button1), "clicked",
GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(1));

  button2 = gtk_button_new_with_label("Linux");
  gtk_signal_connect(GTK_OBJECT(button1), "clicked",
GTK_SIGNAL_FUNC(button_click), GINT_TO_POINTER(2));

  return window;
}

void button_click(GtkWidget *b, gpointer data)
{
  switch((int)data)
  {
    case 0:
    case 2:
      b = button1; // windows button
      break;
    case 1:
      b = button2; // linux button
      break;
  }

  gtk_widget_show(b);
}

_______________________________________________________________________
Busca Yahoo!
O serviço de busca mais completo da Internet. O que você pensar o Yahoo! encontra.
http://br.busca.yahoo.com/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]