annotate src/cellrenderericon.c @ 453:08978246acef

Add missing shortcuts.
author zas_
date Sun, 20 Apr 2008 22:14:54 +0000
parents ddabc4873a3f
children f9bf33be53ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
1 /* cellrenderericon.c, based on:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
2 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
3 * gtkcellrendererpixbuf.c
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
4 * Copyright (C) 2000 Red Hat, Inc., Jonathan Blandford <jrb@redhat.com>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
5 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
6 * This library is free software; you can redistribute it and/or
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
7 * modify it under the terms of the GNU Library General Public
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
9 * version 2 of the License, or (at your option) any later version.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
10 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
14 * Library General Public License for more details.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
15 *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
16 * You should have received a copy of the GNU Library General Public
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
17 * License along with this library; if not, write to the
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
19 * Boston, MA 02111-1307, USA.
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
20 */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
21
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
22 #include <stdlib.h>
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
23 #include "cellrenderericon.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
24 #include "intl.h"
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
25
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
26
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
27 #define FIXED_ICON_SIZE_MAX 512
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
28
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
29 static void gqv_cell_renderer_icon_get_property(GObject *object,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
30 guint param_id,
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
31 GValue *value,
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
32 GParamSpec *pspec);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
33 static void gqv_cell_renderer_icon_set_property(GObject *object,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
34 guint param_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
35 const GValue *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
36 GParamSpec *pspec);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
37 static void gqv_cell_renderer_icon_init(GQvCellRendererIcon *celltext);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
38 static void gqv_cell_renderer_icon_class_init(GQvCellRendererIconClass *class);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
39 static void gqv_cell_renderer_icon_finalize(GObject *object);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
40 static void gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
41 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
42 GdkRectangle *rectangle,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
43 gint *x_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
44 gint *y_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
45 gint *width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
46 gint *height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
47 static void gqv_cell_renderer_icon_render(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
48 GdkWindow *window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
49 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
50 GdkRectangle *background_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
51 GdkRectangle *cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
52 GdkRectangle *expose_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
53 GtkCellRendererState flags);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
54
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
55
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
56 enum {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
57 PROP_ZERO,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
58 PROP_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
59 PROP_TEXT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
60 PROP_BACKGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
61 PROP_FOREGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
62 PROP_FOCUSED,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
63 PROP_FIXED_WIDTH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
64 PROP_FIXED_HEIGHT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
65
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
66 PROP_BACKGROUND_SET,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
67 PROP_FOREGROUND_SET,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
68 PROP_SHOW_TEXT
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
69 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
70
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
71 static gpointer parent_class;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
72
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
73 GType
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
74 gqv_cell_renderer_icon_get_type (void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
75 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
76 static GType cell_icon_type = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
77
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
78 if (!cell_icon_type)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
79 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
80 static const GTypeInfo cell_icon_info =
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
81 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
82 sizeof (GQvCellRendererIconClass),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
83 NULL, /* base_init */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
84 NULL, /* base_finalize */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
85 (GClassInitFunc) gqv_cell_renderer_icon_class_init,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
86 NULL, /* class_finalize */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
87 NULL, /* class_data */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
88 sizeof (GQvCellRendererIcon),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 0, /* n_preallocs */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
90 (GInstanceInitFunc) gqv_cell_renderer_icon_init,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
91 };
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93 cell_icon_type = g_type_register_static(GTK_TYPE_CELL_RENDERER,
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
94 "GQvCellRendererIcon",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
95 &cell_icon_info, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
96 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
97
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98 return cell_icon_type;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
100
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
101 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 gqv_cell_renderer_icon_init (GQvCellRendererIcon *cellicon)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
103 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 GTK_CELL_RENDERER(cellicon)->xpad = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 GTK_CELL_RENDERER(cellicon)->ypad = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
107
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
108 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 gqv_cell_renderer_icon_class_init (GQvCellRendererIconClass *class)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 GObjectClass *object_class = G_OBJECT_CLASS (class);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
112 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114 parent_class = g_type_class_peek_parent (class);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
115
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116 object_class->finalize = gqv_cell_renderer_icon_finalize;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118 object_class->get_property = gqv_cell_renderer_icon_get_property;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 object_class->set_property = gqv_cell_renderer_icon_set_property;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121 cell_class->get_size = gqv_cell_renderer_icon_get_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 cell_class->render = gqv_cell_renderer_icon_render;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 PROP_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 g_param_spec_object("pixbuf",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 _("Pixbuf Object"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 _("The pixbuf to render"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 GDK_TYPE_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 PROP_TEXT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 g_param_spec_string("text",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 _("Text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 _("Text to render"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 PROP_BACKGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 g_param_spec_boxed("background_gdk",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 _("Background color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 _("Background color as a GdkColor"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 GDK_TYPE_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 PROP_FOREGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 g_param_spec_boxed("foreground_gdk",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 _("Foreground color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 _("Foreground color as a GdkColor"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 GDK_TYPE_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 PROP_FOCUSED,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 g_param_spec_boolean ("has_focus",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
159 _("Focus"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 _("Draw focus indicator"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 PROP_FIXED_WIDTH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 g_param_spec_int("fixed_width",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 _("Fixed width"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 _("Width of cell"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 -1, FIXED_ICON_SIZE_MAX,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 PROP_FIXED_HEIGHT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 g_param_spec_int("fixed_height",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 _("Fixed height"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 _("Height of icon excluding text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 -1, FIXED_ICON_SIZE_MAX,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 PROP_BACKGROUND_SET,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 g_param_spec_boolean("background_set",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 _("Background set"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 _("Whether this tag affects the background color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 PROP_FOREGROUND_SET,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 g_param_spec_boolean ("foreground_set",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
193 _("Foreground set"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 _("Whether this tag affects the foreground color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 PROP_SHOW_TEXT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 g_param_spec_boolean("show_text",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 _("Show text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 _("Whether the text is displayed"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
206
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
207 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 gqv_cell_renderer_icon_finalize (GObject *object)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON (object);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212 if (cellicon->pixbuf) g_object_unref (cellicon->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
213
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214 g_free(cellicon->text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
217 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
218
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
219 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 gqv_cell_renderer_icon_get_property(GObject *object,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 guint param_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 GValue *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 GParamSpec *pspec)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON (object);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
226
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
227 switch (param_id)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
229 case PROP_PIXBUF:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
230 g_value_set_object(value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 cellicon->pixbuf ? G_OBJECT (cellicon->pixbuf) : NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 case PROP_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 g_value_set_string (value, cellicon->text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 case PROP_BACKGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238 GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 color.red = cellicon->background.red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 color.green = cellicon->background.green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242 color.blue = cellicon->background.blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
243
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 g_value_set_boxed (value, &color);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 case PROP_FOREGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249 GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 color.red = cellicon->foreground.red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 color.green = cellicon->foreground.green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253 color.blue = cellicon->foreground.blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
254
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 g_value_set_boxed (value, &color);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
258 case PROP_FOCUSED:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 g_value_set_boolean (value, cellicon->focused);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 case PROP_FIXED_WIDTH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 g_value_set_int(value, cellicon->fixed_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 case PROP_FIXED_HEIGHT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 g_value_set_int(value, cellicon->fixed_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 case PROP_BACKGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 g_value_set_boolean(value, cellicon->background_set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 case PROP_FOREGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 g_value_set_boolean(value, cellicon->foreground_set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 case PROP_SHOW_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 g_value_set_boolean(value, cellicon->show_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
276 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
279 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
280 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
281
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
282 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
283 set_bg_color (GQvCellRendererIcon *cellicon,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 GdkColor *color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 if (color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 if (!cellicon->background_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 cellicon->background_set = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 g_object_notify(G_OBJECT(cellicon), "background_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
292 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
293
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 cellicon->background.red = color->red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 cellicon->background.green = color->green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 cellicon->background.blue = color->blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 if (cellicon->background_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 cellicon->background_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 g_object_notify(G_OBJECT(cellicon), "background_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
304 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
305 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
306 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
307
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
308 static void set_fg_color (GQvCellRendererIcon *cellicon,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 GdkColor *color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 if (color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 if (!cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 cellicon->foreground_set = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 g_object_notify(G_OBJECT(cellicon), "foreground_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
317 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
318
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 cellicon->foreground.red = color->red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 cellicon->foreground.green = color->green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 cellicon->foreground.blue = color->blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 if (cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 cellicon->foreground_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 g_object_notify(G_OBJECT(cellicon), "foreground_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
329 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
330 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
331 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
332
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 gqv_cell_renderer_icon_set_property(GObject *object,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 guint param_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 const GValue *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 GParamSpec *pspec)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
338 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
339 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON (object);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
340
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
341 switch (param_id)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
342 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 case PROP_PIXBUF:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
347 pixbuf = (GdkPixbuf*) g_value_get_object (value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
348 if (pixbuf) g_object_ref (pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
349 if (cellicon->pixbuf) g_object_unref (cellicon->pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
350 cellicon->pixbuf = pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 case PROP_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 text = cellicon->text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 cellicon->text = g_strdup(g_value_get_string(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 g_object_notify(object, "text");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 case PROP_BACKGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 set_bg_color(cellicon, g_value_get_boxed(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 case PROP_FOREGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 set_fg_color(cellicon, g_value_get_boxed(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 case PROP_FOCUSED:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 cellicon->focused = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 case PROP_FIXED_WIDTH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 cellicon->fixed_width = g_value_get_int(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 case PROP_FIXED_HEIGHT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 cellicon->fixed_height = g_value_get_int(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 case PROP_BACKGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 cellicon->background_set = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 case PROP_FOREGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 cellicon->foreground_set = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 case PROP_SHOW_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 cellicon->show_text = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
388 default:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
391 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
392 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
393
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 static PangoLayout *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
395 gqv_cell_renderer_icon_get_layout(GQvCellRendererIcon *cellicon, GtkWidget *widget, gboolean will_render)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398 gint width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400 width = (cellicon->fixed_width > 0) ? cellicon->fixed_width * PANGO_SCALE : -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 layout = gtk_widget_create_pango_layout(widget, cellicon->text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 pango_layout_set_width(layout, width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 if (will_render)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409 PangoAttrList *attr_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411 attr_list = pango_attr_list_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 if (cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 PangoColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416 PangoAttribute *attr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418 color = cellicon->foreground;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420 attr = pango_attr_foreground_new(color.red, color.green, color.blue);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 attr->start_index = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 attr->end_index = G_MAXINT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 pango_attr_list_insert(attr_list, attr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
425 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
426
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 pango_layout_set_attributes(layout, attr_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 pango_attr_list_unref(attr_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
429 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
430
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 return layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
432 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
433
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
434 /**
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
435 * gqv_cell_renderer_icon_new:
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
436 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 * Creates a new #GQvCellRendererIcon. Adjust rendering
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 * parameters using object properties. Object properties can be set
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
440 * can bind a property to a value in a #GtkTreeModel. For example, you
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
441 * can bind the "pixbuf" property on the cell renderer to a pixbuf value
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
442 * in the model, thus rendering a different image in each row of the
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
443 * #GtkTreeView.
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
444 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 * Return value: the new cell renderer
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 **/
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 GtkCellRenderer *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 gqv_cell_renderer_icon_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
449 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 return g_object_new (GQV_TYPE_CELL_RENDERER_ICON, NULL);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
451 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
452
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 GdkRectangle *cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gint *x_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 gint *y_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 gint *width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 gint *height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 gint calc_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464 gint calc_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 if (cellicon->fixed_width > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 calc_width = cellicon->fixed_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 calc_width = (cellicon->pixbuf) ? gdk_pixbuf_get_width(cellicon->pixbuf) : 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
473 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
474
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 if (cellicon->fixed_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 calc_height = cellicon->fixed_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 calc_height = (cellicon->pixbuf) ? gdk_pixbuf_get_height(cellicon->pixbuf) : 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
482 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
483
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 if (cellicon->show_text && cellicon->text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487 PangoRectangle rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 pango_layout_get_pixel_extents(layout, NULL, &rect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491 g_object_unref(layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 calc_width = MAX(calc_width, rect.width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 calc_height += rect.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
495 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
496
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 calc_width += (gint)cell->xpad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498 calc_height += (gint)cell->ypad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 if (x_offset) *x_offset = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501 if (y_offset) *y_offset = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 if (cell_area && calc_width > 0 && calc_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 if (x_offset)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
507 *x_offset = (cell->xalign * (cell_area->width - calc_width - 2 * cell->xpad));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 *x_offset = MAX (*x_offset, 0) + cell->xpad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 if (y_offset)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
512 *y_offset = (cell->yalign * (cell_area->height - calc_height - 2 * cell->ypad));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 *y_offset = MAX (*y_offset, 0) + cell->ypad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
514 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
515 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
516
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 if (width) *width = calc_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 if (height) *height = calc_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
519 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
520
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 gqv_cell_renderer_icon_render(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 GdkWindow *window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 GdkRectangle *background_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 GdkRectangle *cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 GdkRectangle *expose_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528 GtkCellRendererState flags)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
529
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
530 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 GdkRectangle cell_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535 GtkStateType state;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 pixbuf = cellicon->pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538 text = cellicon->text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540 if (!pixbuf && !text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 gqv_cell_renderer_icon_get_size(cell, widget, cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 &cell_rect.x, &cell_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544 &cell_rect.width, &cell_rect.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 cell_rect.x += cell->xpad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 cell_rect.y += cell->ypad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 cell_rect.width -= cell->xpad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549 cell_rect.height -= cell->ypad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 if (GTK_WIDGET_HAS_FOCUS(widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 state = GTK_STATE_SELECTED;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 state = GTK_STATE_ACTIVE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 if (GTK_WIDGET_STATE(widget) == GTK_STATE_INSENSITIVE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 state = GTK_STATE_INSENSITIVE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 state = GTK_STATE_NORMAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
564 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
565
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 GdkRectangle pix_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569 GdkRectangle draw_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 pix_rect.width = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572 pix_rect.height = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
574 pix_rect.x = cell_area->x + (cell_area->width - pix_rect.width) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 if (cellicon->fixed_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
578 pix_rect.y = cell_area->y + cell->ypad + (cellicon->fixed_height - pix_rect.height) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 pix_rect.y = cell_area->y + cell_rect.y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
583 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
584
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 gdk_draw_pixbuf(window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 widget->style->black_gc,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 draw_rect.x - pix_rect.x,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 draw_rect.y - pix_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 draw_rect.x,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 draw_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 draw_rect.width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 draw_rect.height,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 GDK_RGB_DITHER_NORMAL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
600 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
601 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
602
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 if (cellicon->show_text && text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 PangoRectangle text_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
607 GdkRectangle pix_rect;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
608 GdkRectangle draw_rect;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611 pango_layout_get_pixel_extents(layout, NULL, &text_rect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 pix_rect.width = text_rect.width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 pix_rect.height = text_rect.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
615 pix_rect.x = cell_area->x + cell->xpad + (cell_rect.width - text_rect.width + 1) / 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
616 pix_rect.y = cell_area->y + cell->ypad + (cell_rect.height - text_rect.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 gtk_paint_layout(widget->style, window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 state, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 cell_area, widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 "cellrenderertext",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 pix_rect.x - text_rect.x, pix_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
627 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
628
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 g_object_unref(layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
631
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 if (cellicon->focused &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 GTK_WIDGET_HAS_FOCUS(widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 gtk_paint_focus(widget->style, window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 state,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 cell_area, widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 "cellrendererfocus",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 cell_area->x, cell_area->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 cell_area->width, cell_area->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
642 }