Mercurial > pidgin
annotate src/gtkpounce.c @ 5866:d6b5cab288bb
[gaim-migrate @ 6297]
Pounces are now imported and saved to disk. However, they are not yet
loaded. I'll get to that tomorrow (later today? awwww!)
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 14 Jun 2003 11:55:15 +0000 |
parents | 417b1001d2b1 |
children | 059d95c67cda |
rev | line source |
---|---|
5032 | 1 /** |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
2 * @file gtkpounce.c GTK+ Buddy Pounce API |
5032 | 3 * |
4 * gaim | |
5 * | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> |
5032 | 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 | |
172 name = gtk_entry_get_text(GTK_ENTRY(dialog->buddy_entry)); | |
173 | |
174 if (*name == '\0') { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
175 gaim_notify_error(NULL, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
176 _("Please enter a buddy to pounce."), NULL); |
5032 | 177 return; |
178 } | |
179 | |
180 /* Events */ | |
181 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signon))) | |
182 events |= GAIM_POUNCE_SIGNON; | |
183 | |
184 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->signoff))) | |
185 events |= GAIM_POUNCE_SIGNOFF; | |
186 | |
187 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away))) | |
188 events |= GAIM_POUNCE_AWAY; | |
189 | |
190 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->away_return))) | |
191 events |= GAIM_POUNCE_AWAY_RETURN; | |
192 | |
193 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle))) | |
194 events |= GAIM_POUNCE_IDLE; | |
195 | |
196 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->idle_return))) | |
197 events |= GAIM_POUNCE_IDLE_RETURN; | |
198 | |
199 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->typing))) | |
200 events |= GAIM_POUNCE_TYPING; | |
201 | |
202 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->stop_typing))) | |
203 events |= GAIM_POUNCE_TYPING_STOPPED; | |
204 | |
205 /* Data fields */ | |
206 message = gtk_entry_get_text(GTK_ENTRY(dialog->send_msg_entry)); | |
207 command = gtk_entry_get_text(GTK_ENTRY(dialog->exec_cmd_entry)); | |
208 sound = gtk_entry_get_text(GTK_ENTRY(dialog->play_sound_entry)); | |
209 | |
210 if (*message == '\0') message = NULL; | |
211 if (*command == '\0') command = NULL; | |
212 if (*sound == '\0') sound = NULL; | |
213 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
214 if (dialog->pounce == NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
215 dialog->pounce = gaim_gtkpounce_new(dialog->account, name, events); |
5032 | 216 } |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
217 else { |
5032 | 218 gaim_pounce_set_events(dialog->pounce, events); |
219 gaim_pounce_set_pouncer(dialog->pounce, dialog->account); | |
220 gaim_pounce_set_pouncee(dialog->pounce, name); | |
221 } | |
222 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
223 /* Actions*/ |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
224 gaim_pounce_action_set_enabled(dialog->pounce, "open-window", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
225 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->open_win))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
226 gaim_pounce_action_set_enabled(dialog->pounce, "popup-notify", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
227 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->popup))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
228 gaim_pounce_action_set_enabled(dialog->pounce, "send-message", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
229 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->send_msg))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
230 gaim_pounce_action_set_enabled(dialog->pounce, "execute-command", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
231 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
232 gaim_pounce_action_set_enabled(dialog->pounce, "play-sound", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
233 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->play_sound))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
234 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
235 gaim_pounce_action_set_attribute(dialog->pounce, "send-message", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
236 "message", message); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
237 gaim_pounce_action_set_attribute(dialog->pounce, "execute-command", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
238 "command", command); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
239 gaim_pounce_action_set_attribute(dialog->pounce, "play-sound", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
240 "filename", sound); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
241 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
242 gaim_pounce_set_save(dialog->pounce, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
243 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->save_pounce))); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
244 |
5032 | 245 delete_win_cb(NULL, NULL, dialog); |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
246 |
5032 | 247 /* Rebuild the pounce menu */ |
248 blist = gaim_get_blist(); | |
249 | |
250 if (GAIM_IS_GTK_BLIST(blist)) | |
251 { | |
252 gtkblist = GAIM_GTK_BLIST(blist); | |
253 | |
254 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
255 } | |
256 } | |
257 | |
5054 | 258 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
259 pounce_choose_cb(GtkWidget *item, GaimGtkPounceDialog *dialog) |
5032 | 260 { |
261 dialog->account = g_object_get_data(G_OBJECT(item), "user_data"); | |
262 } | |
263 | |
264 static GtkWidget * | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
265 pounce_user_menu(GaimGtkPounceDialog *dialog) |
5032 | 266 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
267 GaimAccount *account; |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
268 GaimPlugin *prpl; |
5032 | 269 GtkWidget *opt_menu; |
270 GtkWidget *menu; | |
271 GtkWidget *item; | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
272 GList *l; |
5032 | 273 char buf[2048]; |
5054 | 274 int count, place = 0; |
5032 | 275 |
276 opt_menu = gtk_option_menu_new(); | |
277 menu = gtk_menu_new(); | |
278 | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
279 for (l = gaim_accounts_get_all(), count = 0; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
280 l != NULL; |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
281 l = l->next, count++) { |
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
282 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
283 account = (GaimAccount *)l->data; |
5032 | 284 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
285 prpl = gaim_find_prpl(account->protocol); |
5032 | 286 |
287 g_snprintf(buf, sizeof(buf), "%s (%s)", account->username, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
288 (prpl && prpl->info->name) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5161
diff
changeset
|
289 ? prpl->info->name : _("Unknown")); |
5032 | 290 |
291 item = gtk_menu_item_new_with_label(buf); | |
292 g_object_set_data(G_OBJECT(item), "user_data", account); | |
293 | |
294 g_signal_connect(G_OBJECT(item), "activate", | |
295 G_CALLBACK(pounce_choose_cb), dialog); | |
296 | |
297 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
298 gtk_widget_show(item); | |
299 | |
300 if (dialog->account == account) { | |
301 gtk_menu_item_activate(GTK_MENU_ITEM(item)); | |
302 place = count; | |
303 } | |
304 } | |
305 | |
306 gtk_option_menu_set_menu(GTK_OPTION_MENU(opt_menu), menu); | |
307 gtk_option_menu_set_history(GTK_OPTION_MENU(opt_menu), place); | |
308 | |
309 return opt_menu; | |
310 } | |
311 | |
312 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
313 pounce_cb(GaimPounce *pounce, GaimPounceEvent events, void *data) |
5032 | 314 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5593
diff
changeset
|
315 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
316 GaimAccount *account; |
5032 | 317 const char *pouncee; |
318 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
319 pouncee = gaim_pounce_get_pouncee(pounce); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
320 account = gaim_pounce_get_pouncer(pounce); |
5032 | 321 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
322 if (gaim_pounce_action_is_enabled(pounce, "open-window")) { |
5032 | 323 conv = gaim_find_conversation(pouncee); |
324 | |
325 if (conv == NULL) | |
326 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); | |
327 } | |
328 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
329 if (gaim_pounce_action_is_enabled(pounce, "popup-notify")) { |
5032 | 330 char tmp[1024]; |
331 | |
332 g_snprintf(tmp, sizeof(tmp), | |
333 (events & GAIM_POUNCE_TYPING) ? _("%s has started typing to you") : | |
334 (events & GAIM_POUNCE_SIGNON) ? _("%s has signed on") : | |
335 (events & GAIM_POUNCE_IDLE_RETURN) ? _("%s has returned from being idle") : | |
336 (events & GAIM_POUNCE_AWAY_RETURN) ? _("%s has returned from being away") : | |
337 (events & GAIM_POUNCE_TYPING_STOPPED) ? _("%s has stopped typing to you") : | |
338 (events & GAIM_POUNCE_SIGNOFF) ? _("%s has signed off") : | |
339 (events & GAIM_POUNCE_IDLE) ? _("%s has become idle") : | |
340 (events & GAIM_POUNCE_AWAY) ? _("%s has gone away.") : | |
341 _("Unknown pounce event. Please report this!"), | |
342 pouncee); | |
343 | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5319
diff
changeset
|
344 gaim_notify_info(NULL, NULL, tmp, NULL); |
5032 | 345 } |
346 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
347 if (gaim_pounce_action_is_enabled(pounce, "send-message")) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
348 const char *message; |
5032 | 349 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
350 message = gaim_pounce_action_get_attribute(pounce, "send-message", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
351 "message"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
352 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
353 if (message != NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
354 conv = gaim_find_conversation(pouncee); |
5032 | 355 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
356 if (conv == NULL) |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
357 conv = gaim_conversation_new(GAIM_CONV_IM, account, pouncee); |
5032 | 358 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
359 gaim_conversation_write(conv, NULL, message, -1, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
360 WFLAG_SEND, time(NULL)); |
5032 | 361 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
362 serv_send_im(account->gc, (char *)pouncee, (char *)message, -1, 0); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
363 } |
5032 | 364 } |
365 | |
366 #ifndef _WIN32 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
367 if (gaim_pounce_action_is_enabled(pounce, "execute-command")) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
368 const char *command; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
369 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
370 command = gaim_pounce_action_get_attribute(pounce, "execute-command", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
371 "command"); |
5032 | 372 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
373 if (command != NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
374 int pid = fork(); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
375 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
376 if (pid == 0) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
377 char *args[4]; |
5032 | 378 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
379 args[0] = "sh"; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
380 args[1] = "-c"; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
381 args[2] = (char *)command; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
382 args[3] = NULL; |
5032 | 383 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
384 execvp(args[0], args); |
5032 | 385 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
386 _exit(0); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
387 } |
5032 | 388 } |
389 } | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
390 #endif /* _WIN32 */ |
5032 | 391 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
392 if (gaim_pounce_action_is_enabled(pounce, "play-sound")) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
393 const char *sound; |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
394 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
395 sound = gaim_pounce_action_get_attribute(pounce, "play-sound", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
396 "sound"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
397 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
398 if (sound != NULL) |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
399 gaim_sound_play_file(sound); |
5032 | 400 else |
401 gaim_sound_play_event(GAIM_SOUND_POUNCE_DEFAULT); | |
402 } | |
403 } | |
404 | |
405 static void | |
406 free_pounce(void *data) | |
407 { | |
408 struct gaim_buddy_list *blist; | |
409 struct gaim_gtk_buddy_list *gtkblist; | |
410 | |
411 /* Rebuild the pounce menu */ | |
412 blist = gaim_get_blist(); | |
413 | |
414 if (GAIM_IS_GTK_BLIST(blist)) | |
415 { | |
416 gtkblist = GAIM_GTK_BLIST(blist); | |
417 | |
418 gaim_gtkpounce_menu_build(gtkblist->bpmenu); | |
419 } | |
420 } | |
421 | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
422 GaimPounce * |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
423 gaim_gtkpounce_new(GaimAccount *pouncer, const char *pouncee, |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
424 GaimPounceEvent events) |
5032 | 425 { |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
426 GaimPounce *pounce; |
5032 | 427 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
428 pounce = gaim_pounce_new(GAIM_GTK_UI, pouncer, pouncee, events, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
429 pounce_cb, NULL, free_pounce); |
5032 | 430 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
431 gaim_pounce_action_register(pounce, "open-window"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
432 gaim_pounce_action_register(pounce, "popup-notify"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
433 gaim_pounce_action_register(pounce, "send-message"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
434 gaim_pounce_action_register(pounce, "execute-command"); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
435 gaim_pounce_action_register(pounce, "play-sound"); |
5032 | 436 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
437 return pounce; |
5032 | 438 } |
439 | |
440 void | |
441 gaim_gtkpounce_dialog_show(struct buddy *buddy, | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
442 GaimPounce *cur_pounce) |
5032 | 443 { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
444 GaimGtkPounceDialog *dialog; |
5032 | 445 GtkWidget *window; |
446 GtkWidget *label; | |
447 GtkWidget *bbox; | |
448 GtkWidget *vbox1, *vbox2; | |
449 GtkWidget *hbox; | |
450 GtkWidget *button; | |
451 GtkWidget *frame; | |
452 GtkWidget *table; | |
453 GtkWidget *sep; | |
454 GtkSizeGroup *sg; | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
455 GPtrArray *sound_widgets; |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
456 GPtrArray *exec_widgets; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
457 |
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
458 dialog = g_new0(GaimGtkPounceDialog, 1); |
5032 | 459 |
460 if (cur_pounce != NULL) { | |
461 dialog->pounce = cur_pounce; | |
462 dialog->account = gaim_pounce_get_pouncer(cur_pounce); | |
463 } | |
464 else if (buddy != NULL) { | |
465 dialog->pounce = NULL; | |
466 dialog->account = buddy->account; | |
467 } | |
468 else { | |
469 dialog->pounce = NULL; | |
5580
86456ec3ca25
[gaim-migrate @ 5984]
Christian Hammond <chipx86@chipx86.com>
parents:
5563
diff
changeset
|
470 dialog->account = gaim_accounts_get_all()->data; |
5032 | 471 } |
472 | |
473 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
474 | |
475 /* Create the window. */ | |
476 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
477 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); | |
478 gtk_window_set_role(GTK_WINDOW(window), "buddy_pounce"); | |
479 gtk_window_set_resizable(GTK_WINDOW(window), FALSE); | |
480 gtk_window_set_title(GTK_WINDOW(window), | |
481 (cur_pounce == NULL | |
482 ? _("New Buddy Pounce") : _("Edit Buddy Pounce"))); | |
483 | |
484 gtk_container_set_border_width(GTK_CONTAINER(window), 12); | |
485 gtk_widget_realize(window); | |
486 | |
487 g_signal_connect(G_OBJECT(window), "delete_event", | |
488 G_CALLBACK(delete_win_cb), dialog); | |
489 | |
490 /* Create the parent vbox for everything. */ | |
491 vbox1 = gtk_vbox_new(FALSE, 12); | |
492 gtk_container_add(GTK_CONTAINER(window), vbox1); | |
493 gtk_widget_show(vbox1); | |
494 | |
495 /* Create the vbox that will contain all the prefs stuff. */ | |
496 vbox2 = gtk_vbox_new(FALSE, 18); | |
497 gtk_box_pack_start(GTK_BOX(vbox1), vbox2, TRUE, TRUE, 0); | |
498 | |
499 /* Create the "Pounce Who" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
500 frame = gaim_gtk_make_frame(vbox2, _("Pounce Who")); |
5032 | 501 |
502 /* Account: */ | |
503 hbox = gtk_hbox_new(FALSE, 6); | |
504 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
505 gtk_widget_show(hbox); | |
506 | |
507 label = gtk_label_new_with_mnemonic(_("_Account:")); | |
508 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
509 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
510 gtk_widget_show(label); | |
511 gtk_size_group_add_widget(sg, label); | |
512 | |
513 dialog->account_menu = pounce_user_menu(dialog); | |
514 gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0); | |
515 gtk_widget_show(dialog->account_menu); | |
516 | |
517 /* Buddy: */ | |
518 hbox = gtk_hbox_new(FALSE, 6); | |
519 gtk_box_pack_start(GTK_BOX(frame), hbox, FALSE, FALSE, 0); | |
520 gtk_widget_show(hbox); | |
521 | |
522 label = gtk_label_new_with_mnemonic(_("_Buddy Name:")); | |
523 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
524 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); | |
525 gtk_widget_show(label); | |
526 gtk_size_group_add_widget(sg, label); | |
527 | |
528 dialog->buddy_entry = gtk_entry_new(); | |
529 gtk_box_pack_start(GTK_BOX(hbox), dialog->buddy_entry, TRUE, TRUE, 0); | |
530 gtk_widget_show(dialog->buddy_entry); | |
531 | |
532 if (cur_pounce != NULL) { | |
533 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), | |
534 gaim_pounce_get_pouncee(cur_pounce)); | |
535 } | |
536 else if (buddy != NULL) { | |
537 gtk_entry_set_text(GTK_ENTRY(dialog->buddy_entry), buddy->name); | |
538 } | |
539 | |
540 /* Create the "Pounce When" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
541 frame = gaim_gtk_make_frame(vbox2, _("Pounce When")); |
5032 | 542 |
543 table = gtk_table_new(2, 4, FALSE); | |
544 gtk_container_add(GTK_CONTAINER(frame), table); | |
545 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
546 gtk_widget_show(table); | |
547 | |
548 dialog->signon = | |
549 gtk_check_button_new_with_label(_("Sign on")); | |
550 dialog->signoff = | |
551 gtk_check_button_new_with_label(_("Sign off")); | |
552 dialog->away = | |
553 gtk_check_button_new_with_label(_("Away")); | |
554 dialog->away_return = | |
555 gtk_check_button_new_with_label(_("Return from away")); | |
556 dialog->idle = | |
557 gtk_check_button_new_with_label(_("Idle")); | |
558 dialog->idle_return = | |
559 gtk_check_button_new_with_label(_("Return from idle")); | |
560 dialog->typing = | |
561 gtk_check_button_new_with_label(_("Buddy starts typing")); | |
562 dialog->stop_typing = | |
563 gtk_check_button_new_with_label(_("Buddy stops typing")); | |
564 | |
565 gtk_table_attach(GTK_TABLE(table), dialog->signon, 0, 1, 0, 1, | |
566 GTK_FILL, 0, 0, 0); | |
567 gtk_table_attach(GTK_TABLE(table), dialog->signoff, 1, 2, 0, 1, | |
568 GTK_FILL, 0, 0, 0); | |
569 gtk_table_attach(GTK_TABLE(table), dialog->away, 0, 1, 1, 2, | |
570 GTK_FILL, 0, 0, 0); | |
571 gtk_table_attach(GTK_TABLE(table), dialog->away_return, 1, 2, 1, 2, | |
572 GTK_FILL, 0, 0, 0); | |
573 gtk_table_attach(GTK_TABLE(table), dialog->idle, 0, 1, 2, 3, | |
574 GTK_FILL, 0, 0, 0); | |
575 gtk_table_attach(GTK_TABLE(table), dialog->idle_return, 1, 2, 2, 3, | |
576 GTK_FILL, 0, 0, 0); | |
577 gtk_table_attach(GTK_TABLE(table), dialog->typing, 0, 1, 3, 4, | |
578 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
579 gtk_table_attach(GTK_TABLE(table), dialog->stop_typing, 1, 2, 3, 5, |
5032 | 580 GTK_FILL, 0, 0, 0); |
581 | |
582 gtk_widget_show(dialog->signon); | |
583 gtk_widget_show(dialog->signoff); | |
584 gtk_widget_show(dialog->away); | |
585 gtk_widget_show(dialog->away_return); | |
586 gtk_widget_show(dialog->idle); | |
587 gtk_widget_show(dialog->idle_return); | |
588 gtk_widget_show(dialog->typing); | |
589 gtk_widget_show(dialog->stop_typing); | |
590 | |
591 /* Create the "Pounce Action" frame. */ | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
592 frame = gaim_gtk_make_frame(vbox2, _("Pounce Action")); |
5032 | 593 |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
594 table = gtk_table_new(3, 5, FALSE); |
5032 | 595 gtk_container_add(GTK_CONTAINER(frame), table); |
596 gtk_table_set_col_spacings(GTK_TABLE(table), 12); | |
597 gtk_widget_show(table); | |
598 | |
599 dialog->open_win = gtk_check_button_new_with_label(_("Open an IM window")); | |
600 dialog->popup = gtk_check_button_new_with_label(_("Popup notification")); | |
601 dialog->send_msg = gtk_check_button_new_with_label(_("Send a message")); | |
602 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
|
603 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
|
604 |
5032 | 605 dialog->send_msg_entry = gtk_entry_new(); |
606 dialog->exec_cmd_entry = gtk_entry_new(); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
607 dialog->exec_cmd_browse = gtk_button_new_with_label(_("Browse")); |
5032 | 608 dialog->play_sound_entry = gtk_entry_new(); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
609 dialog->play_sound_browse = gtk_button_new_with_label(_("Browse")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
610 dialog->play_sound_test = gtk_button_new_with_label(_("Test")); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
611 |
5032 | 612 gtk_widget_set_sensitive(dialog->send_msg_entry, FALSE); |
613 gtk_widget_set_sensitive(dialog->exec_cmd_entry, FALSE); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
614 gtk_widget_set_sensitive(dialog->exec_cmd_browse, FALSE); |
5032 | 615 gtk_widget_set_sensitive(dialog->play_sound_entry, FALSE); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
616 gtk_widget_set_sensitive(dialog->play_sound_browse, FALSE); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
617 gtk_widget_set_sensitive(dialog->play_sound_test, FALSE); |
5032 | 618 |
619 gtk_table_attach(GTK_TABLE(table), dialog->open_win, 0, 1, 0, 1, | |
620 GTK_FILL, 0, 0, 0); | |
621 gtk_table_attach(GTK_TABLE(table), dialog->popup, 0, 1, 1, 2, | |
622 GTK_FILL, 0, 0, 0); | |
623 gtk_table_attach(GTK_TABLE(table), dialog->send_msg, 0, 1, 2, 3, | |
624 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
625 gtk_table_attach(GTK_TABLE(table), dialog->send_msg_entry, 1, 4, 2, 3, |
5032 | 626 GTK_FILL, 0, 0, 0); |
627 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd, 0, 1, 3, 4, | |
628 GTK_FILL, 0, 0, 0); | |
629 gtk_table_attach(GTK_TABLE(table), dialog->exec_cmd_entry, 1, 2, 3, 4, | |
630 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
631 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
|
632 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 633 gtk_table_attach(GTK_TABLE(table), dialog->play_sound, 0, 1, 4, 5, |
634 GTK_FILL, 0, 0, 0); | |
635 gtk_table_attach(GTK_TABLE(table), dialog->play_sound_entry, 1, 2, 4, 5, | |
636 GTK_FILL, 0, 0, 0); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
637 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
|
638 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
639 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
|
640 GTK_FILL | GTK_EXPAND, 0, 0, 0); |
5032 | 641 |
642 gtk_widget_show(dialog->open_win); | |
643 gtk_widget_show(dialog->popup); | |
644 gtk_widget_show(dialog->send_msg); | |
645 gtk_widget_show(dialog->send_msg_entry); | |
646 gtk_widget_show(dialog->exec_cmd); | |
647 gtk_widget_show(dialog->exec_cmd_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
648 gtk_widget_show(dialog->exec_cmd_browse); |
5032 | 649 gtk_widget_show(dialog->play_sound); |
650 gtk_widget_show(dialog->play_sound_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
651 gtk_widget_show(dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
652 gtk_widget_show(dialog->play_sound_test); |
5032 | 653 |
654 g_signal_connect(G_OBJECT(dialog->send_msg), "clicked", | |
655 G_CALLBACK(gaim_gtk_toggle_sensitive), | |
656 dialog->send_msg_entry); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
657 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
658 exec_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
659 g_ptr_array_add(exec_widgets,dialog->exec_cmd_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
660 g_ptr_array_add(exec_widgets,dialog->exec_cmd_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
661 |
5032 | 662 g_signal_connect(G_OBJECT(dialog->exec_cmd), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
663 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
664 exec_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
665 g_signal_connect(G_OBJECT(dialog->exec_cmd_browse), "clicked", |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
666 G_CALLBACK(filesel), |
5032 | 667 dialog->exec_cmd_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
668 |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
669 sound_widgets = g_ptr_array_new(); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
670 g_ptr_array_add(sound_widgets,dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
671 g_ptr_array_add(sound_widgets,dialog->play_sound_browse); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
672 g_ptr_array_add(sound_widgets,dialog->play_sound_test); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
673 |
5032 | 674 g_signal_connect(G_OBJECT(dialog->play_sound), "clicked", |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
675 G_CALLBACK(gtk_toggle_sensitive_array), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
676 sound_widgets); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
677 g_signal_connect(G_OBJECT(dialog->play_sound_browse), "clicked", |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
678 G_CALLBACK(filesel), |
5032 | 679 dialog->play_sound_entry); |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
680 g_signal_connect(G_OBJECT(dialog->play_sound_test), "clicked", |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
681 G_CALLBACK(pounce_test_sound), |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
682 dialog->play_sound_entry); |
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
683 |
5032 | 684 g_signal_connect(G_OBJECT(dialog->send_msg_entry), "activate", |
685 G_CALLBACK(save_pounce_cb), dialog); | |
686 g_signal_connect(G_OBJECT(dialog->exec_cmd_entry), "activate", | |
687 G_CALLBACK(save_pounce_cb), dialog); | |
688 g_signal_connect(G_OBJECT(dialog->play_sound_entry), "activate", | |
689 G_CALLBACK(save_pounce_cb), dialog); | |
5319
3adb20b869b4
[gaim-migrate @ 5691]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
690 |
5032 | 691 /* Now the last part, where we have the Save checkbox */ |
692 dialog->save_pounce = gtk_check_button_new_with_mnemonic( | |
693 _("_Save this pounce after activation")); | |
694 | |
695 gtk_box_pack_start(GTK_BOX(vbox2), dialog->save_pounce, FALSE, FALSE, 0); | |
696 | |
697 /* Separator... */ | |
698 sep = gtk_hseparator_new(); | |
699 gtk_box_pack_start(GTK_BOX(vbox1), sep, FALSE, FALSE, 0); | |
700 gtk_widget_show(sep); | |
701 | |
702 /* Now the button box! */ | |
703 bbox = gtk_hbutton_box_new(); | |
704 gtk_box_set_spacing(GTK_BOX(bbox), 6); | |
705 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
706 gtk_box_pack_end(GTK_BOX(vbox1), bbox, FALSE, FALSE, 0); | |
707 gtk_widget_show(bbox); | |
708 | |
5052
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
709 /* Delete button */ |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
710 button = gtk_button_new_from_stock(GTK_STOCK_DELETE); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
711 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
712 gtk_widget_show(button); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
713 |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
714 g_signal_connect(G_OBJECT(button), "clicked", |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
715 G_CALLBACK(delete_cb), dialog); |
6a7759f63766
[gaim-migrate @ 5401]
Christian Hammond <chipx86@chipx86.com>
parents:
5051
diff
changeset
|
716 |
5032 | 717 /* Cancel button */ |
718 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL); | |
719 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
720 gtk_widget_show(button); | |
721 | |
722 g_signal_connect(G_OBJECT(button), "clicked", | |
723 G_CALLBACK(cancel_cb), dialog); | |
724 | |
725 /* OK button */ | |
726 button = gtk_button_new_from_stock(GTK_STOCK_OK); | |
727 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
728 gtk_widget_show(button); | |
729 | |
730 g_signal_connect(G_OBJECT(button), "clicked", | |
731 G_CALLBACK(save_pounce_cb), dialog); | |
732 | |
733 /* Set the values of stuff. */ | |
734 if (cur_pounce != NULL) { | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
735 GaimPounceEvent events = gaim_pounce_get_events(cur_pounce); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
736 const char *value; |
5032 | 737 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
738 /* Events */ |
5032 | 739 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), |
740 (events & GAIM_POUNCE_SIGNON)); | |
741 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signoff), | |
742 (events & GAIM_POUNCE_SIGNOFF)); | |
743 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away), | |
744 (events & GAIM_POUNCE_AWAY)); | |
745 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->away_return), | |
746 (events & GAIM_POUNCE_AWAY_RETURN)); | |
747 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle), | |
748 (events & GAIM_POUNCE_IDLE)); | |
749 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->idle_return), | |
750 (events & GAIM_POUNCE_IDLE_RETURN)); | |
751 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->typing), | |
752 (events & GAIM_POUNCE_TYPING)); | |
753 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->stop_typing), | |
754 (events & GAIM_POUNCE_TYPING_STOPPED)); | |
755 | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
756 /* Actions */ |
5032 | 757 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->open_win), |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
758 gaim_pounce_action_is_enabled(cur_pounce, "open-window")); |
5032 | 759 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->popup), |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
760 gaim_pounce_action_is_enabled(cur_pounce, "popup-notify")); |
5032 | 761 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
762 gaim_pounce_action_is_enabled(cur_pounce, "send-message")); |
5032 | 763 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->exec_cmd), |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
764 gaim_pounce_action_is_enabled(cur_pounce, "execute-command")); |
5032 | 765 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->play_sound), |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
766 gaim_pounce_action_is_enabled(cur_pounce, "play-sound")); |
5032 | 767 |
768 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->save_pounce), | |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
769 gaim_pounce_get_save(cur_pounce)); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
770 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
771 if ((value = gaim_pounce_action_get_attribute(cur_pounce, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
772 "send-message", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
773 "message")) != NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
774 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
775 gtk_entry_set_text(GTK_ENTRY(dialog->send_msg_entry), value); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
776 } |
5032 | 777 |
5864
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
778 if ((value = gaim_pounce_action_get_attribute(cur_pounce, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
779 "execute-command", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
780 "command")) != NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
781 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
782 gtk_entry_set_text(GTK_ENTRY(dialog->exec_cmd_entry), value); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
783 } |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
784 |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
785 if ((value = gaim_pounce_action_get_attribute(cur_pounce, |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
786 "play-sound", |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
787 "filename")) != NULL) { |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
788 gtk_entry_set_text(GTK_ENTRY(dialog->play_sound_entry), value); |
417b1001d2b1
[gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents:
5857
diff
changeset
|
789 } |
5032 | 790 } |
791 else { | |
792 /* Set some defaults */ | |
793 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->send_msg), TRUE); | |
794 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog->signon), TRUE); | |
795 } | |
796 | |
797 gtk_widget_show_all(vbox2); | |
798 gtk_widget_show(window); | |
799 } | |
800 | |
801 static void | |
802 new_pounce_cb(GtkWidget *w, struct buddy *b) | |
803 { | |
804 gaim_gtkpounce_dialog_show(b, NULL); | |
805 } | |
806 | |
807 static void | |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
808 delete_pounce_cb(GtkWidget *w, GaimPounce *pounce) |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
809 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
810 gaim_pounce_destroy(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
811 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
812 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
813 static void |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
814 edit_pounce_cb(GtkWidget *w, GaimPounce *pounce) |
5032 | 815 { |
816 struct buddy *buddy; | |
817 | |
818 buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce), | |
819 gaim_pounce_get_pouncee(pounce)); | |
820 | |
821 gaim_gtkpounce_dialog_show(buddy, pounce); | |
822 } | |
823 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
824 static void |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
825 fill_menu(GtkWidget *menu, GCallback cb) |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
826 { |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
827 GtkWidget *image; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
828 GtkWidget *item; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
829 GdkPixbuf *pixbuf, *scale; |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
830 GaimPounce *pounce; |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
831 const char *buddy; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
832 GList *bp; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
833 |
5866
d6b5cab288bb
[gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents:
5864
diff
changeset
|
834 for (bp = gaim_pounces_get_all(); bp != NULL; bp = bp->next) { |
5857
2fa4aa9c1885
[gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
835 pounce = (GaimPounce *)bp->data; |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
836 buddy = gaim_pounce_get_pouncee(pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
837 |
5161 | 838 /* Build the menu item */ |
839 item = gtk_image_menu_item_new_with_label(buddy); | |
840 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
841 /* Create a pixmap for the protocol icon. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
842 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); |
5161 | 843 if(pixbuf) { |
844 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, | |
845 GDK_INTERP_BILINEAR); | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
846 |
5161 | 847 /* Now convert it to GtkImage */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
848 image = gtk_image_new_from_pixbuf(scale); |
5161 | 849 g_object_unref(G_OBJECT(scale)); |
850 g_object_unref(G_OBJECT(pixbuf)); | |
851 gtk_widget_show(image); | |
852 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); | |
853 } | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
854 |
5161 | 855 /* Put the item in the menu */ |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
856 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
857 gtk_widget_show(item); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
858 |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
859 /* Set our callbacks. */ |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
860 g_signal_connect(G_OBJECT(item), "activate", cb, pounce); |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
861 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
862 } |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
863 |
5032 | 864 void |
865 gaim_gtkpounce_menu_build(GtkWidget *menu) | |
866 { | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
867 GtkWidget *remmenu; |
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
868 GtkWidget *item; |
5032 | 869 GList *l; |
870 | |
871 for (l = gtk_container_get_children(GTK_CONTAINER(menu)); | |
872 l != NULL; | |
873 l = l->next) { | |
874 | |
875 gtk_widget_destroy(GTK_WIDGET(l->data)); | |
876 } | |
877 | |
878 /* "New Buddy Pounce" */ | |
879 item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); | |
880 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
881 gtk_widget_show(item); | |
882 g_signal_connect(G_OBJECT(item), "activate", | |
883 G_CALLBACK(new_pounce_cb), NULL); | |
884 | |
885 /* "Remove Buddy Pounce" */ | |
886 item = gtk_menu_item_new_with_label(_("Remove Buddy Pounce")); | |
887 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
888 | |
889 /* "Remove Buddy Pounce" menu */ | |
890 remmenu = gtk_menu_new(); | |
891 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
892 fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); |
5032 | 893 |
894 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); | |
895 gtk_widget_show(remmenu); | |
896 gtk_widget_show(item); | |
897 | |
898 /* Separator */ | |
899 item = gtk_separator_menu_item_new(); | |
900 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
901 gtk_widget_show(item); | |
902 | |
5153
ab0f12de3718
[gaim-migrate @ 5517]
Christian Hammond <chipx86@chipx86.com>
parents:
5054
diff
changeset
|
903 fill_menu(menu, G_CALLBACK(edit_pounce_cb)); |
5032 | 904 } |
905 |