[Glade-users] Libglade save/restore root window size?



I asked some time back about this, but did not provide detail so the
suggestion that the old glade code ported to libglade should "just work"
was mostly confirmation to me that something odd is going on as it does
not just work.

In case it is relevant:

  lib64glade2.0_0-2.6.0-1mdv2007.0
  glade2-2.12.1-3mdv2007.0

On Thursday 04 October 2007 00:28, Tristan  wrote:
On Wed, 2007-10-03 at 22:34 -0500, Kevin R. Bulgrien wrote:
Does anyone have an idea of how to have a libglade application save the
window size and then use the save settings the next time the application
runs?  The user should not be prevented from being able to manually
resize the window smaller or larger, but the user saved sizes should be
recalled the next time the application is started.

I converted a GTK+ glade project to libglade.  The application used to
be able to save and set the root window size using get_window_coord(),
gtk_window_move(), and gtk_window_set_default_size ().

Since converting the project to use libglade, restoring the window size
on application start no longer works, but rather the default size
defined in the glade file is always used.

Perhaps this has something to do with the fact that the window is
rendered upon loading the XML file, and this is now done prior to using
the gtk_window_set_default_size() function.

   your old code should work fine if left in place, just
use glade_xml_get_widget() at initialization time to store
pointers to the widgets involved, then restore the sizes
after loading the glade file.

I wonder if window sizing must be done in a certain sequence... after
such-and-such call, but before this-or-that call?  I've tried moving
the code that does this, but have not had success yet.

I can confirm that the window sizing is saved properly, as I can code the 
saved sizes in the xml file directly to see that they match what I saved.
The only issue is re-applying the sizing on the next run.

Roughly, main.c contains in this sequence, and the main window is the only one
I'm trying to size at start.  This isn't all the code, but should be the
relevant calls.

  gtk_set_locale()
  gtk_init()
  dialog_xml = glade_xml_new(dialog_xml_path, NULL, NULL);
    // Don't care about sizing this one.
  window_xml = glade_xml_new(window_xml_path, NULL, NULL);
    // This is the one to resize.
  window_root = glade_xml_get_widget(window_xml, "window_root");
  g_signal_connect()s
    // main window connections.
  gtk_window_set_geometry_hints(GTK_WINDOW(window_root), window_root, ...)
    // (non-useful for libglade as the xml hints minimums?)

Here the various panes, etc. of the window_root are initialized.
The calls here make many various calls to do so, including some
gtk_widget_show() for the window components.  Then, finally:

  gtk_widget_show(window_root)

load_window_positions(window_root) is what reads in the sizing.  It uses

  xml_tree = glade_get_widget_tree(GTK_WIDGET (window_root))

and have I tried code like the following, but nothing tried has succeeded:

  widget = glade_xml_get_widget(xml_tree, buf);
  gtk_window_move(GTK_WINDOW(widget), x, y);
  gtk_window_set_default_size (GTK_WINDOW(widget), w, h);
  // gtk_widget_set_size_request (window_root, w, h);
  // gdk_window_move_resize(GDK_WINDOW(window_root), x, y, w, h);

  widget = glade_xml_get_widget(xml_tree, buf);
  if (widget) {
    gtk_paned_set_position(GTK_PANED(widget), atoi(cp));
  }

I have tried placing load window positions several places to no avail.
Can anyone with more experience suggest an idea or two on what might
possibly be going wrong, or suggestions on what greater detail to
provide to enable said help?  The original glade project worked fine
with load_window_positions() immediately before the 
gtk_widget_show(window_root) call.

Thanks again for any input.

Kevin R. Bulgrien




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