[Glade-users] Making a Preference Window



Does anyone know how to save a modification to GTK program as a Glade
Project?  The reason I want to do this is so the next time the program
is run it starts in a certain state.

For example, one of the things I'd like to do is add a preference window
to my GTK program.  I can design the preference window in Glade and call
it with glade_xml_new().  After all options/preferences are selected I'd
like to save them as a .glade file and use that one the next time the
program is run or revert to the original one if desired.

I think I need to use the GladeProject libraries.  Is this correct?  Are
the working examples somewhere?

I have created a test program (see below) using a .glade file, but I get
the following error when calling glade_project_load_from_file().

$ ./gldProject0
(gldProject0:14313): GladeUI-WARNING **: Widget class GtkWindow unknown.
(gldProject0:14313): GladeUI-WARNING **: Failed to read a <widget> tag

This is the program.

#include <gtk/gtk.h>
#include <gtk/gtkwindow.h>
#include <glade/glade.h>
#include <gladeui/glade.h>
#include <gladeui/glade-app.h>
#include <gladeui/glade-debug.h>

int main(int argc, char **argv) {
  const gchar *path1="./preferencesDflt.glade";
  const gchar *path2="./preferencesUser.glade";
  GError **err=NULL;
  GladeProject *gp=glade_project_new();

  gtk_init(&argc, &argv);
  if(glade_project_load_from_file(gp, path1)==FALSE) {
    g_error("glade_project_load_from_file()\n");
  }

  if(glade_project_save(gp, path2, err)==FALSE) {
    g_error("glade_project_save()\n");
  }

  return 0;
}

Is this the correct approach or are there better ways?

Thanks in advance.

Dave




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