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; } ---------------------------------------------------------- _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list