Wed, 20 Aug 2003 11:08:19 +0000
[gaim-migrate @ 7046]
The fortunateprofile.pl script works again. At least, I think it works, but
it's never worked here, but all the events and suff work, so that's good,
and i added a test.pl that people acan also see. now I'm going to bebd.
| 6209 | 1 | /* |
| 2 | * System tray icon (aka docklet) plugin for Gaim | |
| 3 | * | |
| 4 | * Copyright (C) 2002-3 Robert McQueen <robot101@debian.org> | |
| 5 | * Copyright (C) 2003 Herman Bloggs <hermanator12002@yahoo.com> | |
| 6 | * Inspired by a similar plugin by: | |
| 7 | * John (J5) Palmieri <johnp@martianrock.com> | |
| 8 | * | |
| 9 | * This program is free software; you can redistribute it and/or | |
| 10 | * modify it under the terms of the GNU General Public License as | |
| 11 | * published by the Free Software Foundation; either version 2 of the | |
| 12 | * License, or (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, but | |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 17 | * General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
| 22 | * 02111-1307, USA. | |
| 23 | */ | |
| 24 | ||
| 25 | #include "internal.h" | |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6209
diff
changeset
|
26 | #include "gtkinternal.h" |
| 6209 | 27 | #include "debug.h" |
| 28 | #include "stock.h" | |
| 29 | ||
| 30 | #include "gaim.h" | |
| 31 | #include "ui.h" | |
| 32 | ||
| 33 | #include "eggtrayicon.h" | |
| 34 | #include "docklet.h" | |
| 35 | ||
| 36 | /* globals */ | |
| 37 | static EggTrayIcon *docklet = NULL; | |
| 38 | static GtkWidget *image = NULL; | |
| 39 | ||
| 40 | /* protos */ | |
| 41 | static void docklet_x11_create(); | |
| 42 | ||
| 43 | static gboolean | |
| 44 | docklet_x11_create_cb() | |
| 45 | { | |
| 46 | docklet_x11_create(); | |
| 47 | ||
| 48 | return FALSE; /* for when we're called by the glib idle handler */ | |
| 49 | } | |
| 50 | ||
| 51 | static void | |
| 52 | docklet_x11_embedded_cb(GtkWidget *widget, void *data) | |
| 53 | { | |
| 54 | gaim_debug(GAIM_DEBUG_INFO, "tray icon", "embedded\n"); | |
| 55 | ||
| 56 | docklet_embedded(); | |
| 57 | } | |
| 58 | ||
| 59 | static void | |
| 60 | docklet_x11_destroyed_cb(GtkWidget *widget, void *data) | |
| 61 | { | |
| 62 | gaim_debug(GAIM_DEBUG_INFO, "tray icon", "destroyed\n"); | |
| 63 | ||
| 64 | docklet_remove(TRUE); | |
| 65 | ||
| 66 | g_object_unref(G_OBJECT(docklet)); | |
| 67 | docklet = NULL; | |
| 68 | ||
| 69 | g_idle_add(docklet_x11_create_cb, &handle); | |
| 70 | } | |
| 71 | ||
| 72 | static void | |
| 73 | docklet_x11_clicked_cb(GtkWidget *button, GdkEventButton *event, void *data) | |
| 74 | { | |
| 75 | if (event->type != GDK_BUTTON_PRESS) | |
| 76 | return; | |
| 77 | ||
| 78 | docklet_clicked(event->button); | |
| 79 | } | |
| 80 | ||
| 81 | static void | |
| 82 | docklet_x11_update_icon(enum docklet_status icon) | |
| 83 | { | |
| 84 | const gchar *icon_name = NULL; | |
| 85 | ||
| 86 | switch (icon) { | |
| 87 | case offline: | |
| 88 | icon_name = GAIM_STOCK_ICON_OFFLINE; | |
| 89 | break; | |
| 90 | case offline_connecting: | |
| 91 | case online_connecting: | |
| 92 | icon_name = GAIM_STOCK_ICON_CONNECT; | |
| 93 | break; | |
| 94 | case online: | |
| 95 | icon_name = GAIM_STOCK_ICON_ONLINE; | |
| 96 | break; | |
| 97 | case online_pending: | |
| 98 | icon_name = GAIM_STOCK_ICON_ONLINE_MSG; | |
| 99 | break; | |
| 100 | case away: | |
| 101 | icon_name = GAIM_STOCK_ICON_AWAY; | |
| 102 | break; | |
| 103 | case away_pending: | |
| 104 | icon_name = GAIM_STOCK_ICON_AWAY_MSG; | |
| 105 | break; | |
| 106 | } | |
| 107 | ||
| 108 | gtk_image_set_from_stock(GTK_IMAGE(image), icon_name, GTK_ICON_SIZE_LARGE_TOOLBAR); | |
| 109 | } | |
| 110 | ||
| 111 | static void | |
| 112 | docklet_x11_destroy() | |
| 113 | { | |
| 114 | docklet_remove(GTK_WIDGET_VISIBLE(docklet)); | |
| 115 | ||
| 116 | g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_x11_destroyed_cb), NULL); | |
| 117 | gtk_widget_destroy(GTK_WIDGET(docklet)); | |
| 118 | ||
| 119 | g_object_unref(G_OBJECT(docklet)); | |
| 120 | docklet = NULL; | |
| 121 | ||
| 122 | gaim_debug(GAIM_DEBUG_INFO, "tray icon", "destroyed\n"); | |
| 123 | } | |
| 124 | ||
| 125 | static void | |
| 126 | docklet_x11_create() | |
| 127 | { | |
| 128 | GtkWidget *box; | |
| 129 | ||
| 130 | if (docklet) { | |
| 131 | /* if this is being called when a tray icon exists, it's because | |
| 132 | something messed up. try destroying it before we proceed, | |
| 133 | although docklet_refcount may be all hosed. hopefully won't happen. */ | |
| 134 | gaim_debug(GAIM_DEBUG_WARNING, "tray icon", "trying to create icon but it already exists?\n"); | |
| 135 | docklet_x11_destroy(); | |
| 136 | } | |
| 137 | ||
| 138 | docklet = egg_tray_icon_new("Gaim"); | |
| 139 | box = gtk_event_box_new(); | |
| 140 | image = gtk_image_new(); | |
| 141 | ||
| 142 | g_signal_connect(G_OBJECT(docklet), "embedded", G_CALLBACK(docklet_x11_embedded_cb), NULL); | |
| 143 | g_signal_connect(G_OBJECT(docklet), "destroy", G_CALLBACK(docklet_x11_destroyed_cb), NULL); | |
| 144 | g_signal_connect(G_OBJECT(box), "button-press-event", G_CALLBACK(docklet_x11_clicked_cb), NULL); | |
| 145 | ||
| 146 | gtk_container_add(GTK_CONTAINER(box), image); | |
| 147 | gtk_container_add(GTK_CONTAINER(docklet), box); | |
| 148 | gtk_widget_show_all(GTK_WIDGET(docklet)); | |
| 149 | ||
| 150 | /* ref the docklet before we bandy it about the place */ | |
| 151 | g_object_ref(G_OBJECT(docklet)); | |
| 152 | ||
| 153 | gaim_debug(GAIM_DEBUG_INFO, "tray icon", "created\n"); | |
| 154 | } | |
| 155 | ||
| 156 | static struct docklet_ui_ops ui_ops = | |
| 157 | { | |
| 158 | docklet_x11_create, | |
| 159 | docklet_x11_destroy, | |
| 160 | docklet_x11_update_icon | |
| 161 | }; | |
| 162 | ||
| 163 | void | |
| 164 | docklet_ui_init() | |
| 165 | { | |
| 166 | docklet_set_ui_ops(&ui_ops); | |
| 167 | } |