Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically enable/disable resizable #372

Closed
IanTrudel opened this issue Sep 30, 2017 · 10 comments
Closed

Programmatically enable/disable resizable #372

IanTrudel opened this issue Sep 30, 2017 · 10 comments
Assignees
Milestone

Comments

@IanTrudel
Copy link
Collaborator

This feature allows to programmatically change resizable passed down to Shoes.app (or a window). There is still some work to do because while the feature fully works, setting resizable to false will unfortunately resize the window back to its default. Hence, it has been committed to a remote branch.

image

image

Shoes.app(width: 250, height: 100, resizable: false) do
    @p = para
    flow do
        button("enable") do
            app.resizable = true
        end
        button("disable") do
            app.resizable = false
        end
    end
    animate do
        @p.replace "resizable #{app.resizable}"
    end
end

Additional references:

@ccoupe
Copy link

ccoupe commented Oct 1, 2017

Oops, this the issue to talk about what's happening on older Gtk3. After executing line 754 of gtk.c

gtk_window_resize(GTK_WINDOW(app->os.window), app->width, app->height);

Is when the

(shoes:21292): Gtk-WARNING **: Toplevel size doesn't seem to directly depend on the size of the geometry widget from gtk_window_set_geometry_hints(). The geometry widget might not be in the window, or it might not be packed into the window appropriately

occurs - the code to call gtk_window_set_geometry_hints was executed. There we also many
warnings from the compiler in this section of the code so those all need looking at.

@IanTrudel
Copy link
Collaborator Author

IanTrudel commented Oct 1, 2017

Are you in sync with the repo? The only place there is gtk_window_resize in shoes_native_app_resize_window. gtk_window_resize is constrained by geometry.

The part I wrote ultimately went to use gtk_widget_set_size_request. Refer to comment.

@IanTrudel
Copy link
Collaborator Author

Woah. There was a huge bug on Github. It displayed a previous version of the code. Now it all uses gtk_widget_set_size_request. o_O

@ccoupe
Copy link

ccoupe commented Oct 2, 2017

setting NULL instead of gk-window fixes the Gtk console warning - as you suggested.
gtk_window_set_geometry_hints(GTK_WINDOW(gk->window), NULL,

The compiler gtk3 deprecation warning are going to be trouble some. I hate to ignore warning but we may have to.

@IanTrudel
Copy link
Collaborator Author

I hate to ignore warning but we may have to.

This solution in Vala makes me think that a simple dummy call to gtk_widget_get_preferred_width/height() at appropriate places in the code will resolve the warnings.

(<unknown>:77048): Gtk-WARNING **: Allocating size to GtkBox 0x812d81300 without calling gtk_widget_get_preferred_width/height(). How does the code know the size to allocate?

@ccoupe
Copy link

ccoupe commented Oct 2, 2017

That one I do want to fix - it's very visible. Finding the proper places is the challenge. I'm not going to get to it very soon so If you want to give it a try then go for it. shoes -c is good test.

I was talking about the compiler warnings: the deprecations with different versions of gtk3. Those are not as easy as I hoped.

@IanTrudel
Copy link
Collaborator Author

This is a common problem when people moved to 3.20. There are so many hits on google but very little to none solutions.

You may want to take a look at gtkwidget.c top comment. A lengthy informative comment related to geometry management.

It shouldn't be hard to find out: all widgets must check for preferred width and height. And a step-by-step debugging on shoes -c would probably show that. (Notice also splash screen doesn't output warnings because it has no widgets, only Shoes elements that are cairo based anyway).

ccoupe pushed a commit that referenced this issue Oct 2, 2017
* will merge to master for the refactoring - not perfect but
  good enough for now.
* will restore the font setting button code on this branch later
* provisions for the #370, #372 issues.
ccoupe pushed a commit that referenced this issue Oct 2, 2017
* begin work on osx equivalent functions
ccoupe pushed a commit that referenced this issue Oct 2, 2017
* refactor cocoa.m into smaller files - good enough for now
* should allow master branch to build for all platforms
  skeleton code to do the #370 and #372

Conflicts:
	bugs/bug179.rb
	shoes/native/cocoa.m
@IanTrudel
Copy link
Collaborator Author

I removed two lines in gtk/gtkbuttonalt.c and let gtk use its own preferred width/height and it works. Not sure what the actual implications would be to that but shoes -c works without a hitch. Maybe buttons would have a minimal size a bit larger that what shoes normally had.

An attempt to use gtk_widget_get_preferred_width/height within the user functions gtk_button_alt_get_preferred_width/height caused a core dump. First, I tried similar to VALA code with the widget and some dummy &x, &y variables. Secondly, I tried with NULL per the documentation but it yielded in more warnings. Finally, I tried with the actual minimum and natural passed to the function but it core dumps.

ccoupe pushed a commit that referenced this issue Oct 7, 2017
* expect merge to master soon.
@IanTrudel IanTrudel added this to the 3.3.4 milestone Oct 7, 2017
ccoupe pushed a commit that referenced this issue Oct 8, 2017
* cocoa implementation
@ccoupe
Copy link

ccoupe commented Oct 8, 2017

Now merged to master branch. Osx behaves differently on the bugs/bug372.rb script: After resizing and clicking disable the osx window stays at the new size which I think is better but it's such an edge case I'm not going to spend much thought about it.

@IanTrudel
Copy link
Collaborator Author

This should be the expected behaviour. I think GTK is being naughty on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants