Mon, 19 Mar 2007 06:11:46 +0000
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
| 6209 | 1 | /* |
| 2 | * System tray icon (aka docklet) plugin for Gaim | |
| 3 | * | |
| 4 | * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> | |
| 5 | * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> | |
| 6 | * Inspired by a similar plugin by: | |
| 7 | * John (J5) Palmieri <johnp@martianrock.com> | |
| 8 | * | |
| 9 | * This program is free software; you can redistribute it and/or | |
| 10 | * modify it under the terms of the GNU General Public License as | |
| 11 | * published by the Free Software Foundation; either version 2 of the | |
| 12 | * License, or (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, but | |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | * General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 22 | * 02111-1307, USA. | |
| 23 | */ | |
| 24 | ||
| 25 | #include "internal.h" | |
| 15577 | 26 | #include "pidgin.h" |
| 6209 | 27 | #include "debug.h" |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15836
diff
changeset
|
28 | #include "pidginstock.h" |
| 6209 | 29 | |
|
9709
2e73f176cc80
[gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents:
9229
diff
changeset
|
30 | #include "gtkdialogs.h" |
| 6209 | 31 | |
| 32 | #include "eggtrayicon.h" | |
| 14743 | 33 | #include "gtkdocklet.h" |
| 6209 | 34 | |
|
13687
c432ca78c271
[gaim-migrate @ 16088]
Casey Harkins <charkins@pidgin.im>
parents:
12525
diff
changeset
|
35 | #define EMBED_TIMEOUT 5000 |
| 10491 | 36 | |
| 6209 | 37 | /* globals */ |
| 38 | static EggTrayIcon *docklet = NULL; | |
| 39 | static GtkWidget *image = NULL; | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
40 | static GtkTooltips *tooltips = NULL; |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
41 | static GdkPixbuf *blank_icon = NULL; |
| 10491 | 42 | static int embed_timeout = 0; |
| 15836 | 43 | static DockletStatus icon_status = 0; |
| 44 | static int docklet_height = 0; | |
| 6209 | 45 | |
| 46 | /* protos */ | |
|
12397
aa64ec827fdf
[gaim-migrate @ 14704]
Richard Laager <rlaager@pidgin.im>
parents:
12026
diff
changeset
|
47 | static void docklet_x11_create(void); |
| 6209 | 48 | |
| 49 | static gboolean | |
| 50 | docklet_x11_create_cb() | |
| 51 | { | |
| 52 | docklet_x11_create(); | |
| 53 | ||
| 54 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 55 | } | |
| 56 | ||
| 57 | static void | |
| 58 | docklet_x11_embedded_cb(GtkWidget *widget, void *data) | |
| 59 | { | |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
60 | gaim_debug(GAIM_DEBUG_INFO, "docklet", "embedded\n"); |
| 10491 | 61 | |
| 62 | g_source_remove(embed_timeout); | |
| 63 | embed_timeout = 0; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
64 | pidgin_docklet_embedded(); |
| 6209 | 65 | } |
| 66 | ||
| 67 | static void | |
| 68 | docklet_x11_destroyed_cb(GtkWidget *widget, void *data) | |
| 69 | { | |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
70 | gaim_debug(GAIM_DEBUG_INFO, "docklet", "destroyed\n"); |
| 6209 | 71 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
72 | pidgin_docklet_remove(); |
| 6209 | 73 | |
| 74 | g_object_unref(G_OBJECT(docklet)); | |
| 75 | docklet = NULL; | |
| 76 | ||
| 14743 | 77 | g_idle_add(docklet_x11_create_cb, NULL); |
| 6209 | 78 | } |
| 79 | ||
| 80 | static void | |
| 81 | docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data) | |
| 82 | { | |
| 15109 | 83 | if (event->type != GDK_BUTTON_RELEASE) |
| 6209 | 84 | return; |
| 85 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
86 | pidgin_docklet_clicked(event->button); |
| 6209 | 87 | } |
| 88 | ||
| 89 | static void | |
|
11709
da6e9cd5f6d9
[gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents:
11631
diff
changeset
|
90 | docklet_x11_update_icon(DockletStatus icon) |
| 6209 | 91 | { |
| 92 | const gchar *icon_name = NULL; | |
| 93 | ||
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
94 | g_return_if_fail(image != NULL); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
95 | |
| 6209 | 96 | switch (icon) { |
|
11709
da6e9cd5f6d9
[gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents:
11631
diff
changeset
|
97 | case DOCKLET_STATUS_OFFLINE: |
| 15731 | 98 | icon_name = PIDGIN_STOCK_TRAY_OFFLINE; |
| 6209 | 99 | break; |
|
11709
da6e9cd5f6d9
[gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents:
11631
diff
changeset
|
100 | case DOCKLET_STATUS_CONNECTING: |
| 15731 | 101 | icon_name = PIDGIN_STOCK_TRAY_CONNECT; |
| 6209 | 102 | break; |
| 15731 | 103 | case DOCKLET_STATUS_AVAILABLE: |
| 104 | icon_name = PIDGIN_STOCK_TRAY_AVAILABLE; | |
| 6209 | 105 | break; |
| 15731 | 106 | case DOCKLET_STATUS_PENDING: |
| 107 | icon_name = PIDGIN_STOCK_TRAY_PENDING; | |
| 6209 | 108 | break; |
|
11709
da6e9cd5f6d9
[gaim-migrate @ 14000]
Casey Harkins <charkins@pidgin.im>
parents:
11631
diff
changeset
|
109 | case DOCKLET_STATUS_AWAY: |
| 15731 | 110 | icon_name = PIDGIN_STOCK_TRAY_AWAY; |
| 6209 | 111 | break; |
| 15731 | 112 | case DOCKLET_STATUS_BUSY: |
| 113 | icon_name = PIDGIN_STOCK_TRAY_BUSY; | |
| 114 | break; | |
| 115 | case DOCKLET_STATUS_XA: | |
| 116 | icon_name = PIDGIN_STOCK_TRAY_XA; | |
| 6209 | 117 | break; |
| 118 | } | |
| 119 | ||
|
15834
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
120 | if(icon_name) { |
|
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
121 | int icon_size; |
| 15836 | 122 | if (docklet_height < 22) |
|
15834
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
123 | icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_EXTRA_SMALL); |
|
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
124 | else |
|
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
125 | icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
| 15836 | 126 | |
|
15834
ba09306a7b0a
16px tray icons. These are used if the tray is shorter than 22px, and in Windows where all tray icons are 16x16. I still need to attach to a resizing signal to make them automatically update when the tray resizes.
Sean Egan <seanegan@pidgin.im>
parents:
15774
diff
changeset
|
127 | gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, icon_size); |
| 10765 | 128 | } |
| 15836 | 129 | icon_status = icon; |
| 130 | } | |
| 131 | ||
| 132 | static void | |
| 133 | docklet_x11_resize_icon(GtkWidget *widget) | |
| 134 | { | |
| 135 | if (docklet_height == widget->allocation.height) | |
| 136 | return; | |
| 137 | docklet_height = widget->allocation.height; | |
| 138 | docklet_x11_update_icon(icon_status); | |
| 6209 | 139 | } |
| 140 | ||
| 141 | static void | |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
142 | docklet_x11_blank_icon() |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
143 | { |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
144 | if (!blank_icon) { |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
145 | gint width, height; |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
146 | |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
147 | gtk_icon_size_lookup(GTK_ICON_SIZE_LARGE_TOOLBAR, &width, &height); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
148 | blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
149 | gdk_pixbuf_fill(blank_icon, 0); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
150 | } |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
151 | |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
152 | gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
153 | } |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
154 | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
155 | static void |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
156 | docklet_x11_set_tooltip(gchar *tooltip) |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
157 | { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
158 | if (!tooltips) |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
159 | tooltips = gtk_tooltips_new(); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
160 | |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
161 | /* image->parent is a GtkEventBox */ |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
162 | if (tooltip) { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
163 | gtk_tooltips_enable(tooltips); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
164 | gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
165 | } else { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
166 | gtk_tooltips_set_tip(tooltips, image->parent, "", NULL); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
167 | gtk_tooltips_disable(tooltips); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
168 | } |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
169 | } |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
170 | |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
171 | #if GTK_CHECK_VERSION(2,2,0) |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
172 | static void |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
173 | docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in, |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
174 | gpointer user_data) |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
175 | { |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
176 | GtkWidget *widget = GTK_WIDGET(docklet); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
177 | GtkRequisition req; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
178 | gint menu_xpos, menu_ypos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
179 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
180 | gtk_widget_size_request(GTK_WIDGET(menu), &req); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
181 | gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
182 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
183 | menu_xpos += widget->allocation.x; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
184 | menu_ypos += widget->allocation.y; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
185 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
186 | if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2) |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
187 | menu_ypos -= req.height; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
188 | else |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
189 | menu_ypos += widget->allocation.height; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
190 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
191 | *x = menu_xpos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
192 | *y = menu_ypos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
193 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
194 | *push_in = TRUE; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
195 | } |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
196 | #endif |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
197 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
198 | static void |
| 6209 | 199 | docklet_x11_destroy() |
| 200 | { | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
201 | g_return_if_fail(docklet != NULL); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
202 | |
| 14935 | 203 | if (embed_timeout) |
| 204 | g_source_remove(embed_timeout); | |
| 205 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
206 | pidgin_docklet_remove(); |
| 14935 | 207 | |
| 6209 | 208 | g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL); |
| 209 | gtk_widget_destroy(GTK_WIDGET(docklet)); | |
| 210 | ||
| 211 | g_object_unref(G_OBJECT(docklet)); | |
| 212 | docklet = NULL; | |
| 213 | ||
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
214 | if (blank_icon) |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
215 | g_object_unref(G_OBJECT(blank_icon)); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
216 | blank_icon = NULL; |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
217 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
218 | image = NULL; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
219 | |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
220 | gaim_debug(GAIM_DEBUG_INFO, "docklet", "destroyed\n"); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
221 | } |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
222 | |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
223 | static gboolean |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
224 | docklet_x11_embed_timeout_cb() |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
225 | { |
|
12498
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
226 | /* The docklet was not embedded within the timeout. |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
227 | * Remove it as a visibility manager, but leave the plugin |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
228 | * loaded so that it can embed automatically if/when a notification |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
229 | * area becomes available. |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
230 | */ |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
231 | gaim_debug_info("docklet", "failed to embed within timeout\n"); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
232 | pidgin_docklet_remove(); |
| 14743 | 233 | |
| 10491 | 234 | return FALSE; |
| 6209 | 235 | } |
| 236 | ||
| 237 | static void | |
| 238 | docklet_x11_create() | |
| 239 | { | |
| 240 | GtkWidget *box; | |
| 241 | ||
| 242 | if (docklet) { | |
| 243 | /* if this is being called when a tray icon exists, it's because | |
| 244 | something messed up. try destroying it before we proceed, | |
| 245 | although docklet_refcount may be all hosed. hopefully won't happen. */ | |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
246 | gaim_debug(GAIM_DEBUG_WARNING, "docklet", "trying to create icon but it already exists?\n"); |
| 6209 | 247 | docklet_x11_destroy(); |
| 248 | } | |
| 249 | ||
|
15499
9550c30eb265
A few non-gettextized strings
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
250 | docklet = egg_tray_icon_new(PIDGIN_NAME); |
| 6209 | 251 | box = gtk_event_box_new(); |
| 252 | image = gtk_image_new(); | |
| 253 | ||
| 254 | g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL); | |
| 255 | g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL); | |
| 15836 | 256 | g_signal_connect(G_OBJECT(docklet), "size-allocate", G_CALLBACK(docklet_x11_resize_icon), NULL); |
| 15109 | 257 | g_signal_connect(G_OBJECT(box), "button-release-event", G_CALLBACK(docklet_x11_clicked_cb), NULL); |
| 6209 | 258 | gtk_container_add(GTK_CONTAINER(box), image); |
| 259 | gtk_container_add(GTK_CONTAINER(docklet), box); | |
| 9229 | 260 | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
261 | if (!gtk_check_version(2,4,0)) |
| 9229 | 262 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); |
| 263 | ||
| 6209 | 264 | gtk_widget_show_all(GTK_WIDGET(docklet)); |
| 265 | ||
| 266 | /* ref the docklet before we bandy it about the place */ | |
| 267 | g_object_ref(G_OBJECT(docklet)); | |
|
12498
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
268 | |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
269 | /* This is a hack to avoid a race condition between the docklet getting |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
270 | * embedded in the notification area and the gtkblist restoring its |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
271 | * previous visibility state. If the docklet does not get embedded within |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
272 | * the timeout, it will be removed as a visibility manager until it does |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
273 | * get embedded. Ideally, we would only call docklet_embedded() when the |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
274 | * icon was actually embedded. |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
275 | */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
276 | pidgin_docklet_embedded(); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
277 | embed_timeout = g_timeout_add(EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); |
| 6209 | 278 | |
|
14813
c24dda7fb69e
[gaim-migrate @ 17508]
Casey Harkins <charkins@pidgin.im>
parents:
14743
diff
changeset
|
279 | gaim_debug(GAIM_DEBUG_INFO, "docklet", "created\n"); |
| 6209 | 280 | } |
| 281 | ||
| 282 | static struct docklet_ui_ops ui_ops = | |
| 283 | { | |
| 284 | docklet_x11_create, | |
| 285 | docklet_x11_destroy, | |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
286 | docklet_x11_update_icon, |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
287 | docklet_x11_blank_icon, |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
288 | docklet_x11_set_tooltip, |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
289 | #if GTK_CHECK_VERSION(2,2,0) |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
290 | docklet_x11_position_menu |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
291 | #else |
|
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
292 | NULL |
|
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
293 | #endif |
| 6209 | 294 | }; |
| 295 | ||
| 296 | void | |
| 297 | docklet_ui_init() | |
| 298 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
299 | pidgin_docklet_set_ui_ops(&ui_ops); |
| 6209 | 300 | } |