2 * color-combo-color-menu-item.c
3 * Copyright (C) 2008 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "color-combo-color-menu-item.h"
25 #include <glib/gi18n.h>
28 #include "color-swatch.h"
34 /*===========================================*/
35 /* Private macros and constants. */
36 /*===========================================*/
41 /*===========================================*/
43 /*===========================================*/
45 struct _glColorComboColorMenuItemPrivate {
53 /*===========================================*/
55 /*===========================================*/
58 /*===========================================*/
59 /* Local function prototypes */
60 /*===========================================*/
62 static void gl_color_combo_color_menu_item_finalize (GObject *object);
65 /****************************************************************************/
66 /* Boilerplate Object stuff. */
67 /****************************************************************************/
68 G_DEFINE_TYPE (glColorComboColorMenuItem, gl_color_combo_color_menu_item, GTK_TYPE_MENU_ITEM)
71 /*****************************************************************************/
72 /* Class Init Function. */
73 /*****************************************************************************/
75 gl_color_combo_color_menu_item_class_init (glColorComboColorMenuItemClass *class)
77 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
79 gl_color_combo_color_menu_item_parent_class = g_type_class_peek_parent (class);
81 gobject_class->finalize = gl_color_combo_color_menu_item_finalize;
85 /*****************************************************************************/
86 /* Object Instance Init Function. */
87 /*****************************************************************************/
89 gl_color_combo_color_menu_item_init (glColorComboColorMenuItem *this)
91 this->priv = g_new0 (glColorComboColorMenuItemPrivate, 1);
95 /*****************************************************************************/
96 /* Finalize Method. */
97 /*****************************************************************************/
99 gl_color_combo_color_menu_item_finalize (GObject *object)
101 glColorComboColorMenuItem *this = GL_COLOR_COMBO_COLOR_MENU_ITEM (object);
103 g_return_if_fail (object != NULL);
104 g_return_if_fail (GL_IS_COLOR_COMBO_COLOR_MENU_ITEM (object));
108 G_OBJECT_CLASS (gl_color_combo_color_menu_item_parent_class)->finalize (object);
112 /*****************************************************************************/
113 /** New Object Generator. */
114 /*****************************************************************************/
116 gl_color_combo_color_menu_item_new (gint id,
120 glColorComboColorMenuItem *this;
122 this = g_object_new (GL_TYPE_COLOR_COMBO_COLOR_MENU_ITEM, NULL);
126 this->priv->swatch = gl_color_swatch_new (SIZE, SIZE, color);
127 gtk_container_add (GTK_CONTAINER (this), this->priv->swatch);
129 gtk_widget_set_tooltip_text (GTK_WIDGET (this), tip);
131 return GTK_WIDGET (this);
135 /*****************************************************************************/
137 /*****************************************************************************/
139 gl_color_combo_color_menu_item_set_color(glColorComboColorMenuItem *this,
146 gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch), color);
148 gtk_widget_set_tooltip_text (GTK_WIDGET (this), tip);
152 /*****************************************************************************/
154 /*****************************************************************************/
156 gl_color_combo_color_menu_item_get_id (glColorComboColorMenuItem *this)
158 return this->priv->id;
164 * Local Variables: -- emacs
166 * c-basic-offset: 8 -- emacs
167 * tab-width: 8 -- emacs
168 * indent-tabs-mode: nil -- emacs