GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Jul 07, 2015 3:41 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Wed Aug 13, 2014 10:45 am 
Offline
Familiar Face

Joined: Wed Apr 20, 2011 10:00 am
Posts: 10
When I use following line:
Code:
widget = gtk_file_chooser_button_new("Choose directory\0",GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);


Application crashes with following error:
GLib-GIO-Error: No GSetting schemas are installed on this system.

I'm running Windows XP 32 bits with lastest gtk bundle, IDE: Visual 2008 EE


Top
 Profile  
 
 Post subject: Re: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Sat Jan 03, 2015 2:57 pm 
Offline

Joined: Sat Jan 03, 2015 11:51 am
Posts: 3
Hi guys!

I'm struggling with a (I think) similar problem.

When I use the color chooser on windows 8.1(build with codeblocks) I get the error message:

Quote:
GLib-GIO-ERROR **: No GSettings schemas are installed on the system


Did you find a solution or does anybody know how to solve this issue?

many thanks in advance!

Best regards
Stocki


Top
 Profile  
 
 Post subject: Re: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Sun Jan 04, 2015 1:35 pm 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 870
Location: UK
Hallo,

Without a lot more information I am unable to help. Things that will help are the GTK+ version you are using, a sample of code that would reproduce the error and where it happens, if you think there many be any unusual installation features then that would also help for example are you using a standard install or custom.

Imagine that you are a car mechanic in Bern and I phoned you up from Amsterdam to ask "My car does not start, how do I fix it?" and the only other information that I can give you is that the car is coloured silver. As you can see if I was able to give you more information then it would be easier to help.

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Mon Jan 05, 2015 10:52 am 
Offline

Joined: Sat Jan 03, 2015 11:51 am
Posts: 3
Hi errol!

sorry for the missing information.

I'm working with gtk 3.6.4 (32 bit) with Codeblocks 13.12 on windows 8.1. When I am running the gtk-demo everything works fine.

But if I run my GUI and click on the button "Change color" I'll get the following error message:
Quote:
GLib-GIO-ERROR **: No GSettings schemas are installed on the system


The same code works fine on fedora.

Here's my code:

the problem occurs in function "change_color_callback" in the following line(when open the color chooser dialog):
dialog = gtk_color_chooser_dialog_new ("Changing color", GTK_WINDOW (window));

Code:
/*********************************************************** INCLUDES */
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib/gprintf.h>
#include <cairo.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

/************************************************************ DEFINES */


/************************************************ FUNCTION PROTOTYPES */
static gpointer guiThread(gpointer data);
static gboolean guiHandler(GtkWidget *widget);
static gpointer dataThread(gpointer data);
static gboolean dataHandler(gpointer data);
//static void aboutCB (GtkWidget *widget, gpointer data);

/*************************************************** GLOBAL VARIABLES */
static GtkWidget *window = NULL;
static GtkWidget *da;
static GdkRGBA color;
static GtkWidget *frame;
GtkWidget *box, *dbox;
  GtkWidget *label;
 
  //left side
  GtkWidget *leftbox, *statebox, *portbox;
  GtkWidget *statelabel, *portlabel, *portVlabel, *stateVlabel, *colorbox, *colorlabel, *colorVlabel;
  //right side
  GtkWidget *rightbox, *picbox, *pic;
  GtkWidget *button;
  gint pic_size = 150;

/********************************************************** FUNCTIONS */


/*!
* \brief data thread invokes a data generator after a short timeout
*/
static gpointer
dataThread(gpointer data)
{
  g_timeout_add(55, (GSourceFunc)dataHandler, NULL);
  return NULL;
}

/*!
* \brief some data generation
*/
static gboolean
dataHandler(gpointer data)
{
return 0;
}

/* draw callback for the drawing area
*/
static gboolean
draw_callback (GtkWidget *widget,
               cairo_t   *cr,
               gpointer   data)
{
  GtkStyleContext *context;
  GdkRGBA rgba;
  context = gtk_widget_get_style_context (widget);
  gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba);
  gdk_cairo_set_source_rgba(cr, &rgba);
  cairo_paint(cr);

  return TRUE;
}

static void
response_cb (GtkDialog *dialog,
             gint       response_id,
             gpointer   user_data)
{
    gchar *pTest;
  if (response_id == GTK_RESPONSE_OK)
    {
      gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
      gtk_widget_override_background_color (da, 0, &color);
     pTest = gdk_rgba_to_string(&color);
  gtk_label_set_label(GTK_LABEL(colorVlabel),(gchar *)pTest);
    }
  gtk_widget_hide (GTK_WIDGET (dialog));
}

static void
change_color_callback (GtkWidget *button,
                       gpointer   data)
{
  GtkWidget *dialog;
  dialog = gtk_color_chooser_dialog_new ("Changing color", GTK_WINDOW (window));
  gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (dialog),FALSE);
  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);

  g_signal_connect (dialog,
                    "response",
                    G_CALLBACK (response_cb),
                    NULL);
  gtk_widget_show_all (dialog);
}

/*!
* \brief GUI thread only create a plot surface and periodically calls a
* guiHandler that redraws the plot after a short timeout
*/
static gpointer
guiThread(gpointer data)
{
  /* create the top-level window */
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "RGB Control");
  gtk_window_set_default_icon_from_file("RGB.jpg", NULL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400,200);
  g_signal_connect(G_OBJECT(window), "destroy",
                   G_CALLBACK(gtk_main_quit), NULL);

          //ceate main box
  box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (box));

//create label and put it into the box
  label = gtk_label_new ("RGB Control Application");
  gtk_label_set_markup (GTK_LABEL (label), "<big><b><u><tt>RGB Control Application</tt></u></b></big>");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
  gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(label), TRUE, FALSE, 20);

//create databox
  dbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(dbox), TRUE, FALSE, 0);

//create and fill in left box
  leftbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_box_pack_start (GTK_BOX(dbox), GTK_WIDGET(leftbox), TRUE, FALSE, 0);

//state
  statebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(statebox), TRUE, TRUE, 15);
  statelabel = gtk_label_new ("Dimmerstatus: ");
  gtk_box_pack_start (GTK_BOX(statebox), GTK_WIDGET(statelabel), TRUE, TRUE, 0);

  stateVlabel = gtk_label_new ("Offline");
  gtk_box_pack_start (GTK_BOX(statebox), GTK_WIDGET(stateVlabel), TRUE, TRUE, 0);

//Com Port
  portbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(portbox), TRUE, TRUE, 15);
  portlabel = gtk_label_new ("COM Port: ");
  gtk_box_pack_start (GTK_BOX(portbox), GTK_WIDGET(portlabel), TRUE, TRUE, 0);
  portVlabel = gtk_label_new ("COM7");
  gtk_box_pack_start (GTK_BOX(portbox), GTK_WIDGET(portVlabel), TRUE, TRUE, 0);

//Color Port
  colorbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(colorbox), TRUE, TRUE, 15);
   colorlabel = gtk_label_new ("Color: ");
  gtk_box_pack_start (GTK_BOX(colorbox), GTK_WIDGET(colorlabel), TRUE, TRUE, 0);
  colorVlabel = gtk_label_new ("rgb(0,0,0)");
  gtk_box_pack_start (GTK_BOX(colorbox), GTK_WIDGET(colorVlabel), TRUE, TRUE, 0);

//create right box
  rightbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_box_pack_start (GTK_BOX(dbox), GTK_WIDGET(rightbox), TRUE, FALSE, 0);

      color.red = 0;
      color.blue = 0;
      color.green = 0;
      color.alpha = 1;

      /*
       * Create the color swatch area
       */
    gtk_container_set_border_width (GTK_CONTAINER (rightbox), 8);
      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
      gtk_box_pack_start (GTK_BOX (rightbox), frame, TRUE, TRUE, 0);
      da = gtk_drawing_area_new ();
      g_signal_connect (da, "draw", G_CALLBACK (draw_callback), NULL);
      /* set a minimum size */
      gtk_widget_set_size_request (da, 20, 20);
      /* set the color */
      gtk_widget_override_background_color (da, 0, &color);
      gtk_container_add (GTK_CONTAINER (frame), da);

      button = gtk_button_new_with_mnemonic ("_Change color");
      gtk_widget_set_halign (button, GTK_ALIGN_END);
      gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
      gtk_box_pack_start (GTK_BOX (rightbox), button, FALSE, FALSE, 0);
      g_signal_connect (button, "clicked",
                        G_CALLBACK (change_color_callback), NULL);
  gtk_widget_show_all(GTK_WIDGET(window));
  gtk_main();
  return NULL;
}

/*!
* \brief main only creates two threads
*/
int
main (int argc, char *argv[])
{
  GThread* GuiThread;
  GThread* DataThread;

  gtk_init(&argc, &argv);
  // create two threads: one for the GUI and the DATA, respectively
  GuiThread = g_thread_new("Thread GUI", (GThreadFunc)guiThread, (void *)NULL);
  DataThread = g_thread_new("Thread DATA", (GThreadFunc)dataThread, (void *)NULL);

  g_thread_join(DataThread);
  g_thread_join(GuiThread);
  return 0;
}
*! EOF */


When i type "gsettings list-relocatable-schemas" in cmd, I'll geht the following output:
org.gtk.Settings.ColorChooser
org.gtk.File.ColorChooser

So it seems that there are GSettings installed.

I also set the XDG_DATA_DIRS variable to the path where the gtk schema files are located.

I hope that's enough information. Thank you very much!

BR stocki


Top
 Profile  
 
 Post subject: Re: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Tue Jan 06, 2015 7:49 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 870
Location: UK
I am not totally sure on what is happening here, possibly an error with the Windows GTK bundle. I think it is most likely a problem with the installation of the schemas. You could try setting the environment variable 'GSETTINGS_SCHEMA_DIR' to the directory where they are stored.

I did notice from your source that you initialised GTK from the main thread and then carried on using GTK API calls in another thread. GTK+ is not thread safe and all GTK/GDK API calls MUST be done from the same thread, normally initialisation is done in main().

Note try to avoid too much use of global variables. After a while it will become harder for you to maintain your code. You can quickly run out of easy name alternatives and lose the ability to reuse code. Also by using more local variable the compiler can produce better code.

Note that GLib is totally thread safe. You corrected code is below.
Code:
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib/gprintf.h>
#include <cairo.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

/*
GSETTINGS_SCHEMA_DIR.  This variable can be set to the name of a directory that is considered in addition to the glib-2.0/schemas subdirectories of the XDG system data dirs when looking for compiled schemas for GSettings.
*/

/************************************************************ DEFINES */


/************************************************ FUNCTION PROTOTYPES */
static gpointer guiThread(gpointer data);
static gboolean guiHandler(GtkWidget *widget);
static gpointer dataThread(gpointer data);
static gboolean dataHandler(gpointer data);
//static void aboutCB (GtkWidget *widget, gpointer data);

/*************************************************** GLOBAL VARIABLES */
static GtkWidget *window;
static GtkWidget *da;
static GdkRGBA color;
static GtkWidget *frame;
static GtkWidget *colorVlabel;

/********************************************************** FUNCTIONS */


/*!
* \brief data thread invokes a data generator after a short timeout
*/
static gpointer
dataThread(gpointer data)
{
  g_timeout_add(55, (GSourceFunc)dataHandler, NULL);
  return NULL;
}

/*!
* \brief some data generation
*/
static gboolean
dataHandler(gpointer data)
{
  return 0;
}

/* draw callback for the drawing area
*/
static gboolean
draw_callback (GtkWidget *widget,
               cairo_t   *cr,
               gpointer   data)
{
  GtkStyleContext *context;
  GdkRGBA rgba;
  context = gtk_widget_get_style_context (widget);
  gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &rgba);
  gdk_cairo_set_source_rgba(cr, &rgba);
  cairo_paint(cr);

  return TRUE;
}

static void
response_cb (GtkDialog *dialog,
             gint       response_id,
             gpointer   user_data)
{
  gchar *pTest;
  if (response_id == GTK_RESPONSE_OK) {
    gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
    gtk_widget_override_background_color (da, 0, &color);
    pTest = gdk_rgba_to_string(&color);
    gtk_label_set_label(GTK_LABEL(colorVlabel),(gchar *)pTest);
  }
  gtk_widget_hide (GTK_WIDGET (dialog));
}

static void
change_color_callback (GtkWidget *button,
                       gpointer   data)
{
  GtkWidget *dialog;
  dialog = gtk_color_chooser_dialog_new ("Changing color", GTK_WINDOW (window));
  gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (dialog),FALSE);
  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);

  g_signal_connect (dialog,
                    "response",
                    G_CALLBACK (response_cb),
                    NULL);
  gtk_widget_show_all (dialog);
}

/*!
* \brief GUI thread only create a plot surface and periodically calls a
* guiHandler that redraws the plot after a short timeout
*/
static void
gui_main(void)
{
  GtkWidget *label;
  GtkWidget *box, *dbox;
  //left side
  GtkWidget *leftbox, *statebox, *portbox;
  GtkWidget *statelabel, *portlabel, *portVlabel, *stateVlabel, *colorbox, *colorlabel;
  //right side
  GtkWidget *rightbox;
  GtkWidget *button;

  /* create the top-level window */
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(window), "RGB Control");
  gtk_window_set_default_icon_from_file("RGB.jpg", NULL);
  gtk_window_set_default_size (GTK_WINDOW (window), 400,200);
  g_signal_connect(G_OBJECT(window), "destroy",
                   G_CALLBACK(gtk_main_quit), NULL);

          //ceate main box
  box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (box));

//create label and put it into the box
  label = gtk_label_new ("RGB Control Application");
  gtk_label_set_markup (GTK_LABEL (label), "<big><b><u><tt>RGB Control Application</tt></u></b></big>");
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);
  gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(label), TRUE, FALSE, 20);

//create databox
  dbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(dbox), TRUE, FALSE, 0);

//create and fill in left box
  leftbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_box_pack_start (GTK_BOX(dbox), GTK_WIDGET(leftbox), TRUE, FALSE, 0);

//state
  statebox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(statebox), TRUE, TRUE, 15);
  statelabel = gtk_label_new ("Dimmerstatus: ");
  gtk_box_pack_start (GTK_BOX(statebox), GTK_WIDGET(statelabel), TRUE, TRUE, 0);

  stateVlabel = gtk_label_new ("Offline");
  gtk_box_pack_start (GTK_BOX(statebox), GTK_WIDGET(stateVlabel), TRUE, TRUE, 0);

//Com Port
  portbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(portbox), TRUE, TRUE, 15);
  portlabel = gtk_label_new ("COM Port: ");
  gtk_box_pack_start (GTK_BOX(portbox), GTK_WIDGET(portlabel), TRUE, TRUE, 0);
  portVlabel = gtk_label_new ("COM7");
  gtk_box_pack_start (GTK_BOX(portbox), GTK_WIDGET(portVlabel), TRUE, TRUE, 0);

//Color Port
  colorbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
  gtk_box_pack_start (GTK_BOX(leftbox), GTK_WIDGET(colorbox), TRUE, TRUE, 15);
   colorlabel = gtk_label_new ("Color: ");
  gtk_box_pack_start (GTK_BOX(colorbox), GTK_WIDGET(colorlabel), TRUE, TRUE, 0);
  colorVlabel = gtk_label_new ("rgb(0,0,0)");
  gtk_box_pack_start (GTK_BOX(colorbox), GTK_WIDGET(colorVlabel), TRUE, TRUE, 0);

//create right box
  rightbox = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
  gtk_box_pack_start (GTK_BOX(dbox), GTK_WIDGET(rightbox), TRUE, FALSE, 0);

  color.red = 0;
  color.blue = 0;
  color.green = 0;
  color.alpha = 1;

      /*
       * Create the color swatch area
       */
  gtk_container_set_border_width (GTK_CONTAINER (rightbox), 8);
  frame = gtk_frame_new (NULL);
  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
  gtk_box_pack_start (GTK_BOX (rightbox), frame, TRUE, TRUE, 0);
  da = gtk_drawing_area_new ();
  g_signal_connect (da, "draw", G_CALLBACK (draw_callback), NULL);
  /* set a minimum size */
  gtk_widget_set_size_request (da, 20, 20);
  /* set the color */
  gtk_widget_override_background_color (da, 0, &color);
  gtk_container_add (GTK_CONTAINER (frame), da);

  button = gtk_button_new_with_mnemonic ("_Change color");
  gtk_widget_set_halign (button, GTK_ALIGN_END);
  gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
  gtk_box_pack_start (GTK_BOX (rightbox), button, FALSE, FALSE, 0);
  g_signal_connect (button, "clicked",
                        G_CALLBACK (change_color_callback), NULL);
  gtk_widget_show_all(GTK_WIDGET(window));
  gtk_main();
}

/*!
* \brief main only creates two threads
*/
int
main (int argc, char *argv[])
{
  GThread* DataThread;

  gtk_init(&argc, &argv);

  // create two threads: one for the GUI and the DATA, respectively
  DataThread = g_thread_new("Thread DATA", (GThreadFunc)dataThread, (void *)NULL);

  gui_main();

  g_thread_join(DataThread);

  return 0;
}

_________________
E.


Top
 Profile  
 
 Post subject: Re: GTK FileChooserButton crashes - No GSetting schemas
PostPosted: Tue Jan 06, 2015 11:35 am 
Offline

Joined: Sat Jan 03, 2015 11:51 am
Posts: 3
hi errol!

Thank you so much for your help!

The 'GSETTINGS_SCHEMA_DIR' variable solved the problem... :)

cheers stocki


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group