annotate src/cellrenderericon.c @ 747:8a743884483b

Use the same label for toolbar buttons tooltip than in main menu.
author zas_
date Fri, 23 May 2008 22:55:23 +0000
parents 631d626c1f6b
children 8308d3606991
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 {
691
631d626c1f6b Fix some incomplete initialization warnings.
zas_
parents: 534
diff changeset
82 sizeof(GQvCellRendererIconClass), /* class_size */
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 */
691
631d626c1f6b Fix some incomplete initialization warnings.
zas_
parents: 534
diff changeset
85 (GClassInitFunc) gqv_cell_renderer_icon_class_init, /* class_init */
9
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 */
691
631d626c1f6b Fix some incomplete initialization warnings.
zas_
parents: 534
diff changeset
88 sizeof(GQvCellRendererIcon), /* instance_size */
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
89 0, /* n_preallocs */
691
631d626c1f6b Fix some incomplete initialization warnings.
zas_
parents: 534
diff changeset
90 (GInstanceInitFunc) gqv_cell_renderer_icon_init, /* instance_init */
631d626c1f6b Fix some incomplete initialization warnings.
zas_
parents: 534
diff changeset
91 NULL, /* value_table */
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
92 };
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
93
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
94 cell_icon_type = g_type_register_static(GTK_TYPE_CELL_RENDERER,
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
95 "GQvCellRendererIcon",
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
96 &cell_icon_info, 0);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
97 }
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
98
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
99 return cell_icon_type;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
102 static void
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
103 gqv_cell_renderer_icon_init(GQvCellRendererIcon *cellicon)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
104 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
105 GTK_CELL_RENDERER(cellicon)->xpad = 2;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
106 GTK_CELL_RENDERER(cellicon)->ypad = 2;
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
109 static void
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
110 gqv_cell_renderer_icon_class_init(GQvCellRendererIconClass *class)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
111 {
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
112 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
113 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
114
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
115 parent_class = g_type_class_peek_parent(class);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
116
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
117 object_class->finalize = gqv_cell_renderer_icon_finalize;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
118
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
119 object_class->get_property = gqv_cell_renderer_icon_get_property;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
120 object_class->set_property = gqv_cell_renderer_icon_set_property;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
121
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
122 cell_class->get_size = gqv_cell_renderer_icon_get_size;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
123 cell_class->render = gqv_cell_renderer_icon_render;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
124
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
125 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
126 PROP_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
127 g_param_spec_object("pixbuf",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
128 _("Pixbuf Object"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
129 _("The pixbuf to render"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
130 GDK_TYPE_PIXBUF,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
131 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
132
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
133 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
134 PROP_TEXT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
135 g_param_spec_string("text",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
136 _("Text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
137 _("Text to render"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
138 NULL,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
139 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
140
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
141 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
142 PROP_BACKGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
143 g_param_spec_boxed("background_gdk",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
144 _("Background color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
145 _("Background color as a GdkColor"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
146 GDK_TYPE_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
147 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
148
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
149 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
150 PROP_FOREGROUND_GDK,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
151 g_param_spec_boxed("foreground_gdk",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
152 _("Foreground color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
153 _("Foreground color as a GdkColor"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
154 GDK_TYPE_COLOR,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
155 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
156
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
157 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
158 PROP_FOCUSED,
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
159 g_param_spec_boolean("has_focus",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
160 _("Focus"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
161 _("Draw focus indicator"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
162 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
163 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
164
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
165 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
166 PROP_FIXED_WIDTH,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
167 g_param_spec_int("fixed_width",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
168 _("Fixed width"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
169 _("Width of cell"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
170 -1, FIXED_ICON_SIZE_MAX,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
171 -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
172 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
173
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
174 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
175 PROP_FIXED_HEIGHT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
176 g_param_spec_int("fixed_height",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
177 _("Fixed height"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
178 _("Height of icon excluding text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
179 -1, FIXED_ICON_SIZE_MAX,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
180 -1,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
181 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
182
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
183 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
184 PROP_BACKGROUND_SET,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
185 g_param_spec_boolean("background_set",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
186 _("Background set"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
187 _("Whether this tag affects the background color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
188 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
189 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
190
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
191 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
192 PROP_FOREGROUND_SET,
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
193 g_param_spec_boolean("foreground_set",
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
194 _("Foreground set"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
195 _("Whether this tag affects the foreground color"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
196 FALSE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
197 G_PARAM_READWRITE));
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
198
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
199 g_object_class_install_property(object_class,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
200 PROP_SHOW_TEXT,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
201 g_param_spec_boolean("show_text",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
202 _("Show text"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
203 _("Whether the text is displayed"),
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
204 TRUE,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
205 G_PARAM_READWRITE));
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
208 static void
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
209 gqv_cell_renderer_icon_finalize(GObject *object)
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
210 {
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
211 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON(object);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
212
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
213 if (cellicon->pixbuf) g_object_unref(cellicon->pixbuf);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
214
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
215 g_free(cellicon->text);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
216
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
217 (*(G_OBJECT_CLASS(parent_class))->finalize)(object);
9
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
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
220 static void
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
221 gqv_cell_renderer_icon_get_property(GObject *object,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
222 guint param_id,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
223 GValue *value,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
224 GParamSpec *pspec)
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
225 {
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
226 GQvCellRendererIcon *cellicon = GQV_CELL_RENDERER_ICON(object);
442
4b2d7f9af171 Big whitespaces cleanup:
zas_
parents: 9
diff changeset
227
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
228 switch (param_id)
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
229 {
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
230 case PROP_PIXBUF:
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
231 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
232 break;
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
233 case PROP_TEXT:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
234 g_value_set_string(value, cellicon->text);
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
244 g_value_set_boxed(value, &color);
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
255 g_value_set_boxed(value, &color);
9
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:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
259 g_value_set_boolean(value, cellicon->focused);
9
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:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
277 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
283 set_bg_color(GQvCellRendererIcon *cellicon,
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
284 GdkColor *color)
9
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
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
308 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
309 GdkColor *color)
9
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 {
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
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)
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
342 {
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
343 case PROP_PIXBUF:
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
344 {
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
345 GdkPixbuf *pixbuf;
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
346
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
347 pixbuf = (GdkPixbuf*) g_value_get_object(value);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
348 if (pixbuf) g_object_ref(pixbuf);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
349 if (cellicon->pixbuf) g_object_unref(cellicon->pixbuf);
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
350 cellicon->pixbuf = pixbuf;
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
351 }
9
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:
512
f9bf33be53ff Remove whitespace between function name and first parenthesis for the sake of consistency.
zas_
parents: 446
diff changeset
389 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
390 break;
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
391 }
9
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 {
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
450 return g_object_new(GQV_TYPE_CELL_RENDERER_ICON, NULL);
9
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));
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
508 *x_offset = MAX(*x_offset, 0) + cell->xpad;
9
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));
513
985fdfebd89e Remove whitespace between function name and first parenthesis for the sake of consistency. (pass 2)
zas_
parents: 512
diff changeset
513 *y_offset = MAX(*y_offset, 0) + cell->ypad;
9
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
534
0a2b8210ef1d Indentation fixes.
zas_
parents: 513
diff changeset
632 if (cellicon->focused && GTK_WIDGET_HAS_FOCUS(widget))
9
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
633 {
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
634 gtk_paint_focus(widget->style, window,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
635 state,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
636 cell_area, widget,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
637 "cellrendererfocus",
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
638 cell_area->x, cell_area->y,
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
639 cell_area->width, cell_area->height);
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
640 }
d907d608745f Sync to GQview 1.5.9 release.
gqview
parents:
diff changeset
641 }