GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Oct 21, 2014 3:48 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Reducing the size of hbox
PostPosted: Sun Apr 06, 2008 7:17 pm 
Offline

Joined: Sun Apr 06, 2008 6:29 pm
Posts: 1
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);
}


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 8:34 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 06, 2008 8:42 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
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.

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group