summaryrefslogtreecommitdiffhomepage
path: root/mixgtk/mixgtk_mixal.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixgtk/mixgtk_mixal.c')
-rw-r--r--mixgtk/mixgtk_mixal.c51
1 files changed, 46 insertions, 5 deletions
diff --git a/mixgtk/mixgtk_mixal.c b/mixgtk/mixgtk_mixal.c
index 14afacc..8cbb015 100644
--- a/mixgtk/mixgtk_mixal.c
+++ b/mixgtk/mixgtk_mixal.c
@@ -1,7 +1,7 @@
/* -*-c-*- -------------- mixgtk_mixal.c :
* Implementation of the functions declared in mixgtk_mixal.h
* ------------------------------------------------------------------
- * Last change: Time-stamp: "2001-04-22 01:02:28 jao"
+ * Last change: Time-stamp: "2001-04-29 22:30:43 jao"
* ------------------------------------------------------------------
* Copyright (C) 2001 Free Software Foundation, Inc.
*
@@ -26,6 +26,7 @@
#include <string.h>
#include "mixgtk_widgets.h"
+#include "mixgtk_config.h"
#include "mixgtk_mixal.h"
@@ -40,12 +41,37 @@ static const char* default_colors_[3][2] = {
{"white", "black"}
};
+static const char* keys_[3][2] = {
+ {"MIXAL.bp.color.bg", "MIXAL.bp.color.fg"},
+ {"MIXAL.lc.color.bg", "MIXAL.lc.color.fg"},
+ {"MIXAL.pl.color.bg", "MIXAL.pl.color.fg"}
+};
+
+static const GdkColor *
+parse_color_ (const gchar *str)
+{
+ static GdkColor color;
+ if (sscanf (str, "%hd%hd%hd", &(color.red), &(color.green), &(color.blue)) < 3)
+ {
+ g_warning ("Wrong color spec: %s\n", str);
+ return NULL;
+ }
+
+ return &color;
+}
+
+static const gchar *
+color_to_string_ (const GdkColor *color)
+{
+ enum {LEN = 100};
+ static gchar buffer[LEN];
+ g_snprintf (buffer, LEN, "%hd %hd %hd", color->red, color->green, color->blue);
+ return buffer;
+}
static gboolean
init_color_ (GdkColor *c, const gchar *name)
{
- if (!colormap_)
- colormap_ = gtk_widget_get_colormap (GTK_WIDGET (clist_));
return (gdk_color_parse (name, c) &&
gdk_colormap_alloc_color (colormap_, c, FALSE, TRUE));
}
@@ -62,10 +88,23 @@ mixgtk_mixal_init (mix_vm_t *vm)
g_return_val_if_fail (clist_ != NULL, FALSE);
/* allocate colors */
+ colormap_ = gtk_widget_get_colormap (GTK_WIDGET (clist_));
for (i = 0; i < 3; ++i)
for (j = 0; j < 2; ++j)
- g_return_val_if_fail (init_color_ (&colors_[i][j], default_colors_[i][j]),
- FALSE);
+ {
+ const gchar *ccol = mixgtk_config_get (keys_[i][j]);
+ const GdkColor *color = NULL;
+ if (ccol && (color = parse_color_ (ccol)))
+ {
+ mixgtk_mixal_set_color (i, j, color);
+ }
+ else
+ {
+ g_return_val_if_fail (init_color_
+ (&colors_[i][j], default_colors_[i][j]),
+ FALSE);
+ }
+ }
return TRUE;
}
@@ -82,6 +121,8 @@ mixgtk_mixal_set_color (mixal_line_t line, mixal_line_zone_t zone,
colors_[line][zone].blue = color->blue;
gdk_colormap_alloc_color (colormap_, &colors_[line][zone], FALSE, TRUE);
mixgtk_mixal_update_bp_all ();
+ mixgtk_config_update (keys_[line][zone],
+ color_to_string_(&colors_[line][zone]));
}
const GdkColor *