grim/guifications3

e62da38a5799
removed gflib-query-plugins since we're using gplugin now...
/*
* Guifications - The end-all, be-all notification framework
* Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <gflib-gtk/gf_gtk_color.h>
/******************************************************************************
* Color API
*****************************************************************************/
/**
* gf_color_to_gdk_color:
* @gf_color : The #GfColor.
* @gdk_color : The #GdkColor.
*
* Converts a #GfColor to a #GdkColor.
*/
void
gf_color_to_gdk_color(const GfColor *gf_color, GdkColor *gdk_color) {
g_return_if_fail(gf_color);
g_return_if_fail(gdk_color);
gdk_color->red = gf_color->red;
gdk_color->green = gf_color->green;
gdk_color->blue = gf_color->blue;
}
/**
* gf_color_from_gdk_color:
* @gdk_color : The #GdkColor.
* @gf_color : The #GfColor.
*
* Converts a #GdkColor to a #GfColor.
*/
void
gf_color_from_gdk_color(const GdkColor *gdk_color, GfColor *gf_color) {
g_return_if_fail(gdk_color);
g_return_if_fail(gf_color);
gf_color->red = gdk_color->red;
gf_color->green = gdk_color->green;
gf_color->blue = gdk_color->blue;
}
/******************************************************************************
* Colormap Structs
*****************************************************************************/
/******************************************************************************
* Colormap Enums
*****************************************************************************/
enum {
PROP_ZERO = 0,
PROP_NATIVE,
PROP_LAST
};
/******************************************************************************
* Colormap Globals
*****************************************************************************/
static GfColormapClass *parent_class = NULL;
/******************************************************************************
* Colormap mapping
*****************************************************************************/
static gint
gf_gtk_colormap_alloc_colors(GfColormap *colormap,
GfColor *colors, gint ncolors,
gboolean writable, gboolean best_match,
gboolean *success)
{
GfGtkColormap *cmap = GF_GTK_COLORMAP(colormap);
gint ret = ncolors;
ret = gdk_colormap_alloc_colors(cmap->native,
(GdkColor *)colors, ncolors,
writable, best_match, success);
return ret;
}
static void
gf_gtk_colormap_free_colors(GfColormap *colormap, GfColor *colors,
gint ncolors)
{
GfGtkColormap *cmap = GF_GTK_COLORMAP(colormap);
gdk_colormap_free_colors(cmap->native, (GdkColor *)colors, ncolors);
}
static void
gf_gtk_colormap_query_color(GfColormap *colormap, gulong pixel,
GfColor *result)
{
GfGtkColormap *cmap = GF_GTK_COLORMAP(colormap);
gdk_colormap_query_color(cmap->native, pixel, (GdkColor *)result);
}
/******************************************************************************
* Colormap Object stuff
*****************************************************************************/
static void
gf_gtk_colormap_get_property(GObject *obj, guint param_id, GValue *value,
GParamSpec *pspec)
{
}
static void
gf_gtk_colormap_set_property(GObject *obj, guint param_id, const GValue *value,
GParamSpec *pspec)
{
}
static void
gf_gtk_colormap_finalize(GObject *obj) {
GfGtkColormap *cmap = GF_GTK_COLORMAP(obj);
if(GDK_IS_COLORMAP(cmap->native))
g_object_unref(G_OBJECT(cmap->native));
G_OBJECT_CLASS(parent_class)->finalize(obj);
}
static void
gf_gtk_colormap_class_init(GfGtkColormap *klass) {
GfColormapClass *cmap_class = GF_COLORMAP_CLASS(klass);
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
obj_class->finalize = gf_gtk_colormap_finalize;
obj_class->get_property = gf_gtk_colormap_get_property;
obj_class->set_property = gf_gtk_colormap_set_property;
cmap_class->alloc_colors = gf_gtk_colormap_alloc_colors;
cmap_class->free_colors = gf_gtk_colormap_free_colors;
cmap_class->query_color = gf_gtk_colormap_query_color;
}
/******************************************************************************
* Colormap API
*****************************************************************************/
GType
gf_gtk_colormap_get_gtype(void) {
static GType type = 0;
if(type == 0) {
static const GTypeInfo info = {
sizeof(GfGtkColormapClass),
NULL,
NULL,
(GClassInitFunc)gf_gtk_colormap_class_init,
NULL,
NULL,
sizeof(GfGtkColormap),
0,
NULL,
};
type = g_type_register_static(GF_TYPE_COLORMAP, "GfGtkColormap",
&info, 0);
}
return type;
}