2
* Copyright © 2009 Christian Persch
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2.1 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Lesser General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
24
#include "games-frame.h"
31
G_DEFINE_TYPE (GamesFrame, games_frame, GTK_TYPE_BOX);
33
struct GamesFramePrivate {
39
games_frame_init (GamesFrame * frame)
41
GtkBox *box = GTK_BOX (frame);
42
PangoAttrList *attr_list;
45
frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, GAMES_TYPE_FRAME, GamesFramePrivate);
47
gtk_box_set_spacing (box, 6);
48
gtk_box_set_homogeneous (box, FALSE);
49
gtk_orientable_set_orientation (GTK_ORIENTABLE (frame), GTK_ORIENTATION_VERTICAL);
51
frame->priv->label = gtk_label_new (NULL);
52
gtk_misc_set_alignment (GTK_MISC (frame->priv->label), 0.0, 0.5);
54
attr_list = pango_attr_list_new ();
55
attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
56
attr->start_index = 0;
58
pango_attr_list_insert (attr_list, attr);
59
gtk_label_set_attributes (GTK_LABEL (frame->priv->label), attr_list);
60
pango_attr_list_unref (attr_list);
62
frame->priv->alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
63
gtk_alignment_set_padding (GTK_ALIGNMENT (frame->priv->alignment), 0, 0, 12, 0);
65
gtk_box_pack_start (box, frame->priv->label, FALSE, FALSE, 0);
66
gtk_box_pack_start (box, frame->priv->alignment, TRUE, TRUE, 0);
68
gtk_widget_set_no_show_all (frame->priv->label, TRUE);
69
gtk_widget_show (frame->priv->alignment);
73
add_atk_relation (GtkWidget *widget, GtkWidget *other, AtkRelationType type)
76
AtkRelation *relation;
79
object = gtk_widget_get_accessible (other);
80
set = atk_object_ref_relation_set (gtk_widget_get_accessible (widget));
81
relation = atk_relation_new (&object, 1, type);
82
atk_relation_set_add (set, relation);
83
g_object_unref (relation);
88
games_frame_add (GtkContainer *container,
91
GamesFrame *frame = GAMES_FRAME (container);
93
gtk_container_add (GTK_CONTAINER (frame->priv->alignment), child);
95
add_atk_relation (frame->priv->label, child, ATK_RELATION_LABEL_FOR);
96
add_atk_relation (child, frame->priv->label, ATK_RELATION_LABELLED_BY);
100
games_frame_set_property (GObject *object,
105
GamesFrame *frame = GAMES_FRAME (object);
109
games_frame_set_label (frame, g_value_get_string (value));
113
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
119
games_frame_class_init (GamesFrameClass * klass)
121
GObjectClass *object_class = G_OBJECT_CLASS (klass);
122
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
124
object_class->set_property = games_frame_set_property;
125
container_class->add = games_frame_add;
127
g_type_class_add_private (object_class, sizeof (GamesFramePrivate));
129
g_object_class_install_property
132
g_param_spec_string ("label", NULL, NULL,
135
G_PARAM_STATIC_NAME |
136
G_PARAM_STATIC_NICK |
137
G_PARAM_STATIC_BLURB));
142
* @label: the frame's title, or %NULL
144
* Returns: a new #GamesFrame
147
games_frame_new (const char * label)
149
return g_object_new (GAMES_TYPE_FRAME,
155
* games_frame_set_label:
159
* Sets @frame's title label.
162
games_frame_set_label (GamesFrame *frame,
165
g_return_if_fail (GAMES_IS_FRAME (frame));
168
gtk_label_set_text (GTK_LABEL (frame->priv->label), label);
170
gtk_label_set_text (GTK_LABEL (frame->priv->label), "");
173
g_object_set (frame->priv->label, "visible", label && label[0], NULL);
175
g_object_notify (G_OBJECT (frame), "label");