GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 30, 2014 2:25 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Shrink window dynamically when content shrinks?
PostPosted: Fri Jan 20, 2012 9:51 pm 
Offline

Joined: Fri Jan 20, 2012 9:40 pm
Posts: 3
I have a window in a Vala application and an image inside it. This image is changed sometimes by
Code:
img.set_from_pixbuf(imgdata);
and so it's size changes as well. It's embedded in a Gtk.Box.

Code:
box = new Gtk.Box(Orientation.VERTICAL,5);
...
box.pack_end(img,false,false);


So if there was a big image before and I replace it with a smaller one, the window remains ridiculously big and I have not found a method to dynamically shrink it to the space required. I have tried with
Code:
window.set_default_size(box.width_request,box.height_request)
but it always returns -1.

So any ideas how to resize the window? I just tried everything and am so desperate. Thanks!


Top
 Profile  
 
 Post subject: Re: Shrink window dynamically when content shrinks?
PostPosted: Sat Jan 21, 2012 12:08 am 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
hmm in c this returns void. Maybe things are different in the world of python.
The function you are using I think is meant to be used for initially setting the window size before realising it on the screen. Once it is there you'd be better off using gtk_window_resize


Top
 Profile  
 
 Post subject: Re: Shrink window dynamically when content shrinks?
PostPosted: Sat Jan 21, 2012 5:15 pm 
Offline

Joined: Fri Jan 20, 2012 9:40 pm
Posts: 3
I'm using Vala, not Python ;)
Yeah, what you said is probably true. However, it doesn't matter, which function I use, the result remains the same...
I just can't believe that GTK+ is not capable of automatically resizing a window.
Ok, I would even be happy if I was able to resize the window manually. But no luck so far

Would be very happy about any new solutions :)
Conchulio


Top
 Profile  
 
 Post subject: Re: Shrink window dynamically when content shrinks?
PostPosted: Sun Jan 22, 2012 12:06 pm 
Offline
Never Seen the Sunlight

Joined: Thu Mar 24, 2011 2:10 pm
Posts: 328
Location: Sydney, Australia
It's not designed to shrink automatically. Gtk like a lot of widget sets are designed to work on devices with different screen sizes (e.g. desktops, netbooks and android phones). As such widgets are rarely expressed as fxed sizes; rather the window is set by the user and the widgets then fill to make best use of the available space. So yes It'll likely have to be done manually. Why that's not working I'm not sure.
Sorry I see dots and automatically think python. Actually these calls are listed as returning public void http://valadoc.org/gtk+-3.0/Gtk.Window.resize.html so I'm not sure where your -1 comes from.
One possibility I can think of is that the window has had a size request made based on the size of your inital image and so you may need to make a new set_size_request call before it can shrink down smaller than these dimensions.


Top
 Profile  
 
 Post subject: Re: Shrink window dynamically when content shrinks?
PostPosted: Sun Jan 22, 2012 8:33 pm 
Offline

Joined: Fri Jan 20, 2012 9:40 pm
Posts: 3
The -1 was just because I mixed up two different functions. So Gtk isn't buggy ;)
So what I'm experiencing now is that set_size_request(..,..) doesn't affect the widgets on which it is called... strange


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 8 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