Re: Widget sizing?

2014-11-15 Thread The Devils Jester
A GtkLayout does not seem to work, it seems that it does indeed request the
size of its children, so that if I put a GtkLayout inside a GtkWindow, and
I size the GtkLayout to a specific size, then I cant resize the window
smaller than that.

I have included a simple toy sample that demonstrates the issue I am
having.  If you run it, and resize the window, you cant ever make the
window smaller.

If I dont request size for the GtkLayout, then it is always a zero size
(or its initial size) so that any buttons or other widgets I put in it clip
immediately.  All of the children (so the layouts inside of the layouts, or
any widgets inside of those) are all sized based on the root (Window) size,
but I cant resize the root window because those widgets are all holding it
to a minimum size. I don't know what to do to solve this.  Any help solving
this would be much appreciated.

#include gtk/gtk.h
static void container_resize( GtkWidget *widget, GdkEvent *event, gpointer
data)
{
gtk_widget_set_size_request((GtkWidget*)data, event-configure.width,
event-configure.height);
}

int main( int   argc, char *argv[] )
{
gtk_init (argc, argv);

// Create the Window
GtkWidget *window;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

// Create the GtkLayout child
GtkObject* wadjust = gtk_adjustment_new(0, 0, 0, 0, 0, 0);
GtkObject* hadjust = gtk_adjustment_new(0, 0, 0, 0, 0, 0);
GtkWidget* layout = (GtkWidget*)
gtk_layout_new((GtkAdjustment*)wadjust, (GtkAdjustment*)hadjust);
gtk_widget_set_size_request(layout, 500,500);
gtk_container_add (GTK_CONTAINER (window), layout);

// Connect to our resize function
g_signal_connect (window, configure-event, G_CALLBACK
(container_resize), layout);

// Show Everything
gtk_widget_show(layout);
gtk_widget_show  (window);
gtk_main ();

return 0;
}



On Thu, Nov 13, 2014 at 1:04 PM, The Devils Jester 
thedevilsjes...@gmail.com wrote:

 With just a cursory glance at the containers documentation and function
 list, it seems to be exactly what I need, thank you.

 On Thu, Nov 13, 2014 at 12:57 PM, Tristan Van Berkom 
 tris...@upstairslabs.com wrote:

 On Thu, 2014-11-13 at 12:53 -0600, The Devils Jester wrote:
  You say that GTK has a lot of containers, are there any that already
  fit my needs (minimally, I am not looking for overkill).
 
 
  I need a container that I can add an arbitrary number of widgets to as
  children, and it will display these children.
  I don't want any styling, or layout management of any kind, I want to
  position/size the children as I see fit.
  GtkFixed fits the bill pretty nicely except that it has a minimum
  size based on the contents.
 
 
  Before I reinvent the wheel (or sub class the wheel!), is there an
  existing GTK container that can already do this?

 GtkLayout does that, but then it does not request *any* space, and
 child widgets will simply be clipped out of the visible area unless
 the layout is allocated enough space.

 
 
 
  On Thu, Nov 13, 2014 at 12:45 PM, Tristan Van Berkom
  tris...@upstairslabs.com wrote:
  On Thu, 2014-11-13 at 12:42 -0600, The Devils Jester wrote:
   I considered GtkContainer but my Google searches did not
  come up with
   any recent examples of sub classing it and I am having a
  difficult
   time understanding the mechanics behind sub classing a GTK
  object.
   Does anyone have a bare bones hello world subclassed
  GtkContainer
   sample that I could examine?
 
  GTK+ has a lot of containers, my suggestion would be to pick
  one
  that comes close to what you want (a box perhaps ?), and start
  by copying it and removing the bits that are not relevant.
 
  The simplest cases to start with might be bin widgets like
  GtkEventBox (but it does some extra stuff like creating
  an extra event window).
 
  Cheers,
  -Tristan
 
  
   On Thu, Nov 13, 2014 at 11:34 AM, Tristan Van Berkom
   tris...@upstairslabs.com wrote:
   On Thu, 2014-11-13 at 11:23 -0600, The Devils Jester
  wrote:
In a nutshell I am (more or less) trying to
  simulate a
   vertical layout
manager using a GtkFixed layout manager. I have
  specific
   need to do this,
rather than just use the Gtk provided one.
  
   If you need a kind of container that GTK+ does not
  provide,
   you really
   should just subclass GtkContainer and implement the
  size
   requesting
   and size allocation methods.
  
   Trying to simulate it using a GtkFixed and setting
  size
   requests might
   seem tempting, but just wont get you 

Re: Widget sizing?

2014-11-15 Thread Tristan Van Berkom
On Sat, 2014-11-15 at 15:38 -0600, The Devils Jester wrote:
 A GtkLayout does not seem to work, it seems that it does indeed request the
 size of its children, so that if I put a GtkLayout inside a GtkWindow, and
 I size the GtkLayout to a specific size, then I cant resize the window
 smaller than that.

The *I size the GtkLayout to a specific size* is where things go awry.

Use less restrictive API, one that does not force a size, like for
example; gtk_window_set_default_size().

As its not clear to me *exactly* what you want to accomplish with this,
I'm not exactly certain GtkLayout is the behavior you want (maybe you
want to resize and reposition children according to a given aspect
ratio or something ? clipping sounds like a bad idea, and is correct
for GtkLayout because it's intended to be used inside a
GtkScrolledWindow).

Cheers,
-Tristan


___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list