static gchar *
get_desktop_dir (void)
{
    gboolean desktop_is_home_dir = FALSE;
    gchar *desktop_dir;
    const char * const *schemas;
    gboolean schema_exists = FALSE;
    gint i;

    /* Check if caja schema is installed before trying to read settings */
    schemas = g_settings_list_schemas ();
    for (i = 0; schemas[i] != NULL; i++) {
        if (g_strcmp0 (schemas[i], CAJA_PREFERENCES_SCHEMA) == 0) {
            schema_exists = TRUE;
            break;
        }
    }

    if (schema_exists) {
        GSettings *caja_prefs;

        caja_prefs = g_settings_new (CAJA_PREFERENCES_SCHEMA);
        desktop_is_home_dir = g_settings_get_boolean (caja_prefs, "desktop-is-home-dir");

        g_object_unref (caja_prefs);
    }

    if (desktop_is_home_dir)
        desktop_dir = g_strconcat ("file://", g_get_home_dir (), NULL);
    else
        desktop_dir = g_strconcat ("file://", g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP), NULL);

    return desktop_dir;
}
Exemple #2
0
gboolean 
lw_preferences_schema_is_installed (const char *SCHEMA)
{
    //Declarations
    const gchar * const * iter;
    gboolean exists;

    //Initializations
    iter = g_settings_list_schemas ();

    while (iter != NULL && *iter != NULL && strcmp(*iter, SCHEMA) != 0)
      iter++;

    exists = (iter != NULL && *iter != NULL);

    if (!exists)
    {
      g_critical ("The GSettings schema \"%s\" isn't installed!  You must make "
                  "sure both gsettings-desktop-schemas from your package "
                  "manager and org.gnome.gwaei.gschema.xml are installed at "
                  "least locally if not globally. See the man page for "
                  "glib-compile-schemas for more information.\n", SCHEMA);
    }

    return exists;
}
Exemple #3
0
static void
init_gsettings (void)
{
#ifdef HAVE_GSETTINGS
  GVariant *val;
  const gchar *const *schemas;
  int schema_found = 0;

#if ! GLIB_CHECK_VERSION (2, 36, 0)
  g_type_init ();
#endif

  schemas = g_settings_list_schemas ();
  if (schemas == NULL) return;
  while (! schema_found && *schemas != NULL)
    schema_found = strcmp (*schemas++, GSETTINGS_SCHEMA) == 0;
  if (!schema_found) return;

  gsettings_client = g_settings_new (GSETTINGS_SCHEMA);
  if (!gsettings_client) return;
  g_object_ref_sink (G_OBJECT (gsettings_client));
  g_signal_connect (G_OBJECT (gsettings_client), "changed",
                    G_CALLBACK (something_changed_gsettingsCB), NULL);

  val = g_settings_get_value (gsettings_client, GSETTINGS_TOOL_BAR_STYLE);
  if (val)
    {
      g_variant_ref_sink (val);
      if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
        current_tool_bar_style
          = map_tool_bar_style (g_variant_get_string (val, NULL));
      g_variant_unref (val);
    }

#ifdef HAVE_XFT
  val = g_settings_get_value (gsettings_client, GSETTINGS_MONO_FONT);
  if (val)
    {
      g_variant_ref_sink (val);
      if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
        current_mono_font = xstrdup (g_variant_get_string (val, NULL));
      g_variant_unref (val);
    }

  val = g_settings_get_value (gsettings_client, GSETTINGS_FONT_NAME);
  if (val)
    {
      g_variant_ref_sink (val);
      if (g_variant_is_of_type (val, G_VARIANT_TYPE_STRING))
        current_font = xstrdup (g_variant_get_string (val, NULL));
      g_variant_unref (val);
    }
#endif /* HAVE_XFT */

#endif /* HAVE_GSETTINGS */
}
Exemple #4
0
void
_go_conf_init (void)
{
	char const * const *schemas = g_settings_list_schemas ();
	char const * const *cur = schemas;
	installed_schemas = g_hash_table_new (g_str_hash, g_str_equal);
	while (*cur) {
		g_hash_table_insert (installed_schemas, (gpointer) *cur, GUINT_TO_POINTER (TRUE));
		cur++;
	}
	closures = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) go_conf_closure_free);
}
static gboolean
has_geoclue_settings (void)
{
	const gchar * const * list;
	guint i;

	list = g_settings_list_schemas ();
	for (i = 0; list[i] != NULL; i++) {
		if (g_str_equal (list[i], GPS_ID)) {
			return TRUE;
		}
	}
	return FALSE;
}
Exemple #6
0
GSettingsWrapper::GSettingsWrapper( const QString &domain )
: mpGSettings( 0 )
{
#if GLIB_VERSION_2_26
   g_type_init();
   QByteArray domainUtf8( domain.toUtf8() );
   const gchar*const *schemasList = g_settings_list_schemas();
   for( const gchar*const *entry = schemasList; *entry; ++entry )
   {
      if( !::strcasecmp( domainUtf8.constData(), *entry ) )
      {
         GSettings *gsettings = g_settings_new( domain.toUtf8().constData() );
         mpGSettings = static_cast<void*>( gsettings );
         break;
      }
   }
#endif
}
Exemple #7
0
NS_IMETHODIMP
nsGSettingsService::GetCollectionForSchema(const nsACString& schema,
                                           nsIGSettingsCollection** collection)
{
  NS_ENSURE_ARG_POINTER(collection);

  const char * const *schemas = g_settings_list_schemas();

  for (PRUint32 i = 0; schemas[i] != NULL; i++) {
    if (schema.Equals(schemas[i])) {
      GSettings *settings = g_settings_new(PromiseFlatCString(schema).get());
      nsGSettingsCollection *mozGSettings = new nsGSettingsCollection(settings);
      NS_ADDREF(*collection = mozGSettings);
      return NS_OK;
    }
  }

  return NS_ERROR_FAILURE;
}
/**
 * mate_gsettings_schema_exists:
 * @schema: schema to check.
 *
 * Check if a given schema is installed in GSettings.
 *
 * Return value: TRUE if schema exists, FALSE if not.
 * 
 * Since: 1.7.1
 */
gboolean
mate_gsettings_schema_exists (const gchar* schema)
{
    const char * const *schemas;
    gboolean schema_exists;
    gint i;

    schemas = g_settings_list_schemas ();
    schema_exists = FALSE;

    for (i = 0; schemas[i] != NULL; i++) {
        if (g_strcmp0 (schemas[i], schema) == 0) {
            schema_exists = TRUE;
            break;
        }
    }

    return schema_exists;
}
static gboolean
cc_sharing_panel_check_schema_available (CcSharingPanel *self,
                                         const gchar *schema_id)
{
  const gchar * const* schema_list;

  if (schema_id == NULL)
    return FALSE;

  schema_list = g_settings_list_schemas ();

  while (*schema_list)
    {
      if (g_str_equal (*schema_list, schema_id))
        return TRUE;

      schema_list++;
    }

  return FALSE;
}
gboolean
cc_search_locations_dialog_is_available (void)
{
  const gchar * const *schemas;
  const gchar *schema;
  gint idx;
  gboolean found = FALSE;

  schemas = g_settings_list_schemas ();
  for (idx = 0; schemas[idx] != NULL; idx++)
    {
      schema = schemas[idx];
      if (g_strcmp0 (schema, TRACKER_SCHEMA) == 0)
        {
          found = TRUE;
          break;
        }
    }

  return found;
}
/**
 * gpm_control_get_lock_policy:
 * @control: This class instance
 * @policy: The policy string.
 *
 * This function finds out if we should lock the screen when we do an
 * action. It is required as we can either use the mate-screensaver policy
 * or the custom policy. See the yelp file for more information.
 *
 * Return value: TRUE if we should lock.
 **/
gboolean
gpm_control_get_lock_policy (GpmControl *control, const gchar *policy)
{
	gboolean do_lock;
	gboolean use_ss_setting;
	const char * const *schemas;
	gboolean schema_exists;
	gint i;

	/* Check if the mate-screensaver schema exists before trying to read
	   the lock setting to prevent crashing. See GNOME bug #651225. */
	schemas = g_settings_list_schemas ();
	schema_exists = FALSE;
	for (i = 0; schemas[i] != NULL; i++) {
		if (g_strcmp0 (schemas[i], GS_SETTINGS_SCHEMA) == 0) {
			schema_exists = TRUE;
			break;
		}
	}

	/* This allows us to over-ride the custom lock settings set
	   with a system default set in mate-screensaver.
	   See bug #331164 for all the juicy details. :-) */
	use_ss_setting = g_settings_get_boolean (control->priv->settings, GPM_SETTINGS_LOCK_USE_SCREENSAVER);
	if (use_ss_setting && schema_exists) {
		GSettings *settings_ss;
		settings_ss = g_settings_new (GS_SETTINGS_SCHEMA);
		do_lock = g_settings_get_boolean (settings_ss, GS_SETTINGS_PREF_LOCK_ENABLED);
		egg_debug ("Using ScreenSaver settings (%i)", do_lock);
		g_object_unref (settings_ss);
	} else {
		do_lock = g_settings_get_boolean (control->priv->settings, policy);
		egg_debug ("Using custom locking settings (%i)", do_lock);
	}
	return do_lock;
}
Exemple #12
0
static char*
get_atk_bridge_path (void)
{
  GSettings *atspi_settings = NULL;
  GVariant *variant = NULL;
  char *value = NULL;
  const char * const *schemas = NULL;
  gboolean found = FALSE;
  int i = 0;

  schemas = g_settings_list_schemas ();

  for (i = 0; schemas [i]; i++)
    {
      if (!strcmp (schemas[i], AT_SPI_SCHEMA))
        {
          found = TRUE;
          break;
        }
    }

  if (!found)
    {
      g_warning ("Accessibility: %s schema not found. Are you sure that at-spi or"
                 " at-spi2 is installed on your system?", AT_SPI_SCHEMA);
      return NULL;
    }

  atspi_settings = g_settings_new (AT_SPI_SCHEMA);
  variant = g_settings_get_value (atspi_settings, ATK_BRIDGE_LOCATION_KEY);
  value = g_variant_dup_bytestring (variant, NULL);
  g_variant_unref (variant);
  g_object_unref (atspi_settings);

  return value;
}
void
mate_meta_theme_set (MateThemeMetaInfo *meta_theme_info)
{
  GSettings *interface_settings;
  GSettings *marco_settings;
  GSettings *mouse_settings;
  GSettings *notification_settings = NULL;
  const char * const *schemas;
  gboolean schema_exists;
  gint i;
  gchar *old_key;
  gint old_key_int;

  interface_settings = g_settings_new (INTERFACE_SCHEMA);
  marco_settings = g_settings_new (MARCO_SCHEMA);
  mouse_settings = g_settings_new (MOUSE_SCHEMA);
  
  /* We  need this because mate-control-center does not depend on mate-notification-daemon,
   * and if we try to get notification theme without schema installed, gsettings crashes
   * see https://bugzilla.gnome.org/show_bug.cgi?id=651225 */
  schemas = g_settings_list_schemas ();
  schema_exists = FALSE;
  for (i = 0; schemas[i] != NULL; i++) {
    if (g_strcmp0 (schemas[i], NOTIFICATION_SCHEMA) == 0) {
      schema_exists = TRUE;
      break;
      }
  }
  if (schema_exists == TRUE) {
      notification_settings = g_settings_new (NOTIFICATION_SCHEMA);
  }

  /* Set the gtk+ key */
  old_key = g_settings_get_string (interface_settings, GTK_THEME_KEY);
  if (compare (old_key, meta_theme_info->gtk_theme_name))
    {
      g_settings_set_string (interface_settings, GTK_THEME_KEY, meta_theme_info->gtk_theme_name);
    }
  g_free (old_key);

  /* Set the color scheme key */
  old_key = g_settings_get_string (interface_settings, COLOR_SCHEME_KEY);
  if (compare (old_key, meta_theme_info->gtk_color_scheme))
    {
      /* only save the color scheme if it differs from the default
         scheme for the selected gtk theme */
      gchar *newval, *gtkcols;

      newval = meta_theme_info->gtk_color_scheme;
      gtkcols = gtkrc_get_color_scheme_for_theme (meta_theme_info->gtk_theme_name);

      if (newval == NULL || !strcmp (newval, "") ||
          mate_theme_color_scheme_equal (newval, gtkcols))
        {
          g_settings_reset (interface_settings, COLOR_SCHEME_KEY);
        }
      else
        {
          g_settings_set_string (interface_settings, COLOR_SCHEME_KEY, newval);
        }
      g_free (gtkcols);
    }
  g_free (old_key);

  /* Set the wm key */
  g_settings_set_string (marco_settings, MARCO_THEME_KEY, meta_theme_info->marco_theme_name);

  /* set the icon theme */
  old_key = g_settings_get_string (interface_settings, ICON_THEME_KEY);
  if (compare (old_key, meta_theme_info->icon_theme_name))
    {
      g_settings_set_string (interface_settings, ICON_THEME_KEY, meta_theme_info->icon_theme_name);
    }
  g_free (old_key);

  /* set the notification theme */
  if (notification_settings != NULL)
    {
    if (meta_theme_info->notification_theme_name != NULL)
      {
        old_key = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY);
        if (compare (old_key, meta_theme_info->notification_theme_name))
          {
            g_settings_set_string (notification_settings, NOTIFICATION_THEME_KEY, meta_theme_info->notification_theme_name);
          }
        g_free (old_key);
      }
    }

  /* Set the cursor theme key */
#ifdef HAVE_XCURSOR
  old_key = g_settings_get_string (mouse_settings, CURSOR_THEME_KEY);
  if (compare (old_key, meta_theme_info->cursor_theme_name))
    {
      g_settings_set_string (mouse_settings, CURSOR_THEME_KEY, meta_theme_info->cursor_theme_name);
    }

  old_key_int = g_settings_get_int (mouse_settings, CURSOR_SIZE_KEY);
  if (old_key_int != meta_theme_info->cursor_size)
    {
      g_settings_set_int (mouse_settings, CURSOR_SIZE_KEY, meta_theme_info->cursor_size);
    }
#else
  old_key = g_settings_get_string (mouse_settings, CURSOR_FONT_KEY);
  if (compare (old_key, meta_theme_info->cursor_theme_name))
    {
      g_settings_set_string (mouse_settings, CURSOR_FONT_KEY, meta_theme_info->cursor_theme_name);
    }
#endif

  g_free (old_key);
  g_object_unref (interface_settings);
  g_object_unref (marco_settings);
  g_object_unref (mouse_settings);
  if (notification_settings != NULL)
    g_object_unref (notification_settings);
}
static GSList *
tracker_gsettings_get_all (gint *longest_name_length)
{
	typedef struct {
		const gchar *schema;
		const gchar *path;
	} SchemaWithPath;

	TrackerMinerManager *manager;
	GError *error = NULL;
	GSettings *settings;
	GSList *all = NULL;
	GSList *l;
	GSList *miners_available;
	GSList *valid_schemas = NULL;
	const gchar * const *schema;
	gint len = 0;
	SchemaWithPath components[] = {
		{ "Store", "store" },
		{ "Extract", "extract" },
		{ "Writeback", "writeback" },
		{ 0 }
	};
	SchemaWithPath *swp;

	/* Don't auto-start the miners here */
	manager = tracker_miner_manager_new_full (FALSE, &error);
	if (!manager) {
		g_printerr (_("Could not get GSettings for miners, manager could not be created, %s"),
		            error ? error->message : "unknown error");
		g_printerr ("\n");
		g_clear_error (&error);
		return NULL;
	}

	miners_available = tracker_miner_manager_get_available (manager);

	/* Get valid schemas so we don't try to load invalid ones */
	for (schema = g_settings_list_schemas (); schema && *schema; schema++) {
		if (!g_str_has_prefix (*schema, "org.freedesktop.Tracker.")) {
			continue;
		}

		valid_schemas = g_slist_prepend (valid_schemas, g_strdup (*schema));
	}

	/* Store / General */
	for (swp = components; swp && swp->schema; swp++) {
		gchar *schema;
		gchar *path;

		schema = g_strdup_printf ("org.freedesktop.Tracker.%s", swp->schema);
		path = g_strdup_printf ("/org/freedesktop/tracker/%s/", swp->path);

		/* If miner doesn't have a schema, no point in getting config */
		if (!tracker_string_in_gslist (schema, valid_schemas)) {
			g_free (path);
			g_free (schema);
			continue;
		}

		len = MAX (len, strlen (swp->schema));

		settings = g_settings_new_with_path (schema, path);
		if (settings) {
			ComponentGSettings *c = g_slice_new (ComponentGSettings);

			c->name = g_strdup (swp->schema);
			c->settings = settings;
			c->is_miner = FALSE;

			all = g_slist_prepend (all, c);
		}
	}

	/* Miners */
	for (l = miners_available; l; l = l->next) {
		const gchar *name;
		gchar *schema;
		gchar *name_lowercase;
		gchar *path;
		gchar *miner;

		miner = l->data;
		if (!miner) {
			continue;
		}

		name = g_utf8_strrchr (miner, -1, '.');
		if (!name) {
			continue;
		}

		name++;
		name_lowercase = g_utf8_strdown (name, -1);

		schema = g_strdup_printf ("org.freedesktop.Tracker.Miner.%s", name);
		path = g_strdup_printf ("/org/freedesktop/tracker/miner/%s/", name_lowercase);
		g_free (name_lowercase);

		/* If miner doesn't have a schema, no point in getting config */
		if (!tracker_string_in_gslist (schema, valid_schemas)) {
			g_free (path);
			g_free (schema);
			continue;
		}

		settings = g_settings_new_with_path (schema, path);
		g_free (path);
		g_free (schema);

		if (settings) {
			ComponentGSettings *c = g_slice_new (ComponentGSettings);

			c->name = g_strdup (name);
			c->settings = settings;
			c->is_miner = TRUE;

			all = g_slist_prepend (all, c);
			len = MAX (len, strlen (name));
		}
	}

	g_slist_foreach (valid_schemas, (GFunc) g_free, NULL);
	g_slist_free (valid_schemas);
	g_slist_foreach (miners_available, (GFunc) g_free, NULL);
	g_slist_free (miners_available);
	g_object_unref (manager);

	if (longest_name_length) {
		*longest_name_length = len;
	}

	return g_slist_reverse (all);
}
static gpointer
listAllSchemas (gpointer data)
{
    return (gpointer) g_settings_list_schemas ();
}
static MateThemeMetaInfo *
theme_load_from_gsettings (AppearanceData *data)
{
  MateThemeMetaInfo *theme;
  gchar *scheme;
  const char * const *schemas;
  gboolean schema_exists;
  gint i;

  theme = mate_theme_meta_info_new ();

  theme->gtk_theme_name = g_settings_get_string (data->interface_settings, GTK_THEME_KEY);
  if (theme->gtk_theme_name == NULL)
    theme->gtk_theme_name = g_strdup ("Clearlooks");

  scheme = g_settings_get_string (data->interface_settings, COLOR_SCHEME_KEY);
  if (scheme == NULL || !strcmp (scheme, "")) {
    g_free (scheme);
    scheme = gtkrc_get_color_scheme_for_theme (theme->gtk_theme_name);
  }
  theme->gtk_color_scheme = scheme;

  theme->marco_theme_name = g_settings_get_string (data->marco_settings, MARCO_THEME_KEY);
  if (theme->marco_theme_name == NULL)
    theme->marco_theme_name = g_strdup ("Clearlooks");

  theme->icon_theme_name = g_settings_get_string (data->interface_settings, ICON_THEME_KEY);
  if (theme->icon_theme_name == NULL)
    theme->icon_theme_name = g_strdup ("mate");

  /* We  need this because mate-control-center does not depend on mate-notification-daemon,
   * and if we try to get notification theme without schema installed, gsettings crashes
   * see https://bugzilla.gnome.org/show_bug.cgi?id=651225 */
  schemas = g_settings_list_schemas ();
  schema_exists = FALSE;
  for (i = 0; schemas[i] != NULL; i++) {
    if (g_strcmp0 (schemas[i], NOTIFICATION_SCHEMA) == 0) {
      schema_exists = TRUE;
      break;
      }
  }
  if (schema_exists == TRUE) {
    GSettings *notification_settings;
    notification_settings = g_settings_new (NOTIFICATION_SCHEMA);
    theme->notification_theme_name = g_settings_get_string (notification_settings, NOTIFICATION_THEME_KEY);
    g_object_unref (notification_settings);
  }
  else
    theme->notification_theme_name = NULL;

  theme->cursor_theme_name = g_settings_get_string (data->mouse_settings, CURSOR_THEME_KEY);
#ifdef HAVE_XCURSOR
  theme->cursor_size = g_settings_get_int (data->mouse_settings, CURSOR_SIZE_KEY);
#endif
  if (theme->cursor_theme_name == NULL)
    theme->cursor_theme_name = g_strdup ("default");

  theme->application_font = g_settings_get_string (data->interface_settings, GTK_FONT_KEY);

  return theme;
}