strange results from usize, set_policy, and default_size
- From: Kees Cook <gtk-app outflux net>
- To: gtk-app-devel-list gnome org
- Subject: strange results from usize, set_policy, and default_size
- Date: Thu, 16 May 2002 14:46:22 -0700
Hello!
(I posted this on the 14th, but wasn't a list member. Sorry if the
original gets approved at some point, duplicating this one. Also, I
solved this problem by the time I got to the end of writing the
email, but I'm still curious about the described behavior...)
I have hit a wall trying to solve a bug in my application. Here's what I
have the application doing:
- remember the sizes of the multiple user-sizable windows
- remember a user-selectable font (via the glade font-dialog)
All the preference saving etc is done and working. Same for window sizes.
Sizes are restored on startup with "gtk_window_set_default_size" calls.
The only really big "trick" I had to use was doing widget resizing after a
font change. Since the application is based on a older console tool, I
retained the concept of "80 columns". So, after a font is selected, I
call gtk_widget_set_usize(GTK_WIDGET(whatever),wide,-2) after calculating
80*font_width for the value of "wide". (I force only fixed-width fonts.)
While I force the minimum size to 80 columns, I want the user to be able
to expand the window size. Therefore, all the windows have:
gtk_window_set_policy(GTK_WINDOW(whatever),FALSE,TRUE,TRUE);
This lets users resize fine, but if they switch to a smaller font, the
window does not auto_shrink, even if I call "gtk_widget_queue_resize".
Basically, I want font changes to snap the windows to whatever the
80-column size is, regardless of the user's requested window size. BUT, I
want them to be able to grow the window size beyond that, and have it be
remembered as long as they don't change the font.
While I know the set_policy call isn't "recommended" with "FALSE, TRUE,
TRUE", the user can't grow the windows if I use "FALSE, FALSE, TRUE"
(which, btw, DOES auto_shrink my windows on a font size change).
I've looked through the mailing lists, the APIs, tutorials. I can't find
anything that'll handle this. The only thing that I've been able to do
that almost works is calling "gtk_window_set_default_size", but this isn't
proper since I don't know the actual size of the window (I'm setting
widget widths inside containers in the window).
Oh, I was just struck with an idea. While "gtk_widget_queue_resize"
didn't work, calling "gtk_window_set_default_size(window, 0, -2)" seemed
to force it to recalculate the width and set it to the least possible
width! Yay! Well, I guess this mailing list did help me. ;)
So, nevermind, I have a solution. I guess I'll ask a question anyway: why
doesn't auto_shrink work in this situation? Or is this the reason that
"FALSE, TRUE, TRUE" isn't recommended?
--
Kees Cook @outflux.net
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]