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