Well, it worked. Didn't it work for you? Also, in the future please give _compilable_ code - it's no fun to fix compilation errors just to try it out.
On Thu, Oct 31, 2013 at 3:11 PM, Mahesh Chaudhari <mahesh.chaudh...@ymail.com> wrote: > Ruslan , > that is working with mouse clicks (works for me also) > what I wanted is without clicking with mouse, generate a click signal event > (through a program only) and and thus color should be changed > try this one if possible (click only "start" button with mouse and color of > button1 should be changed) > > GtkWidget *button1, *button2, *button3, *button4, *button5; > void click_button1(GtkWidget *widget, gpointer data) > { > printf("in click_button1\n"); > GdkColor color; > color.red = 27000; > color.green = 30325; > color.blue = 34181; > // gtk_widget_modify_fg(GTK_WIDGET(widget), GTK_STATE_NORMAL, &color); > gtk_widget_modify_bg(GTK_WIDGET(button1), GTK_STATE_NORMAL, &color); > } > > void click_button_start(GtkWidget *widget, gpointer data) > { > gtk_button_clicked(GTK_BUTTON(button1)); > } > > int main (int argc,char **argv) > { > GtkWidget *button_start; > GtkWidget *hbox,*vbox; > GdkColor color; > gdk_color_parse ("blue", &color); > gtk_init (&argc,&argv); > > /*...............create top level window...................*/ > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > gtk_window_set_title(GTK_WINDOW(window), "LED status"); > gtk_window_set_default_size(GTK_WINDOW(window), 250, 80); > gtk_container_set_border_width(GTK_CONTAINER(window), 5); > g_signal_connect (G_OBJECT(window), "destroy", > G_CALLBACK (gtk_main_quit), NULL); > > /*................. create buttons ......................*/ > > button_start = gtk_button_new_with_label("start"); > g_signal_connect(G_OBJECT(button_start), "clicked", > G_CALLBACK(click_button_start), NULL); > button1 = gtk_button_new_with_label ("button1"); > g_signal_connect(G_OBJECT(button1), "clicked", > G_CALLBACK(click_button1), NULL); > button2 = gtk_button_new_with_label ("button2"); > g_signal_connect(G_OBJECT(button2), "clicked", > G_CALLBACK(click_button2), NULL); > button3 = gtk_button_new_with_label ("button3"); > button4 = gtk_button_new_with_label ("button4"); > button5 = gtk_button_new_with_label ("button5"); > > /*.................. Alignements......................*/ > > hbox = gtk_hbox_new(TRUE,1); > vbox = gtk_vbox_new(TRUE,1); > gtk_box_pack_start(GTK_BOX(hbox), button1, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(hbox), button2, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(hbox), button3, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(hbox), button4, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(hbox), button5, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(vbox), button_start, 1, 1, 0); > gtk_box_pack_start(GTK_BOX(vbox), hbox, 1, 1, 0); > gtk_container_add (GTK_CONTAINER (window), vbox); > > /*....................show...............................*/ > > gtk_widget_show_all (window); > gtk_main(); > return 0; > > > On Thursday, 31 October 2013 3:09 AM, Ruslan Kabatsayev > <b7.10110...@gmail.com> wrote: > Hi, > > I've tried your code, it works for me. Did you try moving cursor out > of the button after you click it? If the cursor is still inside, the > button is in hovered state, not STATE_NORMAL. > If it still doesn't work, then what widget theme do you use? Maybe it > interferes with your actions (older versions of oxygen-gtk had this > problem, for example). > > Regards, > Ruslan > > On Thu, Oct 31, 2013 at 1:07 PM, Mahesh Chaudhari > <mahesh.chaudh...@ymail.com> wrote: >> what am I doing wrong in Following Code : >> >> GtkWidget *button1; >> void click_button1(GtkWidget *widget, gpointer data) >> { >> printf("I am in click_button\n"); // able to print >> this >> GdkColor color; >> color.red = 27000; >> color.green = 30325; >> color.blue = 34181; >> gtk_widget_modify_bg(GTK_WIDGET(widget), GTK_STATE_NORMAL, &color); >> //gtk_widget_modify_fg(GTK_WIDGET(widget), GTK_STATE_NORMAL, &color); >> } >> >> >> some_callback_func() >> { .... >> gtk_button_clicked(GTK_BUTTON(button1)); >> ..... } >> >> >> >> >> int main(int argc, char** argv) >> { >> gtk_init(&argc,&argv); >> button1 = gtk_button_new_with_label ("button1"); >> g_signal_connect(G_OBJECT(button1), "clicked", >> G_CALLBACK(click_button1), NULL); >> gtk_widget_show_all (window); >> gtk_main(); >> return 0; >> } >> _______________________________________________ >> gtk-app-devel-list mailing list >> gtk-app-devel-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list