annotate src/gtkcellrendererprogress.c @ 12615:e3ca84a8b551

[gaim-migrate @ 14951] Whitespace fixes so I can actually understand what was happening here. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 22 Dec 2005 04:03:06 +0000
parents e856f985a0b9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10297
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
1 /*
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
2 * @file gtkcellrendererprogress.c GTK+ Cell Renderer Progress
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
3 * @ingroup gtkui
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
4 *
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
5 * gaim
ec140184437b [gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents: 9898
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7738
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7738
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7738
diff changeset
9 * source distribution.
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 /* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "gtkcellrendererprogress.h"
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
33 static void gaim_gtk_cell_renderer_progress_get_property (GObject *object,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 GParamSpec *pspec);
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
37 static void gaim_gtk_cell_renderer_progress_set_property (GObject *object,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 const GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 GParamSpec *pspec);
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
41 static void gaim_gtk_cell_renderer_progress_init (GaimGtkCellRendererProgress *cellprogress);
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
42 static void gaim_gtk_cell_renderer_progress_class_init (GaimGtkCellRendererProgressClass *class);
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
43 static void gaim_gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 gint *x_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 gint *y_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 gint *width,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 gint *height);
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
50 static void gaim_gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 GdkWindow *window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 GdkRectangle *expose_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 guint flags);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 3832
diff changeset
57 #if 0
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
58 static gboolean gaim_gtk_cell_renderer_progress_activate (GtkCellRenderer *cell,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 GdkEvent *event,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 const gchar *path,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 guint flags);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 3832
diff changeset
65 #endif
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
66 static void gaim_gtk_cell_renderer_progress_finalize (GObject *gobject);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 enum {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 LAST_SIGNAL
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 };
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 enum {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 PROP_0,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 PROP_PERCENTAGE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 PROP_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 PROP_SHOW_TEXT
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 };
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 static gpointer parent_class;
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 3832
diff changeset
80 /* static guint progress_cell_renderer_signals [LAST_SIGNAL]; */
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
82 GType gaim_gtk_cell_renderer_progress_get_type (void)
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 static GType cell_progress_type = 0;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 if (!cell_progress_type)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 static const GTypeInfo cell_progress_info =
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 {
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
90 sizeof (GaimGtkCellRendererProgressClass),
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 NULL, /* base_init */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 NULL, /* base_finalize */
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
93 (GClassInitFunc) gaim_gtk_cell_renderer_progress_class_init,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 NULL, /* class_finalize */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 NULL, /* class_data */
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
96 sizeof (GaimGtkCellRendererProgress),
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 0, /* n_preallocs */
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
98 (GInstanceInitFunc) gaim_gtk_cell_renderer_progress_init,
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 10297
diff changeset
99 NULL /* value_table */
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 };
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 cell_progress_type =
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
103 g_type_register_static (GTK_TYPE_CELL_RENDERER,
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
104 "GaimGtkCellRendererProgress",
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
105 &cell_progress_info, 0);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 return cell_progress_type;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
111 static void gaim_gtk_cell_renderer_progress_init (GaimGtkCellRendererProgress *cellprogress)
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 GTK_CELL_RENDERER(cellprogress)->mode = GTK_CELL_RENDERER_MODE_INERT;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 GTK_CELL_RENDERER(cellprogress)->xpad = 2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 GTK_CELL_RENDERER(cellprogress)->ypad = 2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
118 static void gaim_gtk_cell_renderer_progress_class_init (GaimGtkCellRendererProgressClass *class)
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 GObjectClass *object_class = G_OBJECT_CLASS(class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 parent_class = g_type_class_peek_parent (class);
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
124 object_class->finalize = gaim_gtk_cell_renderer_progress_finalize;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
126 object_class->get_property = gaim_gtk_cell_renderer_progress_get_property;
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
127 object_class->set_property = gaim_gtk_cell_renderer_progress_set_property;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
129 cell_class->get_size = gaim_gtk_cell_renderer_progress_get_size;
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
130 cell_class->render = gaim_gtk_cell_renderer_progress_render;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 g_object_class_install_property (object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 PROP_PERCENTAGE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 g_param_spec_double ("percentage",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 "Percentage",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 "The fractional progress to display",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 0, 1, 0,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 G_PARAM_READWRITE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 g_object_class_install_property (object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 PROP_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 g_param_spec_string ("text",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 "Text",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 "Text to overlay over progress bar",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 NULL,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 G_PARAM_READWRITE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 g_object_class_install_property(object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 PROP_SHOW_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 g_param_spec_string("text_set",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 "Text set",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 "Whether to overlay text on the progress bar",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 FALSE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 G_PARAM_READABLE | G_PARAM_WRITABLE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
155 static void gaim_gtk_cell_renderer_progress_finalize (GObject *object)
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 {
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 3832
diff changeset
157 /*
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
158 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS(object);
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 3832
diff changeset
159 */
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
164 static void gaim_gtk_cell_renderer_progress_get_property (GObject *object,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 GParamSpec *psec)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 {
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
169 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS(object);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 switch (param_id)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 case PROP_PERCENTAGE:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 g_value_set_double(value, cellprogress->progress);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 case PROP_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_value_set_string(value, cellprogress->text);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 case PROP_SHOW_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 g_value_set_boolean(value, cellprogress->text_set);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 default:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
188 static void gaim_gtk_cell_renderer_progress_set_property (GObject *object,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 const GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 GParamSpec *pspec)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 {
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
193 GaimGtkCellRendererProgress *cellprogress = GAIM_GTK_CELL_RENDERER_PROGRESS (object);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 switch (param_id)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 case PROP_PERCENTAGE:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 cellprogress->progress = g_value_get_double(value);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 case PROP_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 if (cellprogress->text)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 g_free(cellprogress->text);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 cellprogress->text = g_strdup(g_value_get_string(value));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 g_object_notify(object, "text");
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 case PROP_SHOW_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 cellprogress->text_set = g_value_get_boolean(value);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 default:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
215 GtkCellRenderer *gaim_gtk_cell_renderer_progress_new(void)
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 {
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
217 return g_object_new(GAIM_TYPE_GTK_CELL_RENDERER_PROGRESS, NULL);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
220 static void gaim_gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 gint *x_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 gint *y_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 gint *width,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 gint *height)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 gint calc_width;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 gint calc_height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 calc_width = (gint) cell->xpad * 2 + 50;
7705
401deb1e1085 [gaim-migrate @ 8350]
Sean Egan <seanegan@gmail.com>
parents: 4559
diff changeset
232 calc_height = (gint) cell->ypad * 2 + 12;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 if (width)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 *width = calc_width;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 if (height)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 *height = calc_height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 if (cell_area)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 if (x_offset)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 *x_offset = cell->xalign * (cell_area->width - calc_width);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 *x_offset = MAX (*x_offset, 0);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 if (y_offset)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 *y_offset = cell->yalign * (cell_area->height - calc_height);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 *y_offset = MAX (*y_offset, 0);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
256 static void gaim_gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 GdkWindow *window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 GdkRectangle *expose_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 guint flags)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 {
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
264 GaimGtkCellRendererProgress *cellprogress = (GaimGtkCellRendererProgress *) cell;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 gint width, height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 GtkStateType state;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
269 width = cell_area->width;
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
270 height = cell_area->height;
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 if (GTK_WIDGET_HAS_FOCUS (widget))
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 state = GTK_STATE_ACTIVE;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 else
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 state = GTK_STATE_NORMAL;
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
276
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 width -= cell->xpad*2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 height -= cell->ypad*2;
9898
8974a8544279 [gaim-migrate @ 10788]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
279
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 gtk_paint_box (widget->style,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 GTK_STATE_NORMAL, GTK_SHADOW_IN,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 NULL, widget, "trough",
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
284 cell_area->x + cell->xpad,
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
285 cell_area->y + cell->ypad,
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 width - 1, height - 1);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 gtk_paint_box (widget->style,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 state, GTK_SHADOW_OUT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 NULL, widget, "bar",
7738
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
291 cell_area->x + cell->xpad + 1,
b14442b31a9b [gaim-migrate @ 8383]
Sean Egan <seanegan@gmail.com>
parents: 7705
diff changeset
292 cell_area->y + cell->ypad + 1,
7705
401deb1e1085 [gaim-migrate @ 8350]
Sean Egan <seanegan@gmail.com>
parents: 4559
diff changeset
293 (width - 3) * cellprogress->progress,
401deb1e1085 [gaim-migrate @ 8350]
Sean Egan <seanegan@gmail.com>
parents: 4559
diff changeset
294 height - 3);
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295 }