How to control number of leading spaces in a GtkWidget?

Posted by Jack on Stack Overflow See other posts from Stack Overflow or by Jack
Published on 2012-10-09T13:33:31Z Indexed on 2012/10/12 3:37 UTC
Read the original article Hit count: 94

Filed under:
|
|

How do I set the leading spaces in a GtkWidget? as you can see into below imagem, username/password widgets are a bit away from horizontal line when the window begins

enter image description here

My code:

  GtkWidget *window;
  GtkWidget *login_label;
  GtkWidget *username_label, *password_label;
  GtkWidget *username_entry, *password_entry;
  GtkWidget *ok_button;
  GtkWidget *hbox0, *hbox1, *hbox2, *hbox3;
  GtkWidget *vbox;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "hello");
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 200, 300);

  g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);

  login_label    = gtk_label_new("Login");
  username_label = gtk_label_new("Username: ");
  password_label = gtk_label_new("Password: ");
  username_entry = gtk_entry_new();
  password_entry = gtk_entry_new();

  gtk_entry_set_visibility(GTK_ENTRY(password_entry), FALSE);
  ok_button = gtk_button_new_with_label("Enter");

  g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(print_username), ok_button);

  hbox0 = gtk_hbox_new(TRUE, 5);
  hbox1 = gtk_hbox_new(TRUE, 5);
  hbox2 = gtk_hbox_new(TRUE, 5);
  hbox3 = gtk_hbox_new(TRUE, 5);

  vbox =  gtk_vbox_new(FALSE, 10);

  gtk_box_pack_start(GTK_BOX(hbox0), login_label, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(hbox1), username_label, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(hbox1), username_entry, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(hbox2), password_label, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(hbox2), password_entry, TRUE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(hbox3), ok_button, FALSE, FALSE, 5);

  gtk_box_pack_start(GTK_BOX(vbox), hbox0, FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), hbox1, FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 5);
  gtk_box_pack_start(GTK_BOX(vbox), hbox3, FALSE, FALSE, 5);

  gtk_container_add(GTK_CONTAINER(window), vbox);

  gtk_widget_show_all(window);
  gtk_main();

© Stack Overflow or respective owner

Related posts about c

    Related posts about gtk