问题
I use GTK3 , codeblcks IDE, glade3 in windows 7...
In my application i have a button which when clicked should open a gtk_file_chooser_dialog... But gives the fillowing error..
Glib-GIO-ERROR**:No GSettings schemas are installed on the system
static void on_save_clicked(GtkWidget *widget,gpointer data)
{
GtkWidget *dialog;
//dialog=gtk_file_chooser_dialog_new("Save it",GTK_WINDOW(gtk_builder_get_object(builder,"mainwindow")),GTK_FILE_CHOOSER_ACTION_SAVE,GTK_STOCK_OK,GTK_RESPONSE_OK,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL);
//dialog=GTK_FILE_CHOOSER_DIALOG(gtk_builder_get_object(builder,"filechooserdialog"));
gtk_widget_show_all(dialog);
gint resp=gtk_dialog_run(GTK_DIALOG(dialog));
if(resp==GTK_RESPONSE_OK)
g_print("%s\n",gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)));
}
I use g_signal_connect(...) to call this function when the button is clicked...
I cannot understand the problem...
回答1:
I got the very same error when trying to open a FileChooserDialog.
(lancer_ihm.py:1047004): GLib-GIO-CRITICAL **: g_settings_schema_source_lookup: assertion 'source != NULL' failed (lancer_ihm.py:1047004): GLib-GIO-ERROR **: No GSettings schemas are installed on the system Trace/breakpoint trap (core dumped)
I 'm running a Gtk3 interface with python3 on Linux. Gtk3 and all its dependencies were installed from the sources.
I found the solution on this forum http://forum.tinycorelinux.net/index.php?topic=13699.0
I just set XDG_DATA_DIRS variable with the path to where the gtk schema files are located and it works.
$ ls /home/user1/ctcils/dusserm/applications/gtk/3.12.1/share/glib-2.0/schemas/ gschemas.compiled org.gtk.exampleapp.gschema.xml org.gtk.Settings.FileChooser.gschema.xml org.gtk.Demo.gschema.xml org.gtk.Settings.ColorChooser.gschema.xml $ export XDG_DATA_DIRS=/Produits/publics/x86_64.Linux.RH6/glib/2.40.0/share/:/home/user1/ctcils/dusserm/applications/gtk/3.12.1/share/
回答2:
There are probably few errors in there.
- If you commented both, the dialog.show_all () will produce error because, it hasn't been instantiate yet you asked to be shown.
- If you use the first one, object Gtk.FileChooserDialog param has to end with NULL (in c), read the doc
- If you use the second one, check your glade signal property in your glade window
- Check your gtk installation
回答3:
Quoting from this StackOverflow answer,
Seems you're not the one having this problem, and it also happens on Windows on MinGW. Luckily, that person gave a solution:
The thing, as it seems as I was running the test-widget example (that I built with gtksourceview-3.0.0 using MSVC), was that I need to compile the
org.gtk.Settings.FileChooser.gschema.xml
file (from GTK+-3.x, under$(srcroot)/gtk
) with theglib-compile-schemas
utility that is from GLib, which will generategschemas.compiled
in the same folder.After that, place that
gschemas.compiled
file in the this folder:$(parent_folder_of_the_gtk3_dll)\share\glib-2.0\schemas
and one will be set to use the gtkfilechooser without the puzzling[GLib-GIO-ERROR **: Settings schema 'org.gtk.Settings.FileChooser' is not installed] error.
I will add to my GLib project files to compile the
glib-compile-schemas
utility and add to my GTK+-3.x project files to compile the theorg.gtk.Settings.FileChooser.gschema.xml
shortly.
来源:https://stackoverflow.com/questions/24370294/glib-gio-error-when-opening-an-file-chooser-dialog