something basic



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I think I'm missing something very basic here. I am trying to add
a few widgets into a box in such a way that the box expands to hold
the child widgets and the text widget expands to show all text. I
am obviously missing the boat here since neither happens. I am including
the code that produces the wrong result with the stuff that works cut
away.


/*
 * CreateMainWindow
 *
 * Create the main window and the menu/toolbar associated with it
 */
static void CreateMainWindow ()
{
    GtkWidget *vbox_main;
    GtkWidget *vbox;
    GtkWidget *vbox2;
    GtkWidget *vbox3;
    GtkWidget *text;
    GtkWidget *enterprompt;
    GtkWidget *entry_widget;

    /* --- Create the top window and size it. --- */
    win_main = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    /* --- Let the window to be resized. --- */
    gtk_window_set_policy (GTK_WINDOW (win_main), FALSE, TRUE, FALSE);

    /* --- Title --- */
    gtk_window_set_title (GTK_WINDOW (win_main), "Anvil Cash");
    gtk_container_set_border_width (GTK_CONTAINER (win_main), 5);

    /* --- Top level window should listen for the destroy --- */
    gtk_signal_connect (GTK_OBJECT (win_main), "destroy",
              GTK_SIGNAL_FUNC(ExitProgram), NULL);

    /* --- Create v-box-main for win_main --- */
    vbox_main = gtk_vbox_new (FALSE, 0);

    /* --- Put up v-box --- */
    gtk_container_add (GTK_CONTAINER (win_main), vbox_main);

    /* --- Create v-box for menu --- */
    vbox = gtk_vbox_new (FALSE, 0);

    /* --- Put up v-box --- */
    gtk_box_pack_start (GTK_BOX (vbox_main), vbox, FALSE, TRUE, 0);

printf("Creating VBOX2.\n");
    /* --- Create v-box for text and widgets --- */
    vbox2 = gtk_vbox_new (FALSE, 0);
printf("Adding vbox to container.\n");
    /* --- Put up v-box --- */
    gtk_box_pack_start (GTK_BOX (vbox_main), vbox2, FALSE, TRUE, 0);

    /*------- Create text--------*/
printf("Creating text .\n");
    text = gtk_text_new (NULL, NULL);
    gtk_text_insert (GTK_TEXT (text), NULL, NULL, NULL,
		"Now it's time to get acquainted.", 34);
    gtk_text_set_word_wrap (GTK_TEXT (text), FALSE);
    gtk_text_set_editable (GTK_TEXT (text), FALSE);
printf("Adding text into vbox2.\n");
    gtk_box_pack_start (GTK_BOX (vbox2), text, FALSE, TRUE, 0);
    gtk_widget_show (text);

    /* --- Create v-box for prompt and entry widgets --- */
    vbox3 = gtk_vbox_new (FALSE, 0);
printf("Adding vbox to container.\n");
    /* --- Put up v-box --- */
    gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, TRUE, 0);

    /* Create enter prompt ----------------*/
    enterprompt = gtk_entry_new ();
    gtk_entry_set_text (GTK_ENTRY (enterprompt),
			"Enter your name.");

    gtk_entry_set_editable (GTK_ENTRY (enterprompt), FALSE);
    gtk_box_pack_start (GTK_BOX (vbox3), enterprompt, FALSE, TRUE, 0);

    entry_widget = gtk_entry_new_with_max_length (30);
    gtk_box_pack_start (GTK_BOX (vbox3), entry_widget, FALSE, TRUE, 0);

    gtk_widget_show (enterprompt);
    gtk_widget_show (entry_widget);
    gtk_widget_show (vbox);
    gtk_widget_show (vbox2);
    gtk_widget_show (vbox3);
    gtk_widget_show (vbox_main);
    gtk_widget_show (win_main);
}

Any help is greatly appreciated.
- -Vicki
+-----------------------------------------------------------------+
|              E-mail:  vicki thepenguin org                      |
|    My public key - http://www.thepenguin.org/vicki/key.txt      |
|         My Linux page - http://www.thepenguin.org               |
+-----------------------------------------------------------------+
**The best things in life aren't things.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.4 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6+JGHvFwCsl/kaSARAr2KAJ9Q7ZTKviMj8TsfLleLjhSuk6hWdwCgv/bc
F+HGHTTlkEwBWQKwpZKRpMs=
=M8ug
-----END PGP SIGNATURE-----





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]