annotate src/gtkcellrendererprogress.c @ 4220:0cff8ec38935

[gaim-migrate @ 4464] Chris (darth_sebulba04) writes: "I made it so the timestamp.c iChat plugin can be configured from the gaim configuration menu to set the delay for when each stamp is shown." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Tue, 07 Jan 2003 14:21:43 +0000
parents 29664b8a1368
children 7521e29658bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3832
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* gtkcellrendererprogress.c
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * Copyright (C) 2002, Sean Egan <bj91704@binghamton.edu>
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or modify
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * 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
6 * the Free Software Foundation; either version 2 of the License, or
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * (at your option) any later version.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * GNU General Public License for more details.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 /* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc.
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "gtkcellrendererprogress.h"
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 static void gtk_cell_renderer_progress_get_property (GObject *object,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 GParamSpec *pspec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 static void gtk_cell_renderer_progress_set_property (GObject *object,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 const GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 GParamSpec *pspec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 static void gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 static void gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 static void gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 gint *x_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 gint *y_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 gint *width,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 gint *height);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static void gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 GdkWindow *window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 GdkRectangle *expose_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 guint flags);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 static gboolean gtk_cell_renderer_progress_activate (GtkCellRenderer *cell,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 GdkEvent *event,
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 const gchar *path,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 guint flags);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static void gtk_cell_renderer_progress_finalize (GObject *gobject);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 enum {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 LAST_SIGNAL
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 };
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 enum {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 PROP_0,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 PROP_PERCENTAGE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 PROP_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 PROP_SHOW_TEXT
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 };
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 static gpointer parent_class;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 static guint progress_cell_renderer_signals [LAST_SIGNAL];
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 GType gtk_cell_renderer_progress_get_type (void)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 static GType cell_progress_type = 0;
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 if (!cell_progress_type)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 static const GTypeInfo cell_progress_info =
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 sizeof (GtkCellRendererProgressClass),
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 NULL, /* base_init */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 NULL, /* base_finalize */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 (GClassInitFunc) gtk_cell_renderer_progress_class_init,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 NULL, /* class_finalize */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 NULL, /* class_data */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 sizeof (GtkCellRendererProgress),
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 0, /* n_preallocs */
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 (GInstanceInitFunc) gtk_cell_renderer_progress_init,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 };
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 cell_progress_type =
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 g_type_register_static (GTK_TYPE_CELL_RENDERER, "GtkCellRendererProgress",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 &cell_progress_info, 0);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 return cell_progress_type;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 }
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 static void gtk_cell_renderer_progress_init (GtkCellRendererProgress *cellprogress)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 GTK_CELL_RENDERER(cellprogress)->mode = GTK_CELL_RENDERER_MODE_INERT;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 GTK_CELL_RENDERER(cellprogress)->xpad = 2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 GTK_CELL_RENDERER(cellprogress)->ypad = 2;
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
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 static void gtk_cell_renderer_progress_class_init (GtkCellRendererProgressClass *class)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 GObjectClass *object_class = G_OBJECT_CLASS(class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 parent_class = g_type_class_peek_parent (class);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 object_class->finalize = gtk_cell_renderer_progress_finalize;
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 object_class->get_property = gtk_cell_renderer_progress_get_property;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 object_class->set_property = gtk_cell_renderer_progress_set_property;
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 cell_class->get_size = gtk_cell_renderer_progress_get_size;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 cell_class->render = gtk_cell_renderer_progress_render;
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 g_object_class_install_property (object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 PROP_PERCENTAGE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 g_param_spec_double ("percentage",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 "Percentage",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 "The fractional progress to display",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 0, 1, 0,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 G_PARAM_READWRITE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 g_object_class_install_property (object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 PROP_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 g_param_spec_string ("text",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 "Text",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 "Text to overlay over progress bar",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 NULL,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 G_PARAM_READWRITE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 g_object_class_install_property(object_class,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 PROP_SHOW_TEXT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 g_param_spec_string("text_set",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 "Text set",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 "Whether to overlay text on the progress bar",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 FALSE,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 G_PARAM_READABLE | G_PARAM_WRITABLE));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 static void gtk_cell_renderer_progress_finalize (GObject *object)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS(object);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 static void gtk_cell_renderer_progress_get_property (GObject *object,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 GParamSpec *psec)
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 GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS(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 switch (param_id)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 case PROP_PERCENTAGE:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 g_value_set_double(value, cellprogress->progress);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 case PROP_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 g_value_set_string(value, cellprogress->text);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 case PROP_SHOW_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 g_value_set_boolean(value, cellprogress->text_set);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 default:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 static void gtk_cell_renderer_progress_set_property (GObject *object,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 guint param_id,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 const GValue *value,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 GParamSpec *pspec)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (object);
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 switch (param_id)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 case PROP_PERCENTAGE:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 cellprogress->progress = g_value_get_double(value);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 case PROP_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (cellprogress->text)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 g_free(cellprogress->text);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 cellprogress->text = g_strdup(g_value_get_string(value));
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 g_object_notify(object, "text");
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 case PROP_SHOW_TEXT:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 cellprogress->text_set = g_value_get_boolean(value);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 default:
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 break;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 GtkCellRenderer *gtk_cell_renderer_progress_new(void)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 return g_object_new(GTK_TYPE_CELL_RENDERER_PROGRESS, NULL);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 static void gtk_cell_renderer_progress_get_size (GtkCellRenderer *cell,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 gint *x_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 gint *y_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 gint *width,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 gint *height)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 gint calc_width;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 gint calc_height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 calc_width = (gint) cell->xpad * 2 + 50;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 calc_height = (gint) cell->ypad * 2 + 10;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 if (width)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 *width = calc_width;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 if (height)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 *height = calc_height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 if (cell_area)
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 (x_offset)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 *x_offset = cell->xalign * (cell_area->width - calc_width);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 *x_offset = MAX (*x_offset, 0);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 if (y_offset)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 *y_offset = cell->yalign * (cell_area->height - calc_height);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 *y_offset = MAX (*y_offset, 0);
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 }
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 }
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
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 static void gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 GdkWindow *window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 GtkWidget *widget,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 GdkRectangle *background_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 GdkRectangle *cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 GdkRectangle *expose_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 guint flags)
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 {
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 GtkCellRendererProgress *cellprogress = (GtkCellRendererProgress *) cell;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 gint width, height;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 gint x_offset, y_offset;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 GtkStateType state;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 gtk_cell_renderer_progress_get_size (cell, widget, cell_area,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 &x_offset, &y_offset,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 &width, &height);
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
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 if (GTK_WIDGET_HAS_FOCUS (widget))
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 state = GTK_STATE_ACTIVE;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 else
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 state = GTK_STATE_NORMAL;
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
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 width -= cell->xpad*2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 height -= cell->ypad*2;
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 gtk_paint_box (widget->style,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 GTK_STATE_NORMAL, GTK_SHADOW_IN,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 NULL, widget, "trough",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 cell_area->x + x_offset + cell->xpad,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 cell_area->y + y_offset + cell->ypad,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 width - 1, height - 1);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 gtk_paint_box (widget->style,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 window,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 state, GTK_SHADOW_OUT,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 NULL, widget, "bar",
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 cell_area->x + x_offset + cell->xpad + 1,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 cell_area->y + y_offset + cell->ypad + 1,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 width * cellprogress->progress,
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 height - 2);
29664b8a1368 [gaim-migrate @ 3981]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 }