Sat, 09 Jun 2007 17:31:28 +0000
Patch from Pekka Riikonen to update the SILC protocol plugin to work with
SILC Toolkit 1.1
I added the fallback to SILC Toolkit 1.0 support (silc10 protocol
directory) and configure.ac adjustments, any problems with this are 100%
my fault.
| 6209 | 1 | /* |
| 15884 | 2 | * System tray icon (aka docklet) plugin for Purple |
| 6209 | 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" |
| 16621 | 28 | #include "prefs.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
|
29 | #include "pidginstock.h" |
| 6209 | 30 | |
|
9709
2e73f176cc80
[gaim-migrate @ 10570]
Mark Doliner <markdoliner@pidgin.im>
parents:
9229
diff
changeset
|
31 | #include "gtkdialogs.h" |
| 6209 | 32 | |
| 33 | #include "eggtrayicon.h" | |
| 14743 | 34 | #include "gtkdocklet.h" |
| 6209 | 35 | |
| 16621 | 36 | #define SHORT_EMBED_TIMEOUT 5000 |
| 37 | #define LONG_EMBED_TIMEOUT 15000 | |
| 10491 | 38 | |
| 6209 | 39 | /* globals */ |
| 40 | static EggTrayIcon *docklet = NULL; | |
| 41 | static GtkWidget *image = NULL; | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
42 | static GtkTooltips *tooltips = NULL; |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
43 | static GdkPixbuf *blank_icon = NULL; |
| 10491 | 44 | static int embed_timeout = 0; |
| 15836 | 45 | static int docklet_height = 0; |
| 6209 | 46 | |
| 47 | /* protos */ | |
| 16621 | 48 | static void docklet_x11_create(gboolean); |
| 6209 | 49 | |
| 50 | static gboolean | |
| 16621 | 51 | docklet_x11_recreate_cb() |
| 6209 | 52 | { |
| 16621 | 53 | docklet_x11_create(TRUE); |
| 6209 | 54 | |
| 55 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 56 | } | |
| 57 | ||
| 58 | static void | |
| 59 | docklet_x11_embedded_cb(GtkWidget *widget, void *data) | |
| 60 | { | |
| 15884 | 61 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "embedded\n"); |
| 10491 | 62 | |
| 63 | g_source_remove(embed_timeout); | |
| 64 | embed_timeout = 0; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
65 | pidgin_docklet_embedded(); |
| 16621 | 66 | purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE); |
| 6209 | 67 | } |
| 68 | ||
| 69 | static void | |
| 70 | docklet_x11_destroyed_cb(GtkWidget *widget, void *data) | |
| 71 | { | |
| 15884 | 72 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "destroyed\n"); |
| 6209 | 73 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
74 | pidgin_docklet_remove(); |
| 6209 | 75 | |
| 76 | g_object_unref(G_OBJECT(docklet)); | |
| 77 | docklet = NULL; | |
| 78 | ||
|
16628
8fc264ea344f
Charkins renamed the callback function, but missed the g_idle_add
Kevin Stange <kstange@pidgin.im>
parents:
16621
diff
changeset
|
79 | g_idle_add(docklet_x11_recreate_cb, NULL); |
| 6209 | 80 | } |
| 81 | ||
| 82 | static void | |
| 83 | docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data) | |
| 84 | { | |
| 15109 | 85 | if (event->type != GDK_BUTTON_RELEASE) |
| 6209 | 86 | return; |
| 87 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
88 | pidgin_docklet_clicked(event->button); |
| 6209 | 89 | } |
| 90 | ||
| 91 | static void | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
92 | docklet_x11_update_icon(PurpleStatusPrimitive status, gboolean connecting, gboolean pending) |
| 6209 | 93 | { |
| 94 | const gchar *icon_name = NULL; | |
| 95 | ||
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
96 | g_return_if_fail(image != NULL); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
97 | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
98 | switch (status) { |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
99 | case PURPLE_STATUS_OFFLINE: |
| 15731 | 100 | icon_name = PIDGIN_STOCK_TRAY_OFFLINE; |
| 6209 | 101 | break; |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
102 | case PURPLE_STATUS_AWAY: |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
103 | icon_name = PIDGIN_STOCK_TRAY_AWAY; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
104 | break; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
105 | case PURPLE_STATUS_UNAVAILABLE: |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
106 | icon_name = PIDGIN_STOCK_TRAY_BUSY; |
| 6209 | 107 | break; |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
108 | case PURPLE_STATUS_EXTENDED_AWAY: |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
109 | icon_name = PIDGIN_STOCK_TRAY_XA; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
110 | break; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
111 | case PURPLE_STATUS_INVISIBLE: |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
112 | icon_name = PIDGIN_STOCK_TRAY_INVISIBLE; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
113 | break; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
114 | default: |
| 15731 | 115 | icon_name = PIDGIN_STOCK_TRAY_AVAILABLE; |
| 6209 | 116 | break; |
| 117 | } | |
| 118 | ||
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
119 | if (pending) |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
120 | icon_name = PIDGIN_STOCK_TRAY_PENDING; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
121 | if (connecting) |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
122 | icon_name = PIDGIN_STOCK_TRAY_CONNECT; |
|
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
123 | |
|
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
|
124 | 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
|
125 | int icon_size; |
| 15836 | 126 | 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
|
127 | 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
|
128 | 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
|
129 | icon_size = gtk_icon_size_from_name(PIDGIN_ICON_SIZE_TANGO_SMALL); |
| 15836 | 130 | |
|
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
|
131 | gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, icon_size); |
| 10765 | 132 | } |
| 15836 | 133 | } |
| 134 | ||
| 135 | static void | |
| 136 | docklet_x11_resize_icon(GtkWidget *widget) | |
| 137 | { | |
| 138 | if (docklet_height == widget->allocation.height) | |
| 139 | return; | |
| 140 | docklet_height = widget->allocation.height; | |
|
16996
749cb2af2e40
Now that the docklet icon is based on the status from status selector, it
Casey Harkins <charkins@pidgin.im>
parents:
16808
diff
changeset
|
141 | pidgin_docklet_update_icon(); |
| 6209 | 142 | } |
| 143 | ||
| 144 | static void | |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
145 | docklet_x11_blank_icon() |
|
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 | if (!blank_icon) { |
|
16422
2a36f5d04f5b
Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15884
diff
changeset
|
148 | GtkIconSize size = GTK_ICON_SIZE_LARGE_TOOLBAR; |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
149 | gint width, height; |
|
16422
2a36f5d04f5b
Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15884
diff
changeset
|
150 | g_object_get(G_OBJECT(image), "icon-size", &size, NULL); |
|
2a36f5d04f5b
Make sure the blinking docklet has the same size. Fixes #174.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15884
diff
changeset
|
151 | gtk_icon_size_lookup(size, &width, &height); |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
152 | 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
|
153 | gdk_pixbuf_fill(blank_icon, 0); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
154 | } |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
155 | |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
156 | gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
157 | } |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
158 | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
159 | static void |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
160 | docklet_x11_set_tooltip(gchar *tooltip) |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
161 | { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
162 | if (!tooltips) |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
163 | tooltips = gtk_tooltips_new(); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
164 | |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
165 | /* image->parent is a GtkEventBox */ |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
166 | if (tooltip) { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
167 | gtk_tooltips_enable(tooltips); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
168 | gtk_tooltips_set_tip(tooltips, image->parent, tooltip, NULL); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
169 | } else { |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
170 | gtk_tooltips_set_tip(tooltips, image->parent, "", NULL); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
171 | gtk_tooltips_disable(tooltips); |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
172 | } |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
173 | } |
|
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
174 | |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
175 | #if GTK_CHECK_VERSION(2,2,0) |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
176 | static void |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
177 | 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
|
178 | gpointer user_data) |
|
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 | GtkWidget *widget = GTK_WIDGET(docklet); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
181 | GtkRequisition req; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
182 | gint menu_xpos, menu_ypos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
183 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
184 | gtk_widget_size_request(GTK_WIDGET(menu), &req); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
185 | gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos); |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
186 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
187 | menu_xpos += widget->allocation.x; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
188 | menu_ypos += widget->allocation.y; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
189 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
190 | 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
|
191 | menu_ypos -= req.height; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
192 | else |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
193 | menu_ypos += widget->allocation.height; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
194 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
195 | *x = menu_xpos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
196 | *y = menu_ypos; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
197 | |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
198 | *push_in = TRUE; |
|
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
199 | } |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
200 | #endif |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
201 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
202 | static void |
| 6209 | 203 | docklet_x11_destroy() |
| 204 | { | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
205 | g_return_if_fail(docklet != NULL); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
206 | |
| 14935 | 207 | if (embed_timeout) |
| 208 | g_source_remove(embed_timeout); | |
| 209 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
210 | pidgin_docklet_remove(); |
| 14935 | 211 | |
| 6209 | 212 | g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL); |
| 213 | gtk_widget_destroy(GTK_WIDGET(docklet)); | |
| 214 | ||
| 215 | g_object_unref(G_OBJECT(docklet)); | |
| 216 | docklet = NULL; | |
| 217 | ||
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
218 | if (blank_icon) |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
219 | g_object_unref(G_OBJECT(blank_icon)); |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
220 | blank_icon = NULL; |
|
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
221 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
222 | image = NULL; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
223 | |
| 15884 | 224 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "destroyed\n"); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
225 | } |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
226 | |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
227 | static gboolean |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
228 | docklet_x11_embed_timeout_cb() |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10491
diff
changeset
|
229 | { |
|
12498
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
230 | /* The docklet was not embedded within the timeout. |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
231 | * Remove it as a visibility manager, but leave the plugin |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
232 | * loaded so that it can embed automatically if/when a notification |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
233 | * area becomes available. |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
234 | */ |
| 15884 | 235 | purple_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
|
236 | pidgin_docklet_remove(); |
| 14743 | 237 | |
| 10491 | 238 | return FALSE; |
| 6209 | 239 | } |
| 240 | ||
| 241 | static void | |
| 16621 | 242 | docklet_x11_create(gboolean recreate) |
| 6209 | 243 | { |
| 244 | GtkWidget *box; | |
| 245 | ||
| 246 | if (docklet) { | |
| 247 | /* if this is being called when a tray icon exists, it's because | |
| 248 | something messed up. try destroying it before we proceed, | |
| 249 | although docklet_refcount may be all hosed. hopefully won't happen. */ | |
| 15884 | 250 | purple_debug(PURPLE_DEBUG_WARNING, "docklet", "trying to create icon but it already exists?\n"); |
| 6209 | 251 | docklet_x11_destroy(); |
| 252 | } | |
| 253 | ||
|
15499
9550c30eb265
A few non-gettextized strings
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
254 | docklet = egg_tray_icon_new(PIDGIN_NAME); |
| 6209 | 255 | box = gtk_event_box_new(); |
| 256 | image = gtk_image_new(); | |
| 257 | ||
| 258 | g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL); | |
| 259 | g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL); | |
| 15836 | 260 | g_signal_connect(G_OBJECT(docklet), "size-allocate", G_CALLBACK(docklet_x11_resize_icon), NULL); |
| 15109 | 261 | g_signal_connect(G_OBJECT(box), "button-release-event", G_CALLBACK(docklet_x11_clicked_cb), NULL); |
| 6209 | 262 | gtk_container_add(GTK_CONTAINER(box), image); |
| 263 | gtk_container_add(GTK_CONTAINER(docklet), box); | |
| 9229 | 264 | |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
265 | if (!gtk_check_version(2,4,0)) |
| 9229 | 266 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); |
| 267 | ||
| 6209 | 268 | gtk_widget_show_all(GTK_WIDGET(docklet)); |
| 269 | ||
| 270 | /* ref the docklet before we bandy it about the place */ | |
| 271 | g_object_ref(G_OBJECT(docklet)); | |
|
12498
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
272 | |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
273 | /* 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
|
274 | * embedded in the notification area and the gtkblist restoring its |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
275 | * previous visibility state. If the docklet does not get embedded within |
|
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
276 | * 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
|
277 | * get embedded. Ideally, we would only call docklet_embedded() when the |
| 16621 | 278 | * icon was actually embedded. This only happens when the docklet is first |
| 279 | * created, not when being recreated. | |
| 280 | * | |
| 281 | * The x11 docklet tracks whether it successfully embedded in a pref and | |
| 282 | * allows for a longer timeout period if it successfully embedded the last | |
| 283 | * time it was run. This should hopefully solve problems with the buddy | |
|
17645
32a0fe7965b7
Get rid of 'Gaim' in a few more places
Mark Doliner <markdoliner@pidgin.im>
parents:
16996
diff
changeset
|
284 | * list not properly starting hidden when Pidgin is started on login. |
|
12498
93591c1f68f1
[gaim-migrate @ 14810]
Casey Harkins <charkins@pidgin.im>
parents:
12471
diff
changeset
|
285 | */ |
| 16621 | 286 | if(!recreate) { |
| 287 | pidgin_docklet_embedded(); | |
| 288 | if(purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded")) { | |
| 289 | embed_timeout = g_timeout_add(LONG_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); | |
| 290 | } else { | |
| 291 | embed_timeout = g_timeout_add(SHORT_EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); | |
| 292 | } | |
| 293 | } | |
| 6209 | 294 | |
| 15884 | 295 | purple_debug(PURPLE_DEBUG_INFO, "docklet", "created\n"); |
| 6209 | 296 | } |
| 297 | ||
| 16621 | 298 | static void |
| 299 | docklet_x11_create_ui_op() | |
| 300 | { | |
| 301 | docklet_x11_create(FALSE); | |
| 302 | } | |
| 303 | ||
| 6209 | 304 | static struct docklet_ui_ops ui_ops = |
| 305 | { | |
| 16621 | 306 | docklet_x11_create_ui_op, |
| 6209 | 307 | docklet_x11_destroy, |
|
6894
8c6e286b079d
[gaim-migrate @ 7441]
Herman Bloggs <herman@bluedigits.com>
parents:
6371
diff
changeset
|
308 | docklet_x11_update_icon, |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
309 | docklet_x11_blank_icon, |
|
12471
5d7c12d525ed
[gaim-migrate @ 14781]
Casey Harkins <charkins@pidgin.im>
parents:
12397
diff
changeset
|
310 | docklet_x11_set_tooltip, |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
311 | #if GTK_CHECK_VERSION(2,2,0) |
|
10268
862ed5d3f227
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
312 | docklet_x11_position_menu |
|
10505
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
313 | #else |
|
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
314 | NULL |
|
4c063ce8ed62
[gaim-migrate @ 11799]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
315 | #endif |
| 6209 | 316 | }; |
| 317 | ||
| 318 | void | |
| 319 | docklet_ui_init() | |
| 320 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15499
diff
changeset
|
321 | pidgin_docklet_set_ui_ops(&ui_ops); |
| 16621 | 322 | purple_prefs_add_none(PIDGIN_PREFS_ROOT "/docklet/x11"); |
| 323 | purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/docklet/x11/embedded", FALSE); | |
| 6209 | 324 | } |