2011-11-07 13:46:58 -06:00
|
|
|
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
|
|
|
|
/*
|
2011-11-07 16:52:18 -06:00
|
|
|
* pluma-prefs-manager.c
|
|
|
|
* This file is part of pluma
|
2011-11-07 13:46:58 -06:00
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Paolo Maggi
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2011-11-07 16:52:18 -06:00
|
|
|
* Modified by the pluma Team, 2002. See the AUTHORS file for a
|
|
|
|
* list of people on the pluma Team.
|
2011-11-07 13:46:58 -06:00
|
|
|
* See the ChangeLog files for a list of changes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib/gi18n.h>
|
|
|
|
#include <mateconf/mateconf-value.h>
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
#include "pluma-prefs-manager.h"
|
|
|
|
#include "pluma-prefs-manager-private.h"
|
|
|
|
#include "pluma-debug.h"
|
|
|
|
#include "pluma-encodings.h"
|
|
|
|
#include "pluma-utils.h"
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
#define DEFINE_BOOL_PREF(name, key, def) gboolean \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_ ## name (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_bool (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
(def)); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_ ## name (gboolean v) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_bool (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
v); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
gboolean \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_ ## name ## _can_set (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (key); \
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFINE_INT_PREF(name, key, def) gint \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_ ## name (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_int (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
(def)); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_ ## name (gint v) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_int (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
v); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
gboolean \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_ ## name ## _can_set (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (key); \
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DEFINE_STRING_PREF(name, key, def) gchar* \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_ ## name (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_string (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
def); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
void \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_ ## name (const gchar* v) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (key, \
|
2011-11-07 13:46:58 -06:00
|
|
|
v); \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
gboolean \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_ ## name ## _can_set (void) \
|
2011-11-07 13:46:58 -06:00
|
|
|
{ \
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS); \
|
2011-11-07 13:46:58 -06:00
|
|
|
\
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (key); \
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
PlumaPrefsManager *pluma_prefs_manager = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
|
|
|
|
static GtkWrapMode get_wrap_mode_from_string (const gchar* str);
|
|
|
|
|
|
|
|
static gboolean mateconf_client_get_bool_with_default (MateConfClient* client,
|
|
|
|
const gchar* key,
|
|
|
|
gboolean def,
|
|
|
|
GError** err);
|
|
|
|
|
|
|
|
static gchar *mateconf_client_get_string_with_default (MateConfClient* client,
|
|
|
|
const gchar* key,
|
|
|
|
const gchar* def,
|
|
|
|
GError** err);
|
|
|
|
|
|
|
|
static gint mateconf_client_get_int_with_default (MateConfClient* client,
|
|
|
|
const gchar* key,
|
|
|
|
gint def,
|
|
|
|
GError** err);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
static gboolean pluma_prefs_manager_get_bool (const gchar* key,
|
2011-11-07 13:46:58 -06:00
|
|
|
gboolean def);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
static gint pluma_prefs_manager_get_int (const gchar* key,
|
2011-11-07 13:46:58 -06:00
|
|
|
gint def);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
static gchar *pluma_prefs_manager_get_string (const gchar* key,
|
2011-11-07 13:46:58 -06:00
|
|
|
const gchar* def);
|
|
|
|
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_init (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager == NULL)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
MateConfClient *mateconf_client;
|
|
|
|
|
|
|
|
mateconf_client = mateconf_client_get_default ();
|
|
|
|
if (mateconf_client == NULL)
|
|
|
|
{
|
|
|
|
g_warning (_("Cannot initialize preferences manager."));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager = g_new0 (PlumaPrefsManager, 1);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager->mateconf_client = mateconf_client;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager->mateconf_client == NULL)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
g_free (pluma_prefs_manager);
|
|
|
|
pluma_prefs_manager = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager != NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_shutdown (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_object_unref (pluma_prefs_manager->mateconf_client);
|
|
|
|
pluma_prefs_manager->mateconf_client = NULL;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_bool (const gchar* key, gboolean def)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, def);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, def);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return mateconf_client_get_bool_with_default (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
key,
|
|
|
|
def,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_int (const gchar* key, gint def)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, def);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, def);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return mateconf_client_get_int_with_default (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
key,
|
|
|
|
def,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_string (const gchar* key, const gchar* def)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL,
|
2011-11-07 13:46:58 -06:00
|
|
|
def ? g_strdup (def) : NULL);
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL,
|
2011-11-07 13:46:58 -06:00
|
|
|
def ? g_strdup (def) : NULL);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return mateconf_client_get_string_with_default (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
key,
|
|
|
|
def,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_bool (const gchar* key, gboolean value)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
g_return_if_fail (mateconf_client_key_is_writable (
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager->mateconf_client, key, NULL));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
mateconf_client_set_bool (pluma_prefs_manager->mateconf_client, key, value, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_int (const gchar* key, gint value)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
g_return_if_fail (mateconf_client_key_is_writable (
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager->mateconf_client, key, NULL));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
mateconf_client_set_int (pluma_prefs_manager->mateconf_client, key, value, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (const gchar* key, const gchar* value)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
g_return_if_fail (value != NULL);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
g_return_if_fail (mateconf_client_key_is_writable (
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager->mateconf_client, key, NULL));
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
mateconf_client_set_string (pluma_prefs_manager->mateconf_client, key, value, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_key_is_writable (const gchar* key)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, FALSE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return mateconf_client_key_is_writable (pluma_prefs_manager->mateconf_client, key, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Use default font */
|
|
|
|
DEFINE_BOOL_PREF (use_default_font,
|
|
|
|
GPM_USE_DEFAULT_FONT,
|
|
|
|
GPM_DEFAULT_USE_DEFAULT_FONT)
|
|
|
|
|
|
|
|
/* Editor font */
|
|
|
|
DEFINE_STRING_PREF (editor_font,
|
|
|
|
GPM_EDITOR_FONT,
|
|
|
|
GPM_DEFAULT_EDITOR_FONT)
|
|
|
|
|
|
|
|
/* System font */
|
|
|
|
gchar *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_system_font (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_string (GPM_SYSTEM_FONT,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_SYSTEM_FONT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create backup copy */
|
|
|
|
DEFINE_BOOL_PREF (create_backup_copy,
|
|
|
|
GPM_CREATE_BACKUP_COPY,
|
|
|
|
GPM_DEFAULT_CREATE_BACKUP_COPY)
|
|
|
|
|
|
|
|
/* Auto save */
|
|
|
|
DEFINE_BOOL_PREF (auto_save,
|
|
|
|
GPM_AUTO_SAVE,
|
|
|
|
GPM_DEFAULT_AUTO_SAVE)
|
|
|
|
|
|
|
|
/* Auto save interval */
|
|
|
|
DEFINE_INT_PREF (auto_save_interval,
|
|
|
|
GPM_AUTO_SAVE_INTERVAL,
|
|
|
|
GPM_DEFAULT_AUTO_SAVE_INTERVAL)
|
|
|
|
|
|
|
|
|
|
|
|
/* Undo actions limit: if < 1 then no limits */
|
|
|
|
DEFINE_INT_PREF (undo_actions_limit,
|
|
|
|
GPM_UNDO_ACTIONS_LIMIT,
|
|
|
|
GPM_DEFAULT_UNDO_ACTIONS_LIMIT)
|
|
|
|
|
|
|
|
static GtkWrapMode
|
|
|
|
get_wrap_mode_from_string (const gchar* str)
|
|
|
|
{
|
|
|
|
GtkWrapMode res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (str != NULL, GTK_WRAP_WORD);
|
|
|
|
|
|
|
|
if (strcmp (str, "GTK_WRAP_NONE") == 0)
|
|
|
|
res = GTK_WRAP_NONE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strcmp (str, "GTK_WRAP_CHAR") == 0)
|
|
|
|
res = GTK_WRAP_CHAR;
|
|
|
|
else
|
|
|
|
res = GTK_WRAP_WORD;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wrap mode */
|
|
|
|
GtkWrapMode
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_wrap_mode (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
gchar *str;
|
|
|
|
GtkWrapMode res;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
str = pluma_prefs_manager_get_string (GPM_WRAP_MODE,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_WRAP_MODE);
|
|
|
|
|
|
|
|
res = get_wrap_mode_from_string (str);
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_wrap_mode (GtkWrapMode wp)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
const gchar * str;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
switch (wp)
|
|
|
|
{
|
|
|
|
case GTK_WRAP_NONE:
|
|
|
|
str = "GTK_WRAP_NONE";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_WRAP_CHAR:
|
|
|
|
str = "GTK_WRAP_CHAR";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* GTK_WRAP_WORD */
|
|
|
|
str = "GTK_WRAP_WORD";
|
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (GPM_WRAP_MODE,
|
2011-11-07 13:46:58 -06:00
|
|
|
str);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_wrap_mode_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_WRAP_MODE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Tabs size */
|
|
|
|
DEFINE_INT_PREF (tabs_size,
|
|
|
|
GPM_TABS_SIZE,
|
|
|
|
GPM_DEFAULT_TABS_SIZE)
|
|
|
|
|
|
|
|
/* Insert spaces */
|
|
|
|
DEFINE_BOOL_PREF (insert_spaces,
|
|
|
|
GPM_INSERT_SPACES,
|
|
|
|
GPM_DEFAULT_INSERT_SPACES)
|
|
|
|
|
|
|
|
/* Auto indent */
|
|
|
|
DEFINE_BOOL_PREF (auto_indent,
|
|
|
|
GPM_AUTO_INDENT,
|
|
|
|
GPM_DEFAULT_AUTO_INDENT)
|
|
|
|
|
|
|
|
/* Display line numbers */
|
|
|
|
DEFINE_BOOL_PREF (display_line_numbers,
|
|
|
|
GPM_DISPLAY_LINE_NUMBERS,
|
|
|
|
GPM_DEFAULT_DISPLAY_LINE_NUMBERS)
|
|
|
|
|
|
|
|
/* Toolbar visibility */
|
|
|
|
DEFINE_BOOL_PREF (toolbar_visible,
|
|
|
|
GPM_TOOLBAR_VISIBLE,
|
|
|
|
GPM_DEFAULT_TOOLBAR_VISIBLE)
|
|
|
|
|
|
|
|
|
|
|
|
/* Toolbar suttons style */
|
2011-11-07 16:52:18 -06:00
|
|
|
PlumaToolbarSetting
|
|
|
|
pluma_prefs_manager_get_toolbar_buttons_style (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
gchar *str;
|
2011-11-07 16:52:18 -06:00
|
|
|
PlumaToolbarSetting res;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
str = pluma_prefs_manager_get_string (GPM_TOOLBAR_BUTTONS_STYLE,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_TOOLBAR_BUTTONS_STYLE);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (strcmp (str, "PLUMA_TOOLBAR_ICONS") == 0)
|
|
|
|
res = PLUMA_TOOLBAR_ICONS;
|
2011-11-07 13:46:58 -06:00
|
|
|
else
|
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
if (strcmp (str, "PLUMA_TOOLBAR_ICONS_AND_TEXT") == 0)
|
|
|
|
res = PLUMA_TOOLBAR_ICONS_AND_TEXT;
|
2011-11-07 13:46:58 -06:00
|
|
|
else
|
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
if (strcmp (str, "PLUMA_TOOLBAR_ICONS_BOTH_HORIZ") == 0)
|
|
|
|
res = PLUMA_TOOLBAR_ICONS_BOTH_HORIZ;
|
2011-11-07 13:46:58 -06:00
|
|
|
else
|
2011-11-07 16:52:18 -06:00
|
|
|
res = PLUMA_TOOLBAR_SYSTEM;
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_toolbar_buttons_style (PlumaToolbarSetting tbs)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
const gchar * str;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
switch (tbs)
|
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
case PLUMA_TOOLBAR_ICONS:
|
|
|
|
str = "PLUMA_TOOLBAR_ICONS";
|
2011-11-07 13:46:58 -06:00
|
|
|
break;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
case PLUMA_TOOLBAR_ICONS_AND_TEXT:
|
|
|
|
str = "PLUMA_TOOLBAR_ICONS_AND_TEXT";
|
2011-11-07 13:46:58 -06:00
|
|
|
break;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
case PLUMA_TOOLBAR_ICONS_BOTH_HORIZ:
|
|
|
|
str = "PLUMA_TOOLBAR_ICONS_BOTH_HORIZ";
|
2011-11-07 13:46:58 -06:00
|
|
|
break;
|
2011-11-07 16:52:18 -06:00
|
|
|
default: /* PLUMA_TOOLBAR_SYSTEM */
|
|
|
|
str = "PLUMA_TOOLBAR_SYSTEM";
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (GPM_TOOLBAR_BUTTONS_STYLE,
|
2011-11-07 13:46:58 -06:00
|
|
|
str);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_toolbar_buttons_style_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_TOOLBAR_BUTTONS_STYLE);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Statusbar visiblity */
|
|
|
|
DEFINE_BOOL_PREF (statusbar_visible,
|
|
|
|
GPM_STATUSBAR_VISIBLE,
|
|
|
|
GPM_DEFAULT_STATUSBAR_VISIBLE)
|
|
|
|
|
|
|
|
/* Side Pane visiblity */
|
|
|
|
DEFINE_BOOL_PREF (side_pane_visible,
|
|
|
|
GPM_SIDE_PANE_VISIBLE,
|
|
|
|
GPM_DEFAULT_SIDE_PANE_VISIBLE)
|
|
|
|
|
|
|
|
/* Bottom Panel visiblity */
|
|
|
|
DEFINE_BOOL_PREF (bottom_panel_visible,
|
|
|
|
GPM_BOTTOM_PANEL_VISIBLE,
|
|
|
|
GPM_DEFAULT_BOTTOM_PANEL_VISIBLE)
|
|
|
|
|
|
|
|
/* Print syntax highlighting */
|
|
|
|
DEFINE_BOOL_PREF (print_syntax_hl,
|
|
|
|
GPM_PRINT_SYNTAX,
|
|
|
|
GPM_DEFAULT_PRINT_SYNTAX)
|
|
|
|
|
|
|
|
/* Print header */
|
|
|
|
DEFINE_BOOL_PREF (print_header,
|
|
|
|
GPM_PRINT_HEADER,
|
|
|
|
GPM_DEFAULT_PRINT_HEADER)
|
|
|
|
|
|
|
|
|
|
|
|
/* Print Wrap mode */
|
|
|
|
GtkWrapMode
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_print_wrap_mode (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
gchar *str;
|
|
|
|
GtkWrapMode res;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
str = pluma_prefs_manager_get_string (GPM_PRINT_WRAP_MODE,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_PRINT_WRAP_MODE);
|
|
|
|
|
|
|
|
if (strcmp (str, "GTK_WRAP_NONE") == 0)
|
|
|
|
res = GTK_WRAP_NONE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strcmp (str, "GTK_WRAP_WORD") == 0)
|
|
|
|
res = GTK_WRAP_WORD;
|
|
|
|
else
|
|
|
|
res = GTK_WRAP_CHAR;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_print_wrap_mode (GtkWrapMode pwp)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
const gchar *str;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
switch (pwp)
|
|
|
|
{
|
|
|
|
case GTK_WRAP_NONE:
|
|
|
|
str = "GTK_WRAP_NONE";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_WRAP_WORD:
|
|
|
|
str = "GTK_WRAP_WORD";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* GTK_WRAP_CHAR */
|
|
|
|
str = "GTK_WRAP_CHAR";
|
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (GPM_PRINT_WRAP_MODE, str);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_print_wrap_mode_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_PRINT_WRAP_MODE);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Print line numbers */
|
|
|
|
DEFINE_INT_PREF (print_line_numbers,
|
|
|
|
GPM_PRINT_LINE_NUMBERS,
|
|
|
|
GPM_DEFAULT_PRINT_LINE_NUMBERS)
|
|
|
|
|
|
|
|
/* Printing fonts */
|
|
|
|
DEFINE_STRING_PREF (print_font_body,
|
|
|
|
GPM_PRINT_FONT_BODY,
|
|
|
|
GPM_DEFAULT_PRINT_FONT_BODY)
|
|
|
|
|
|
|
|
const gchar *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_default_print_font_body (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
return GPM_DEFAULT_PRINT_FONT_BODY;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_STRING_PREF (print_font_header,
|
|
|
|
GPM_PRINT_FONT_HEADER,
|
|
|
|
GPM_DEFAULT_PRINT_FONT_HEADER)
|
|
|
|
|
|
|
|
const gchar *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_default_print_font_header (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
return GPM_DEFAULT_PRINT_FONT_HEADER;
|
|
|
|
}
|
|
|
|
|
|
|
|
DEFINE_STRING_PREF (print_font_numbers,
|
|
|
|
GPM_PRINT_FONT_NUMBERS,
|
|
|
|
GPM_DEFAULT_PRINT_FONT_NUMBERS)
|
|
|
|
|
|
|
|
const gchar *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_default_print_font_numbers (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
return GPM_DEFAULT_PRINT_FONT_NUMBERS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Max number of files in "Recent Files" menu.
|
|
|
|
* This is configurable only using mateconftool or mateconf-editor
|
|
|
|
*/
|
|
|
|
gint
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_max_recents (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_int (GPM_MAX_RECENTS,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_MAX_RECENTS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Encodings */
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
data_exists (GSList *list,
|
|
|
|
const gpointer data)
|
|
|
|
{
|
|
|
|
while (list != NULL)
|
|
|
|
{
|
|
|
|
if (list->data == data)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_auto_detected_encodings (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GSList *strings;
|
|
|
|
GSList *res = NULL;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, NULL);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_AUTO_DETECTED_ENCODINGS,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (strings == NULL)
|
|
|
|
{
|
|
|
|
gint i = 0;
|
|
|
|
const gchar* s[] = GPM_DEFAULT_AUTO_DETECTED_ENCODINGS;
|
|
|
|
|
|
|
|
while (s[i] != NULL)
|
|
|
|
{
|
|
|
|
strings = g_slist_prepend (strings, g_strdup (s[i]));
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
strings = g_slist_reverse (strings);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strings != NULL)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
2011-11-07 16:52:18 -06:00
|
|
|
const PlumaEncoding *enc;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
tmp = strings;
|
|
|
|
|
|
|
|
while (tmp)
|
|
|
|
{
|
|
|
|
const char *charset = tmp->data;
|
|
|
|
|
|
|
|
if (strcmp (charset, "CURRENT") == 0)
|
|
|
|
g_get_charset (&charset);
|
|
|
|
|
|
|
|
g_return_val_if_fail (charset != NULL, NULL);
|
2011-11-07 16:52:18 -06:00
|
|
|
enc = pluma_encoding_get_from_charset (charset);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
if (enc != NULL)
|
|
|
|
{
|
|
|
|
if (!data_exists (res, (gpointer)enc))
|
|
|
|
res = g_slist_prepend (res, (gpointer)enc);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = g_slist_next (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_foreach (strings, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (strings);
|
|
|
|
|
|
|
|
res = g_slist_reverse (res);
|
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug_message (DEBUG_PREFS, "Done");
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
GSList *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_shown_in_menu_encodings (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GSList *strings;
|
|
|
|
GSList *res = NULL;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, NULL);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_SHOWN_IN_MENU_ENCODINGS,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (strings != NULL)
|
|
|
|
{
|
|
|
|
GSList *tmp;
|
2011-11-07 16:52:18 -06:00
|
|
|
const PlumaEncoding *enc;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
tmp = strings;
|
|
|
|
|
|
|
|
while (tmp)
|
|
|
|
{
|
|
|
|
const char *charset = tmp->data;
|
|
|
|
|
|
|
|
if (strcmp (charset, "CURRENT") == 0)
|
|
|
|
g_get_charset (&charset);
|
|
|
|
|
|
|
|
g_return_val_if_fail (charset != NULL, NULL);
|
2011-11-07 16:52:18 -06:00
|
|
|
enc = pluma_encoding_get_from_charset (charset);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
if (enc != NULL)
|
|
|
|
{
|
|
|
|
if (!data_exists (res, (gpointer)enc))
|
|
|
|
res = g_slist_prepend (res, (gpointer)enc);
|
|
|
|
}
|
|
|
|
|
|
|
|
tmp = g_slist_next (tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_foreach (strings, (GFunc) g_free, NULL);
|
|
|
|
g_slist_free (strings);
|
|
|
|
|
|
|
|
res = g_slist_reverse (res);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_shown_in_menu_encodings (const GSList *encs)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GSList *list = NULL;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager_shown_in_menu_encodings_can_set ());
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
while (encs != NULL)
|
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
const PlumaEncoding *enc;
|
2011-11-07 13:46:58 -06:00
|
|
|
const gchar *charset;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
enc = (const PlumaEncoding *)encs->data;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
charset = pluma_encoding_get_charset (enc);
|
2011-11-07 13:46:58 -06:00
|
|
|
g_return_if_fail (charset != NULL);
|
|
|
|
|
|
|
|
list = g_slist_prepend (list, (gpointer)charset);
|
|
|
|
|
|
|
|
encs = g_slist_next (encs);
|
|
|
|
}
|
|
|
|
|
|
|
|
list = g_slist_reverse (list);
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
mateconf_client_set_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_SHOWN_IN_MENU_ENCODINGS,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
list,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
g_slist_free (list);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_shown_in_menu_encodings_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_SHOWN_IN_MENU_ENCODINGS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Highlight current line */
|
|
|
|
DEFINE_BOOL_PREF (highlight_current_line,
|
|
|
|
GPM_HIGHLIGHT_CURRENT_LINE,
|
|
|
|
GPM_DEFAULT_HIGHLIGHT_CURRENT_LINE)
|
|
|
|
|
|
|
|
/* Highlight matching bracket */
|
|
|
|
DEFINE_BOOL_PREF (bracket_matching,
|
|
|
|
GPM_BRACKET_MATCHING,
|
|
|
|
GPM_DEFAULT_BRACKET_MATCHING)
|
|
|
|
|
|
|
|
/* Display Right Margin */
|
|
|
|
DEFINE_BOOL_PREF (display_right_margin,
|
|
|
|
GPM_DISPLAY_RIGHT_MARGIN,
|
|
|
|
GPM_DEFAULT_DISPLAY_RIGHT_MARGIN)
|
|
|
|
|
|
|
|
/* Right Margin Position */
|
|
|
|
DEFINE_INT_PREF (right_margin_position,
|
|
|
|
GPM_RIGHT_MARGIN_POSITION,
|
|
|
|
GPM_DEFAULT_RIGHT_MARGIN_POSITION)
|
|
|
|
|
|
|
|
static GtkSourceSmartHomeEndType
|
|
|
|
get_smart_home_end_from_string (const gchar *str)
|
|
|
|
{
|
|
|
|
GtkSourceSmartHomeEndType res;
|
|
|
|
|
|
|
|
g_return_val_if_fail (str != NULL, GTK_SOURCE_SMART_HOME_END_AFTER);
|
|
|
|
|
|
|
|
if (strcmp (str, "DISABLED") == 0)
|
|
|
|
res = GTK_SOURCE_SMART_HOME_END_DISABLED;
|
|
|
|
else if (strcmp (str, "BEFORE") == 0)
|
|
|
|
res = GTK_SOURCE_SMART_HOME_END_BEFORE;
|
|
|
|
else if (strcmp (str, "ALWAYS") == 0)
|
|
|
|
res = GTK_SOURCE_SMART_HOME_END_ALWAYS;
|
|
|
|
else
|
|
|
|
res = GTK_SOURCE_SMART_HOME_END_AFTER;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkSourceSmartHomeEndType
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_smart_home_end (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
gchar *str;
|
|
|
|
GtkSourceSmartHomeEndType res;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
str = pluma_prefs_manager_get_string (GPM_SMART_HOME_END,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_SMART_HOME_END);
|
|
|
|
|
|
|
|
res = get_smart_home_end_from_string (str);
|
|
|
|
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_smart_home_end (GtkSourceSmartHomeEndType smart_he)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
const gchar *str;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
switch (smart_he)
|
|
|
|
{
|
|
|
|
case GTK_SOURCE_SMART_HOME_END_DISABLED:
|
|
|
|
str = "DISABLED";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_SOURCE_SMART_HOME_END_BEFORE:
|
|
|
|
str = "BEFORE";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GTK_SOURCE_SMART_HOME_END_ALWAYS:
|
|
|
|
str = "ALWAYS";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: /* GTK_SOURCE_SMART_HOME_END_AFTER */
|
|
|
|
str = "AFTER";
|
|
|
|
}
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_string (GPM_WRAP_MODE, str);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_smart_home_end_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_SMART_HOME_END);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable syntax highlighting */
|
|
|
|
DEFINE_BOOL_PREF (enable_syntax_highlighting,
|
|
|
|
GPM_SYNTAX_HL_ENABLE,
|
|
|
|
GPM_DEFAULT_SYNTAX_HL_ENABLE)
|
|
|
|
|
|
|
|
/* Enable search highlighting */
|
|
|
|
DEFINE_BOOL_PREF (enable_search_highlighting,
|
|
|
|
GPM_SEARCH_HIGHLIGHTING_ENABLE,
|
|
|
|
GPM_DEFAULT_SEARCH_HIGHLIGHTING_ENABLE)
|
|
|
|
|
|
|
|
/* Source style scheme */
|
|
|
|
DEFINE_STRING_PREF (source_style_scheme,
|
|
|
|
GPM_SOURCE_STYLE_SCHEME,
|
|
|
|
GPM_DEFAULT_SOURCE_STYLE_SCHEME)
|
|
|
|
|
|
|
|
GSList *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_writable_vfs_schemes (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GSList *strings;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, NULL);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
strings = mateconf_client_get_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_WRITABLE_VFS_SCHEMES,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
if (strings == NULL)
|
|
|
|
{
|
|
|
|
gint i = 0;
|
|
|
|
const gchar* s[] = GPM_DEFAULT_WRITABLE_VFS_SCHEMES;
|
|
|
|
|
|
|
|
while (s[i] != NULL)
|
|
|
|
{
|
|
|
|
strings = g_slist_prepend (strings, g_strdup (s[i]));
|
|
|
|
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
strings = g_slist_reverse (strings);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The 'file' scheme is writable by default. */
|
|
|
|
strings = g_slist_prepend (strings, g_strdup ("file"));
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug_message (DEBUG_PREFS, "Done");
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
return strings;
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_restore_cursor_position (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_get_bool (GPM_RESTORE_CURSOR_POSITION,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_DEFAULT_RESTORE_CURSOR_POSITION);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Plugins: we just store/return a list of strings, all the magic has to
|
|
|
|
* happen in the plugin engine */
|
|
|
|
|
|
|
|
GSList *
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_get_active_plugins (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
GSList *plugins;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_val_if_fail (pluma_prefs_manager != NULL, NULL);
|
|
|
|
g_return_val_if_fail (pluma_prefs_manager->mateconf_client != NULL, NULL);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
plugins = mateconf_client_get_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_ACTIVE_PLUGINS,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
return plugins;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_set_active_plugins (const GSList *plugins)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
g_return_if_fail (pluma_prefs_manager != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager->mateconf_client != NULL);
|
|
|
|
g_return_if_fail (pluma_prefs_manager_active_plugins_can_set ());
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
mateconf_client_set_list (pluma_prefs_manager->mateconf_client,
|
2011-11-07 13:46:58 -06:00
|
|
|
GPM_ACTIVE_PLUGINS,
|
|
|
|
MATECONF_VALUE_STRING,
|
|
|
|
(GSList *) plugins,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_prefs_manager_active_plugins_can_set (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
2011-11-07 16:52:18 -06:00
|
|
|
pluma_debug (DEBUG_PREFS);
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
return pluma_prefs_manager_key_is_writable (GPM_ACTIVE_PLUGINS);
|
2011-11-07 13:46:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Global Lockdown */
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
PlumaLockdownMask
|
|
|
|
pluma_prefs_manager_get_lockdown (void)
|
2011-11-07 13:46:58 -06:00
|
|
|
{
|
|
|
|
guint lockdown = 0;
|
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_COMMAND_LINE, FALSE))
|
|
|
|
lockdown |= PLUMA_LOCKDOWN_COMMAND_LINE;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_PRINTING, FALSE))
|
|
|
|
lockdown |= PLUMA_LOCKDOWN_PRINTING;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_PRINT_SETUP, FALSE))
|
|
|
|
lockdown |= PLUMA_LOCKDOWN_PRINT_SETUP;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
2011-11-07 16:52:18 -06:00
|
|
|
if (pluma_prefs_manager_get_bool (GPM_LOCKDOWN_SAVE_TO_DISK, FALSE))
|
|
|
|
lockdown |= PLUMA_LOCKDOWN_SAVE_TO_DISK;
|
2011-11-07 13:46:58 -06:00
|
|
|
|
|
|
|
return lockdown;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The following functions are taken from mateconf-client.c
|
|
|
|
* and partially modified.
|
|
|
|
* The licensing terms on these is:
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* MateConf
|
|
|
|
* Copyright (C) 1999, 2000, 2000 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static const gchar*
|
|
|
|
mateconf_value_type_to_string(MateConfValueType type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case MATECONF_VALUE_INT:
|
|
|
|
return "int";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_STRING:
|
|
|
|
return "string";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_FLOAT:
|
|
|
|
return "float";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_BOOL:
|
|
|
|
return "bool";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_SCHEMA:
|
|
|
|
return "schema";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_LIST:
|
|
|
|
return "list";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_PAIR:
|
|
|
|
return "pair";
|
|
|
|
break;
|
|
|
|
case MATECONF_VALUE_INVALID:
|
|
|
|
return "*invalid*";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Emit the proper signals for the error, and fill in err */
|
|
|
|
static gboolean
|
|
|
|
handle_error (MateConfClient* client, GError* error, GError** err)
|
|
|
|
{
|
|
|
|
if (error != NULL)
|
|
|
|
{
|
|
|
|
mateconf_client_error(client, error);
|
|
|
|
|
|
|
|
if (err == NULL)
|
|
|
|
{
|
|
|
|
mateconf_client_unreturned_error(client, error);
|
|
|
|
|
|
|
|
g_error_free(error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*err = error;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
check_type (const gchar* key, MateConfValue* val, MateConfValueType t, GError** err)
|
|
|
|
{
|
|
|
|
if (val->type != t)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
mateconf_set_error(err, MATECONF_ERROR_TYPE_MISMATCH,
|
|
|
|
_("Expected `%s' got, `%s' for key %s"),
|
|
|
|
mateconf_value_type_to_string(t),
|
|
|
|
mateconf_value_type_to_string(val->type),
|
|
|
|
key);
|
|
|
|
*/
|
|
|
|
g_set_error (err, MATECONF_ERROR, MATECONF_ERROR_TYPE_MISMATCH,
|
|
|
|
_("Expected `%s', got `%s' for key %s"),
|
|
|
|
mateconf_value_type_to_string(t),
|
|
|
|
mateconf_value_type_to_string(val->type),
|
|
|
|
key);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
mateconf_client_get_bool_with_default (MateConfClient* client, const gchar* key,
|
|
|
|
gboolean def, GError** err)
|
|
|
|
{
|
|
|
|
GError* error = NULL;
|
|
|
|
MateConfValue* val;
|
|
|
|
|
|
|
|
g_return_val_if_fail (err == NULL || *err == NULL, def);
|
|
|
|
|
|
|
|
val = mateconf_client_get (client, key, &error);
|
|
|
|
|
|
|
|
if (val != NULL)
|
|
|
|
{
|
|
|
|
gboolean retval = def;
|
|
|
|
|
|
|
|
g_return_val_if_fail (error == NULL, retval);
|
|
|
|
|
|
|
|
if (check_type (key, val, MATECONF_VALUE_BOOL, &error))
|
|
|
|
retval = mateconf_value_get_bool (val);
|
|
|
|
else
|
|
|
|
handle_error (client, error, err);
|
|
|
|
|
|
|
|
mateconf_value_free (val);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (error != NULL)
|
|
|
|
handle_error (client, error, err);
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar*
|
|
|
|
mateconf_client_get_string_with_default (MateConfClient* client, const gchar* key,
|
|
|
|
const gchar* def, GError** err)
|
|
|
|
{
|
|
|
|
GError* error = NULL;
|
|
|
|
gchar* val;
|
|
|
|
|
|
|
|
g_return_val_if_fail (err == NULL || *err == NULL, def ? g_strdup (def) : NULL);
|
|
|
|
|
|
|
|
val = mateconf_client_get_string (client, key, &error);
|
|
|
|
|
|
|
|
if (val != NULL)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (error == NULL, def ? g_strdup (def) : NULL);
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (error != NULL)
|
|
|
|
handle_error (client, error, err);
|
|
|
|
return def ? g_strdup (def) : NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
mateconf_client_get_int_with_default (MateConfClient* client, const gchar* key,
|
|
|
|
gint def, GError** err)
|
|
|
|
{
|
|
|
|
GError* error = NULL;
|
|
|
|
MateConfValue* val;
|
|
|
|
|
|
|
|
g_return_val_if_fail (err == NULL || *err == NULL, def);
|
|
|
|
|
|
|
|
val = mateconf_client_get (client, key, &error);
|
|
|
|
|
|
|
|
if (val != NULL)
|
|
|
|
{
|
|
|
|
gint retval = def;
|
|
|
|
|
|
|
|
g_return_val_if_fail (error == NULL, def);
|
|
|
|
|
|
|
|
if (check_type (key, val, MATECONF_VALUE_INT, &error))
|
|
|
|
retval = mateconf_value_get_int(val);
|
|
|
|
else
|
|
|
|
handle_error (client, error, err);
|
|
|
|
|
|
|
|
mateconf_value_free (val);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (error != NULL)
|
|
|
|
handle_error (client, error, err);
|
|
|
|
return def;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|