 |
GTK+ Forums Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
|
|
|
| Author |
Message |
|
|
bandalli
Joined: 06 Apr 2008 Posts: 1
|
Posted: Sun Apr 06, 2008 7:17 pm Post subject: Reducing the size of hbox |
|
|
Hi All,
This is Sowmya Bandalli, I am trying to develop GUI for N800, I have created 5 colorbuttons and 5 labels in the hbox,but the problem is with the width,the GUI I developed is occupying the whole screen, So I want to reduce the width, I am very new in this field,So can someone help me with this, Thanks for all your help.
Best,
Sowmya
I am attaching the code which I have written.
#include <gtk/gtk.h>
static void color_changed (GtkColorButton*, GtkWidget*);
int i;
int main(int argc, char *argv[])
{
GtkWidget *window, *button, *label, *hbox;
GdkColor color;
int i;
gtk_init(&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Color Button");
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
gdk_color_parse("#0065535", &color);
button = gtk_color_button_new_with_color (&color);
gtk_color_button_set_title (GTK_COLOR_BUTTON (button), "Select a Color");
hbox = gtk_hbox_new (FALSE, 3);
for(i=0; i<5; i++)
{
label = gtk_label_new ("mote1!");
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color);
g_signal_connect (G_OBJECT (button), "color_set",G_CALLBACK (color_changed), (gpointer) label);
/*hbox = gtk_hbox_new (FALSE, 2);*/
gtk_box_pack_start_defaults (GTK_BOX (hbox), button);
gtk_box_pack_start_defaults (GTK_BOX (hbox), label);
button = gtk_color_button_new_with_color (&color);
gtk_color_button_set_title (GTK_COLOR_BUTTON (button), "Select a Color");
}
/*label = gtk_label_new ("mote1!");
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color);
g_signal_connect (G_OBJECT (button), "color_set",G_CALLBACK (color_changed), (gpointer) label);
hbox = gtk_hbox_new (FALSE, 800);
gtk_box_pack_start_defaults (GTK_BOX (hbox), button);
gtk_box_pack_start_defaults (GTK_BOX (hbox), label);
button = gtk_color_button_new_with_color (&color);
gtk_color_button_set_title (GTK_COLOR_BUTTON (button), "Select a Color");
label = gtk_label_new ("mote1!");
gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &color);
g_signal_connect (G_OBJECT (button), "color_set",G_CALLBACK (color_changed), (gpointer) label);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start_defaults (GTK_BOX (hbox), button);
gtk_box_pack_start_defaults (GTK_BOX (hbox), label);
button = gtk_color_button_new_with_color (&color);
gtk_color_button_set_title (GTK_COLOR_BUTTON (button), "Select a Color");*/
gtk_container_add (GTK_CONTAINER (window), hbox);
gtk_widget_show_all (window);
gtk_main();
return 0;
}
static void
color_changed (GtkColorButton *button, GtkWidget *label)
{
GdkColor color;
gtk_color_button_get_color (button,&color);
gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color);
} |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 376 Location: State College, Pennsylvania
|
Posted: Sun Apr 06, 2008 8:34 pm Post subject: |
|
|
| Sizing in GTK+ generally does not use fixed sizes. This allows applications to accommodate all different types of fonts, sizes, themes, languages, etc. If it is really too large, you have a few options. One is to add a blank label as a third column in the table and set only that column to expand. Another option is to place it into a GtkAlignment widget, which allows proportional sizing. |
|
| Back to top |
|
 |
openldev Never Seen the Sunlight
Joined: 21 Sep 2005 Posts: 376 Location: State College, Pennsylvania
|
Posted: Sun Apr 06, 2008 8:42 pm Post subject: |
|
|
| You should really use a table rather than an hbox so that all of the labels are in the left column and the color buttons are in the right column. This is a cleaner design and more closely follows the GNOME Human Interface Guidelines. |
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group CodeBB 1.0 Beta 2
|