annotate plugins/docklet/docklet.c @ 3513:ab939e746bdd

[gaim-migrate @ 3585] and Robot101 wants things initialized. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 15 Sep 2002 14:37:54 +0000
parents 1ea341091de8
children b1ebeecfd2aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* System tray docklet plugin for Gaim
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * Copyright (C) 2002 Robert McQueen <robot101@debian.org>
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * Inspired by a similar plugin by:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * John (J5) Palmieri <johnp@martianrock.com>
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation; either version 2 of the
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, but
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * General Public License for more details.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * 02111-1307, USA.
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 /* todo (in order of importance):
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 - don't crash when the plugin gets unloaded (it seems to crash after
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 the plugin has gone, when gtk updates the button in the plugins
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 dialog. backtrace is always useless. weird)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 - have a toggle on the menu to mute all Gaim sounds
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 - handle and update tooltips to show your current accounts
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 - connecting status support (needs more fruxing with the core)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 - dernyi's account status menu in the right click
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 - store icons in gtk2 stock icon thing (needs doing for the whole prog)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 - pop up notices when GNOME2's system-tray-applet supports it, with a
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 prefs dialog to choose what to alert for */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 /* includes */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 #define GAIM_PLUGINS
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 #include <gtk/gtk.h>
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 #include "gaim.h"
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 #include "eggtrayicon.h"
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 /* macros */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 #define DOCKLET_WINDOW_ICONIFIED(x) (gdk_window_get_state(GTK_WIDGET(x)->window) & GDK_WINDOW_STATE_ICONIFIED)
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 /* types */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 enum docklet_status {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 online,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 away,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 away_pending,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 connecting,
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 offline
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 };
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 /* functions */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 static void docklet_create();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 /* globals */
3513
ab939e746bdd [gaim-migrate @ 3585]
Luke Schierer <lschiere@pidgin.im>
parents: 3512
diff changeset
56 static EggTrayIcon *docklet = NULL;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 static GtkWidget *icon;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 static enum docklet_status status;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 static void docklet_embedded(GtkWidget *widget, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 debug_printf("Docklet: embedded\n");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 docklet_add();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 static void docklet_destroyed(GtkWidget *widget, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 debug_printf("Docklet: destroyed\n");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 docklet_remove();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 docklet_create();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 static void docklet_toggle() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 /* this looks bad, but we need to use (un)hide_buddy_list to allow buddy.c to
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 correctly hide/iconify depending on the docklet refcount, and to reposition
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 the blist for us when we unhide. no such constraint for the login window
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 because nothing else needs a unified way to hide/iconify it. otherwise I'd
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 make a function and use it for both. */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 if (connections) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 if (GTK_WIDGET_VISIBLE(blist)) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 if (DOCKLET_WINDOW_ICONIFIED(blist)) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 unhide_buddy_list();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 hide_buddy_list();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 unhide_buddy_list();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 if (GTK_WIDGET_VISIBLE(mainwindow)) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 if (DOCKLET_WINDOW_ICONIFIED(mainwindow)) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 gtk_window_present(GTK_WINDOW(mainwindow));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 gtk_widget_hide(mainwindow);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 gtk_window_present(GTK_WINDOW(mainwindow));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 static void docklet_menu(GdkEventButton *event) {
3513
ab939e746bdd [gaim-migrate @ 3585]
Luke Schierer <lschiere@pidgin.im>
parents: 3512
diff changeset
101 static GtkWidget *menu = NULL;
3512
1ea341091de8 [gaim-migrate @ 3584]
Luke Schierer <lschiere@pidgin.im>
parents: 3510
diff changeset
102 GtkWidget *entry;
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 if (menu) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 gtk_widget_destroy(menu);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 menu = gtk_menu_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 if (status == offline) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 entry = gtk_menu_item_new_with_label(_("Auto-login"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(auto_login), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 if (status == online) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 GtkWidget *docklet_awaymenu;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 GSList *awy = NULL;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 struct away_message *a = NULL;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 docklet_awaymenu = gtk_menu_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 awy = away_messages;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 while (awy) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 a = (struct away_message *)awy->data;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 entry = gtk_menu_item_new_with_label(a->name);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_away_message), a);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 gtk_menu_append(GTK_MENU(docklet_awaymenu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 awy = g_slist_next(awy);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 entry = gtk_separator_menu_item_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 gtk_menu_append(GTK_MENU(docklet_awaymenu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 entry = gtk_menu_item_new_with_label(_("New..."));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(create_away_mess), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 gtk_menu_append(GTK_MENU(docklet_awaymenu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 entry = gtk_menu_item_new_with_label(_("Away"));
3512
1ea341091de8 [gaim-migrate @ 3584]
Luke Schierer <lschiere@pidgin.im>
parents: 3510
diff changeset
141 gtk_menu_item_set_submenu(GTK_MENU_ITEM(entry), docklet_awaymenu);
3510
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 entry = gtk_menu_item_new_with_label(_("Back"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_im_back), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 entry = gtk_menu_item_new_with_label(_("Signoff"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(signoff_all), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 entry = gtk_separator_menu_item_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 entry = gtk_menu_item_new_with_label(_("Accounts"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(account_editor), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_PREFERENCES, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_prefs), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 entry = gtk_menu_item_new_with_label(_("Plugins"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_plugins), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 entry = gtk_separator_menu_item_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 entry = gtk_menu_item_new_with_label(_("About"));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(show_about), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 entry = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_signal_connect(GTK_WIDGET(entry), "activate", G_CALLBACK(do_quit), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 gtk_menu_append(GTK_MENU(menu), entry);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 gtk_widget_show_all(menu);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, event->button, event->time);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 switch (event->button) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186 case 1:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 docklet_toggle();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 case 2:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 case 3:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192 docklet_menu(event);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197 static void docklet_update_icon() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 gchar *filename;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 GdkPixbuf *unscaled;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 switch (status) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 case online:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "online.png", NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 case away:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "away.png", NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 case away_pending:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgpend.png", NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 case connecting:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "connecting.png", NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213 break;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 case offline:
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "offline.png", NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 unscaled = gdk_pixbuf_new_from_file(filename, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 if (unscaled) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 GdkPixbuf *scaled;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223 scaled = gdk_pixbuf_scale_simple(unscaled, 24, 24, GDK_INTERP_BILINEAR);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), scaled);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 g_object_unref(unscaled);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 g_object_unref(scaled);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 debug_printf("Docklet: updated icon to %s\n",filename);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
230 debug_printf("Docklet: failed to load icon from %s\n",filename);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 g_free(filename);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 static void docklet_update_status() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237 enum docklet_status oldstatus;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239 oldstatus = status;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
240
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 if (connections) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 if (imaway) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243 if (message_queue) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 status = away_pending;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 status = away;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 status = online;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 } else {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 status = offline;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255 if (status != oldstatus) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 docklet_update_icon();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 static void docklet_create() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261 GtkWidget *box;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 /* is this necessary/wise? */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 if (docklet) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 g_signal_handlers_disconnect_by_func(GTK_WIDGET(docklet), G_CALLBACK(docklet_destroyed), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 gtk_widget_destroy(GTK_WIDGET(docklet));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 debug_printf("Docklet: freed\n");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 docklet = egg_tray_icon_new("Gaim");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 box = gtk_event_box_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 icon = gtk_image_new();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274 g_signal_connect(GTK_WIDGET(docklet), "embedded", G_CALLBACK(docklet_embedded), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 g_signal_connect(GTK_WIDGET(docklet), "destroy", G_CALLBACK(docklet_destroyed), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 g_signal_connect(box, "button-press-event", G_CALLBACK(docklet_clicked), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 gtk_container_add(GTK_CONTAINER(box), icon);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279 gtk_container_add(GTK_CONTAINER(docklet), box);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 gtk_widget_show_all(GTK_WIDGET(docklet));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 docklet_update_icon();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 debug_printf("Docklet: created\n");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 static void gaim_signon(struct gaim_connection *gc, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292 static void gaim_signoff(struct gaim_connection *gc, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 static void gaim_connecting(struct aim_user *user, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301 /* we only support global away. this is the way it is, ok? */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305 static void gaim_im_recv(struct gaim_connection *gc, char **who, char **what, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 /* if message queuing while away is enabled, this event could be the first
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 message so we need to see if the status (and hence icon) needs changing */
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308 docklet_update_status();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314 static void gaim_buddy_signoff(struct gaim_connection *gc, char *who, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 static void gaim_buddy_away(struct gaim_connection *gc, char *who, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
318 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 static void gaim_buddy_back(struct gaim_connection *gc, char *who, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 static void gaim_new_conversation(char *who, void *data) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 char *gaim_plugin_init(GModule *handle) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 docklet_create();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 gaim_signal_connect(handle, event_signon, gaim_signon, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
331 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 gaim_signal_connect(handle, event_away, gaim_away, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 gaim_signal_connect(handle, event_im_recv, gaim_im_recv, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
336 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 return NULL;
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 void gaim_plugin_remove() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 if (GTK_WIDGET_VISIBLE(docklet)) {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 docklet_remove();
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 g_signal_handlers_disconnect_by_func(GTK_WIDGET(docklet), G_CALLBACK(docklet_destroyed), NULL);
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 gtk_widget_destroy(GTK_WIDGET(docklet));
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 debug_printf("Docklet: removed\n");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
354 const char *name() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 return _("System Tray Docklet");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 }
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
358 const char *description() {
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window.");
e23909729192 [gaim-migrate @ 3576]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 }