Re: Callback Question
- From: Roman Makurin <drolyk gmail com>
- To: Matías Alejandro Torres <torresmat gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Callback Question
- Date: Sun, 13 Apr 2008 23:30:55 +0400
Ð ÐÑÐ, 13/04/2008 Ð 15:46 -0300, MatÃÂas Alejandro Torres ÐÐÑÐÑ:
Hi,
Can I call GTK Functions that modifies the GUI inside a callback?
Just an example:
/*CALLBACK*/
void text_to_upper_callback (GtkEntry *entry, gpointer data) {
/* I modify the GUI by setting the text of an entry */
gtk_entry_set_text (entry,
g_utf8_strup (gtk_entry_get_text
(entry), -1)));
}
void* init () {
[...]
g_signal_connect (entry, "activate", (GCallback)
text_to_upper_callback, NULL);
[...]
}
#include <gtk/gtk.h>
static void destroy(GtkWidget *widget, gpointer data) {
gtk_main_quit();
}
static void convert(GtkButton *button, GtkEntry *entry) {
gtk_entry_set_text(entry,
g_utf8_strup(gtk_entry_get_text(entry), -1));
}
int main(int argc, char **argv) {
GtkWidget *window, *entry, *button, *box;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Converter");
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(destroy), NULL);
box = gtk_hbox_new(FALSE, 0);
entry = gtk_entry_new();
button = gtk_button_new_with_mnemonic("_Convert");
gtk_box_pack_start(GTK_BOX(box), entry, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 0);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(convert), entry);
gtk_container_add(GTK_CONTAINER(window), box);
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
--
If you think of MS-DOS as mono, and Windows as stereo,
then Linux is Dolby Digital and all the music is free...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]