From d70252b1e331dc0e79e47a18ef1a2a9bde18edad Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Tue, 11 Oct 2005 09:44:39 +0000 Subject: [PATCH] Added updating options when color information changes in the color table --- src/gm-app.c | 39 +++++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/src/gm-app.c b/src/gm-app.c index 3cce64d..6cd039e 100644 --- a/src/gm-app.c +++ b/src/gm-app.c @@ -7,7 +7,7 @@ #include #include -#include "gm-app-view.h" +#include "widgets/gm-app-view.h" #include "gm-world.h" #include "gm-color-table.h" @@ -31,7 +31,13 @@ static GmApp *application; //gboolean on_gm_app_tray_destroy(GtkWidget *widget, gpointer user_data); void on_gm_app_view_size_allocate(GmAppView *view, GtkAllocation *allocation, GmApp *app); - +void on_gm_app_color_table_color_changed(GmColorTable *color_table, + const gchar *color, GmApp *app); +void on_gm_app_color_table_bold_toggled(GmColorTable *color_table, + gboolean bold, GmApp *app); +void on_gm_app_color_table_font_changed(GmColorTable *color_table, + const gchar *font, GmApp *app); + struct poptOption poptions[] = { { "debug", @@ -277,7 +283,6 @@ gm_app_create_settings(GmApp *app) { gm_options_set(app->priv->options, "editor_alternative", "0"); gm_options_set(app->priv->options, "editor_embed", "0"); gm_options_set(app->priv->options, "editor_needs_terminal", "0"); - gm_options_set(app->priv->options, "font-family", "Monospace 8"); gm_options_set(app->priv->options, "worlds_saved_state", ""); gm_options_set(app->priv->options, "search_direction", "1"); } @@ -336,11 +341,19 @@ gm_app_initialize(GmApp *app) { app->priv->scripts = gm_scripts_new(); #endif - /* Create the main view */ gm_app_create_settings(app); gm_options_load(app->priv->options, app->priv->options_path); + + // Load color table app->priv->color_table = gm_color_table_new_from_options(app->priv->options); + // Add color table signals + g_signal_connect(app->priv->color_table, "color_changed", + G_CALLBACK(on_gm_app_color_table_color_changed), app); + g_signal_connect(app->priv->color_table, "font_changed", + G_CALLBACK(on_gm_app_color_table_font_changed), app); + g_signal_connect(app->priv->color_table, "bold_toggled", + G_CALLBACK(on_gm_app_color_table_bold_toggled), app); } void @@ -546,6 +559,24 @@ on_gm_app_view_size_allocate(GmAppView *view, GtkAllocation *allocation, gm_options_set_int(app->priv->options, "height", allocation->height); } +void +on_gm_app_color_table_color_changed(GmColorTable *color_table, + const gchar *color, GmApp *app) { + gm_options_set(app->priv->options, color, + gm_color_table_get_hex(color_table, color)); +} + +void +on_gm_app_color_table_bold_toggled(GmColorTable *color_table, + gboolean bold, GmApp *app) { + gm_options_set_int(app->priv->options, "bold-colors", bold); +} + +void on_gm_app_color_table_font_changed(GmColorTable *color_table, + const gchar *font, GmApp *app) { + gm_options_set(app->priv->options, "font-family", font); +} + /*gboolean on_gm_app_tray_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data) {