Mercurial > pidgin.yaz
comparison console/gntblist.c @ 14062:fa8f65cd912c
[gaim-migrate @ 16681]
You can now add buddies or groups in the buddylist from the context-menu
for a group. Adding chats is not yet possible.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 09 Aug 2006 17:22:55 +0000 |
parents | 2d1b41e3cf0d |
children | ccbd43daa1a3 |
comparison
equal
deleted
inserted
replaced
14061:eb58c6169e6c | 14062:fa8f65cd912c |
---|---|
1 #include <account.h> | 1 #include <account.h> |
2 #include <blist.h> | 2 #include <blist.h> |
3 #include <notify.h> | |
3 #include <request.h> | 4 #include <request.h> |
4 #include <savedstatuses.h> | 5 #include <savedstatuses.h> |
5 #include <server.h> | 6 #include <server.h> |
6 #include <signal.h> | 7 #include <signal.h> |
7 #include <status.h> | 8 #include <status.h> |
139 static void | 140 static void |
140 new_list(GaimBuddyList *list) | 141 new_list(GaimBuddyList *list) |
141 { | 142 { |
142 } | 143 } |
143 | 144 |
145 static void | |
146 add_buddy_cb(void *data, GaimRequestFields *allfields) | |
147 { | |
148 const char *username = gaim_request_fields_get_string(allfields, "screenname"); | |
149 const char *alias = gaim_request_fields_get_string(allfields, "alias"); | |
150 const char *group = gaim_request_fields_get_string(allfields, "group"); | |
151 GaimAccount *account = gaim_request_fields_get_account(allfields, "account"); | |
152 const char *error = NULL; | |
153 GaimGroup *grp; | |
154 GaimBuddy *buddy; | |
155 | |
156 if (!username) | |
157 error = _("You must provide a screename for the buddy."); | |
158 else if (!group) | |
159 error = _("You must provide a group."); | |
160 else if (!account) | |
161 error = _("You must select an account."); | |
162 | |
163 if (error) | |
164 { | |
165 gaim_notify_error(NULL, _("Error"), _("Error adding buddy"), error); | |
166 return; | |
167 } | |
168 | |
169 grp = gaim_find_group(group); | |
170 if (!grp) | |
171 { | |
172 grp = gaim_group_new(group); | |
173 gaim_blist_add_group(grp, NULL); | |
174 } | |
175 | |
176 buddy = gaim_buddy_new(account, username, alias); | |
177 gaim_blist_add_buddy(buddy, NULL, grp, NULL); | |
178 gaim_account_add_buddy(account, buddy); | |
179 } | |
180 | |
181 static void | |
182 gg_request_add_buddy(GaimAccount *account, const char *username, const char *grp, const char *alias) | |
183 { | |
184 GaimRequestFields *fields = gaim_request_fields_new(); | |
185 GaimRequestFieldGroup *group = gaim_request_field_group_new(NULL); | |
186 GaimRequestField *field; | |
187 | |
188 gaim_request_fields_add_group(fields, group); | |
189 | |
190 field = gaim_request_field_string_new("screenname", _("Screen Name"), username, FALSE); | |
191 gaim_request_field_group_add_field(group, field); | |
192 | |
193 field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE); | |
194 gaim_request_field_group_add_field(group, field); | |
195 | |
196 field = gaim_request_field_string_new("group", _("Group"), grp, FALSE); | |
197 gaim_request_field_group_add_field(group, field); | |
198 | |
199 field = gaim_request_field_account_new("account", _("Account"), NULL); | |
200 gaim_request_field_account_set_show_all(field, FALSE); | |
201 if (account) | |
202 gaim_request_field_account_set_value(field, account); | |
203 gaim_request_field_group_add_field(group, field); | |
204 | |
205 gaim_request_fields(NULL, _("Add Buddy"), NULL, _("Please enter buddy information."), | |
206 fields, _("Add"), G_CALLBACK(add_buddy_cb), _("Cancel"), NULL, NULL); | |
207 } | |
208 | |
209 static void | |
210 add_group_cb(gpointer null, const char *group) | |
211 { | |
212 GaimGroup *grp; | |
213 | |
214 if (!group || !*group) | |
215 { | |
216 gaim_notify_error(NULL, _("Error"), _("Error adding group"), | |
217 _("You must give a name for the group to add.")); | |
218 return; | |
219 } | |
220 | |
221 grp = gaim_find_group(group); | |
222 if (!grp) | |
223 { | |
224 grp = gaim_group_new(group); | |
225 gaim_blist_add_group(grp, NULL); | |
226 } | |
227 else | |
228 { | |
229 gaim_notify_error(NULL, _("Error"), _("Error adding group"), | |
230 _("A group with the name already exists.")); | |
231 } | |
232 } | |
233 | |
234 static void | |
235 gg_request_add_group() | |
236 { | |
237 gaim_request_input(NULL, _("Add Group"), NULL, _("Enter the name of the group"), | |
238 NULL, FALSE, FALSE, NULL, | |
239 _("Add"), G_CALLBACK(add_group_cb), _("Cancel"), NULL, NULL); | |
240 } | |
241 | |
144 static GaimBlistUiOps blist_ui_ops = | 242 static GaimBlistUiOps blist_ui_ops = |
145 { | 243 { |
146 new_list, | 244 new_list, |
147 new_node, | 245 new_node, |
148 NULL, | 246 NULL, |
149 node_update, /* This doesn't do crap */ | 247 node_update, /* This doesn't do crap */ |
150 node_remove, | 248 node_remove, |
151 NULL, | 249 NULL, |
152 NULL, | 250 NULL, |
251 .request_add_buddy = gg_request_add_buddy, | |
153 NULL, | 252 NULL, |
154 NULL, | 253 .request_add_group = gg_request_add_group |
155 NULL | |
156 }; | 254 }; |
157 | 255 |
158 static gpointer | 256 static gpointer |
159 gg_blist_get_handle() | 257 gg_blist_get_handle() |
160 { | 258 { |
358 create_chat_menu(GntTree *tree, GaimChat *chat) | 456 create_chat_menu(GntTree *tree, GaimChat *chat) |
359 { | 457 { |
360 } | 458 } |
361 | 459 |
362 static void | 460 static void |
461 gg_add_buddy(GaimGroup *grp, GaimBlistNode *node) | |
462 { | |
463 gaim_blist_request_add_buddy(NULL, NULL, grp->name, NULL); | |
464 } | |
465 | |
466 static void | |
467 gg_add_group(GaimGroup *grp, GaimBlistNode *node) | |
468 { | |
469 gaim_blist_request_add_group(); | |
470 } | |
471 | |
472 static void | |
363 create_group_menu(GntTree *tree, GaimGroup *group) | 473 create_group_menu(GntTree *tree, GaimGroup *group) |
364 { | 474 { |
475 add_custom_action(tree, _("Add Buddy"), | |
476 GAIM_CALLBACK(gg_add_buddy), group); | |
477 add_custom_action(tree, _("Add Group"), | |
478 GAIM_CALLBACK(gg_add_group), group); | |
365 } | 479 } |
366 | 480 |
367 static void | 481 static void |
368 gg_blist_get_buddy_info_cb(GaimBuddy *buddy, GaimBlistNode *null) | 482 gg_blist_get_buddy_info_cb(GaimBuddy *buddy, GaimBlistNode *null) |
369 { | 483 { |
553 GAIM_CALLBACK(gg_blist_rename_node_cb), node); | 667 GAIM_CALLBACK(gg_blist_rename_node_cb), node); |
554 add_custom_action(GNT_TREE(context), _("Remove"), | 668 add_custom_action(GNT_TREE(context), _("Remove"), |
555 GAIM_CALLBACK(gg_blist_remove_node_cb), node); | 669 GAIM_CALLBACK(gg_blist_remove_node_cb), node); |
556 | 670 |
557 window = gnt_vbox_new(FALSE); | 671 window = gnt_vbox_new(FALSE); |
672 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT); | |
558 gnt_box_set_toplevel(GNT_BOX(window), TRUE); | 673 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
559 gnt_box_set_title(GNT_BOX(window), title); | 674 gnt_box_set_title(GNT_BOX(window), title); |
560 | 675 |
561 gnt_widget_set_size(context, 0, g_list_length(GNT_TREE(context)->list)); | 676 gnt_widget_set_size(context, 0, g_list_length(GNT_TREE(context)->list)); |
562 gnt_box_add_widget(GNT_BOX(window), context); | 677 gnt_box_add_widget(GNT_BOX(window), context); |