link ColorDisplay modules with libgimpconfig.
2005-02-05 Sven Neumann <sven@gimp.org> * modules/Makefile.am: link ColorDisplay modules with libgimpconfig. * modules/cdisplay_colorblind.c: added the GimpConfig interface and use it.
This commit is contained in:

committed by
Sven Neumann

parent
5cf9a16f9f
commit
3e7c5ff976
@ -1,3 +1,10 @@
|
|||||||
|
2005-02-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* modules/Makefile.am: link ColorDisplay modules with libgimpconfig.
|
||||||
|
|
||||||
|
* modules/cdisplay_colorblind.c: added the GimpConfig interface
|
||||||
|
and use it.
|
||||||
|
|
||||||
2005-02-05 Sven Neumann <sven@gimp.org>
|
2005-02-05 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* libgimpwidgets/gimppropwidgets.[ch]: documentation fixes.
|
* libgimpwidgets/gimppropwidgets.[ch]: documentation fixes.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
|
||||||
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
|
||||||
|
libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
|
||||||
libgimpmodule = $(top_builddir)/libgimpmodule/libgimpmodule-$(GIMP_API_VERSION).la
|
libgimpmodule = $(top_builddir)/libgimpmodule/libgimpmodule-$(GIMP_API_VERSION).la
|
||||||
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
|
libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
|
||||||
|
|
||||||
@ -39,9 +40,12 @@ lib_LTLIBRARIES = \
|
|||||||
$(controller_linux_input_module)
|
$(controller_linux_input_module)
|
||||||
|
|
||||||
|
|
||||||
colorsel_libadd = $(libgimpcolor) $(libgimpmodule) $(libgimpwidgets) $(GTK_LIBS)
|
|
||||||
cdisplay_libadd = $(libgimpbase) $(libgimpmodule) $(libgimpwidgets) $(GTK_LIBS)
|
modules_libadd = $(libgimpmodule) $(libgimpwidgets) $(GTK_LIBS)
|
||||||
controller_libadd = $(libgimpmodule) $(libgimpwidgets) $(GTK_LIBS)
|
|
||||||
|
colorsel_libadd = $(libgimpcolor) $(modules_libadd)
|
||||||
|
cdisplay_libadd = $(libgimpbase) $(libgimpconfig) $(modules_libadd)
|
||||||
|
controller_libadd = $(modules_libadd)
|
||||||
|
|
||||||
libcolorsel_cmyk_la_SOURCES = colorsel_cmyk.c
|
libcolorsel_cmyk_la_SOURCES = colorsel_cmyk.c
|
||||||
libcolorsel_cmyk_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
libcolorsel_cmyk_la_LDFLAGS = -avoid-version -module $(no_undefined)
|
||||||
|
@ -28,15 +28,15 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "libgimpbase/gimpbase.h"
|
#include "libgimpbase/gimpbase.h"
|
||||||
|
#include "libgimpconfig/gimpconfig.h"
|
||||||
|
#include "libgimpmath/gimpmath.h"
|
||||||
#include "libgimpmodule/gimpmodule.h"
|
#include "libgimpmodule/gimpmodule.h"
|
||||||
#include "libgimpwidgets/gimpwidgets.h"
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
#include "libgimpmath/gimpmath.h"
|
|
||||||
|
|
||||||
#include "libgimp/libgimp-intl.h"
|
#include "libgimp/libgimp-intl.h"
|
||||||
|
|
||||||
@ -104,7 +104,6 @@ struct _CdisplayColorblind
|
|||||||
guint32 cache[2 * COLOR_CACHE_SIZE];
|
guint32 cache[2 * COLOR_CACHE_SIZE];
|
||||||
|
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *combo;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _CdisplayColorblindClass
|
struct _CdisplayColorblindClass
|
||||||
@ -153,10 +152,6 @@ static void cdisplay_colorblind_changed (GimpColorDisplay *displa
|
|||||||
static void cdisplay_colorblind_set_deficiency (CdisplayColorblind *colorblind,
|
static void cdisplay_colorblind_set_deficiency (CdisplayColorblind *colorblind,
|
||||||
ColorblindDeficiency value);
|
ColorblindDeficiency value);
|
||||||
|
|
||||||
static void colorblind_deficiency_callback (GtkWidget *widget,
|
|
||||||
CdisplayColorblind *colorblind);
|
|
||||||
|
|
||||||
|
|
||||||
static const GimpModuleInfo cdisplay_colorblind_info =
|
static const GimpModuleInfo cdisplay_colorblind_info =
|
||||||
{
|
{
|
||||||
GIMP_MODULE_ABI_VERSION,
|
GIMP_MODULE_ABI_VERSION,
|
||||||
@ -206,11 +201,20 @@ cdisplay_colorblind_get_type (GTypeModule *module)
|
|||||||
(GInstanceInitFunc) cdisplay_colorblind_init,
|
(GInstanceInitFunc) cdisplay_colorblind_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const GInterfaceInfo display_iface_info =
|
||||||
|
{
|
||||||
|
NULL, /* iface_init */
|
||||||
|
NULL, /* iface_finalize */
|
||||||
|
NULL /* iface_data */
|
||||||
|
};
|
||||||
|
|
||||||
cdisplay_colorblind_type =
|
cdisplay_colorblind_type =
|
||||||
g_type_module_register_type (module,
|
g_type_module_register_type (module,
|
||||||
GIMP_TYPE_COLOR_DISPLAY,
|
GIMP_TYPE_COLOR_DISPLAY,
|
||||||
"CdisplayColorblind",
|
"CdisplayColorblind",
|
||||||
&display_info, 0);
|
&display_info, 0);
|
||||||
|
g_type_add_interface_static (cdisplay_colorblind_type,
|
||||||
|
GIMP_TYPE_CONFIG, &display_iface_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cdisplay_colorblind_type;
|
return cdisplay_colorblind_type;
|
||||||
@ -245,13 +249,11 @@ cdisplay_colorblind_class_init (CdisplayColorblindClass *klass)
|
|||||||
object_class->get_property = cdisplay_colorblind_get_property;
|
object_class->get_property = cdisplay_colorblind_get_property;
|
||||||
object_class->set_property = cdisplay_colorblind_set_property;
|
object_class->set_property = cdisplay_colorblind_set_property;
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_DEFICIENCY,
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DEFICIENCY,
|
||||||
g_param_spec_enum ("deficiency", NULL, NULL,
|
"deficiency", NULL,
|
||||||
CDISPLAY_TYPE_COLORBLIND_DEFICIENCY,
|
CDISPLAY_TYPE_COLORBLIND_DEFICIENCY,
|
||||||
DEFAULT_DEFICIENCY,
|
DEFAULT_DEFICIENCY,
|
||||||
G_PARAM_READWRITE |
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
|
||||||
G_PARAM_CONSTRUCT |
|
|
||||||
GIMP_MODULE_PARAM_SERIALIZE));
|
|
||||||
|
|
||||||
display_class->name = _("Color Deficient Vision");
|
display_class->name = _("Color Deficient Vision");
|
||||||
display_class->help_id = "gimp-colordisplay-colorblind";
|
display_class->help_id = "gimp-colordisplay-colorblind";
|
||||||
@ -369,14 +371,7 @@ cdisplay_colorblind_set_property (GObject *object,
|
|||||||
static GimpColorDisplay *
|
static GimpColorDisplay *
|
||||||
cdisplay_colorblind_clone (GimpColorDisplay *display)
|
cdisplay_colorblind_clone (GimpColorDisplay *display)
|
||||||
{
|
{
|
||||||
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
return GIMP_COLOR_DISPLAY (gimp_config_duplicate (GIMP_CONFIG (display)));
|
||||||
CdisplayColorblind *copy;
|
|
||||||
|
|
||||||
copy = CDISPLAY_COLORBLIND (gimp_color_display_new (G_TYPE_FROM_INSTANCE (colorblind)));
|
|
||||||
|
|
||||||
copy->deficiency = colorblind->deficiency;
|
|
||||||
|
|
||||||
return GIMP_COLOR_DISPLAY (copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -510,30 +505,26 @@ static void
|
|||||||
cdisplay_colorblind_load_state (GimpColorDisplay *display,
|
cdisplay_colorblind_load_state (GimpColorDisplay *display,
|
||||||
GimpParasite *state)
|
GimpParasite *state)
|
||||||
{
|
{
|
||||||
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
gimp_config_deserialize_string (GIMP_CONFIG (display),
|
||||||
const gchar *str;
|
gimp_parasite_data (state),
|
||||||
|
gimp_parasite_data_size (state),
|
||||||
str = gimp_parasite_data (state);
|
NULL, NULL);
|
||||||
|
|
||||||
if (str[gimp_parasite_data_size (state) - 1] == '\0')
|
|
||||||
{
|
|
||||||
gint value;
|
|
||||||
|
|
||||||
if (sscanf (str, "%d", &value) == 1)
|
|
||||||
cdisplay_colorblind_set_deficiency (colorblind, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GimpParasite *
|
static GimpParasite *
|
||||||
cdisplay_colorblind_save_state (GimpColorDisplay *display)
|
cdisplay_colorblind_save_state (GimpColorDisplay *display)
|
||||||
{
|
{
|
||||||
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
GimpParasite *parasite;
|
||||||
gchar buf[32];
|
gchar *str;
|
||||||
|
|
||||||
g_snprintf (buf, sizeof (buf), "%d", colorblind->deficiency);
|
str = gimp_config_serialize_to_string (GIMP_CONFIG (display), NULL);
|
||||||
|
|
||||||
return gimp_parasite_new ("Display/Colorblind", GIMP_PARASITE_PERSISTENT,
|
parasite = gimp_parasite_new ("Display/Colorblind",
|
||||||
strlen (buf) + 1, buf);
|
GIMP_PARASITE_PERSISTENT,
|
||||||
|
strlen (str) + 1, str);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
return parasite;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
@ -541,6 +532,7 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
|
|||||||
{
|
{
|
||||||
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
GtkWidget *combo;
|
||||||
|
|
||||||
if (colorblind->hbox)
|
if (colorblind->hbox)
|
||||||
gtk_widget_destroy (colorblind->hbox);
|
gtk_widget_destroy (colorblind->hbox);
|
||||||
@ -555,20 +547,13 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
|
|||||||
gtk_box_pack_start (GTK_BOX (colorblind->hbox), label, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (colorblind->hbox), label, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
colorblind->combo =
|
combo =
|
||||||
gimp_enum_combo_box_new (CDISPLAY_TYPE_COLORBLIND_DEFICIENCY);
|
gimp_prop_enum_combo_box_new (G_OBJECT (colorblind), "deficiency", 0, 0);
|
||||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (colorblind->combo),
|
|
||||||
colorblind->deficiency);
|
|
||||||
|
|
||||||
g_signal_connect (colorblind->combo, "changed",
|
gtk_box_pack_start (GTK_BOX (colorblind->hbox), combo, TRUE, TRUE, 0);
|
||||||
G_CALLBACK (colorblind_deficiency_callback),
|
gtk_widget_show (combo);
|
||||||
colorblind);
|
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (colorblind->hbox), colorblind->combo,
|
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
|
||||||
TRUE, TRUE, 0);
|
|
||||||
gtk_widget_show (colorblind->combo);
|
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), colorblind->combo);
|
|
||||||
|
|
||||||
return colorblind->hbox;
|
return colorblind->hbox;
|
||||||
}
|
}
|
||||||
@ -576,16 +561,7 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
|
|||||||
static void
|
static void
|
||||||
cdisplay_colorblind_configure_reset (GimpColorDisplay *display)
|
cdisplay_colorblind_configure_reset (GimpColorDisplay *display)
|
||||||
{
|
{
|
||||||
CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
|
gimp_config_reset (GIMP_CONFIG (display));
|
||||||
|
|
||||||
if (colorblind->combo)
|
|
||||||
{
|
|
||||||
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (colorblind->combo),
|
|
||||||
DEFAULT_DEFICIENCY);
|
|
||||||
colorblind->deficiency = DEFAULT_DEFICIENCY;
|
|
||||||
|
|
||||||
gimp_color_display_changed (GIMP_COLOR_DISPLAY (colorblind));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -682,14 +658,3 @@ cdisplay_colorblind_set_deficiency (CdisplayColorblind *colorblind,
|
|||||||
gimp_color_display_changed (GIMP_COLOR_DISPLAY (colorblind));
|
gimp_color_display_changed (GIMP_COLOR_DISPLAY (colorblind));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
colorblind_deficiency_callback (GtkWidget *widget,
|
|
||||||
CdisplayColorblind *colorblind)
|
|
||||||
{
|
|
||||||
gint value;
|
|
||||||
|
|
||||||
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value);
|
|
||||||
|
|
||||||
cdisplay_colorblind_set_deficiency (colorblind, value);
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user