davimint |
09-08-2008 08:50 PM |
How do you control size and placement of widgets in table under gtk
Hi, I'm trying to learn a little about GUI programing and I'm having problems understanding how to control the placement of widgets in a table. Here's the code of something I'm working on.
Code:
#include <gtk/gtk.h>
int main( int argc, char* argv[])
{
GtkWidget *window;
GtkWidget *calendar;
GtkWidget *table;
GtkWidget *combo;
GtkWidget *button;
GList *items = NULL;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), "Account Manager Window ");
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
table = gtk_table_new(3, 3, TRUE);
gtk_container_add(GTK_CONTAINER(window), table);
gtk_container_border_width(GTK_CONTAINER(window), 15);
items = g_list_append(items, "005-Jackson");
items = g_list_append(items, "011-Birmingham");
items = g_list_append(items, "018-Greenville");
items = g_list_append(items, "036-Decater");
items = g_list_append(items, "039-Hattiesburg");
items = g_list_append(items, "043-Tupelo");
combo = gtk_combo_new();
gtk_combo_set_popdown_strings(GTK_COMBO(combo), items);
gtk_table_attach_defaults(GTK_TABLE(table), combo, 2, 3, 0, 1);
calendar = gtk_calendar_new();
gtk_table_attach_defaults(GTK_TABLE(table), calendar, 0, 1, 0, 1);
button = gtk_button_new_with_label("button");
gtk_table_attach_defaults(GTK_TABLE(table), button, 1, 2, 0, 1);
g_signal_connect_swapped(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show_all(window);
gtk_main();
return 0;
}
The problem is that the button is the same size as the calendar and the combo box is centered. I want to control the size and placements of the widgets(combo box & button) inside the table. Knowing me I'm going about it all wrong and the table may not be my best option but I'm planning on putting about 9 widgets inside the table(window). Maybe I've explained this well enough. I'm an example kind of person so if you don't mind that would best help me.
Thanks.
|