annotate plugins/chatlist.c @ 3207:75912ec1a1cb

[gaim-migrate @ 3224] Replaced back-tics with forward-tics for autoconf 2.13 compatibility. committer: Tailor Script <tailor@pidgin.im>
author Jim Seymour <jseymour>
date Sat, 04 May 2002 19:06:01 +0000
parents 6d95285533df
children ee79ca85fe0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 #define GAIM_PLUGINS
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 #include "pixmaps/cancel.xpm"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 #include "pixmaps/refresh.xpm"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 #include "pixmaps/gnome_add.xpm"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 #include "pixmaps/gnome_remove.xpm"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 #include "proxy.h"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 #include "gaim.h"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 #include <stdlib.h>
2272
4ecc9a9a75d8 [gaim-migrate @ 2282]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2241
diff changeset
12 #include <string.h>
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2900
diff changeset
14 #define AOL_SRCHSTR "aim:GoChat?RoomName="
2417
5473c8c5378d [gaim-migrate @ 2430]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2356
diff changeset
15
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 struct chat_page {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 GtkWidget *list1;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 GtkWidget *list2;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 };
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 struct chat_room {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 char name[80];
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 int exchange;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 };
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 static GtkWidget *item = NULL; /* this is the parent tree */
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 static GList *chat_rooms = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 static GtkWidget *parent = NULL; /* this is the config thing where you can see the list */
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 static struct chat_page *cp = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 static void des_item()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 if (item)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 gtk_widget_destroy(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 item = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 static void handle_click_chat(GtkWidget *widget, GdkEventButton * event, struct chat_room *cr)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 if (event->type == GDK_2BUTTON_PRESS && event->button == 1) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 GList *m = g_list_append(NULL, cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 int *x = g_new0(int, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 *x = cr->exchange;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 m = g_list_append(m, x);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 serv_join_chat(connections->data, m);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 g_free(x);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 g_list_free(m);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 static void setup_buddy_chats()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 GList *crs = chat_rooms;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 GtkWidget *tree;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 if (!blist)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 if (item)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 gtk_tree_remove_item(GTK_TREE(buddies), item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 item = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 if (!chat_rooms)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 item = gtk_tree_item_new_with_label(_("Buddy Chat"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 gtk_signal_connect(GTK_OBJECT(item), "destroy", GTK_SIGNAL_FUNC(des_item), NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 gtk_tree_append(GTK_TREE(buddies), item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 gtk_tree_item_expand(GTK_TREE_ITEM(item));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 tree = gtk_tree_new();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), tree);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 gtk_widget_show(tree);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 while (crs) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 struct chat_room *cr = (struct chat_room *)crs->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 GtkWidget *titem = gtk_tree_item_new_with_label(cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 gtk_object_set_user_data(GTK_OBJECT(titem), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 gtk_tree_append(GTK_TREE(tree), titem);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 gtk_widget_show(titem);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 gtk_signal_connect(GTK_OBJECT(titem), "button_press_event",
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 GTK_SIGNAL_FUNC(handle_click_chat), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 crs = crs->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 }
2900
aaaca46b507b [gaim-migrate @ 2913]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2892
diff changeset
87
aaaca46b507b [gaim-migrate @ 2913]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2892
diff changeset
88 gtk_tree_item_expand(GTK_TREE_ITEM(item));
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 static void save_chat_prefs()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 FILE *f;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 char path[1024];
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 char *x = gaim_user_dir();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 GList *crs = chat_rooms;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 g_snprintf(path, sizeof(path), "%s/%s", x, "chats");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 f = fopen(path, "w");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 if (!f) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 g_free(x);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 while (crs) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 struct chat_room *cr = crs->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 crs = crs->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 fprintf(f, "%s\n%d\n", cr->name, cr->exchange);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 }
2692
c74482cb3a8b [gaim-migrate @ 2705]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2664
diff changeset
109 g_free(x);
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 fclose(f);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 static void restore_chat_prefs()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 FILE *f;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 char path[1024];
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 char *x = gaim_user_dir();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 char buf[1024];
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 g_snprintf(path, sizeof(path), "%s/%s", x, "chats");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 f = fopen(path, "r");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 if (!f) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 g_free(x);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 while (fgets(buf, 1024, f)) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 struct chat_room *cr = g_new0(struct chat_room, 1);
2356
ddf404cd9757 [gaim-migrate @ 2369]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2272
diff changeset
128 g_snprintf(cr->name, sizeof(cr->name), "%s", g_strchomp(buf));
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 if (!fgets(buf, 1024, f)) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 g_free(cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 break;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 cr->exchange = atoi(buf);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 chat_rooms = g_list_append(chat_rooms, cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 }
2692
c74482cb3a8b [gaim-migrate @ 2705]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2664
diff changeset
136 g_free(x);
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 fclose(f);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 setup_buddy_chats();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 static void ref_list_callback(gpointer data, char *text)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 char *c;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 int len;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 GtkWidget *item;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 GList *items = GTK_LIST(cp->list1)->children;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 struct chat_room *cr;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 c = text;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 if (!text)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 return;
2892
3a8df5c3d1ee [gaim-migrate @ 2905]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2872
diff changeset
152 if (!parent)
3a8df5c3d1ee [gaim-migrate @ 2905]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2872
diff changeset
153 return;
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 len = strlen(text);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 while (items) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 g_free(gtk_object_get_user_data(GTK_OBJECT(items->data)));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 items = items->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 items = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 gtk_list_clear_items(GTK_LIST(cp->list1), 0, -1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 item = gtk_list_item_new_with_label(_("Gaim Chat"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 cr = g_new0(struct chat_room, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 strcpy(cr->name, _("Gaim Chat"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 cr->exchange = 4;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 gtk_object_set_user_data(GTK_OBJECT(item), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 items = g_list_append(NULL, item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 while (c) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 if (c - text > len - 30)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 break; /* assume no chat rooms 30 from end, padding */
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 if (!g_strncasecmp(AOL_SRCHSTR, c, strlen(AOL_SRCHSTR))) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 char *t;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 int len = 0;
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
181 int exchange = 5;
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 char *name = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 c += strlen(AOL_SRCHSTR);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 t = c;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 while (t) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 len++;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 name = g_realloc(name, len);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 if (*t == '+')
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 name[len - 1] = ' ';
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 else if (*t == '&') {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 name[len - 1] = 0;
3000
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
193 sscanf(t, "&Exchange=%d", &exchange);
6d95285533df [gaim-migrate @ 3013]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
194 c = t + strlen("&Exchange=x");
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 break;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 } else
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 name[len - 1] = *t;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 t++;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 cr = g_new0(struct chat_room, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 strcpy(cr->name, name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 cr->exchange = exchange;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 item = gtk_list_item_new_with_label(name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 items = g_list_append(items, item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 gtk_object_set_user_data(GTK_OBJECT(item), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 g_free(name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 c++;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 gtk_list_append_items(GTK_LIST(cp->list1), items);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 static void refresh_list(GtkWidget *w, gpointer *m)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 {
2872
30828b83143d [gaim-migrate @ 2885]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2692
diff changeset
216 grab_url("http://www.aim.com/community/chats.adp", FALSE, ref_list_callback, NULL);
2241
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 static void add_chat(GtkWidget *w, gpointer *m)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 GList *sel = GTK_LIST(cp->list1)->selection;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 struct chat_room *cr, *cr2;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 GList *crs = chat_rooms;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 GtkWidget *item;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 if (sel) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(sel->data));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 } else
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 while (crs) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 cr2 = (struct chat_room *)crs->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 if (!g_strcasecmp(cr->name, cr2->name))
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 crs = crs->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 item = gtk_list_item_new_with_label(cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 cr2 = g_new0(struct chat_room, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 strcpy(cr2->name, cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 cr2->exchange = cr->exchange;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 gtk_object_set_user_data(GTK_OBJECT(item), cr2);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 sel = g_list_append(NULL, item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 gtk_list_append_items(GTK_LIST(cp->list2), sel);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 chat_rooms = g_list_append(chat_rooms, cr2);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 setup_buddy_chats();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 save_chat_prefs();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 static void remove_chat(GtkWidget *w, gpointer *m)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 GList *sel = GTK_LIST(cp->list2)->selection;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 struct chat_room *cr;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 GList *crs;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 GtkWidget *item;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 if (sel) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 item = (GtkWidget *)sel->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 cr = (struct chat_room *)gtk_object_get_user_data(GTK_OBJECT(item));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 } else
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 chat_rooms = g_list_remove(chat_rooms, cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 gtk_list_clear_items(GTK_LIST(cp->list2), 0, -1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 if (g_list_length(chat_rooms) == 0)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 chat_rooms = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 crs = chat_rooms;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 while (crs) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 cr = (struct chat_room *)crs->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 item = gtk_list_item_new_with_label(cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 gtk_object_set_user_data(GTK_OBJECT(item), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 gtk_list_append_items(GTK_LIST(cp->list2), g_list_append(NULL, item));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 crs = crs->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 setup_buddy_chats();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 save_chat_prefs();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 static void parent_destroy()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 if (parent)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 gtk_widget_destroy(parent);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 parent = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 void gaim_plugin_config()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 GtkWidget *vbox;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 GtkWidget *frame;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 GtkWidget *box;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 GtkWidget *table;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 GtkWidget *rem_button, *add_button, *ref_button;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 GtkWidget *list1, *list2;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 GtkWidget *label;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 GtkWidget *sw1, *sw2;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 GtkWidget *item;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 GtkWidget *hbox;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 GtkWidget *button;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 GList *crs = chat_rooms;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 GList *items = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 struct chat_room *cr;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 if (parent) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 gtk_widget_show(parent);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 return;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 if (cp)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 g_free(cp);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 cp = g_new0(struct chat_page, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 parent = gtk_window_new(GTK_WINDOW_TOPLEVEL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 gtk_widget_set_usize(parent, 300, 400);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 gtk_window_set_title(GTK_WINDOW(parent), "Chat Rooms");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 gtk_window_set_wmclass(GTK_WINDOW(parent), "chatlist", "Gaim");
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 gtk_widget_realize(parent);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 aol_icon(parent->window);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 gtk_signal_connect(GTK_OBJECT(parent), "destroy",
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 GTK_SIGNAL_FUNC(parent_destroy), NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 vbox = gtk_vbox_new(FALSE, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 gtk_container_add(GTK_CONTAINER(parent), vbox);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 gtk_widget_show(vbox);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 hbox = gtk_hbox_new(FALSE, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 gtk_box_pack_end(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 gtk_widget_show(hbox);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 button = picture_button(parent, _("Close"), cancel_xpm);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 gtk_signal_connect(GTK_OBJECT(button), "clicked",
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 GTK_SIGNAL_FUNC(parent_destroy), NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 frame = gtk_frame_new(_("Chat Rooms"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 gtk_widget_show(frame);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 box = gtk_vbox_new(FALSE, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 gtk_container_set_border_width(GTK_CONTAINER(box), 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 gtk_container_add(GTK_CONTAINER(frame), box);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 gtk_widget_show(box);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 table = gtk_table_new(4, 2, FALSE);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 gtk_widget_show(table);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 gtk_box_pack_start(GTK_BOX(box), table, TRUE, TRUE, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 list1 = gtk_list_new();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 list2 = gtk_list_new();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 sw1 = gtk_scrolled_window_new(NULL, NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 sw2 = gtk_scrolled_window_new(NULL, NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 ref_button = picture_button(parent, _("Refresh"), refresh_xpm);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 add_button = picture_button(parent, _("Add"), gnome_add_xpm);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 rem_button = picture_button(parent, _("Remove"), gnome_remove_xpm);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 gtk_widget_show(list1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 gtk_widget_show(sw1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 gtk_widget_show(list2);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 gtk_widget_show(sw2);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw1), list1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list2);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw1),
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2),
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 cp->list1 = list1;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 cp->list2 = list2;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 gtk_signal_connect(GTK_OBJECT(ref_button), "clicked", GTK_SIGNAL_FUNC(refresh_list), cp);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 gtk_signal_connect(GTK_OBJECT(rem_button), "clicked", GTK_SIGNAL_FUNC(remove_chat), cp);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 gtk_signal_connect(GTK_OBJECT(add_button), "clicked", GTK_SIGNAL_FUNC(add_chat), cp);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 label = gtk_label_new(_("List of available chats"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 gtk_widget_show(label);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 gtk_table_attach(GTK_TABLE(table), ref_button, 0, 1, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 gtk_table_attach(GTK_TABLE(table), sw1, 0, 1, 2, 3,
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 gtk_table_attach(GTK_TABLE(table), add_button, 0, 1, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 label = gtk_label_new(_("List of subscribed chats"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 gtk_widget_show(label);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 gtk_table_attach(GTK_TABLE(table), label, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 gtk_table_attach(GTK_TABLE(table), sw2, 1, 2, 2, 3,
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 5, 5);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 gtk_table_attach(GTK_TABLE(table), rem_button, 1, 2, 3, 4, GTK_SHRINK, GTK_SHRINK, 0, 0);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 item = gtk_list_item_new_with_label(_("Gaim Chat"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 cr = g_new0(struct chat_room, 1);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 strcpy(cr->name, _("Gaim Chat"));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 cr->exchange = 4;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 gtk_object_set_user_data(GTK_OBJECT(item), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 gtk_list_append_items(GTK_LIST(list1), g_list_append(NULL, item));
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 while (crs) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 cr = (struct chat_room *)crs->data;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 item = gtk_list_item_new_with_label(cr->name);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 gtk_object_set_user_data(GTK_OBJECT(item), cr);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 gtk_widget_show(item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 items = g_list_append(items, item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 crs = crs->next;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 gtk_list_append_items(GTK_LIST(list2), items);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 gtk_widget_show(parent);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 static void handle_signon(struct gaim_connection *gc)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 setup_buddy_chats();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 char *gaim_plugin_init(GModule *m)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 restore_chat_prefs();
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 gaim_signal_connect(m, event_signon, handle_signon, NULL);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 return NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 void gaim_plugin_remove()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 if (parent)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 gtk_widget_destroy(parent);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 parent = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 if (item)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 gtk_tree_remove_item(GTK_TREE(buddies), item);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 item = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 while (chat_rooms) {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 g_free(chat_rooms->data);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 chat_rooms = g_list_remove(chat_rooms, chat_rooms->data);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 if (cp)
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 g_free(cp);
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 cp = NULL;
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 char *name()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 return "Chat List";
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 }
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 char *description()
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 {
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 return "Allows you to add chat rooms to your buddy list. Click the configure button to choose"
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 " which rooms.";
a0ee02e861b9 [gaim-migrate @ 2251]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 }