Mercurial > pidgin.yaz
annotate src/gtkmenutray.c @ 11771:08b1dd8aa11c
[gaim-migrate @ 14062]
I don't think the plugin title needs to be shown in the details section, since it's shown in the list above. Also, I'm changing the tabbing on the Website line; if that breaks the layout for others, feel free to revert, but this makes things line up for me.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 23 Oct 2005 23:04:31 +0000 |
parents | 767e3c0c5062 |
children | c9188d3eb9d3 |
rev | line source |
---|---|
11553 | 1 /* |
2 * Gaim is the legal property of its developers, whose names are too numerous | |
3 * to list here. Please refer to the COPYRIGHT file distributed with this | |
4 * source distribution. | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 */ | |
20 #include "gtkmenutray.h" | |
21 | |
22 /****************************************************************************** | |
23 * Enums | |
24 *****************************************************************************/ | |
25 enum { | |
26 PROP_ZERO = 0, | |
27 PROP_BOX | |
28 }; | |
29 | |
30 /****************************************************************************** | |
31 * Globals | |
32 *****************************************************************************/ | |
33 static GObjectClass *parent_class = NULL; | |
34 | |
35 /****************************************************************************** | |
36 * Internal Stuff | |
37 *****************************************************************************/ | |
38 | |
39 /****************************************************************************** | |
40 * Item Stuff | |
41 *****************************************************************************/ | |
42 static void | |
43 gaim_gtk_menu_tray_select(GtkItem *item) { | |
44 /* this may look like nothing, but it's really overriding the | |
45 * GtkMenuItem's select function so that it doesn't get highlighted like | |
46 * a normal menu item would. | |
47 */ | |
48 } | |
49 | |
50 static void | |
51 gaim_gtk_menu_tray_deselect(GtkItem *item) { | |
52 /* Probably not necessary, but I'd rather be safe than sorry. We're | |
53 * overridding the select, so it makes sense to override deselect as well. | |
54 */ | |
55 } | |
56 | |
57 /****************************************************************************** | |
58 * Widget Stuff | |
59 *****************************************************************************/ | |
60 | |
61 /****************************************************************************** | |
62 * Object Stuff | |
63 *****************************************************************************/ | |
64 static void | |
65 gaim_gtk_menu_tray_get_property(GObject *obj, guint param_id, GValue *value, | |
66 GParamSpec *pspec) | |
67 { | |
68 GaimGtkMenuTray *menu_tray = GAIM_GTK_MENU_TRAY(obj); | |
69 | |
70 switch(param_id) { | |
71 case PROP_BOX: | |
72 g_value_set_object(value, gaim_gtk_menu_tray_get_box(menu_tray)); | |
73 break; | |
74 default: | |
75 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); | |
76 break; | |
77 } | |
78 } | |
79 | |
80 static void | |
81 gaim_gtk_menu_tray_finalize(GObject *obj) { | |
11599
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
82 #if 0 |
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
83 /* This _might_ be leaking, but I have a sneaking suspicion that the widget is |
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
84 * getting destroyed in GtkContainer's finalize function. But if were are |
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
85 * leaking here, be sure to figure out why this causes a crash. |
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
86 * -- Gary |
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
87 */ |
11558 | 88 GaimGtkMenuTray *tray = GAIM_GTK_MENU_TRAY(obj); |
11599
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
89 |
11558 | 90 if(GTK_IS_WIDGET(tray->tray)) |
91 gtk_widget_destroy(GTK_WIDGET(tray->tray)); | |
11599
767e3c0c5062
[gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents:
11558
diff
changeset
|
92 #endif |
11553 | 93 |
94 G_OBJECT_CLASS(parent_class)->finalize(obj); | |
95 } | |
96 | |
97 static void | |
98 gaim_gtk_menu_tray_class_init(GaimGtkMenuTrayClass *klass) { | |
99 GObjectClass *object_class = G_OBJECT_CLASS(klass); | |
100 GtkItemClass *item_class = GTK_ITEM_CLASS(klass); | |
101 GParamSpec *pspec; | |
102 | |
103 parent_class = g_type_class_peek_parent(klass); | |
104 | |
105 object_class->finalize = gaim_gtk_menu_tray_finalize; | |
106 object_class->get_property = gaim_gtk_menu_tray_get_property; | |
107 | |
108 item_class->select = gaim_gtk_menu_tray_select; | |
109 item_class->deselect = gaim_gtk_menu_tray_deselect; | |
110 | |
111 pspec = g_param_spec_object("box", "The box", | |
112 "The box", | |
113 GTK_TYPE_BOX, | |
114 G_PARAM_READABLE); | |
115 g_object_class_install_property(object_class, PROP_BOX, pspec); | |
116 } | |
117 | |
118 static void | |
119 gaim_gtk_menu_tray_init(GaimGtkMenuTray *menu_tray) { | |
120 gtk_menu_item_set_right_justified(GTK_MENU_ITEM(menu_tray), TRUE); | |
121 | |
11558 | 122 if(!GTK_IS_WIDGET(menu_tray->tray)) |
123 menu_tray->tray = gtk_hbox_new(FALSE, 0); | |
11553 | 124 |
11558 | 125 gtk_container_add(GTK_CONTAINER(menu_tray), menu_tray->tray); |
11553 | 126 |
11558 | 127 gtk_widget_show(menu_tray->tray); |
11553 | 128 } |
129 | |
130 /****************************************************************************** | |
131 * API | |
132 *****************************************************************************/ | |
133 GType | |
134 gaim_gtk_menu_tray_get_gtype(void) { | |
135 static GType type = 0; | |
136 | |
137 if(type == 0) { | |
138 static const GTypeInfo info = { | |
139 sizeof(GaimGtkMenuTrayClass), | |
140 NULL, | |
141 NULL, | |
142 (GClassInitFunc)gaim_gtk_menu_tray_class_init, | |
143 NULL, | |
144 NULL, | |
145 sizeof(GaimGtkMenuTray), | |
146 0, | |
147 (GInstanceInitFunc)gaim_gtk_menu_tray_init, | |
148 NULL | |
149 }; | |
150 | |
151 type = g_type_register_static(GTK_TYPE_MENU_ITEM, | |
152 "GaimGtkMenuTray", | |
153 &info, 0); | |
154 } | |
155 | |
156 return type; | |
157 } | |
158 | |
159 GtkWidget * | |
160 gaim_gtk_menu_tray_new() { | |
161 return g_object_new(GAIM_GTK_TYPE_MENU_TRAY, NULL); | |
162 } | |
163 | |
164 GtkWidget * | |
165 gaim_gtk_menu_tray_get_box(GaimGtkMenuTray *menu_tray) { | |
166 g_return_val_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray), NULL); | |
11558 | 167 return menu_tray->tray; |
11553 | 168 } |
169 | |
170 void | |
171 gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget) { | |
172 g_return_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray)); | |
173 g_return_if_fail(GTK_IS_WIDGET(widget)); | |
174 | |
11558 | 175 gtk_box_pack_end(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0); |
11553 | 176 } |
177 | |
178 void | |
179 gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget) { | |
180 g_return_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray)); | |
181 g_return_if_fail(GTK_IS_WIDGET(widget)); | |
182 | |
11558 | 183 gtk_box_pack_start(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0); |
11553 | 184 } |