annotate gtk/gtkcellrendererexpander.c @ 15164:fe05223b5d04

[gaim-migrate @ 17949] Gmail notifications patch from Chris Stafford - The plugin will only do anything if it sees "google:mail:notify" in disco. - I decided to give Jabber a mail notification option for this, since the feature has traditionally meant "notify me of new mail if I happen to have a mail account that this server will notify me of" - I decided to show the first unread mail in a thread, rather than all unread messages[A - I made a google.c/google.h file to keep code for Google Talk extensions committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sun, 10 Dec 2006 23:08:45 +0000
parents 063fe56aa427
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file gtkcellrendererexpander.c GTK+ Cell Renderer Expander
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * @ingroup gtkui
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * gaim
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * source distribution.
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 *
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 /* This is taken largely from GtkCellRenderer[Text|Pixbuf|Toggle] by
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 * Jonathon Blandford <jrb@redhat.com> for RedHat, Inc.
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
14657
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
31 #include <gtk/gtk.h>
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include <gtk/gtktreeview.h>
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 #include "gtkcellrendererexpander.h"
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 static void gaim_gtk_cell_renderer_expander_get_property (GObject *object,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 guint param_id,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 GValue *value,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 GParamSpec *pspec);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39 static void gaim_gtk_cell_renderer_expander_set_property (GObject *object,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 guint param_id,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 const GValue *value,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 GParamSpec *pspec);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 static void gaim_gtk_cell_renderer_expander_init (GaimGtkCellRendererExpander *cellexpander);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 static void gaim_gtk_cell_renderer_expander_class_init (GaimGtkCellRendererExpanderClass *class);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 static void gaim_gtk_cell_renderer_expander_get_size (GtkCellRenderer *cell,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 GtkWidget *widget,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 GdkRectangle *cell_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 gint *x_offset,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 gint *y_offset,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 gint *width,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 gint *height);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 static void gaim_gtk_cell_renderer_expander_render (GtkCellRenderer *cell,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 GdkWindow *window,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GtkWidget *widget,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 GdkRectangle *background_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 GdkRectangle *cell_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 GdkRectangle *expose_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 guint flags);
14891
063fe56aa427 [gaim-migrate @ 17663]
Richard Laager <rlaager@wiktel.com>
parents: 14798
diff changeset
59 static gboolean gaim_gtk_cell_renderer_expander_activate (GtkCellRenderer *r,
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 GdkEvent *event,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 GtkWidget *widget,
14891
063fe56aa427 [gaim-migrate @ 17663]
Richard Laager <rlaager@wiktel.com>
parents: 14798
diff changeset
62 const gchar *p,
063fe56aa427 [gaim-migrate @ 17663]
Richard Laager <rlaager@wiktel.com>
parents: 14798
diff changeset
63 GdkRectangle *bg,
063fe56aa427 [gaim-migrate @ 17663]
Richard Laager <rlaager@wiktel.com>
parents: 14798
diff changeset
64 GdkRectangle *cell,
14798
a413bcb6f19a [gaim-migrate @ 17563]
Richard Laager <rlaager@wiktel.com>
parents: 14657
diff changeset
65 GtkCellRendererState flags);
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 static void gaim_gtk_cell_renderer_expander_finalize (GObject *gobject);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 enum {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 LAST_SIGNAL
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 };
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 enum {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 PROP_0,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 PROP_IS_EXPANDER
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 };
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 static gpointer parent_class;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 /* static guint expander_cell_renderer_signals [LAST_SIGNAL]; */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 GType gaim_gtk_cell_renderer_expander_get_type (void)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 static GType cell_expander_type = 0;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 if (!cell_expander_type)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 static const GTypeInfo cell_expander_info =
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 sizeof (GaimGtkCellRendererExpanderClass),
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 NULL, /* base_init */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 NULL, /* base_finalize */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 (GClassInitFunc) gaim_gtk_cell_renderer_expander_class_init,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 NULL, /* class_finalize */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 NULL, /* class_data */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 sizeof (GaimGtkCellRendererExpander),
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 0, /* n_preallocs */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 (GInstanceInitFunc) gaim_gtk_cell_renderer_expander_init,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 NULL /* value_table */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 };
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 cell_expander_type =
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 g_type_register_static (GTK_TYPE_CELL_RENDERER,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 "GaimGtkCellRendererExpander",
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 &cell_expander_info, 0);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 return cell_expander_type;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 static void gaim_gtk_cell_renderer_expander_init (GaimGtkCellRendererExpander *cellexpander)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 GTK_CELL_RENDERER(cellexpander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE;
14591
fc99573b0b62 [gaim-migrate @ 17315]
Sean Egan <seanegan@gmail.com>
parents: 14564
diff changeset
112 GTK_CELL_RENDERER(cellexpander)->xpad = 0;
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 GTK_CELL_RENDERER(cellexpander)->ypad = 2;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 static void gaim_gtk_cell_renderer_expander_class_init (GaimGtkCellRendererExpanderClass *class)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 GObjectClass *object_class = G_OBJECT_CLASS(class);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS(class);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 parent_class = g_type_class_peek_parent (class);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 object_class->finalize = gaim_gtk_cell_renderer_expander_finalize;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 object_class->get_property = gaim_gtk_cell_renderer_expander_get_property;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 object_class->set_property = gaim_gtk_cell_renderer_expander_set_property;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 cell_class->get_size = gaim_gtk_cell_renderer_expander_get_size;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 cell_class->render = gaim_gtk_cell_renderer_expander_render;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 cell_class->activate = gaim_gtk_cell_renderer_expander_activate;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 g_object_class_install_property (object_class,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 PROP_IS_EXPANDER,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 g_param_spec_boolean ("expander-visible",
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 "Is Expander",
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 "True if the renderer should draw an expander",
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 FALSE,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 G_PARAM_READWRITE));
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 static void gaim_gtk_cell_renderer_expander_finalize (GObject *object)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 /*
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 GaimGtkCellRendererExpander *cellexpander = GAIM_GTK_CELL_RENDERER_EXPANDER(object);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 */
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 static void gaim_gtk_cell_renderer_expander_get_property (GObject *object,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 guint param_id,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 GValue *value,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 GParamSpec *psec)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 GaimGtkCellRendererExpander *cellexpander = GAIM_GTK_CELL_RENDERER_EXPANDER(object);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 switch (param_id)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 case PROP_IS_EXPANDER:
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 g_value_set_boolean(value, cellexpander->is_expander);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 break;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 default:
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, psec);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 break;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 static void gaim_gtk_cell_renderer_expander_set_property (GObject *object,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 guint param_id,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 const GValue *value,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 GParamSpec *pspec)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 GaimGtkCellRendererExpander *cellexpander = GAIM_GTK_CELL_RENDERER_EXPANDER (object);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 switch (param_id)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 case PROP_IS_EXPANDER:
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 cellexpander->is_expander = g_value_get_boolean(value);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 break;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 default:
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 break;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 GtkCellRenderer *gaim_gtk_cell_renderer_expander_new(void)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 return g_object_new(GAIM_TYPE_GTK_CELL_RENDERER_EXPANDER, NULL);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 static void gaim_gtk_cell_renderer_expander_get_size (GtkCellRenderer *cell,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 GtkWidget *widget,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 GdkRectangle *cell_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 gint *x_offset,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 gint *y_offset,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 gint *width,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 gint *height)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 gint calc_width;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 gint calc_height;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 gint expander_size;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 gtk_widget_style_get(widget, "expander-size", &expander_size, NULL);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 calc_width = (gint) cell->xpad * 2 + expander_size;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 calc_height = (gint) cell->ypad * 2 + expander_size;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 if (width)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 *width = calc_width;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 if (height)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 *height = calc_height;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 if (cell_area)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 if (x_offset)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 *x_offset = cell->xalign * (cell_area->width - calc_width);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 *x_offset = MAX (*x_offset, 0);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 if (y_offset)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 *y_offset = cell->yalign * (cell_area->height - calc_height);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 *y_offset = MAX (*y_offset, 0);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 static void gaim_gtk_cell_renderer_expander_render (GtkCellRenderer *cell,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 GdkWindow *window,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 GtkWidget *widget,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GdkRectangle *background_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 GdkRectangle *cell_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 GdkRectangle *expose_area,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 guint flags)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 GaimGtkCellRendererExpander *cellexpander = (GaimGtkCellRendererExpander *) cell;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240 gint width, height;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 GtkStateType state;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 if (!cellexpander->is_expander)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 return;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 width = cell_area->width;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 height = cell_area->height;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248
14657
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
249 #if GTK_CHECK_VERSION(2,6,0)
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 if (!cell->sensitive)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 state = GTK_STATE_INSENSITIVE;
14657
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
252 #else
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
253 if (GTK_WIDGET_STATE(widget) == GTK_STATE_INSENSITIVE)
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
254 state = GTK_STATE_INSENSITIVE;
38d1052611bc [gaim-migrate @ 17403]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14592
diff changeset
255 #endif
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 else if (flags & GTK_CELL_RENDERER_PRELIT)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 state = GTK_STATE_PRELIGHT;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 else if (GTK_WIDGET_HAS_FOCUS (widget) && flags & GTK_CELL_RENDERER_SELECTED)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 state = GTK_STATE_ACTIVE;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 else
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 state = GTK_STATE_NORMAL;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 width -= cell->xpad*2;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 height -= cell->ypad*2;
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 gtk_paint_expander (widget->style,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 window, state,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 NULL, widget, "treeview",
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 cell_area->x + cell->xpad + (width / 2),
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 cell_area->y + cell->ypad + (height / 2),
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 cell->is_expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 }
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
14564
4c14862f7fcc [gaim-migrate @ 17287]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14561
diff changeset
274 static gboolean gaim_gtk_cell_renderer_expander_activate(GtkCellRenderer *r,
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 GdkEvent *event,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 GtkWidget *widget,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 const gchar *p,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 GdkRectangle *bg,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 GdkRectangle *cell,
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 GtkCellRendererState flags)
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 {
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 GtkTreePath *path = gtk_tree_path_new_from_string(p);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 if (gtk_tree_view_row_expanded(GTK_TREE_VIEW(widget), path))
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 gtk_tree_view_collapse_row(GTK_TREE_VIEW(widget), path);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 else
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 gtk_tree_view_expand_row(GTK_TREE_VIEW(widget),path,FALSE);
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 gtk_tree_path_free(path);
14564
4c14862f7fcc [gaim-migrate @ 17287]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14561
diff changeset
288 return FALSE;
14561
3ff55ec8203a [gaim-migrate @ 17284]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 }