Why doesn't it work ??
- From: B Mohrgan Pratten <mohrgan sympatico ca>
- To: gtk-list redhat com
- Subject: Why doesn't it work ??
- Date: Wed, 15 Mar 2000 20:03:25 -0500
I am vary new to gtk, but like what I have seen,.
I have a question with source code. As far as I can tell it should
work, but it dose not (for me). If someone could have a look at the
code and try it would be great. I wrote this simple code fragment that
contains the problem. I want the 'label' of a 'toggle' button to change
as the button is toggled form one state to the next. The program tries
to just change it once from "UP" to "DOWN". If this works, I can add
the code to have the right label for the right state of the button.
If I am doing this all wrong, or am just plan stupid, I would appreciate
your insight and hopefully your solution.
I compile the attached code with:
gcc -g toggle.c -o toggle `gtk-config --cflags --libs`
About my system:
RedHat 6.1
IBM ThinkPad 390X
gtk 1.2.5 (I get this from the line:
g_print ("gtk %d.%d.%d\n",gtk_major_version, gtk_minor_version,
gtk_micro_version);
If you want any other information, please ask.
P.s. I seem to have a couple of issues with passing args to callbacks, I
am hopping to find the problem with this problem, there by fixing the
other problems.
I appreciate your help.
Mohrgan.
#include <gtk/gtk.h>
void cb_toggle (GtkWidget*, GdkEvent*, GtkWidget*);
void cb_exit (GtkWidget*, GdkEvent*, gpointer);
int main (int, char**);
void cb_toggle (widget, event, label)
GtkWidget *widget;
GdkEvent *event;
GtkWidget *label;
{
gtk_label_set_text (GTK_LABEL (label), "DOWN");
}
void cb_exit (widget, event, data)
GtkWidget *widget;
GdkEvent *event;
gpointer data;
{
gtk_main_quit ();
}
int main (num, str)
int num;
char **str;
{
GtkWidget *window;
GtkWidget *toggle;
GtkWidget *label;
gtk_init (&num, &str);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
GTK_SIGNAL_FUNC (cb_exit), NULL);
toggle = gtk_toggle_button_new ();
gtk_container_add (GTK_CONTAINER (window), toggle);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (cb_toggle), label);
gtk_widget_show (toggle);
label = gtk_label_new ("UP");
gtk_container_add (GTK_CONTAINER (toggle), label);
gtk_widget_show (label);
gtk_widget_show (window);
gtk_main ();
return (0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]