1
/* LIBGIMP - The GIMP Library
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
5
* Copyright (C) 2005 Sven Neumann <sven@gimp.org>
7
* This library is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2 of the License, or (at your option) any later version.
12
* This library 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 GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this library; if not, write to the
19
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
* Boston, MA 02111-1307, USA.
27
#include "libgimpbase/gimpbase.h"
29
#include "gimpwidgetstypes.h"
31
#include "gimpenumlabel.h"
34
static void gimp_enum_label_finalize (GObject *object);
37
G_DEFINE_TYPE (GimpEnumLabel, gimp_enum_label, GTK_TYPE_LABEL)
39
#define parent_class gimp_enum_label_parent_class
43
gimp_enum_label_class_init (GimpEnumLabelClass *klass)
45
GObjectClass *object_class = G_OBJECT_CLASS (klass);
47
object_class->finalize = gimp_enum_label_finalize;
51
gimp_enum_label_init (GimpEnumLabel *enum_label)
56
gimp_enum_label_finalize (GObject *object)
58
GimpEnumLabel *enum_label = GIMP_ENUM_LABEL (object);
60
if (enum_label->enum_class)
61
g_type_class_unref (enum_label->enum_class);
63
G_OBJECT_CLASS (parent_class)->finalize (object);
67
* gimp_enum_label_new:
68
* @enum_type: the #GType of an enum.
71
* Return value: a new #GimpEnumLabel.
76
gimp_enum_label_new (GType enum_type,
81
g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
83
label = g_object_new (GIMP_TYPE_ENUM_LABEL, NULL);
85
label->enum_class = g_type_class_ref (enum_type);
87
gimp_enum_label_set_value (label, value);
89
return GTK_WIDGET (label);
93
* gimp_enum_label_set_value
94
* @label: a #GimpEnumLabel
100
gimp_enum_label_set_value (GimpEnumLabel *label,
105
g_return_if_fail (GIMP_IS_ENUM_LABEL (label));
107
if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (label->enum_class), value,
108
NULL, NULL, &desc, NULL))
110
g_warning ("%s: %d is not valid for enum of type '%s'",
112
g_type_name (G_TYPE_FROM_CLASS (label->enum_class)));
116
gtk_label_set_text (GTK_LABEL (label), desc);