annotate src/gtkmenutray.c @ 12792:33cb3206af90

[gaim-migrate @ 15139] More whitespace, and return type stuff. I'm beginning to get to the end of the easy ones now. committer: Tailor Script <tailor@pidgin.im>
author Etan Reisner <pidgin@unreliablesource.net>
date Mon, 09 Jan 2006 08:49:05 +0000
parents 91aaa1b3ac30
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Gaim is the legal property of its developers, whose names are too numerous
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * to list here. Please refer to the COPYRIGHT file distributed with this
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * source distribution.
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 *
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * under the terms of the GNU General Public License as published by
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * (at your option) any later version.
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 *
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * GNU General Public License for more details.
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 *
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 */
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
20 #include "debug.h"
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
21
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #include "gtkmenutray.h"
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
24 #include <gtk/gtkeventbox.h>
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
25 #include <gtk/gtkiconfactory.h>
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
26 #include <gtk/gtkversion.h>
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
27
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 * Enums
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 enum {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 PROP_ZERO = 0,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 PROP_BOX
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 };
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 * Globals
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 static GObjectClass *parent_class = NULL;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 * Internal Stuff
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 * Item Stuff
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 gaim_gtk_menu_tray_select(GtkItem *item) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 /* this may look like nothing, but it's really overriding the
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 * GtkMenuItem's select function so that it doesn't get highlighted like
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 * a normal menu item would.
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 */
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 gaim_gtk_menu_tray_deselect(GtkItem *item) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 /* Probably not necessary, but I'd rather be safe than sorry. We're
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 * overridding the select, so it makes sense to override deselect as well.
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 */
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 * Widget Stuff
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 * Object Stuff
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 gaim_gtk_menu_tray_get_property(GObject *obj, guint param_id, GValue *value,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 GParamSpec *pspec)
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 GaimGtkMenuTray *menu_tray = GAIM_GTK_MENU_TRAY(obj);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 switch(param_id) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 case PROP_BOX:
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 g_value_set_object(value, gaim_gtk_menu_tray_get_box(menu_tray));
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 break;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 default:
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 break;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 gaim_gtk_menu_tray_finalize(GObject *obj) {
11599
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
88 #if 0
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
89 /* 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
90 * getting destroyed in GtkContainer's finalize function. But if were are
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
91 * 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
92 * -- Gary
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
93 */
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
94 GaimGtkMenuTray *tray = GAIM_GTK_MENU_TRAY(obj);
11599
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
95
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
96 if(GTK_IS_WIDGET(tray->tray))
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
97 gtk_widget_destroy(GTK_WIDGET(tray->tray));
11599
767e3c0c5062 [gaim-migrate @ 13869]
Gary Kramlich <grim@reaperworld.com>
parents: 11558
diff changeset
98 #endif
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 G_OBJECT_CLASS(parent_class)->finalize(obj);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 gaim_gtk_menu_tray_class_init(GaimGtkMenuTrayClass *klass) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 GObjectClass *object_class = G_OBJECT_CLASS(klass);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 GtkItemClass *item_class = GTK_ITEM_CLASS(klass);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 GParamSpec *pspec;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 parent_class = g_type_class_peek_parent(klass);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 object_class->finalize = gaim_gtk_menu_tray_finalize;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 object_class->get_property = gaim_gtk_menu_tray_get_property;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 item_class->select = gaim_gtk_menu_tray_select;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 item_class->deselect = gaim_gtk_menu_tray_deselect;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 pspec = g_param_spec_object("box", "The box",
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 "The box",
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 GTK_TYPE_BOX,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 G_PARAM_READABLE);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 g_object_class_install_property(object_class, PROP_BOX, pspec);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 static void
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 gaim_gtk_menu_tray_init(GaimGtkMenuTray *menu_tray) {
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
126 GtkWidget *widget = GTK_WIDGET(menu_tray);
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11787
diff changeset
127 #if GTK_CHECK_VERSION(2,2,0)
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
128 GtkSettings *settings;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11787
diff changeset
129 #endif
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
130 gint height = -1;
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
131
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 gtk_menu_item_set_right_justified(GTK_MENU_ITEM(menu_tray), TRUE);
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
133
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
134 if(!GTK_IS_WIDGET(menu_tray->tray))
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
135 menu_tray->tray = gtk_hbox_new(FALSE, 0);
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
137 menu_tray->tooltips = gtk_tooltips_new();
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
138
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
139 #if GTK_CHECK_VERSION(2,2,0)
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
140 settings =
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
141 gtk_settings_get_for_screen(gtk_widget_get_screen(widget));
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
142
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
143 if(gtk_icon_size_lookup_for_settings(settings, GTK_ICON_SIZE_MENU,
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
144 NULL, &height))
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11787
diff changeset
145 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11787
diff changeset
146 if(gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, NULL, &height))
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11787
diff changeset
147 #endif
11787
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
148 {
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
149 gtk_widget_set_size_request(widget, -1, height);
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
150 }
c9188d3eb9d3 [gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents: 11599
diff changeset
151
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
152 gtk_container_add(GTK_CONTAINER(menu_tray), menu_tray->tray);
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
154 gtk_widget_show(menu_tray->tray);
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 /******************************************************************************
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 * API
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 *****************************************************************************/
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 GType
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 gaim_gtk_menu_tray_get_gtype(void) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 static GType type = 0;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 if(type == 0) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 static const GTypeInfo info = {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 sizeof(GaimGtkMenuTrayClass),
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 NULL,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 NULL,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 (GClassInitFunc)gaim_gtk_menu_tray_class_init,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 NULL,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 NULL,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 sizeof(GaimGtkMenuTray),
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 0,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 (GInstanceInitFunc)gaim_gtk_menu_tray_init,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 NULL
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 };
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 type = g_type_register_static(GTK_TYPE_MENU_ITEM,
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 "GaimGtkMenuTray",
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 &info, 0);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 return type;
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 GtkWidget *
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 gaim_gtk_menu_tray_new() {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 return g_object_new(GAIM_GTK_TYPE_MENU_TRAY, NULL);
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 GtkWidget *
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 gaim_gtk_menu_tray_get_box(GaimGtkMenuTray *menu_tray) {
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 g_return_val_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray), NULL);
11558
19941a47405c [gaim-migrate @ 13820]
Sean Egan <seanegan@gmail.com>
parents: 11553
diff changeset
194 return menu_tray->tray;
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
197 static void
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
198 gaim_gtk_menu_tray_add(GaimGtkMenuTray *menu_tray, GtkWidget *widget,
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
199 const char *tooltip, gboolean prepend)
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
200 {
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 g_return_if_fail(GAIM_GTK_IS_MENU_TRAY(menu_tray));
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 g_return_if_fail(GTK_IS_WIDGET(widget));
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
204 if (GTK_WIDGET_NO_WINDOW(widget))
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
205 {
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
206 GtkWidget *event;
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
207
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
208 event = gtk_event_box_new();
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
209 gtk_container_add(GTK_CONTAINER(event), widget);
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
210 gtk_widget_show(event);
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
211 widget = event;
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
212 }
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
213
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
214 gaim_gtk_menu_tray_set_tooltip(menu_tray, widget, tooltip);
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
215
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
216 if (prepend)
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
217 gtk_box_pack_start(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0);
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
218 else
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
219 gtk_box_pack_end(GTK_BOX(menu_tray->tray), widget, FALSE, FALSE, 0);
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
220 }
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
221
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
222 void
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
223 gaim_gtk_menu_tray_append(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
224 {
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
225 gaim_gtk_menu_tray_add(menu_tray, widget, tooltip, FALSE);
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 }
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 void
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
229 gaim_gtk_menu_tray_prepend(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
230 {
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
231 gaim_gtk_menu_tray_add(menu_tray, widget, tooltip, TRUE);
11553
5c8210f7cbe2 [gaim-migrate @ 13813]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 }
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
233
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
234 void
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
235 gaim_gtk_menu_tray_set_tooltip(GaimGtkMenuTray *menu_tray, GtkWidget *widget, const char *tooltip)
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
236 {
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
237 if (!menu_tray->tooltips)
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
238 return;
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
239
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
240 /* Should we check whether widget is a child of menu_tray? */
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
241
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
242 /*
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
243 * If the widget does not have it's own window, then it
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
244 * must have automatically been added to an event box
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
245 * when it was added to the menu tray. If this is the
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
246 * case, we want to set the tooltip on the widget's parent,
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
247 * not on the widget itself.
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
248 */
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
249 if (GTK_WIDGET_NO_WINDOW(widget))
12008
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
250 widget = widget->parent;
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
251
91aaa1b3ac30 [gaim-migrate @ 14301]
Mark Doliner <mark@kingant.net>
parents: 11908
diff changeset
252 gtk_tooltips_set_tip(menu_tray->tooltips, widget, tooltip, NULL);
11908
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
253 }
34ea75bdd0c9 [gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents: 11888
diff changeset
254