annotate src/applet.c @ 1456:6650776468b3

[gaim-migrate @ 1466] trying to pass -Wall committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 01 Feb 2001 08:37:16 +0000
parents 13a34fb4abb0
children 5c74d8b6cb57
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /**************************************************************
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 ** GaimGnomeAppletMgr
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 ** Author - Quinticent (John Palmieri: johnp@martianrock.com)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 ** Purpose - Takes over the task of managing the GNOME applet
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 ** code and provides a centralized codebase for
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 ** GNOME integration for Gaim.
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 ** gaim
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 ** Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 ** This program is free software; you can redistribute it and/or modify
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 ** it under the terms of the GNU General Public License as published by
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 ** the Free Software Foundation; either version 2 of the License, or
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 ** (at your option) any later version.
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 ** This program is distributed in the hope that it will be useful,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 ** GNU General Public License for more details.
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 ** You should have received a copy of the GNU General Public License
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 ** along with this program; if not, write to the Free Software
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 */
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #ifdef HAVE_CONFIG_H
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include "../config.h"
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #endif
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #ifdef USE_APPLET
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include <string.h>
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 #include <gdk_imlib.h>
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 #include "gaim.h"
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 #include "applet.h"
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 static int connecting = 0;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 gboolean applet_buddy_show = FALSE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 GtkWidget *applet_popup = NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 GtkWidget *applet;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 GtkWidget *appletframe;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 GtkWidget *status_label;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 GtkWidget *icon;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 GdkPixmap *icon_offline_pm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 GdkPixmap *icon_offline_bm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 GdkPixmap *icon_online_pm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 GdkPixmap *icon_online_bm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 GdkPixmap *icon_connect_pm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 GdkPixmap *icon_connect_bm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 GdkPixmap *icon_msg_pending_pm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 GdkPixmap *icon_msg_pending_bm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 GdkPixmap *icon_away_pm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 GdkPixmap *icon_away_bm=NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 static GtkAllocation get_applet_pos(gboolean);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 gint sizehint=48;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 static gboolean load_applet_icon(const char *name, int height, int width,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 GdkPixmap **pm, GdkBitmap **bm)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 gboolean result = TRUE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 char *path;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 GdkImlibImage *im;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 path = gnome_pixmap_file(name);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 im=gdk_imlib_load_image( path );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 if ((*pm)!=NULL)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 gdk_imlib_free_pixmap((*pm));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 if( im!= NULL ){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 gdk_imlib_render(im,width,height);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 (*pm) = gdk_imlib_move_image(im);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 (*bm) = gdk_imlib_move_mask(im);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 result = FALSE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 debug_printf(_("file not found: %s\n"),path);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 free(path);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 return result;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 #ifdef HAVE_PANEL_PIXEL_SIZE
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 static void applet_change_pixel_size(GtkWidget *w, int size, gpointer data)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 sizehint = size;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 update_pixmaps();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 #endif
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 static gboolean update_applet(){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 char buf[BUF_LONG];
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 GSList *c = connections;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 if (connecting) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 gtk_pixmap_set( GTK_PIXMAP(icon),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 icon_connect_pm,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 icon_connect_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 gtk_label_set( GTK_LABEL(status_label), _MSG_CONNECT_ );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 applet_set_tooltips(_("Attempting to sign on...."));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 } else if (!connections) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 gtk_pixmap_set( GTK_PIXMAP(icon),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 icon_offline_pm,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 icon_offline_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 gtk_label_set( GTK_LABEL(status_label), _MSG_OFFLINE_ );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 applet_set_tooltips(_("Offilne. Click to bring up login box."));
1281
83d8b2078f4c [gaim-migrate @ 1291]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1280
diff changeset
120 } else if (!awaymessage) {
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 gtk_pixmap_set( GTK_PIXMAP(icon),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 icon_online_pm,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 icon_online_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 gtk_label_set( GTK_LABEL(status_label), _MSG_ONLINE_ );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 g_snprintf(buf, sizeof buf, "Online: ");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 while (c) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 strcat(buf, ((struct gaim_connection *)c->data)->username);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 c = g_slist_next(c);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 if (c) strcat(buf, ", ");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 applet_set_tooltips(buf);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 gtk_pixmap_set( GTK_PIXMAP(icon),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 icon_online_pm,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 icon_online_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 gtk_label_set( GTK_LABEL(status_label), _("Away") );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 return TRUE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 void update_pixmaps() {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, (sizehint-16), (sizehint-12),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 &icon_offline_pm, &icon_offline_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 load_applet_icon( GAIM_GNOME_CONNECT_ICON, (sizehint-16), (sizehint-12),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 &icon_connect_pm, &icon_connect_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 load_applet_icon( GAIM_GNOME_ONLINE_ICON, (sizehint-16), (sizehint-12),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 &icon_online_pm, &icon_online_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 update_applet();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 gtk_widget_set_usize(appletframe, sizehint, sizehint);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 extern GtkWidget *mainwindow;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 void applet_show_login(AppletWidget *widget, gpointer data) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 show_login();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 if (general_options & OPT_GEN_NEAR_APPLET) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 GtkAllocation a = get_applet_pos(FALSE);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 gtk_widget_set_uposition(mainwindow, a.x, a.y);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 void applet_do_signon(AppletWidget *widget, gpointer data) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 applet_show_login(NULL, 0);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 void insert_applet_away() {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 GSList *awy = away_messages;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 struct away_message *a;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 char *awayname;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 applet_widget_register_callback_dir(APPLET_WIDGET(applet),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 "away/",
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 _("Away"));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 applet_widget_register_callback(APPLET_WIDGET(applet),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 "away/new",
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 _("New Away Message"),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 (AppletCallbackFunc)create_away_mess,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 while(awy) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 a = (struct away_message *)awy->data;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name)));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 awayname[0] = '\0';
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 strcat(awayname, "away/");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 strcat(awayname, a->name);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 applet_widget_register_callback(APPLET_WIDGET(applet),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 awayname,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 a->name,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 (AppletCallbackFunc)do_away_message,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 a);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 awy = g_slist_next(awy);
1421
13a34fb4abb0 [gaim-migrate @ 1431]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1420
diff changeset
195 g_free(awayname);
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 void remove_applet_away() {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 GSList *awy = away_messages;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 struct away_message *a;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 char *awayname;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away/new");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 while (awy) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 a = (struct away_message *)awy->data;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 awayname = g_malloc(sizeof *awayname * (6 + strlen(a->name)));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 awayname[0] = '\0';
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 strcat(awayname, "away/");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 strcat(awayname, a->name);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 applet_widget_unregister_callback(APPLET_WIDGET(applet), awayname);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 awy = g_slist_next(awy);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 free(awayname);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 applet_widget_unregister_callback_dir(APPLET_WIDGET(applet), "away/");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 applet_widget_unregister_callback(APPLET_WIDGET(applet), "away");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 static GtkAllocation get_applet_pos(gboolean for_blist) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 gint x,y,pad;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 GtkRequisition buddy_req, applet_req;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 GtkAllocation result;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 GNOME_Panel_OrientType orient = applet_widget_get_panel_orient( APPLET_WIDGET(applet) );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 pad = 5;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228
1420
9be6790092dc [gaim-migrate @ 1430]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1413
diff changeset
229 gdk_window_get_position(gtk_widget_get_parent_window(appletframe), &x, &y);
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 if (for_blist) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 if (general_options & OPT_GEN_SAVED_WINDOWS) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 buddy_req.width = blist_pos.width;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 buddy_req.height = blist_pos.height;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 buddy_req = blist->requisition;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 buddy_req = mainwindow->requisition;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 applet_req = appletframe->requisition;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 /* FIXME : we need to be smarter here */
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 switch( orient ){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 case ORIENT_UP:
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 result.x=x;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 result.y=y-(buddy_req.height+pad);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 break;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 case ORIENT_DOWN:
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 result.x=x;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 result.y=y+applet_req.height+pad;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 break;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 case ORIENT_LEFT:
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 result.x=x-(buddy_req.width + pad );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 result.y=y;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 break;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 case ORIENT_RIGHT:
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 result.x=x+applet_req.width+pad;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 result.y=y;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 break;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 return result;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 void createOnlinePopup(){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 GtkAllocation al;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 if (blist) gtk_widget_show(blist);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 al = get_applet_pos(TRUE);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 if (general_options & OPT_GEN_NEAR_APPLET)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 gtk_widget_set_uposition ( blist, al.x, al.y );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 else if (general_options & OPT_GEN_SAVED_WINDOWS)
1420
9be6790092dc [gaim-migrate @ 1430]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1413
diff changeset
271 gtk_widget_set_uposition(blist, blist_pos.x - blist_pos.xoff, blist_pos.y - blist_pos.yoff);
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 void AppletClicked( GtkWidget *sender, GdkEventButton *ev, gpointer data ){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 if (!ev || ev->button != 1 || ev->type != GDK_BUTTON_PRESS)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 return;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 if(applet_buddy_show) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 applet_buddy_show = FALSE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 if (!connections && mainwindow)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 gtk_widget_hide(mainwindow);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 else
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 gtk_widget_hide(blist);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 applet_buddy_show = TRUE;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 if (!connections)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 applet_show_login( APPLET_WIDGET(applet), NULL );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 else
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 createOnlinePopup();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 /***************************************************************
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 ** Initialize GNOME stuff
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 **
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 ****************************************************************/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 gint init_applet_mgr(int argc, char *argv[]) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 GtkWidget *vbox;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 GtkStyle *label_style;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 GdkFont *label_font = NULL;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 applet_widget_init("GAIM",VERSION,argc,argv,NULL,0,NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 /*init imlib for graphics*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 gdk_imlib_init();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 gtk_widget_push_visual(gdk_imlib_get_visual());
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 gtk_widget_push_colormap(gdk_imlib_get_colormap());
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 applet=applet_widget_new("gaim_applet");
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 if(!applet) g_error(_("Can't create GAIM applet!"));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 gtk_widget_set_events(applet, gtk_widget_get_events(applet) |
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 GDK_BUTTON_PRESS_MASK);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 appletframe = gtk_frame_new(NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 #ifdef HAVE_PANEL_PIXEL_SIZE
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 gtk_widget_set_usize(appletframe, 5, 5);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 #else
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 gtk_widget_set_usize(appletframe, 48, 48);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 #endif
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 /*load offline icon*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 load_applet_icon( GAIM_GNOME_OFFLINE_ICON, 32, 32,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 &icon_offline_pm, &icon_offline_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 /*load connecting icon*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 load_applet_icon( GAIM_GNOME_CONNECT_ICON, 32, 32,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 &icon_connect_pm, &icon_connect_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 /*load online icon*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 load_applet_icon( GAIM_GNOME_ONLINE_ICON, 32, 32,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 &icon_online_pm, &icon_online_bm );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 /*icon_away and icon_msg_pennding need to be implemented*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 icon=gtk_pixmap_new(icon_offline_pm,icon_offline_bm);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 vbox = gtk_vbox_new(FALSE,0);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 gtk_box_pack_start(GTK_BOX(vbox), icon, FALSE, TRUE, 0);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 status_label = gtk_label_new(_("Offline"));
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 update_applet();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 /*set this label's font*/
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 label_style = gtk_widget_get_style( status_label );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 label_font = gdk_font_load( _MSG_FONT_ );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 if( label_font != NULL ){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 label_style->font = label_font;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 gtk_widget_set_style( status_label, label_style );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 } else {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 debug_printf(_("Font does not exist") );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 gtk_box_pack_start(GTK_BOX(vbox), status_label, FALSE, TRUE, 0);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 gtk_container_add( GTK_CONTAINER(appletframe), vbox );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 applet_widget_add(APPLET_WIDGET(applet), appletframe);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 gtk_widget_show( status_label );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 gtk_widget_show( vbox );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 gtk_widget_show( appletframe );
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 applet_widget_register_stock_callback(APPLET_WIDGET(applet),
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 "about",
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 GNOME_STOCK_MENU_ABOUT,
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 _("About..."),
1456
6650776468b3 [gaim-migrate @ 1466]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1421
diff changeset
375 (AppletCallbackFunc)show_about,
1261
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378 gtk_signal_connect( GTK_OBJECT(applet), "button_press_event", GTK_SIGNAL_FUNC( AppletClicked), NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 gtk_signal_connect( GTK_OBJECT(applet), "destroy", GTK_SIGNAL_FUNC( do_quit), NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 #ifdef HAVE_PANEL_PIXEL_SIZE
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 gtk_signal_connect(GTK_OBJECT(applet), "change_pixel_size",
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 GTK_SIGNAL_FUNC(applet_change_pixel_size), NULL);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 #endif
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 gtk_widget_show(icon);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 gtk_widget_show(applet);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 return 0;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 void set_user_state( enum gaim_user_states state ){
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 if (state == signing_on)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 connecting++;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 else if ((state == away || state == online) && connecting > 0)
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 connecting--;
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 update_applet();
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 void applet_set_tooltips(char *msg) {
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 applet_widget_set_tooltip(APPLET_WIDGET(applet), msg);
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 }
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403
07f0bb41bbe1 [gaim-migrate @ 1271]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 #endif /*USE_APPLET*/