Mercurial > pidgin.yaz
annotate plugins/docklet/docklet-x11.c @ 10694:06f68443e6e5
[gaim-migrate @ 12246]
sf patch #1026516, from Marc ("sanmarcos-")
Add an icon for the roomlist and privacy menu actions. I think
these look ok. Hopefully they'll still be ok with other
icon sets.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 14 Mar 2005 03:58:09 +0000 |
parents | 77ef3f2f0df8 |
children | 80b8be10dc42 |
rev | line source |
---|---|
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
1 /* |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
2 * System tray icon (aka docklet) plugin for Gaim |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
3 * |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
4 * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
5 * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
6 * Inspired by a similar plugin by: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
7 * John (J5) Palmieri <johnp@martianrock.com> |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
8 * |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
9 * This program is free software; you can redistribute it and/or |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
10 * modify it under the terms of the GNU General Public License as |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
11 * published by the Free Software Foundation; either version 2 of the |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
12 * License, or (at your option) any later version. |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
13 * |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
14 * This program is distributed in the hope that it will be useful, but |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
15 * WITHOUT ANY WARRANTY; without even the implied warranty of |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
17 * General Public License for more details. |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
18 * |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
19 * You should have received a copy of the GNU General Public License |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
20 * along with this program; if not, write to the Free Software |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
22 * 02111-1307, USA. |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
23 */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
24 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
25 #include "internal.h" |
9791 | 26 #include "gtkgaim.h" |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
27 #include "debug.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10268
diff
changeset
|
28 #include "gtkstock.h" |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
29 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
30 #include "gaim.h" |
9709 | 31 #include "gtkdialogs.h" |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
32 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
33 #include "eggtrayicon.h" |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
34 #include "docklet.h" |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
35 |
10491 | 36 #define EMBED_TIMEOUT 3000 |
37 | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
38 /* globals */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
39 static EggTrayIcon *docklet = NULL; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
40 static GtkWidget *image = NULL; |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
41 static GdkPixbuf *blank_icon = NULL; |
10491 | 42 static int embed_timeout = 0; |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
43 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
44 /* protos */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
45 static void docklet_x11_create(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
46 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
47 static gboolean |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
48 docklet_x11_create_cb() |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
49 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
50 docklet_x11_create(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
51 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
52 return FALSE; /* for when we're called by the glib idle handler */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
53 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
54 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
55 static void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
56 docklet_x11_embedded_cb(GtkWidget *widget, void *data) |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
57 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
58 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "embedded\n"); |
10491 | 59 |
60 g_source_remove(embed_timeout); | |
61 embed_timeout = 0; | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
62 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
63 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
64 static void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
65 docklet_x11_destroyed_cb(GtkWidget *widget, void *data) |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
66 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
67 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "destroyed\n"); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
68 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
69 docklet_remove(TRUE); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
70 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
71 g_object_unref(G_OBJECT(docklet)); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
72 docklet = NULL; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
73 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
74 g_idle_add(docklet_x11_create_cb, &handle); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
75 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
76 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
77 static void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
78 docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data) |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
79 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
80 if (event->type != GDK_BUTTON_PRESS) |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
81 return; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
82 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
83 docklet_clicked(event->button); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
84 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
85 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
86 static void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
87 docklet_x11_update_icon(enum docklet_status icon) |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
88 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
89 const gchar *icon_name = NULL; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
90 |
10504 | 91 g_return_if_fail(image != NULL); |
92 | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
93 switch (icon) { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
94 case offline: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
95 icon_name = GAIM_STOCK_ICON_OFFLINE; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
96 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
97 case offline_connecting: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
98 case online_connecting: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
99 icon_name = GAIM_STOCK_ICON_CONNECT; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
100 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
101 case online: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
102 icon_name = GAIM_STOCK_ICON_ONLINE; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
103 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
104 case online_pending: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
105 icon_name = GAIM_STOCK_ICON_ONLINE_MSG; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
106 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
107 case away: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
108 icon_name = GAIM_STOCK_ICON_AWAY; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
109 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
110 case away_pending: |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
111 icon_name = GAIM_STOCK_ICON_AWAY_MSG; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
112 break; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
113 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
114 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
115 gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
116 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
117 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
118 static void |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
119 docklet_x11_blank_icon() |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
120 { |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
121 if (!blank_icon) { |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
122 gint width, height; |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
123 |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
124 gtk_icon_size_lookup(GTK_ICON_SIZE_LARGE_TOOLBAR, &width, &height); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
125 blank_icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
126 gdk_pixbuf_fill(blank_icon, 0); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
127 } |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
128 |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
129 gtk_image_set_from_pixbuf(GTK_IMAGE(image), blank_icon); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
130 } |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
131 |
10505 | 132 #if GTK_CHECK_VERSION(2,2,0) |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
133 static void |
10268
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
134 docklet_x11_position_menu(GtkMenu *menu, int *x, int *y, gboolean *push_in, |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
135 gpointer user_data) |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
136 { |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
137 GtkWidget *widget = GTK_WIDGET(docklet); |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
138 GtkRequisition req; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
139 gint menu_xpos, menu_ypos; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
140 |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
141 gtk_widget_size_request(GTK_WIDGET(menu), &req); |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
142 gdk_window_get_origin(widget->window, &menu_xpos, &menu_ypos); |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
143 |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
144 menu_xpos += widget->allocation.x; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
145 menu_ypos += widget->allocation.y; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
146 |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
147 if (menu_ypos > gdk_screen_get_height(gtk_widget_get_screen(widget)) / 2) |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
148 menu_ypos -= req.height; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
149 else |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
150 menu_ypos += widget->allocation.height; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
151 |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
152 *x = menu_xpos; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
153 *y = menu_ypos; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
154 |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
155 *push_in = TRUE; |
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
156 } |
10505 | 157 #endif |
10268
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
158 |
10504 | 159 static void |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
160 docklet_x11_destroy() |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
161 { |
10504 | 162 g_return_if_fail(docklet != NULL); |
163 | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
164 docklet_remove(GTK_WIDGET_VISIBLE(docklet)); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
165 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
166 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
167 gtk_widget_destroy(GTK_WIDGET(docklet)); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
168 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
169 g_object_unref(G_OBJECT(docklet)); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
170 docklet = NULL; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
171 |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
172 if (blank_icon) |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
173 g_object_unref(G_OBJECT(blank_icon)); |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
174 blank_icon = NULL; |
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
175 |
10504 | 176 image = NULL; |
177 | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
178 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "destroyed\n"); |
10504 | 179 } |
180 | |
181 static gboolean | |
182 docklet_x11_embed_timeout_cb() | |
183 { | |
184 docklet_unload(); | |
185 | |
10491 | 186 return FALSE; |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
187 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
188 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
189 static void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
190 docklet_x11_create() |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
191 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
192 GtkWidget *box; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
193 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
194 if (docklet) { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
195 /* if this is being called when a tray icon exists, it's because |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
196 something messed up. try destroying it before we proceed, |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
197 although docklet_refcount may be all hosed. hopefully won't happen. */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
198 gaim_debug(GAIM_DEBUG_WARNING, "tray icon", "trying to create icon but it already exists?\n"); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
199 docklet_x11_destroy(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
200 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
201 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
202 docklet = egg_tray_icon_new("Gaim"); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
203 box = gtk_event_box_new(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
204 image = gtk_image_new(); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
205 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
206 g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
207 g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
208 g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_x11_clicked_cb), NULL); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
209 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
210 gtk_container_add(GTK_CONTAINER(box), image); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
211 gtk_container_add(GTK_CONTAINER(docklet), box); |
9229 | 212 |
213 if(!gtk_check_version(2,4,0)) | |
214 g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); | |
215 | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
216 gtk_widget_show_all(GTK_WIDGET(docklet)); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
217 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
218 /* ref the docklet before we bandy it about the place */ |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
219 g_object_ref(G_OBJECT(docklet)); |
10491 | 220 docklet_embedded(); |
10504 | 221 embed_timeout = g_timeout_add(EMBED_TIMEOUT, docklet_x11_embed_timeout_cb, NULL); |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
222 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
223 gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n"); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
224 } |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
225 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
226 static struct docklet_ui_ops ui_ops = |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
227 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
228 docklet_x11_create, |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
229 docklet_x11_destroy, |
6894
c2fb9192377b
[gaim-migrate @ 7441]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6371
diff
changeset
|
230 docklet_x11_update_icon, |
10268
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
231 docklet_x11_blank_icon, |
10505 | 232 #if GTK_CHECK_VERSION(2,2,0) |
10268
d082b2a71ee7
[gaim-migrate @ 11414]
Christian Hammond <chipx86@chipx86.com>
parents:
9791
diff
changeset
|
233 docklet_x11_position_menu |
10505 | 234 #else |
235 NULL | |
236 #endif | |
6209
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
237 }; |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
238 |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
239 void |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
240 docklet_ui_init() |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
241 { |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
242 docklet_set_ui_ops(&ui_ops); |
dd715b02df41
[gaim-migrate @ 6695]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
diff
changeset
|
243 } |