Hi, First of all: Thanks. Your reply indeed solved my problem. Thanks.
Other than that: Why is this silly? (You see, i didn't agree, but did continue to read ...) My reasoning is: A gtkentry for me is just "something that contains some text which may change". Now in this particular setup is text entry a problem (as the device doesn't always have a keyboard). So i build something based on a button which changes its label by some "input magic" that kicks into place when the user clicks the button. And whenever the user does this i want it to trigger the same behaviour the original gtkentry did. If you think this is silly: What do you think is the non-silly way to solve this? Thanks again, Till ----- original Nachricht -------- Betreff: Re: Howto make a gtkbutton send a "changed" signal? Gesendet: Di, 01. Dez 2009 Von: David Ne?as<y...@physics.muni.cz> > On Tue, Dec 01, 2009 at 09:59:07AM +0100, Till Harbaum wrote: > > i am changing the UI of an existing app for mobile usage in a way that i > replace > > some gtkentry's with some gtkbuttons which the use some alternate input > method. > > > > I want to keep as much of the application as it is and one of the things > the app expects > > is that this particular widget emits a "changed" event whenever its > contents changes. > > > > So i'd like to enable my gtkbutton to emit a "changed" event, but i don't > find any examples > > on how to achieve that. How do i "attach" a new signal to an existing > widget type? > > If you agree that what you are trying to do is silly and you are > desperate, you are allowed to read on. > > I'm not sure what it means `contents changed' for a button. So I > respond to "clicked". But you can emit the signal in response to > "notify::label" (i.e. the change of the label) or whatever it means > `contents changed' for you. > > Yeti > > ---------------------------------------------------------- > #include <gtk/gtk.h> > > static void > emit(GObject *object, gpointer user_data) > { > guint id = GPOINTER_TO_UINT(user_data); > g_signal_emit(object, id, 0); > } > > static void > changed(GObject *object) > { > g_print("signal \"changed\" emitted on instance %p (%s)\n", > object, G_OBJECT_TYPE_NAME(object)); > } > > int > main(int argc, char *argv[]) > { > GtkWidget *window, *button; > guint id; > > gtk_init(&argc, &argv); > window = gtk_window_new(GTK_WINDOW_TOPLEVEL); > g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); > > id = g_signal_new("changed", GTK_TYPE_BUTTON, > G_SIGNAL_RUN_FIRST, 0, NULL, NULL, > g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); > > button = gtk_button_new_with_label("Click Me!"); > g_signal_connect(button, "clicked", G_CALLBACK(emit), > GUINT_TO_POINTER(id)); > g_signal_connect(button, "changed", G_CALLBACK(changed), NULL); > gtk_container_add(GTK_CONTAINER(window), button); > gtk_widget_show_all(window); > > gtk_main(); > > return 0; > } > ---------------------------------------------------------- > --- original Nachricht Ende ---- _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list