~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpenumlabel.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 
3
 *
 
4
 * gimpenumlabel.c
 
5
 * Copyright (C) 2005  Sven Neumann <sven@gimp.org>
 
6
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
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.
 
21
 */
 
22
 
 
23
#include "config.h"
 
24
 
 
25
#include <gtk/gtk.h>
 
26
 
 
27
#include "libgimpbase/gimpbase.h"
 
28
 
 
29
#include "gimpwidgetstypes.h"
 
30
 
 
31
#include "gimpenumlabel.h"
 
32
 
 
33
 
 
34
static void   gimp_enum_label_finalize (GObject *object);
 
35
 
 
36
 
 
37
G_DEFINE_TYPE (GimpEnumLabel, gimp_enum_label, GTK_TYPE_LABEL)
 
38
 
 
39
#define parent_class gimp_enum_label_parent_class
 
40
 
 
41
 
 
42
static void
 
43
gimp_enum_label_class_init (GimpEnumLabelClass *klass)
 
44
{
 
45
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
46
 
 
47
  object_class->finalize = gimp_enum_label_finalize;
 
48
}
 
49
 
 
50
static void
 
51
gimp_enum_label_init (GimpEnumLabel *enum_label)
 
52
{
 
53
}
 
54
 
 
55
static void
 
56
gimp_enum_label_finalize (GObject *object)
 
57
{
 
58
  GimpEnumLabel *enum_label = GIMP_ENUM_LABEL (object);
 
59
 
 
60
  if (enum_label->enum_class)
 
61
    g_type_class_unref (enum_label->enum_class);
 
62
 
 
63
  G_OBJECT_CLASS (parent_class)->finalize (object);
 
64
}
 
65
 
 
66
/**
 
67
 * gimp_enum_label_new:
 
68
 * @enum_type: the #GType of an enum.
 
69
 * @value:
 
70
 *
 
71
 * Return value: a new #GimpEnumLabel.
 
72
 *
 
73
 * Since: GIMP 2.4
 
74
 **/
 
75
GtkWidget *
 
76
gimp_enum_label_new (GType enum_type,
 
77
                     gint  value)
 
78
{
 
79
  GimpEnumLabel *label;
 
80
 
 
81
  g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL);
 
82
 
 
83
  label = g_object_new (GIMP_TYPE_ENUM_LABEL, NULL);
 
84
 
 
85
  label->enum_class = g_type_class_ref (enum_type);
 
86
 
 
87
  gimp_enum_label_set_value (label, value);
 
88
 
 
89
  return GTK_WIDGET (label);
 
90
}
 
91
 
 
92
/**
 
93
 * gimp_enum_label_set_value
 
94
 * @label: a #GimpEnumLabel
 
95
 * @value:
 
96
 *
 
97
 * Since: GIMP 2.4
 
98
 **/
 
99
void
 
100
gimp_enum_label_set_value (GimpEnumLabel *label,
 
101
                           gint           value)
 
102
{
 
103
  const gchar *desc;
 
104
 
 
105
  g_return_if_fail (GIMP_IS_ENUM_LABEL (label));
 
106
 
 
107
  if (! gimp_enum_get_value (G_TYPE_FROM_CLASS (label->enum_class), value,
 
108
                             NULL, NULL, &desc, NULL))
 
109
    {
 
110
      g_warning ("%s: %d is not valid for enum of type '%s'",
 
111
                 G_STRLOC, value,
 
112
                 g_type_name (G_TYPE_FROM_CLASS (label->enum_class)));
 
113
      return;
 
114
    }
 
115
 
 
116
  gtk_label_set_text (GTK_LABEL (label), desc);
 
117
}