Re: Size negotiation and initial top-window size



On Tue, Sep 09, 2008 at 11:54:01AM +0200, Olivier Guilyardi wrote:
Hi all,

in my app, I need the top-window to have an initial size that suits the content.
It's a bit like in the Gimp, where the image window initial size is set
accordingly to the image size, at a carefully chosen zoom level.

However, this initial size is not mandatory. The user must be able to shrink the
window if he like, there are scrollbars anyway, just like in the Gimp.


Try removing the initial size request after the negotitations are complete:

void
new_window()
{
  void
  on_allocate(GtkWidget* window, gpointer user_data)
  {
    static gboolean first_time = TRUE;
    if(first_time && GTK_WIDGET_REALIZED(window)){
      //remove previous minimum size so that user can resize the window.
      gtk_widget_set_size_request(window, 20, 20);
      first_time = FALSE;
    }
  }

  GtkWidget* window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT(window), "size-allocate", G_CALLBACK(on_allocate), NULL);
}


Regards
--
Tim Orford




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]