Added old config conversion, fixed SIGINT signal
This commit is contained in:
parent
ffcc9c7b6c
commit
bb7b69fb41
|
@ -7,12 +7,14 @@
|
|||
#include <libgnomevfs/gnome-vfs.h>
|
||||
#include <libgnomeui/libgnomeui.h>
|
||||
#include <strings.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "widgets/gm-app-view.h"
|
||||
#include "gm-world.h"
|
||||
#include "gm-color-table.h"
|
||||
|
||||
#include "gm-app.h"
|
||||
#include "ansi.h"
|
||||
//#include "editor.h"
|
||||
#include "gm-debug.h"
|
||||
#include "gm-pixbuf.h"
|
||||
|
@ -307,11 +309,66 @@ gm_app_load_worlds(GmApp *app, gboolean autoload) {
|
|||
|
||||
g_dir_close(handle);
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_DEFAULT, "GmApp.load_worlds: failed to open worlds path %s",
|
||||
app->priv->path);
|
||||
gm_debug_msg(DEBUG_DEFAULT, "GmApp.load_worlds: failed to open worlds "
|
||||
"path %s", app->priv->path);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_convert_old_color_configuration(GmApp *app, gchar const *colors_path) {
|
||||
guint i;
|
||||
gchar const *color, *value;
|
||||
FILE *f;
|
||||
GmColorTable *table;
|
||||
gboolean is_scheme = TRUE;
|
||||
|
||||
f = fopen(colors_path, "w");
|
||||
|
||||
if (!f) {
|
||||
gm_debug_msg(DEBUG_DEFAULT, "Can't open colors file (%s) for writing!",
|
||||
colors_path);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a template color table with the WHITE_ON_BLACK scheme
|
||||
table = gm_color_table_new();
|
||||
gm_color_table_load_scheme(table, SCHEME_WHITE_ON_BLACK);
|
||||
|
||||
// Copy every color related item from ->options_path to colors_path
|
||||
for (i = 0; i < sizeof(ansi_colors) / sizeof(ansinamepair); ++i) {
|
||||
color = ansi_colors[i].name;
|
||||
value = gm_options_get(app->priv->options, color);
|
||||
|
||||
if (value) {
|
||||
is_scheme = is_scheme && strcmp(value,
|
||||
gm_color_table_get_hex(table, color)) == 0;
|
||||
fprintf(f, "%s=%s\n", color, value);
|
||||
|
||||
gm_options_remove(app->priv->options, color);
|
||||
}
|
||||
}
|
||||
|
||||
value = gm_options_get(app->priv->options, "font-family");
|
||||
|
||||
if (value) {
|
||||
fprintf(f, "font_family=%s\n", value);
|
||||
}
|
||||
|
||||
gm_options_remove(app->priv->options, "font-family");
|
||||
gm_options_remove(app->priv->options, "bold-colors");
|
||||
gm_options_remove(app->priv->options, "background_transparancy");
|
||||
gm_options_remove(app->priv->options, "background_transparent");
|
||||
|
||||
if (is_scheme) {
|
||||
fputs("color_scheme=default\n", f);
|
||||
} else {
|
||||
fputs("color_scheme=user\n", f);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
g_object_unref(G_OBJECT(table));
|
||||
}
|
||||
|
||||
void
|
||||
gm_app_initialize(GmApp *app) {
|
||||
gchar *colors_path;
|
||||
|
@ -331,13 +388,19 @@ gm_app_initialize(GmApp *app) {
|
|||
#ifdef HAVE_RUBY
|
||||
app->priv->scripts = gm_scripts_new();
|
||||
#endif
|
||||
|
||||
|
||||
gm_app_create_settings(app);
|
||||
gm_options_load(app->priv->options, app->priv->options_path);
|
||||
|
||||
// Load color table
|
||||
colors_path = g_strconcat(app->priv->path, G_DIR_SEPARATOR_S, "colors",
|
||||
NULL);
|
||||
|
||||
if (!g_file_test(colors_path, G_FILE_TEST_EXISTS)) {
|
||||
// There is no `new` color configuration yet. Copy from general options
|
||||
gm_app_convert_old_color_configuration(app, colors_path);
|
||||
}
|
||||
|
||||
app->priv->color_table = gm_color_table_new_from_options(colors_path);
|
||||
g_free(colors_path);
|
||||
}
|
||||
|
@ -404,6 +467,7 @@ gm_app_run(GmApp *app) {
|
|||
g_strfreev(wrlds);
|
||||
}
|
||||
|
||||
signal(SIGINT, SIG_DFL);
|
||||
gtk_main();
|
||||
}
|
||||
|
||||
|
@ -420,11 +484,9 @@ gm_app_new(int argc, char *argv[]) {
|
|||
return app;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_NLS
|
||||
bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
|
||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
||||
textdomain(GETTEXT_PACKAGE);
|
||||
#endif
|
||||
|
||||
gtk_set_locale();
|
||||
gtk_init(&argc, &argv);
|
||||
|
|
Reference in New Issue