From 631d57ac88a927c31435bc654f4d9bc68555e390 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 4 Jun 2012 14:08:48 +0200 Subject: only save transcript widget font and colors if they have been changed (via keyfile or dialogs) * so if they haven't been changed, the widget defaults are active (may depend on gtk theme and RC files) * currently it is not possible reset changed fonts/colors to the widget defaults (via the UI, the keyfile may be edited manually) --- .../gtk-experiment-transcript.c | 1 + src/main.c | 28 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c index 0c2b373..4d0fd46 100644 --- a/lib/gtk-experiment-widgets/gtk-experiment-transcript.c +++ b/lib/gtk-experiment-widgets/gtk-experiment-transcript.c @@ -110,6 +110,7 @@ gtk_experiment_transcript_init(GtkExperimentTranscript *klass) klass->priv->interactive_format.regexp = NULL; klass->priv->interactive_format.attribs = NULL; + /** @todo It should be possible to reset font and colors (to widget defaults) */ klass->priv->menu = gtk_menu_new(); gtk_menu_attach_to_widget(GTK_MENU(klass->priv->menu), GTK_WIDGET(klass), NULL); diff --git a/src/main.c b/src/main.c index f036e5b..93233fa 100644 --- a/src/main.c +++ b/src/main.c @@ -257,6 +257,7 @@ main(int argc, char *argv[]) GtkAdjustment *adj; PangoFontDescription *font_desc; GdkColor color; + GtkRcStyle *modified_style; /* FIXME: support internationalization instead of enforcing English */ #ifdef __WIN32__ @@ -370,13 +371,17 @@ main(int argc, char *argv[]) gtk_main(); gdk_threads_leave(); - /** @todo only modify style if it isn't the default widget style */ - config_set_transcript_font(SPEAKER_WIZARD, - transcript_wizard_widget->style->font_desc); + modified_style = gtk_widget_get_modifier_style(transcript_wizard_widget); + config_set_transcript_font(SPEAKER_WIZARD, modified_style->font_desc); config_set_transcript_text_color(SPEAKER_WIZARD, - &transcript_wizard_widget->style->text[GTK_STATE_NORMAL]); + modified_style->color_flags[GTK_STATE_NORMAL] & GTK_RC_TEXT + ? &modified_style->text[GTK_STATE_NORMAL] + : NULL); config_set_transcript_bg_color(SPEAKER_WIZARD, - &transcript_wizard_widget->style->bg[GTK_STATE_NORMAL]); + modified_style->color_flags[GTK_STATE_NORMAL] & GTK_RC_BG + ? &modified_style->bg[GTK_STATE_NORMAL] + : NULL); + g_object_unref(modified_style); config_set_transcript_default_format_font(SPEAKER_WIZARD, transcript_wizard->interactive_format.default_font); @@ -385,12 +390,17 @@ main(int argc, char *argv[]) config_set_transcript_default_format_bg_color(SPEAKER_WIZARD, transcript_wizard->interactive_format.default_bg_color); - config_set_transcript_font(SPEAKER_PROBAND, - transcript_proband_widget->style->font_desc); + modified_style = gtk_widget_get_modifier_style(transcript_proband_widget); + config_set_transcript_font(SPEAKER_PROBAND, modified_style->font_desc); config_set_transcript_text_color(SPEAKER_PROBAND, - &transcript_proband_widget->style->text[GTK_STATE_NORMAL]); + modified_style->color_flags[GTK_STATE_NORMAL] & GTK_RC_TEXT + ? &modified_style->text[GTK_STATE_NORMAL] + : NULL); config_set_transcript_bg_color(SPEAKER_PROBAND, - &transcript_proband_widget->style->bg[GTK_STATE_NORMAL]); + modified_style->color_flags[GTK_STATE_NORMAL] & GTK_RC_BG + ? &modified_style->bg[GTK_STATE_NORMAL] + : NULL); + g_object_unref(modified_style); config_set_transcript_default_format_font(SPEAKER_PROBAND, transcript_proband->interactive_format.default_font); -- cgit v1.2.3