Mercurial > pidgin
annotate src/gtkpounce.c @ 5857:2fa4aa9c1885
[gaim-migrate @ 6288]
Renamed the pounce structures and typedefs to be in sync with the rest of
the API. Also added some g_return_*_if_fail() checks in place of the if
statements we had. I'll try to get pounces working again.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Fri, 13 Jun 2003 23:04:26 +0000 |
parents | dae79aefac8d |
children | 417b1001d2b1 |
rev | line source |
---|---|
5032 | 1 /** |
2 * @file gtkpounce.h GTK+ buddy pounce API | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003, Christian Hammond <chipx86@gnupdate.org> | |
7 * | |
8 * This program is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * This program is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License | |
19 * along with this program; if not, write to the Free Software | |
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 * | |
22 */ | |
5054 | 23 #include <unistd.h> |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
24 #include <string.h> |
5032 | 25 #include "gaim.h" |
26 #include "gtkpounce.h" | |
5228
1a53330dfd34
[gaim-migrate @ 5598]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
27 #include "gtkblist.h" |
5032 | 28 #include "prpl.h" |
29 #include "sound.h" | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
30 #include "notify.h" |
5032 | 31 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
32 typedef struct |
5032 | 33 { |
34 /* Pounce data */ | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
35 GaimPounce *pounce; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
36 GaimAccount *account; |
5032 | 37 |
38 /* The window */ | |
39 GtkWidget *window; | |
40 | |
41 /* Pounce Who */ | |
42 GtkWidget *account_menu; | |
43 GtkWidget *buddy_entry; | |
44 | |
45 /* Pounce When */ | |
46 GtkWidget *signon; | |
47 GtkWidget *signoff; | |
48 GtkWidget *away; | |
49 GtkWidget *away_return; | |
50 GtkWidget *idle; | |
51 GtkWidget *idle_return; | |
52 GtkWidget *typing; | |
53 GtkWidget *stop_typing; | |
54 | |
55 /* Pounce Action */ | |
56 GtkWidget *open_win; | |
57 GtkWidget *popup; | |
58 GtkWidget *send_msg; | |
59 GtkWidget *send_msg_entry; | |
60 GtkWidget *exec_cmd; | |
61 GtkWidget *exec_cmd_entry; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
62 GtkWidget *exec_cmd_browse; |
5032 | 63 GtkWidget *play_sound; |
64 GtkWidget *play_sound_entry; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
65 GtkWidget *play_sound_browse; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
66 GtkWidget *play_sound_test; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
67 |
5032 | 68 GtkWidget *save_pounce; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
69 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
70 } GaimGtkPounceDialog; |
5032 | 71 |
72 /************************************************************************** | |
73 * Callbacks | |
74 **************************************************************************/ | |
75 static gint | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
76 delete_win_cb(GtkWidget *w, GdkEventAny *e, GaimGtkPounceDialog *dialog) |
5032 | 77 { |
78 gtk_widget_destroy(dialog->window); | |
79 g_free(dialog); | |
80 | |
81 return TRUE; | |
82 } | |
83 | |
84 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
85 delete_cb(GtkWidget *w, GaimGtkPounceDialog *dialog) |
5052
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
86 { |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
87 gaim_pounce_destroy(dialog->pounce); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
88 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
89 delete_win_cb(NULL, NULL, dialog); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
90 } |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
91 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
92 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
93 cancel_cb(GtkWidget *w, GaimGtkPounceDialog *dialog) |
5032 | 94 { |
95 delete_win_cb(NULL, NULL, dialog); | |
96 } | |
97 | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
98 static void |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
99 pounce_update_entryfields(GtkWidget *w, gpointer data) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
100 { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
101 const char *filename; |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
102 GHashTable *args; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
103 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
104 args = (GHashTable *)data; |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
105 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
106 filename = gtk_file_selection_get_filename(GTK_FILE_SELECTION( |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
107 g_hash_table_lookup(args, "filesel"))); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
108 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
109 if (filename != NULL) |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
110 gtk_entry_set_text(GTK_ENTRY(g_hash_table_lookup(args, "entry")), |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
111 filename); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
112 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
113 g_free(args); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
114 } |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
115 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
116 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
117 filesel(GtkWidget *w, gpointer data) |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
118 { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
119 GtkWidget *filesel; |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
120 GtkWidget *entry; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
121 GHashTable *args; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
122 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
123 entry = (GtkWidget *)data; |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
124 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
125 filesel = gtk_file_selection_new(_("Select a file")); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
126 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
127 gtk_entry_get_text(GTK_ENTRY(entry))); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
128 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(filesel)); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
129 gtk_file_selection_set_select_multiple(GTK_FILE_SELECTION(filesel), FALSE); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
130 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
131 args = g_hash_table_new(g_str_hash,g_str_equal); |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
132 g_hash_table_insert(args, "filesel", filesel); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
133 g_hash_table_insert(args, "entry", entry); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
134 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
135 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
136 "clicked", |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
137 G_CALLBACK(pounce_update_entryfields), args); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
138 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
139 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
140 "clicked", |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
141 G_CALLBACK(gtk_widget_destroy), filesel); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
142 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
143 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
144 "clicked", |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
145 G_CALLBACK(gtk_widget_destroy), filesel); |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
146 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
147 gtk_widget_show(filesel); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
148 } |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
149 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
150 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
151 pounce_test_sound(GtkWidget *w, GtkWidget *entry) |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
152 { |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
153 const char *filename; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
154 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
155 filename = gtk_entry_get_text(GTK_ENTRY(entry)); |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
156 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
157 if (filename != NULL && *filename != '\0') |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
158 gaim_sound_play_file((char *) filename); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
159 else |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
160 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
161 } |
5032 | 162 |
163 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
164 save_pounce_cb(GtkWidget *w, GaimGtkPounceDialog *dialog) |
5032 | 165 { |
166 const char *name; | |
167 const char *message, *command, *sound; | |
168 struct gaim_buddy_list *blist; | |
169 struct gaim_gtk_buddy_list *gtkblist; | |
170 GaimPounceEvent events = GAIM_POUNCE_NONE; | |
171 GaimGtkPounceAction actions = GAIM_GTKPOUNCE_NONE; | |
172 gboolean save; | |
173 | |
174 name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); | |
175 | |
176 if (*name == '\0') { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
177 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
178 _("Please enter a buddy to pounce."), NULL); |
5032 | 179 return; |
180 } | |
181 | |
182 /* Events */ | |
183 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signon))) | |
184 events |= GAIM_POUNCE_SIGNON; | |
185 | |
186 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signoff))) | |
187 events |= GAIM_POUNCE_SIGNOFF; | |
188 | |
189 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away))) | |
190 events |= GAIM_POUNCE_AWAY; | |
191 | |
192 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away_return))) | |
193 events |= GAIM_POUNCE_AWAY_RETURN; | |
194 | |
195 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle))) | |
196 events |= GAIM_POUNCE_IDLE; | |
197 | |
198 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle_return))) | |
199 events |= GAIM_POUNCE_IDLE_RETURN; | |
200 | |
201 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typing))) | |
202 events |= GAIM_POUNCE_TYPING; | |
203 | |
204 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing))) | |
205 events |= GAIM_POUNCE_TYPING_STOPPED; | |
206 | |
207 | |
208 /* Actions */ | |
209 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))) | |
210 actions |= GAIM_GTKPOUNCE_OPEN_WIN; | |
211 | |
212 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup))) | |
213 actions |= GAIM_GTKPOUNCE_POPUP; | |
214 | |
215 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg))) | |
216 actions |= GAIM_GTKPOUNCE_SEND_MSG; | |
217 | |
218 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd))) | |
219 actions |= GAIM_GTKPOUNCE_EXEC_CMD; | |
220 | |
221 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound))) | |
222 actions |= GAIM_GTKPOUNCE_PLAY_SOUND; | |
223 | |
224 save = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce)); | |
225 | |
226 /* Data fields */ | |
227 message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); | |
228 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); | |
229 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); | |
230 | |
231 if (*message == '\0') message = NULL; | |
232 if (*command == '\0') command = NULL; | |
233 if (*sound == '\0') sound = NULL; | |
234 | |
235 if (dialog->pounce == NULL) | |
236 { | |
237 gaim_gtkpounce_new(dialog->account, name, events, actions, | |
238 message, command, sound, save); | |
239 } | |
240 else | |
241 { | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
242 GaimGtkPounceData *pounce_data; |
5032 | 243 |
244 gaim_pounce_set_events(dialog->pounce, events); | |
245 gaim_pounce_set_pouncer(dialog->pounce, dialog->account); | |
246 gaim_pounce_set_pouncee(dialog->pounce, name); | |
247 | |
248 pounce_data = GAIM_GTKPOUNCE(dialog->pounce); | |
249 | |
250 if (pounce_data->message != NULL) g_free(pounce_data->message); | |
251 if (pounce_data->command != NULL) g_free(pounce_data->command); | |
252 if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
253 | |
254 pounce_data->message = (message == NULL ? NULL : g_strdup(message)); | |
255 pounce_data->command = (command == NULL ? NULL : g_strdup(command)); | |
256 pounce_data->sound = (sound == NULL ? NULL : g_strdup(sound)); | |
257 | |
258 pounce_data->actions = actions; | |
259 pounce_data->save = save; | |
260 } | |
261 | |
262 delete_win_cb(NULL, NULL, dialog); | |
263 /* Rebuild the pounce menu */ | |
264 blist = gaim_get_blist(); | |
265 | |
266 if (GAIM_IS_GTK_BLIST(blist)) | |
267 { | |
268 gtkblist = GAIM_GTK_BLIST(blist); | |
269 | |
270 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
271 } | |
272 } | |
273 | |
5054 | 274 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
275 pounce_choose_cb(GtkWidget *item, GaimGtkPounceDialog *dialog) |
5032 | 276 { |
277 dialog->account = g_object_get_data(G_OBJECT(item), "user_data"); | |
278 } | |
279 | |
280 static GtkWidget * | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
281 pounce_user_menu(GaimGtkPounceDialog *dialog) |
5032 | 282 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
283 GaimAccount *account; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
284 GaimPlugin *prpl; |
5032 | 285 GtkWidget *opt_menu; |
286 GtkWidget *menu; | |
287 GtkWidget *item; | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
288 GList *l; |
5032 | 289 char buf[2048]; |
5054 | 290 int count, place = 0; |
5032 | 291 |
292 opt_menu = gtk_option_menu_new(); | |
293 menu = gtk_menu_new(); | |
294 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
295 for (l = gaim_accounts_get_all(), count = 0; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
296 l != NULL; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
297 l = l->next, count++) { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
298 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
299 account = (GaimAccount *)l->data; |
5032 | 300 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
301 prpl = gaim_find_prpl(account->protocol); |
5032 | 302 |
303 g_snprintf(buf, sizeof(buf), "%s (%s)", account->username, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
304 (prpl && prpl->info->name) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
305 ? prpl->info->name : _("Unknown")); |
5032 | 306 |
307 item = gtk_menu_item_new_with_label(buf); | |
308 g_object_set_data(G_OBJECT(item), "user_data", account); | |
309 | |
310 g_signal_connect(G_OBJECT(item), "activate", | |
311 G_CALLBACK(pounce_choose_cb), dialog); | |
312 | |
313 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
314 gtk_widget_show(item); | |
315 | |
316 if (dialog->account == account) { | |
317 gtk_menu_item_activate(GTK_MENU_ITEM(item)); | |
318 place = count; | |
319 } | |
320 } | |
321 | |
322 gtk_option_menu_set_menu(GTK_OPTION_MENU(opt_menu), menu); | |
323 gtk_option_menu_set_history(GTK_OPTION_MENU(opt_menu), place); | |
324 | |
325 return opt_menu; | |
326 } | |
327 | |
328 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
329 pounce_cb(GaimPounce *pounce, GaimPounceEvent events, void *data) |
5032 | 330 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
331 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
332 GaimAccount *account; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
333 GaimGtkPounceData *pounce_data; |
5032 | 334 const char *pouncee; |
335 | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
336 pounce_data = (GaimGtkPounceData *)data; |
5032 | 337 pouncee = gaim_pounce_get_pouncee(pounce); |
338 account = gaim_pounce_get_pouncer(pounce); | |
339 | |
340 if (pounce_data->actions & GAIM_GTKPOUNCE_OPEN_WIN) { | |
341 conv = gaim_find_conversation(pouncee); | |
342 | |
343 if (conv == NULL) | |
344 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
345 } | |
346 | |
347 if (pounce_data->actions & GAIM_GTKPOUNCE_POPUP) { | |
348 char tmp[1024]; | |
349 | |
350 g_snprintf(tmp, sizeof(tmp), | |
351 (events & GAIM_POUNCE_TYPING) ? _("%s has started typing to you") : | |
352 (events & GAIM_POUNCE_SIGNON) ? _("%s has signed on") : | |
353 (events & GAIM_POUNCE_IDLE_RETURN) ? _("%s has returned from being idle") : | |
354 (events & GAIM_POUNCE_AWAY_RETURN) ? _("%s has returned from being away") : | |
355 (events & GAIM_POUNCE_TYPING_STOPPED) ? _("%s has stopped typing to you") : | |
356 (events & GAIM_POUNCE_SIGNOFF) ? _("%s has signed off") : | |
357 (events & GAIM_POUNCE_IDLE) ? _("%s has become idle") : | |
358 (events & GAIM_POUNCE_AWAY) ? _("%s has gone away.") : | |
359 _("Unknown pounce event. Please report this!"), | |
360 pouncee); | |
361 | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
362 gaim_notify_info(NULL, NULL, tmp, NULL); |
5032 | 363 } |
364 | |
365 if (pounce_data->actions & GAIM_GTKPOUNCE_SEND_MSG && | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
366 pounce_data->message != NULL) { |
5032 | 367 |
368 conv = gaim_find_conversation(pouncee); | |
369 | |
370 if (conv == NULL) | |
371 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
372 | |
373 gaim_conversation_write(conv, NULL, pounce_data->message, -1, | |
374 WFLAG_SEND, time(NULL)); | |
375 | |
376 serv_send_im(account->gc, (char *)pouncee, pounce_data->message, -1, 0); | |
377 } | |
378 | |
379 if (pounce_data->actions & GAIM_GTKPOUNCE_EXEC_CMD && | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
380 pounce_data->command != NULL) { |
5032 | 381 #ifndef _WIN32 |
382 int pid = fork(); | |
383 | |
384 if (pid == 0) { | |
385 char *args[4]; | |
386 | |
387 args[0] = "sh"; | |
388 args[1] = "-c"; | |
389 args[2] = pounce_data->command; | |
390 args[3] = NULL; | |
391 | |
392 execvp(args[0], args); | |
393 | |
394 _exit(0); | |
395 } | |
396 #endif /* _WIN32 */ | |
397 } | |
398 | |
399 if (pounce_data->actions & GAIM_GTKPOUNCE_PLAY_SOUND) { | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
400 if (pounce_data->sound != NULL) |
5032 | 401 gaim_sound_play_file(pounce_data->sound); |
402 else | |
403 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); | |
404 } | |
405 | |
406 if (!pounce_data->save) | |
407 gaim_pounce_destroy(pounce); | |
408 } | |
409 | |
410 static void | |
411 free_pounce(void *data) | |
412 { | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
413 GaimGtkPounceData *pounce_data; |
5032 | 414 struct gaim_buddy_list *blist; |
415 struct gaim_gtk_buddy_list *gtkblist; | |
416 | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
417 pounce_data = (GaimGtkPounceData *)data; |
5032 | 418 |
419 if (pounce_data->message != NULL) g_free(pounce_data->message); | |
420 if (pounce_data->command != NULL) g_free(pounce_data->command); | |
421 if (pounce_data->sound != NULL) g_free(pounce_data->sound); | |
422 | |
423 g_free(data); | |
424 | |
425 /* Rebuild the pounce menu */ | |
426 blist = gaim_get_blist(); | |
427 | |
428 if (GAIM_IS_GTK_BLIST(blist)) | |
429 { | |
430 gtkblist = GAIM_GTK_BLIST(blist); | |
431 | |
432 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
433 } | |
434 } | |
435 | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
436 GaimPounce * |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
437 gaim_gtkpounce_new(GaimAccount *pouncer, const char *pouncee, |
5032 | 438 GaimPounceEvent events, GaimGtkPounceAction actions, |
439 const char *message, const char *command, | |
440 const char *sound, gboolean save) | |
441 { | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
442 GaimGtkPounceData *data; |
5032 | 443 |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
444 data = g_new0(GaimGtkPounceData, 1); |
5032 | 445 |
446 data->actions = actions; | |
447 | |
448 if (message != NULL) data->message = g_strdup(message); | |
449 if (command != NULL) data->command = g_strdup(command); | |
450 if (sound != NULL) data->sound = g_strdup(sound); | |
451 | |
452 data->save = save; | |
453 | |
454 return gaim_pounce_new(pouncer, pouncee, events, pounce_cb, data, | |
455 free_pounce); | |
456 } | |
457 | |
458 void | |
459 gaim_gtkpounce_dialog_show(struct buddy *buddy, | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
460 GaimPounce *cur_pounce) |
5032 | 461 { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
462 GaimGtkPounceDialog *dialog; |
5032 | 463 GtkWidget *window; |
464 GtkWidget *label; | |
465 GtkWidget *bbox; | |
466 GtkWidget *vbox1, *vbox2; | |
467 GtkWidget *hbox; | |
468 GtkWidget *button; | |
469 GtkWidget *frame; | |
470 GtkWidget *table; | |
471 GtkWidget *sep; | |
472 GtkSizeGroup *sg; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
473 GPtrArray *sound_widgets; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
474 GPtrArray *exec_widgets; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
475 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
476 dialog = g_new0(GaimGtkPounceDialog, 1); |
5032 | 477 |
478 if (cur_pounce != NULL) { | |
479 dialog->pounce = cur_pounce; | |
480 dialog->account = gaim_pounce_get_pouncer(cur_pounce); | |
481 } | |
482 else if (buddy != NULL) { | |
483 dialog->pounce = NULL; | |
484 dialog->account = buddy->account; | |
485 } | |
486 else { | |
487 dialog->pounce = NULL; | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
488 dialog->account = gaim_accounts_get_all()->data; |
5032 | 489 } |
490 | |
491 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
492 | |
493 /* Create the window. */ | |
494 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
495 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
496 gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce"); | |
497 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
498 gtk_window_set_title(GTK_WINDOW(window), | |
499 (cur_pounce == NULL | |
500 ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
501 | |
502 gtk_container_set_border_width(GTK_CONTAINER(window), 12); | |
503 gtk_widget_realize(window); | |
504 | |
505 g_signal_connect(G_OBJECT(window), "delete_event", | |
506 G_CALLBACK(delete_win_cb), dialog); | |
507 | |
508 /* Create the parent vbox for everything. */ | |
509 vbox1 = gtk_vbox_new(FALSE, 12); | |
510 gtk_container_add(GTK_CONTAINER(window), vbox1); | |
511 gtk_widget_show(vbox1); | |
512 | |
513 /* Create the vbox that will contain all the prefs stuff. */ | |
514 vbox2 = gtk_vbox_new(FALSE, 18); | |
515 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); | |
516 | |
517 /* Create the "Pounce Who" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
518 frame = gaim_gtk_make_frame(vbox2, _("Pounce Who")); |
5032 | 519 |
520 /* Account: */ | |
521 hbox = gtk_hbox_new(FALSE, 6); | |
522 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
523 gtk_widget_show(hbox); | |
524 | |
525 label = gtk_label_new_with_mnemonic(_("_Account:")); | |
526 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
527 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
528 gtk_widget_show(label); | |
529 gtk_size_group_add_widget(sg, label); | |
530 | |
531 dialog->account_menu = pounce_user_menu(dialog); | |
532 gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0); | |
533 gtk_widget_show(dialog->account_menu); | |
534 | |
535 /* Buddy: */ | |
536 hbox = gtk_hbox_new(FALSE, 6); | |
537 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
538 gtk_widget_show(hbox); | |
539 | |
540 label = gtk_label_new_with_mnemonic(_("_Buddy Name:")); | |
541 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
542 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
543 gtk_widget_show(label); | |
544 gtk_size_group_add_widget(sg, label); | |
545 | |
546 dialog->buddy_entry = gtk_entry_new(); | |
547 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0); | |
548 gtk_widget_show(dialog->buddy_entry); | |
549 | |
550 if (cur_pounce != NULL) { | |
551 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), | |
552 gaim_pounce_get_pouncee(cur_pounce)); | |
553 } | |
554 else if (buddy != NULL) { | |
555 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), buddy->name); | |
556 } | |
557 | |
558 /* Create the "Pounce When" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
559 frame = gaim_gtk_make_frame(vbox2, _("Pounce When")); |
5032 | 560 |
561 table = gtk_table_new(2, 4, FALSE); | |
562 gtk_container_add(GTK_CONTAINER(frame), table); | |
563 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
564 gtk_widget_show(table); | |
565 | |
566 dialog->signon = | |
567 gtk_check_button_new_with_label(_("Sign on")); | |
568 dialog->signoff = | |
569 gtk_check_button_new_with_label(_("Sign off")); | |
570 dialog->away = | |
571 gtk_check_button_new_with_label(_("Away")); | |
572 dialog->away_return = | |
573 gtk_check_button_new_with_label(_("Return from away")); | |
574 dialog->idle = | |
575 gtk_check_button_new_with_label(_("Idle")); | |
576 dialog->idle_return = | |
577 gtk_check_button_new_with_label(_("Return from idle")); | |
578 dialog->typing = | |
579 gtk_check_button_new_with_label(_("Buddy starts typing")); | |
580 dialog->stop_typing = | |
581 gtk_check_button_new_with_label(_("Buddy stops typing")); | |
582 | |
583 gtk_table_attach(GTK_TABLE(table), dialog->signon, 0, 1, 0, 1, | |
584 GTK_FILL, 0, 0, 0); | |
585 gtk_table_attach(GTK_TABLE(table), dialog->signoff, 1, 2, 0, 1, | |
586 GTK_FILL, 0, 0, 0); | |
587 gtk_table_attach(GTK_TABLE(table), dialog->away, 0, 1, 1, 2, | |
588 GTK_FILL, 0, 0, 0); | |
589 gtk_table_attach(GTK_TABLE(table), dialog->away_return, 1, 2, 1, 2, | |
590 GTK_FILL, 0, 0, 0); | |
591 gtk_table_attach(GTK_TABLE(table), dialog->idle, 0, 1, 2, 3, | |
592 GTK_FILL, 0, 0, 0); | |
593 gtk_table_attach(GTK_TABLE(table), dialog->idle_return, 1, 2, 2, 3, | |
594 GTK_FILL, 0, 0, 0); | |
595 gtk_table_attach(GTK_TABLE(table), dialog->typing, 0, 1, 3, 4, | |
596 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
597 gtk_table_attach(GTK_TABLE(table), dialog->stop_typing, 1, 2, 3, 5, |
5032 | 598 GTK_FILL, 0, 0, 0); |
599 | |
600 gtk_widget_show(dialog->signon); | |
601 gtk_widget_show(dialog->signoff); | |
602 gtk_widget_show(dialog->away); | |
603 gtk_widget_show(dialog->away_return); | |
604 gtk_widget_show(dialog->idle); | |
605 gtk_widget_show(dialog->idle_return); | |
606 gtk_widget_show(dialog->typing); | |
607 gtk_widget_show(dialog->stop_typing); | |
608 | |
609 /* Create the "Pounce Action" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
610 frame = gaim_gtk_make_frame(vbox2, _("Pounce Action")); |
5032 | 611 |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
612 table = gtk_table_new(3, 5, FALSE); |
5032 | 613 gtk_container_add(GTK_CONTAINER(frame), table); |
614 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
615 gtk_widget_show(table); | |
616 | |
617 dialog->open_win = gtk_check_button_new_with_label(_("Open an IM window")); | |
618 dialog->popup = gtk_check_button_new_with_label(_("Popup notification")); | |
619 dialog->send_msg = gtk_check_button_new_with_label(_("Send a message")); | |
620 dialog->exec_cmd = gtk_check_button_new_with_label(_("Execute a command")); | |
5051
b3d9195777bb
[gaim-migrate @ 5400]
Christian Hammond <chipx86@chipx86.com>
parents:
5032
diff
changeset
|
621 dialog->play_sound = gtk_check_button_new_with_label(_("Play a sound")); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
622 |
5032 | 623 dialog->send_msg_entry = gtk_entry_new(); |
624 dialog->exec_cmd_entry = gtk_entry_new(); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
625 dialog->exec_cmd_browse = gtk_button_new_with_label(_("Browse")); |
5032 | 626 dialog->play_sound_entry = gtk_entry_new(); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
627 dialog->play_sound_browse = gtk_button_new_with_label(_("Browse")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
628 dialog->play_sound_test = gtk_button_new_with_label(_("Test")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
629 |
5032 | 630 gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); |
631 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
632 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); |
5032 | 633 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
634 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
635 gtk_widget_set_sensitive(dialog->play_sound_test, FALSE); |
5032 | 636 |
637 gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, | |
638 GTK_FILL, 0, 0, 0); | |
639 gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, | |
640 GTK_FILL, 0, 0, 0); | |
641 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, | |
642 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
643 gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 4, 2, 3, |
5032 | 644 GTK_FILL, 0, 0, 0); |
645 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, | |
646 GTK_FILL, 0, 0, 0); | |
647 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 3, 4, | |
648 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
649 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_browse, 2, 3, 3, 4, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
650 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 651 gtk_table_attach(GTK_TABLE(table), dialog->play_sound, 0, 1, 4, 5, |
652 GTK_FILL, 0, 0, 0); | |
653 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_entry, 1, 2, 4, 5, | |
654 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
655 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_browse, 2, 3, 4, 5, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
656 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
657 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_test, 3, 4, 4, 5, |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
658 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 659 |
660 gtk_widget_show(dialog->open_win); | |
661 gtk_widget_show(dialog->popup); | |
662 gtk_widget_show(dialog->send_msg); | |
663 gtk_widget_show(dialog->send_msg_entry); | |
664 gtk_widget_show(dialog->exec_cmd); | |
665 gtk_widget_show(dialog->exec_cmd_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
666 gtk_widget_show(dialog->exec_cmd_browse); |
5032 | 667 gtk_widget_show(dialog->play_sound); |
668 gtk_widget_show(dialog->play_sound_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
669 gtk_widget_show(dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
670 gtk_widget_show(dialog->play_sound_test); |
5032 | 671 |
672 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", | |
673 G_CALLBACK(gaim_gtk_toggle_sensitive), | |
674 dialog->send_msg_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
675 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
676 exec_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
677 g_ptr_array_add(exec_widgets,dialog->exec_cmd_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
678 g_ptr_array_add(exec_widgets,dialog->exec_cmd_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
679 |
5032 | 680 g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
681 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
682 exec_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
683 g_signal_connect(G_OBJECT(dialog->exec_cmd_browse), "clicked", |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
684 G_CALLBACK(filesel), |
5032 | 685 dialog->exec_cmd_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
686 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
687 sound_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
688 g_ptr_array_add(sound_widgets,dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
689 g_ptr_array_add(sound_widgets,dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
690 g_ptr_array_add(sound_widgets,dialog->play_sound_test); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
691 |
5032 | 692 g_signal_connect(G_OBJECT(dialog->play_sound), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
693 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
694 sound_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
695 g_signal_connect(G_OBJECT(dialog->play_sound_browse), "clicked", |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
696 G_CALLBACK(filesel), |
5032 | 697 dialog->play_sound_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
698 g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked", |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
699 G_CALLBACK(pounce_test_sound), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
700 dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
701 |
5032 | 702 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", |
703 G_CALLBACK(save_pounce_cb), dialog); | |
704 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", | |
705 G_CALLBACK(save_pounce_cb), dialog); | |
706 g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", | |
707 G_CALLBACK(save_pounce_cb), dialog); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
708 |
5032 | 709 /* Now the last part, where we have the Save checkbox */ |
710 dialog->save_pounce = gtk_check_button_new_with_mnemonic( | |
711 _("_Save this pounce after activation")); | |
712 | |
713 gtk_box_pack_start(GTK_BOX(vbox2), dialog->save_pounce, FALSE, FALSE, 0); | |
714 | |
715 /* Separator... */ | |
716 sep = gtk_hseparator_new(); | |
717 gtk_box_pack_start(GTK_BOX(vbox1), sep, FALSE, FALSE, 0); | |
718 gtk_widget_show(sep); | |
719 | |
720 /* Now the button box! */ | |
721 bbox = gtk_hbutton_box_new(); | |
722 gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
723 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
724 gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, FALSE, 0); | |
725 gtk_widget_show(bbox); | |
726 | |
5052
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
727 /* Delete button */ |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
728 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
729 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
730 gtk_widget_show(button); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
731 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
732 g_signal_connect(G_OBJECT(button), "clicked", |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
733 G_CALLBACK(delete_cb), dialog); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
734 |
5032 | 735 /* Cancel button */ |
736 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
737 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
738 gtk_widget_show(button); | |
739 | |
740 g_signal_connect(G_OBJECT(button), "clicked", | |
741 G_CALLBACK(cancel_cb), dialog); | |
742 | |
743 /* OK button */ | |
744 button = gtk_button_new_from_stock(GTK_STOCK_OK); | |
745 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
746 gtk_widget_show(button); | |
747 | |
748 g_signal_connect(G_OBJECT(button), "clicked", | |
749 G_CALLBACK(save_pounce_cb), dialog); | |
750 | |
751 /* Set the values of stuff. */ | |
752 if (cur_pounce != NULL) { | |
753 GaimPounceEvent events; | |
754 GaimGtkPounceAction actions; | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
755 GaimGtkPounceData *pounce_data; |
5032 | 756 |
757 pounce_data = GAIM_GTKPOUNCE(cur_pounce); | |
758 events = gaim_pounce_get_events(cur_pounce); | |
759 actions = pounce_data->actions; | |
760 | |
761 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), | |
762 (events & GAIM_POUNCE_SIGNON)); | |
763 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff), | |
764 (events & GAIM_POUNCE_SIGNOFF)); | |
765 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away), | |
766 (events & GAIM_POUNCE_AWAY)); | |
767 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away_return), | |
768 (events & GAIM_POUNCE_AWAY_RETURN)); | |
769 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle), | |
770 (events & GAIM_POUNCE_IDLE)); | |
771 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle_return), | |
772 (events & GAIM_POUNCE_IDLE_RETURN)); | |
773 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typing), | |
774 (events & GAIM_POUNCE_TYPING)); | |
775 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing), | |
776 (events & GAIM_POUNCE_TYPING_STOPPED)); | |
777 | |
778 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win), | |
779 (actions & GAIM_GTKPOUNCE_OPEN_WIN)); | |
780 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup), | |
781 (actions & GAIM_GTKPOUNCE_POPUP)); | |
782 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), | |
783 (actions & GAIM_GTKPOUNCE_SEND_MSG)); | |
784 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd), | |
785 (actions & GAIM_GTKPOUNCE_EXEC_CMD)); | |
786 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->play_sound), | |
787 (actions & GAIM_GTKPOUNCE_PLAY_SOUND)); | |
788 | |
789 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce), | |
790 pounce_data->save); | |
791 | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
792 if (pounce_data->message != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
793 gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
794 pounce_data->message); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
795 if (pounce_data->command != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
796 gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
797 pounce_data->command); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
798 if (pounce_data->sound != NULL) |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
799 gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
800 pounce_data->sound); |
5032 | 801 } |
802 else { | |
803 /* Set some defaults */ | |
804 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), TRUE); | |
805 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), TRUE); | |
806 } | |
807 | |
808 gtk_widget_show_all(vbox2); | |
809 gtk_widget_show(window); | |
810 } | |
811 | |
812 static void | |
813 new_pounce_cb(GtkWidget *w, struct buddy *b) | |
814 { | |
815 gaim_gtkpounce_dialog_show(b, NULL); | |
816 } | |
817 | |
818 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
819 delete_pounce_cb(GtkWidget *w, GaimPounce *pounce) |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
820 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
821 gaim_pounce_destroy(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
822 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
823 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
824 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
825 edit_pounce_cb(GtkWidget *w, GaimPounce *pounce) |
5032 | 826 { |
827 struct buddy *buddy; | |
828 | |
829 buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce), | |
830 gaim_pounce_get_pouncee(pounce)); | |
831 | |
832 gaim_gtkpounce_dialog_show(buddy, pounce); | |
833 } | |
834 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
835 static void |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
836 fill_menu(GtkWidget *menu, GCallback cb) |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
837 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
838 GtkWidget *image; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
839 GtkWidget *item; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
840 GdkPixbuf *pixbuf, *scale; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
841 GaimPounce *pounce; |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
842 const char *buddy; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
843 GList *bp; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
844 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
845 for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
846 pounce = (GaimPounce *)bp->data; |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
847 buddy = gaim_pounce_get_pouncee(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
848 |
5161 | 849 /* Build the menu item */ |
850 item = gtk_image_menu_item_new_with_label(buddy); | |
851 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
852 /* Create a pixmap for the protocol icon. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
853 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); |
5161 | 854 if(pixbuf) { |
855 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
856 GDK_INTERP_BILINEAR); | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
857 |
5161 | 858 /* Now convert it to GtkImage */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
859 image = gtk_image_new_from_pixbuf(scale); |
5161 | 860 g_object_unref(G_OBJECT(scale)); |
861 g_object_unref(G_OBJECT(pixbuf)); | |
862 gtk_widget_show(image); | |
863 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); | |
864 } | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
865 |
5161 | 866 /* Put the item in the menu */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
867 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
868 gtk_widget_show(item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
869 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
870 /* Set our callbacks. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
871 g_signal_connect(G_OBJECT(item), "activate", cb, pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
872 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
873 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
874 |
5032 | 875 void |
876 gaim_gtkpounce_menu_build(GtkWidget *menu) | |
877 { | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
878 GtkWidget *remmenu; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
879 GtkWidget *item; |
5032 | 880 GList *l; |
881 | |
882 for (l = gtk_container_get_children(GTK_CONTAINER(menu)); | |
883 l != NULL; | |
884 l = l->next) { | |
885 | |
886 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
887 } | |
888 | |
889 /* "New Buddy Pounce" */ | |
890 item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); | |
891 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
892 gtk_widget_show(item); | |
893 g_signal_connect(G_OBJECT(item), "activate", | |
894 G_CALLBACK(new_pounce_cb), NULL); | |
895 | |
896 /* "Remove Buddy Pounce" */ | |
897 item = gtk_menu_item_new_with_label(_("Remove Buddy Pounce")); | |
898 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
899 | |
900 /* "Remove Buddy Pounce" menu */ | |
901 remmenu = gtk_menu_new(); | |
902 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
903 fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); |
5032 | 904 |
905 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); | |
906 gtk_widget_show(remmenu); | |
907 gtk_widget_show(item); | |
908 | |
909 /* Separator */ | |
910 item = gtk_separator_menu_item_new(); | |
911 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
912 gtk_widget_show(item); | |
913 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
914 fill_menu(menu, G_CALLBACK(edit_pounce_cb)); |
5032 | 915 } |
916 |