annotate src/cellrenderericon.c @ 587:5963c394ba53

added .gqv to known file types
author nadvornik
date Mon, 05 May 2008 19:20:46 +0000
parents 0a2b8210ef1d
children 631d626c1f6b
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
74 gqv_cell_renderer_icon_get_type(void)
9
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 {
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
82 sizeof(GQvCellRendererIconClass),
9
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 */
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
88 sizeof(GQvCellRendererIcon),
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 0, /* n_preallocs */
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
90 (GInstanceInitFunc) gqv_cell_renderer_icon_init,
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
91 };
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
92
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
93 cell_icon_type = g_type_register_static(GTK_TYPE_CELL_RENDERER,
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
94 "GQvCellRendererIcon",
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
95 &cell_icon_info, 0);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
96 }
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
102 gqv_cell_renderer_icon_init(GQvCellRendererIcon *cellicon)
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
109 gqv_cell_renderer_icon_class_init(GQvCellRendererIconClass *class)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
110 {
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
111 GObjectClass *object_class = G_OBJECT_CLASS(class);
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
112 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
113
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
114 parent_class = g_type_class_peek_parent(class);
9
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,
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
158 g_param_spec_boolean("has_focus",
9
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,
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
192 g_param_spec_boolean("foreground_set",
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
208 gqv_cell_renderer_icon_finalize(GObject *object)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
209 {
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
210 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON(object);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
211
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
212 if (cellicon->pixbuf) g_object_unref(cellicon->pixbuf);
9
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
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
216 (*(G_OBJECT_CLASS(parent_class))->finalize)(object);
9
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 {
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
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)
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
228 {
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
229 case PROP_PIXBUF:
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
230 g_value_set_object(value, cellicon->pixbuf ? G_OBJECT(cellicon->pixbuf) : NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
231 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
232 case PROP_TEXT:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
233 g_value_set_string(value, cellicon->text);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
234 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
235 case PROP_BACKGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
236 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
237 GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
238
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
239 color.red = cellicon->background.red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
240 color.green = cellicon->background.green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
241 color.blue = cellicon->background.blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
242
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
243 g_value_set_boxed(value, &color);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
244 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
245 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
246 case PROP_FOREGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
247 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
248 GdkColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
249
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
250 color.red = cellicon->foreground.red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
251 color.green = cellicon->foreground.green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
252 color.blue = cellicon->foreground.blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
253
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
254 g_value_set_boxed(value, &color);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
255 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
256 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
257 case PROP_FOCUSED:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
258 g_value_set_boolean(value, cellicon->focused);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
259 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
260 case PROP_FIXED_WIDTH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
261 g_value_set_int(value, cellicon->fixed_width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
262 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
263 case PROP_FIXED_HEIGHT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
264 g_value_set_int(value, cellicon->fixed_height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
265 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
266 case PROP_BACKGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
267 g_value_set_boolean(value, cellicon->background_set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
268 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
269 case PROP_FOREGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
270 g_value_set_boolean(value, cellicon->foreground_set);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
271 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
272 case PROP_SHOW_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
273 g_value_set_boolean(value, cellicon->show_text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
274 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
275 default:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
276 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
277 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
278 }
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 static void
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
282 set_bg_color(GQvCellRendererIcon *cellicon,
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
283 GdkColor *color)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
284 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
285 if (color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
286 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
287 if (!cellicon->background_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
288 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
289 cellicon->background_set = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
290 g_object_notify(G_OBJECT(cellicon), "background_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
291 }
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 cellicon->background.red = color->red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
294 cellicon->background.green = color->green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
295 cellicon->background.blue = color->blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
296 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
297 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
298 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
299 if (cellicon->background_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
300 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
301 cellicon->background_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
302 g_object_notify(G_OBJECT(cellicon), "background_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
303 }
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
307 static void set_fg_color(GQvCellRendererIcon *cellicon,
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
308 GdkColor *color)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
309 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
310 if (color)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
311 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
312 if (!cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
313 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
314 cellicon->foreground_set = TRUE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
315 g_object_notify(G_OBJECT(cellicon), "foreground_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
316 }
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 cellicon->foreground.red = color->red;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
319 cellicon->foreground.green = color->green;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
320 cellicon->foreground.blue = color->blue;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
321 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
322 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
323 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
324 if (cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
325 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
326 cellicon->foreground_set = FALSE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
327 g_object_notify(G_OBJECT(cellicon), "foreground_set");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
328 }
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 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
333 gqv_cell_renderer_icon_set_property(GObject *object,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
334 guint param_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
335 const GValue *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
336 GParamSpec *pspec)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
337 {
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
338 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON(object);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
339
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
340 switch (param_id)
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
341 {
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
342 case PROP_PIXBUF:
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
343 {
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
344 GdkPixbuf *pixbuf;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
345
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
346 pixbuf = (GdkPixbuf*) g_value_get_object(value);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
347 if (pixbuf) g_object_ref(pixbuf);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
348 if (cellicon->pixbuf) g_object_unref(cellicon->pixbuf);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
349 cellicon->pixbuf = pixbuf;
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
350 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
351 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
352 case PROP_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
353 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
354 gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
355
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
356 text = cellicon->text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
357 cellicon->text = g_strdup(g_value_get_string(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
358 g_free(text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
359
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
360 g_object_notify(object, "text");
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
361 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
362 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
363 case PROP_BACKGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
364 set_bg_color(cellicon, g_value_get_boxed(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
365 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
366 case PROP_FOREGROUND_GDK:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
367 set_fg_color(cellicon, g_value_get_boxed(value));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
368 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
369 case PROP_FOCUSED:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
370 cellicon->focused = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
371 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
372 case PROP_FIXED_WIDTH:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
373 cellicon->fixed_width = g_value_get_int(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
374 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
375 case PROP_FIXED_HEIGHT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
376 cellicon->fixed_height = g_value_get_int(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
377 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
378 case PROP_BACKGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
379 cellicon->background_set = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
380 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
381 case PROP_FOREGROUND_SET:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
382 cellicon->foreground_set = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
383 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
384 case PROP_SHOW_TEXT:
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
385 cellicon->show_text = g_value_get_boolean(value);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
386 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
387 default:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
388 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
389 break;
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
390 }
9
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 static PangoLayout *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
394 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
395 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
396 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
397 gint width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
398
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
399 width = (cellicon->fixed_width > 0) ? cellicon->fixed_width * PANGO_SCALE : -1;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
400
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
401 layout = gtk_widget_create_pango_layout(widget, cellicon->text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
402 pango_layout_set_width(layout, width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
403 pango_layout_set_alignment(layout, PANGO_ALIGN_CENTER);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
404 pango_layout_set_wrap(layout, PANGO_WRAP_WORD_CHAR);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
405
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
406 if (will_render)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
407 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
408 PangoAttrList *attr_list;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
409
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
410 attr_list = pango_attr_list_new();
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
411
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
412 if (cellicon->foreground_set)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
413 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
414 PangoColor color;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
415 PangoAttribute *attr;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
416
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
417 color = cellicon->foreground;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
418
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
419 attr = pango_attr_foreground_new(color.red, color.green, color.blue);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
420
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
421 attr->start_index = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
422 attr->end_index = G_MAXINT;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
423 pango_attr_list_insert(attr_list, attr);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
424 }
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 pango_layout_set_attributes(layout, attr_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
427 pango_attr_list_unref(attr_list);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
428 }
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 return layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
431 }
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 * gqv_cell_renderer_icon_new:
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
435 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
436 * Creates a new #GQvCellRendererIcon. Adjust rendering
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
437 * parameters using object properties. Object properties can be set
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
438 * globally (with g_object_set()). Also, with #GtkTreeViewColumn, you
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
439 * 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
440 * 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
441 * 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
442 * #GtkTreeView.
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
443 *
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
444 * Return value: the new cell renderer
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
445 **/
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
446 GtkCellRenderer *
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
447 gqv_cell_renderer_icon_new(void)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
448 {
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
449 return g_object_new(GQV_TYPE_CELL_RENDERER_ICON, NULL);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
450 }
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 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
453 gqv_cell_renderer_icon_get_size(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
454 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
455 GdkRectangle *cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
456 gint *x_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
457 gint *y_offset,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
458 gint *width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
459 gint *height)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
460 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
461 GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
462 gint calc_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
463 gint calc_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
464
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
465 if (cellicon->fixed_width > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
466 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
467 calc_width = cellicon->fixed_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
468 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
469 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
470 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
471 calc_width = (cellicon->pixbuf) ? gdk_pixbuf_get_width(cellicon->pixbuf) : 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
472 }
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 if (cellicon->fixed_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
475 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
476 calc_height = cellicon->fixed_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
477 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
478 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
479 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
480 calc_height = (cellicon->pixbuf) ? gdk_pixbuf_get_height(cellicon->pixbuf) : 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
481 }
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 if (cellicon->show_text && cellicon->text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
484 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
485 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
486 PangoRectangle rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
487
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
488 layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, FALSE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
489 pango_layout_get_pixel_extents(layout, NULL, &rect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
490 g_object_unref(layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
491
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
492 calc_width = MAX(calc_width, rect.width);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
493 calc_height += rect.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
494 }
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 calc_width += (gint)cell->xpad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
497 calc_height += (gint)cell->ypad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
498
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
499 if (x_offset) *x_offset = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
500 if (y_offset) *y_offset = 0;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
501
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
502 if (cell_area && calc_width > 0 && calc_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
503 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
504 if (x_offset)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
505 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
506 *x_offset = (cell->xalign * (cell_area->width - calc_width - 2 * cell->xpad));
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
507 *x_offset = MAX(*x_offset, 0) + cell->xpad;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
508 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
509 if (y_offset)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
510 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
511 *y_offset = (cell->yalign * (cell_area->height - calc_height - 2 * cell->ypad));
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
512 *y_offset = MAX(*y_offset, 0) + cell->ypad;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
513 }
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 if (width) *width = calc_width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
517 if (height) *height = calc_height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
518 }
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 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
521 gqv_cell_renderer_icon_render(GtkCellRenderer *cell,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
522 GdkWindow *window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
523 GtkWidget *widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
524 GdkRectangle *background_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
525 GdkRectangle *cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
526 GdkRectangle *expose_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
527 GtkCellRendererState flags)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
528
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 GQvCellRendererIcon *cellicon = (GQvCellRendererIcon *) cell;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
531 GdkPixbuf *pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
532 const gchar *text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
533 GdkRectangle cell_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
534 GtkStateType state;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
535
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
536 pixbuf = cellicon->pixbuf;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
537 text = cellicon->text;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
538
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
539 if (!pixbuf && !text) return;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
540
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
541 gqv_cell_renderer_icon_get_size(cell, widget, cell_area,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
542 &cell_rect.x, &cell_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
543 &cell_rect.width, &cell_rect.height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
544
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
545 cell_rect.x += cell->xpad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
546 cell_rect.y += cell->ypad;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
547 cell_rect.width -= cell->xpad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
548 cell_rect.height -= cell->ypad * 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
549
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
550 if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
551 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
552 if (GTK_WIDGET_HAS_FOCUS(widget))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
553 state = GTK_STATE_SELECTED;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
554 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
555 state = GTK_STATE_ACTIVE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
556 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
557 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
558 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
559 if (GTK_WIDGET_STATE(widget) == GTK_STATE_INSENSITIVE)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
560 state = GTK_STATE_INSENSITIVE;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
561 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
562 state = GTK_STATE_NORMAL;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
563 }
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 if (pixbuf)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
566 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
567 GdkRectangle pix_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
568 GdkRectangle draw_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
569
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
570 pix_rect.width = gdk_pixbuf_get_width(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
571 pix_rect.height = gdk_pixbuf_get_height(pixbuf);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
572
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
573 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
574
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
575 if (cellicon->fixed_height > 0)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
576 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
577 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
578 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
579 else
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
580 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
581 pix_rect.y = cell_area->y + cell_rect.y;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
582 }
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 if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
585 gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
586 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
587 gdk_draw_pixbuf(window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
588 widget->style->black_gc,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
589 pixbuf,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
590 /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
591 draw_rect.x - pix_rect.x,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
592 draw_rect.y - pix_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
593 draw_rect.x,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
594 draw_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
595 draw_rect.width,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
596 draw_rect.height,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
597 GDK_RGB_DITHER_NORMAL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
598 0, 0);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
599 }
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 if (cellicon->show_text && text)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
603 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
604 PangoLayout *layout;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
605 PangoRectangle text_rect;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
606 GdkRectangle pix_rect;
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
607 GdkRectangle draw_rect;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
608
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
609 layout = gqv_cell_renderer_icon_get_layout(cellicon, widget, TRUE);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
610 pango_layout_get_pixel_extents(layout, NULL, &text_rect);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
611
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
612 pix_rect.width = text_rect.width;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
613 pix_rect.height = text_rect.height;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
614 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
615 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
616
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
617 if (gdk_rectangle_intersect(cell_area, &pix_rect, &draw_rect) &&
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
618 gdk_rectangle_intersect(expose_area, &draw_rect, &draw_rect))
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
619 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
620 gtk_paint_layout(widget->style, window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
621 state, TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
622 cell_area, widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
623 "cellrenderertext",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
624 pix_rect.x - text_rect.x, pix_rect.y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
625 layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
626 }
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 g_object_unref(layout);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
629 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
630
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
631 if (cellicon->focused && GTK_WIDGET_HAS_FOCUS(widget))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
632 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 gtk_paint_focus(widget->style, window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 state,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 cell_area, widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 "cellrendererfocus",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 cell_area->x, cell_area->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 cell_area->width, cell_area->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }