Commit 2bff4b63 authored by Christian Persch's avatar Christian Persch
Browse files

Start gsettings port

This introduces a couple of regressions, the most important one
being that there can only be one profile (supporting multi-profile
depends on gsettingslist in glib). Also, profile data migration
isn't working yet.
parent a548dfe4
......@@ -2,6 +2,8 @@ SUBDIRS = src po help
NULL =
ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
DISTCHECK_CONFIGURE_FLAGS = \
--disable-scrollkeeper \
--disable-schemas-install \
......
......@@ -40,26 +40,21 @@ GNOME_COMPILE_WARNINGS([maximum])
AM_GLIB_GNU_GETTEXT
GLIB_REQUIRED=2.26.0
GIO_REQUIRED=2.26.0
GCONF_REQUIRED=2.31.3
GIO_REQUIRED=2.27.0
GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=0.1.0
AC_MSG_CHECKING([which gtk+ version to compile against])
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk=2.0|3.0],[which gtk+ version to compile against (default: 3.0)])],
[AS_HELP_STRING([--with-gtk=3.0],[which gtk+ version to compile against (default: 3.0)])],
[case "$with_gtk" in
2.0|3.0) ;;
*) AC_MSG_ERROR([invalid gtk version specified]) ;;
3.0) ;;
2.0) AC_MSG_ERROR([unsupported gtk version $with_gtk specified]) ;;
*) AC_MSG_ERROR([invalid gtk version $with_gtk specified]) ;;
esac],
[with_gtk=3.0])
AC_MSG_RESULT([$with_gtk])
case "$with_gtk" in
2.0) GTK_API_VERSION=2.0
GTK_REQUIRED=2.18.0
VTE_PC_VERSION=
VTE_REQUIRED=0.26.0
;;
3.0) GTK_API_VERSION=3.0
GTK_REQUIRED=3.0.0
VTE_PC_VERSION=-2.90
......@@ -69,7 +64,6 @@ esac
AC_MSG_CHECKING([for GDK target])
case "$with_gtk" in
2.0) GDK_TARGET="$($PKG_CONFIG --variable target gdk-$GTK_API_VERSION)" ;;
3.0) for target in $($PKG_CONFIG --variable targets gdk-$GTK_API_VERSION); do
GDK_TARGET="$target"
break
......@@ -90,10 +84,15 @@ PKG_CHECK_MODULES([TERM],
gthread-2.0
gio-2.0 >= $GIO_REQUIRED
gtk+-$GTK_API_VERSION >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
gsettings-desktop-schemas >= $GSETTINGS_DESKTOP_SCHEMAS_REQUIRED
$PLATFORM_DEPS])
# *********
# GSettings
# *********
GLIB_GSETTINGS
# ********
# smclient
# ********
......@@ -125,17 +124,20 @@ AM_CONDITIONAL([WITH_SMCLIENT_XSMP],[test "$with_smclient" = "xsmp"])
AM_CONDITIONAL([WITH_SMCLIENT_WIN32],[test "$with_smclient" = "win32"])
AM_CONDITIONAL([WITH_SMCLIENT_QUARTZ],[test "$with_smclient" = "quartz"])
# *****
# GConf
# *****
# *************************
# GConf-GSettings Migration
# *************************
AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
GCONF_REQUIRED=2.31.3
if test x"$GCONFTOOL" = xno; then
AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
fi
PKG_CHECK_MODULES([MIGRATOR],[
gio-2.0 >= $GIO_REQUIRED
vte$VTE_PC_VERSION >= $VTE_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED])
AM_GCONF_SOURCE_2
# ***********
# Build tools
# ***********
GLIB_GENMARSHAL="$($PKG_CONFIG --variable=glib_genmarshal glib-2.0)"
AC_SUBST([GLIB_GENMARSHAL])
......@@ -149,7 +151,6 @@ if test "$GTK_BUILDER_CONVERT" = "false"; then
fi
case "$with_gtk" in
2.0) GTK_BUILDER_CONVERT_FLAGS="" ;;
3.0) GTK_BUILDER_CONVERT_FLAGS="--target-version=3.0" ;;
esac
......
......@@ -5,7 +5,6 @@ gnome-terminal.desktop.in.in
src/eggsmclient.c
src/encodings-dialog.glade
src/find-dialog.glade
src/gnome-terminal.schemas.in
src/keybinding-editor.glade
src/profile-editor.c
src/profile-manager.glade
......@@ -24,3 +23,4 @@ src/terminal-tabs-menu.c
src/terminal-util.c
src/terminal-window.c
src/extra-strings.c
src/org.gnome.Terminal.Preferences.gschema.xml.in
......@@ -30,8 +30,7 @@ gnome_terminal_SOURCES= \
terminal-intl.h \
terminal-options.c \
terminal-options.h \
terminal-profile.c \
terminal-profile.h \
terminal-schemas.h \
terminal-screen.c \
terminal-screen.h \
terminal-screen-container.c \
......@@ -105,7 +104,7 @@ endif
endif
TYPES_H_FILES = \
terminal-profile.h \
terminal-enums.h \
$(NULL)
terminal-type-builtins.h: stamp-terminal-type-builtins.h
......@@ -137,9 +136,27 @@ terminal-marshal.c: $(srcdir)/terminal-marshal.list
&& mv terminal-marshal.c.tmp terminal-marshal.c ) \
|| ( rm -f terminal-marshal.c.tmp && exit 1 )
schemadir = $(GCONF_SCHEMA_FILE_DIR)
schema_in_files = gnome-terminal.schemas.in
schema_DATA = gnome-terminal.schemas
migrationdir = $(libexecdir)/GConf/gsettings
migration_PROGRAMS = gnome-terminal-migration
gnome_terminal_migration_SOURCES = \
migration.c \
terminal-schemas.h \
terminal-type-builtins.c \
terminal-type-builtins.h \
$(NULL)
gnome_terminal_migration_CPPFLAGS = \
$(AM_CPPFLAGS)
gnome_terminal_migration_CFLAGS = \
$(MIGRATOR_CFLAGS) \
$(AM_CFLAGS)
gnome_terminal_migration_LDFLAGS = \
$(AM_LDFLAGS)
gnome_terminal_migration_LDADD = \
$(MIGRATOR_LIBS) \
$(INTLLIBS)
aboutdir = $(pkgdatadir)
about_DATA = \
......@@ -163,11 +180,15 @@ builder_in_files = \
builderdir = $(pkgdatadir)
builder_DATA = $(builder_in_files:.glade=.ui)
gsettingsschema_in_files = org.gnome.Terminal.Preferences.gschema.xml.in
gsettings_SCHEMAS = $(gsettingsschema_in_files:.gschema.xml.in=.gschema.xml)
CLEANFILES = \
stamp-terminal-type-builtins.h \
gnome-terminal.schemas \
stamp-terminal-type-builtins.h \
$(builder_DATA) \
$(gsettings_SCHEMAS) \
$(BUILT_SOURCES)
EXTRA_DIST = \
......@@ -176,17 +197,13 @@ EXTRA_DIST = \
terminal-type-builtins.h.template \
extra-strings.c \
$(about_DATA) \
$(schema_in_files) \
$(uimanager_DATA) \
$(builder_in_files) \
$(gsettingsschema_in_files) \
$(NULL)
@INTLTOOL_SCHEMAS_RULE@
if GCONF_SCHEMAS_INSTALL
install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/src/$(schema_DATA)
endif
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
%.ui: %.glade
$(AM_V_GEN) $(GTK_BUILDER_CONVERT) $(GTK_BUILDER_CONVERT_FLAGS) $< $@
......
......@@ -46,11 +46,11 @@ N_("Restart the command")
N_("Hold the terminal open")
/* Translators: Scrollbar is: ... */
N_("On the left side")
N_("Always visible")
/* Translators: Scrollbar is: ... */
N_("On the right side")
N_("Visible only when necessary")
/* Translators: Scrollbar is: ... */
N_("Disabled")
N_("Hidden")
/* Translators: When terminal commands set their own titles: ... */
N_("Replace initial title")
......
This diff is collapsed.
/*
* Copyright © 2011 Christian Persch
*
* Gnome-terminal 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 3 of the License, or
* (at your option) any later version.
*
* Gnome-terminal 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, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <locale.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <gconf/gconf-client.h>
#include <vte/vte.h>
#include "terminal-schemas.h"
#include "terminal-type-builtins.h"
static gboolean dry_run = FALSE;
static gboolean verbose = FALSE;
static const GOptionEntry options[] = {
{ "dry-run", 0, 0, G_OPTION_ARG_NONE, &dry_run, NULL, NULL },
{ "verbose", 0, 0, G_OPTION_ARG_NONE, &verbose, NULL, NULL },
{ NULL }
};
#define ERROR_DOMAIN (g_intern_static_string ("gnome-terminal-migration-error"))
enum {
ERROR_GENERIC
};
#define GCONF_PREFIX "/apps/gnome-terminal"
#define GCONF_GLOBAL_PREFIX GCONF_PREFIX "/global"
#define GCONF_PROFILES_PREFIX GCONF_PREFIX "/profiles"
#define KEY_ALLOW_BOLD "allow_bold"
#define KEY_BACKGROUND_COLOR "background_color"
#define KEY_BACKGROUND_DARKNESS "background_darkness"
#define KEY_BACKGROUND_IMAGE_FILE "background_image"
#define KEY_BACKGROUND_TYPE "background_type"
#define KEY_BACKSPACE_BINDING "backspace_binding"
#define KEY_BOLD_COLOR "bold_color"
#define KEY_BOLD_COLOR_SAME_AS_FG "bold_color_same_as_fg"
#define KEY_CURSOR_BLINK_MODE "cursor_blink_mode"
#define KEY_CURSOR_SHAPE "cursor_shape"
#define KEY_CUSTOM_COMMAND "custom_command"
#define KEY_DEFAULT_SHOW_MENUBAR "default_show_menubar"
#define KEY_DEFAULT_SIZE_COLUMNS "default_size_columns"
#define KEY_DEFAULT_SIZE_ROWS "default_size_rows"
#define KEY_DELETE_BINDING "delete_binding"
#define KEY_EXIT_ACTION "exit_action"
#define KEY_FONT "font"
#define KEY_FOREGROUND_COLOR "foreground_color"
#define KEY_LOGIN_SHELL "login_shell"
#define KEY_PALETTE "palette"
#define KEY_SCROLL_BACKGROUND "scroll_background"
#define KEY_SCROLLBACK_LINES "scrollback_lines"
#define KEY_SCROLLBACK_UNLIMITED "scrollback_unlimited"
#define KEY_SCROLLBAR_POSITION "scrollbar_position"
#define KEY_SCROLL_ON_KEYSTROKE "scroll_on_keystroke"
#define KEY_SCROLL_ON_OUTPUT "scroll_on_output"
#define KEY_SILENT_BELL "silent_bell"
#define KEY_TITLE_MODE "title_mode"
#define KEY_TITLE "title"
#define KEY_UPDATE_RECORDS "update_records"
#define KEY_USE_CUSTOM_COMMAND "use_custom_command"
#define KEY_USE_CUSTOM_DEFAULT_SIZE "use_custom_default_size"
#define KEY_USE_SYSTEM_FONT "use_system_font"
#define KEY_USE_THEME_COLORS "use_theme_colors"
#define KEY_VISIBLE_NAME "visible_name"
#define KEY_WORD_CHARS "word_chars"
static const GConfEnumStringPair erase_binding_pairs[] = {
{ VTE_ERASE_AUTO, "auto" },
{ VTE_ERASE_ASCII_BACKSPACE, "control-h" },
{ VTE_ERASE_ASCII_DELETE, "ascii-del" },
{ VTE_ERASE_DELETE_SEQUENCE, "escape-sequence" },
{ VTE_ERASE_TTY, "tty" },
{ -1, NULL }
};
static const GConfEnumStringPair scrollbar_position_pairs[] = {
{ GTK_POLICY_ALWAYS, "left" },
{ GTK_POLICY_ALWAYS, "right" },
{ GTK_POLICY_NEVER, "hidden" },
{ -1, NULL }
};
static gboolean
string_to_enum (GType type,
const char *s,
int *val)
{
GEnumClass *klass;
GEnumValue *eval = NULL;
guint i;
klass = g_type_class_ref (type);
for (i = 0; i < klass->n_values; ++i) {
if (strcmp (klass->values[i].value_nick, s) != 0)
continue;
eval = &klass->values[i];
break;
}
if (eval)
*val = eval->value;
g_type_class_unref (klass);
return eval != NULL;
}
static void
migrate_bool (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
GSettings *settings,
const char *settings_key,
gboolean invert)
{
GConfValue *value;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_BOOL)
g_settings_set_boolean (settings, settings_key,
invert ? !gconf_value_get_bool (value)
: gconf_value_get_bool (value));
if (value)
gconf_value_free (value);
}
static void
migrate_int (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
GSettings *settings,
const char *settings_key)
{
GConfValue *value;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_INT)
g_settings_set_int (settings, settings_key, gconf_value_get_int (value));
if (value)
gconf_value_free (value);
}
static void
migrate_string (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
GSettings *settings,
const char *settings_key)
{
GConfValue *value;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_STRING)
g_settings_set_string (settings, settings_key, gconf_value_get_string (value));
if (value)
gconf_value_free (value);
}
static void
migrate_string_list (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
GSettings *settings,
const char *settings_key)
{
GConfValue *value;
GVariantBuilder builder;
GSList *l;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_LIST &&
gconf_value_get_list_type (value) == GCONF_VALUE_STRING) {
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
for (l = gconf_value_get_list (value); l != NULL; l = l->next)
g_variant_builder_add (&builder, "s", gconf_value_get_string (l->data));
g_settings_set (settings, settings_key, "as", &builder);
}
if (value)
gconf_value_free (value);
}
static void
migrate_enum (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
const GConfEnumStringPair *pairs,
GSettings *settings,
const char *settings_key)
{
GConfValue *value;
int val;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_STRING &&
gconf_string_to_enum ((GConfEnumStringPair*) pairs, gconf_value_get_string (value), &val))
g_settings_set_enum (settings, settings_key, val);
if (value)
gconf_value_free (value);
}
static void
migrate_genum (GConfClient *client,
const char *gconf_path,
const char *gconf_key,
GSettings *settings,
const char *settings_key,
GType enum_type)
{
GConfValue *value;
int val;
char *key;
key = gconf_concat_dir_and_key (gconf_path, gconf_key);
value = gconf_client_get_without_default (client, key, NULL);
g_free (key);
if (value != NULL &&
value->type == GCONF_VALUE_STRING &&
string_to_enum (enum_type, gconf_value_get_string (value), &val))
g_settings_set_enum (settings, settings_key, val);
if (value)
gconf_value_free (value);
}
static gboolean
migrate_global_prefs (GError **error)
{
GConfClient *client;
GSettings *settings;
settings = g_settings_new (TERMINAL_SETTING_SCHEMA);
client = gconf_client_get_default ();
migrate_bool (client, GCONF_GLOBAL_PREFIX, "confirm_window_close",
settings, TERMINAL_SETTING_CONFIRM_CLOSE_KEY,
FALSE);
migrate_bool (client, GCONF_GLOBAL_PREFIX, "use_mnemonics",
settings, TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
FALSE);
migrate_bool (client, GCONF_GLOBAL_PREFIX, "use_menu_accelerator",
settings, TERMINAL_SETTING_ENABLE_MENU_BAR_ACCEL_KEY,
FALSE);
migrate_string_list (client, GCONF_GLOBAL_PREFIX, "active_encodings",
settings, TERMINAL_SETTING_ENCODINGS_KEY);
g_object_unref (settings);
g_object_unref (client);
return TRUE;
}
static void
migrate_profile (GConfClient *client,
const char *gconf_id,
int id,
GError **error)
{
GSettings *settings;
char *path;
if (verbose)
g_print ("Migrating profile \"%s\"\n", gconf_id);
path = g_strdup_printf (PROFILES_PATH_PREFIX, "profile%d:/", id);
settings = g_settings_new_with_path (TERMINAL_PROFILE_SCHEMA, path);
g_free (path);
path = gconf_concat_dir_and_key (GCONF_PROFILES_PREFIX, gconf_id);
migrate_string (client, path, KEY_VISIBLE_NAME,
settings, TERMINAL_PROFILE_VISIBLE_NAME_KEY);
migrate_string (client, path, KEY_FOREGROUND_COLOR,
settings, TERMINAL_PROFILE_FOREGROUND_COLOR_KEY);
migrate_string (client, path, KEY_BACKGROUND_COLOR,
settings, TERMINAL_PROFILE_BACKGROUND_COLOR_KEY);
migrate_string (client, path, KEY_BOLD_COLOR,
settings, TERMINAL_PROFILE_BOLD_COLOR_KEY);
migrate_bool (client, path, KEY_BOLD_COLOR_SAME_AS_FG,
settings, TERMINAL_PROFILE_BOLD_COLOR_SAME_AS_FG_KEY,
FALSE);
migrate_genum (client, path, KEY_TITLE_MODE,
settings, TERMINAL_PROFILE_TITLE_MODE_KEY,
TERMINAL_TYPE_TITLE_MODE);
migrate_string (client, path, KEY_TITLE,
settings, TERMINAL_PROFILE_TITLE_KEY);
migrate_bool (client, path, KEY_ALLOW_BOLD,
settings, TERMINAL_PROFILE_ALLOW_BOLD_KEY,
FALSE);
migrate_bool (client, path, KEY_SILENT_BELL,
settings, TERMINAL_PROFILE_AUDIBLE_BELL_KEY,
TRUE);
migrate_string (client, path, KEY_WORD_CHARS,
settings, TERMINAL_PROFILE_WORD_CHARS_KEY);
migrate_bool (client, path, KEY_USE_CUSTOM_DEFAULT_SIZE,
settings, TERMINAL_PROFILE_USE_CUSTOM_DEFAULT_SIZE_KEY,
FALSE);
migrate_int (client, path, KEY_DEFAULT_SIZE_COLUMNS,
settings, TERMINAL_PROFILE_DEFAULT_SIZE_COLUMNS_KEY);
migrate_int (client, path, KEY_DEFAULT_SIZE_ROWS,
settings, TERMINAL_PROFILE_DEFAULT_SIZE_ROWS_KEY);
migrate_enum (client, path, KEY_SCROLLBAR_POSITION,
scrollbar_position_pairs,
settings, TERMINAL_PROFILE_SCROLLBAR_POLICY_KEY);
{ // FIX these as -1 == unlimited?
migrate_int (client, path, KEY_SCROLLBACK_LINES,
settings, TERMINAL_PROFILE_SCROLLBACK_LINES_KEY);
migrate_bool (client, path, KEY_SCROLLBACK_UNLIMITED,
settings, TERMINAL_PROFILE_SCROLLBACK_UNLIMITED_KEY,
FALSE);
}
migrate_bool (client, path, KEY_SCROLL_ON_KEYSTROKE,
settings, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE_KEY,
FALSE);
migrate_bool (client, path, KEY_SCROLL_ON_OUTPUT,
settings, TERMINAL_PROFILE_SCROLL_ON_OUTPUT_KEY,
FALSE);
migrate_genum (client, path, KEY_EXIT_ACTION,
settings, TERMINAL_PROFILE_EXIT_ACTION_KEY,
TERMINAL_TYPE_EXIT_ACTION);
migrate_bool (client, path, KEY_LOGIN_SHELL,
settings, TERMINAL_PROFILE_LOGIN_SHELL_KEY,
FALSE);
migrate_bool (client, path, KEY_UPDATE_RECORDS,
settings, TERMINAL_PROFILE_UPDATE_RECORDS_KEY,
FALSE);
migrate_bool (client, path, KEY_USE_CUSTOM_COMMAND,
settings, TERMINAL_PROFILE_USE_CUSTOM_COMMAND_KEY,
FALSE);
migrate_string (client, path, KEY_CUSTOM_COMMAND,
settings, TERMINAL_PROFILE_CUSTOM_COMMAND_KEY);
migrate_genum (client, path, KEY_CURSOR_BLINK_MODE,
settings, TERMINAL_PROFILE_CURSOR_BLINK_MODE_KEY,
VTE_TYPE_TERMINAL_CURSOR_BLINK_MODE);
migrate_genum (client, path, KEY_CURSOR_SHAPE,
settings, TERMINAL_PROFILE_CURSOR_SHAPE_KEY,
VTE_TYPE_TERMINAL_CURSOR_SHAPE);
migrate_string_list (client, path, KEY_PALETTE,
settings, TERMINAL_PROFILE_PALETTE_KEY);
migrate_string (client, path, KEY_FONT,
settings, TERMINAL_PROFILE_FONT_KEY);
migrate_enum (client, path, KEY_BACKSPACE_BINDING, erase_binding_pairs,
settings, TERMINAL_PROFILE_BACKSPACE_BINDING_KEY);
migrate_enum (client, path, KEY_DELETE_BINDING, erase_binding_pairs,
settings, TERMINAL_PROFILE_DELETE_BINDING_KEY);
migrate_bool (client, path, KEY_USE_THEME_COLORS,
settings, TERMINAL_PROFILE_USE_THEME_COLORS_KEY,
FALSE);
migrate_bool (client, path, KEY_USE_SYSTEM_FONT,
settings, TERMINAL_PROFILE_USE_SYSTEM_FONT_KEY,
FALSE);
g_free (path);
g_object_unref (settings);
}
static gboolean
migrate_profiles (GError **error)
{
GSettings *settings;
GConfClient *client;
GConfValue *value, *dvalue;
GSList *l;
char *path;
const char *profile, *default_profile = NULL;
int profile_nr;
client = gconf_client_get_default ();