/* * gtk-xabc0.c * * Copyright (C) 2007 Pau Espin Pedrol (Sharwin_F) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see */ #include #include "inc.h" /* MAIN */ int main(int argc, char *argv[]) { GtkWidget *window, *vbox, *hbox, *button, *textinfo, *textarea, *result; GtkWidget** dades = g_new(GtkWidget*, 4); gtk_init(&argc, &argv); /* DEFINIM WIDGETS: */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_container_set_border_width (GTK_CONTAINER (window), 10); gtk_widget_set_size_request (GTK_WIDGET (window), 400, 250); gtk_window_set_title (GTK_WINDOW (window), "gtk - xabc0"); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL); vbox = gtk_vbox_new (0, 1); gtk_container_add(GTK_CONTAINER (window), vbox); gtk_widget_show(vbox); hbox = crea_hbox( vbox ); textinfo = gtk_label_new ("Insereix el valor d'a, b i c:"); gtk_box_pack_start (GTK_BOX (hbox), textinfo, TRUE, FALSE, 0); gtk_widget_show(textinfo); hbox = crea_hbox( vbox ); textinfo = gtk_label_new ("A = "); gtk_box_pack_start (GTK_BOX (hbox), textinfo, FALSE, FALSE, 0); gtk_widget_show(textinfo); textarea = gtk_entry_new(); gtk_container_add(GTK_CONTAINER (hbox), textarea); gtk_widget_show(textarea); dades[0] = textarea; hbox = crea_hbox( vbox ); textinfo = gtk_label_new ("B = "); gtk_box_pack_start (GTK_BOX (hbox), textinfo, FALSE, FALSE, 0); gtk_widget_show(textinfo); textarea = gtk_entry_new(); gtk_container_add(GTK_CONTAINER (hbox), textarea); gtk_widget_show(textarea); dades[1] = textarea; hbox = crea_hbox( vbox ); textinfo = gtk_label_new ("C = "); gtk_box_pack_start (GTK_BOX (hbox), textinfo, FALSE, FALSE, 0); gtk_widget_show(textinfo); textarea = gtk_entry_new(); gtk_container_add(GTK_CONTAINER (hbox), textarea); gtk_widget_show(textarea); dades[2] = textarea; hbox = crea_hbox( vbox ); button = gtk_button_new_with_label("Calcular"); gtk_box_pack_start (GTK_BOX (hbox), button, 1, 0, 0); gtk_widget_show(button); hbox = crea_hbox( vbox ); result = gtk_label_new("\n\n\n"); gtk_box_pack_start (GTK_BOX (hbox), result, 1, 0, 20); gtk_widget_show(result); dades[3] = result; g_signal_connect_swapped(G_OBJECT (button), "clicked", G_CALLBACK (Resol), (gpointer) dades); gtk_widget_show(window); gtk_main(); return 0; }