LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-16-2007, 10:23 PM   #1
RHLinuxGUY
Member
 
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889
Blog Entries: 1

Rep: Reputation: 30
C++: Gtk+-2.0: Problem with tables and widget cell attachments.


My problem is with GTK+-2.0 using C++.

I made a table, which is in a fixed location on my window. It is 7 columns wide, and 6 rows in height.

The table cells are not homogeneous. (table = gtk_table_new (7, 6, false))

I have several GtkEntry's attached to the table, but they are all attached in the same columns, just in different rows. So here is how I attached them.

gtk_table_attach ( GTK_TABLE (table), myentry, 0, 5, 0, 1, GTK_FILL, GTK_FILL, 0, 0);

The function explained here.

As you can see, the x and y options are set to GTK_FILL to only use the cells allocated to it.

Except for me, it does not do so. No matter how many cells I tell gtk to attach the entries to, it always ends up to be about 2 or 3 cells.

It is only when I change homogeneous parameter in gtk_table_new () to TRUE does it change the width of the entries. But it changes the width of all the other cells to be the same size as the largest cell. Which I don't want.

How do I accomplish having the entries stretch out to take up the EXACT amount of cells I attached it to?

Here is code to one of the entries I made:

Code:
...

fixed[0] = gtk_fixed_new ();

table[0] = gtk_table_new (7, 6, false);

gtk_fixed_put ( GTK_FIXED (fixed[0]), table[0], 300, 10); // positioned at x(300), and y

...

outentry = gtk_entry_new ();

gtk_table_attach ( GTK_TABLE (table[0]), outentry, 0, 6, 5, 6, GTK_FILL, GTK_FILL,
0, 5);

...

Last edited by RHLinuxGUY; 03-16-2007 at 10:25 PM.
 
Old 03-17-2007, 02:35 PM   #2
RHLinuxGUY
Member
 
Registered: Oct 2003
Distribution: Ubuntu 7.04
Posts: 889

Original Poster
Blog Entries: 1

Rep: Reputation: 30
I fixed my problem. It still doesn't stretch out to fit all the cells that I wanted to attach to. But after looking at GtkEntry's page, I noticed
Code:
gtk_entry_set_width_chars(GtkEntry*, gint)
, which solved my problem.
 
Old 03-18-2007, 05:32 AM   #3
Harmaa Kettu
Member
 
Registered: Apr 2005
Location: Finland
Posts: 196

Rep: Reputation: 30
Except that it probably breaks again if you change your gtk theme or font settings...
The correct way is to use both GTK_EXPAND and GTK_FILL flags for the option parameters. There is also gtk_table_attach_defaults(), which does exactly that.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
GTK widget which to use? cranium2004 Programming 1 02-20-2006 01:29 PM
Gtk widget problem iali Linux - General 0 01-21-2006 12:56 AM
GTK widget appearance neiljmac Linux - Software 1 12-25-2004 06:43 AM
Which GTK Widget to use? jpbarto Programming 0 11-20-2003 07:34 PM
what is a gtk-widget ? gladeiator Programming 3 10-30-2003 05:34 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration