3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
32 #include "purpleaccountoption.h"
34 #include "savedstatuses.h"
38 #include "gtkaccount.h"
40 #include "gtkdialogs.h"
42 #include "gtkstatusbox.h"
43 #include "pidginstock.h"
44 #include "minidialog.h"
46 #include "gtk3compat.h"
61 PurpleAccount
*account
;
65 } PidginAccountAddUserData
;
72 GtkWidget
*modify_button
;
73 GtkWidget
*delete_button
;
77 GtkTreeIter drag_iter
;
79 GtkTreeViewColumn
*username_col
;
92 PidginAccountDialogType type
;
94 PurpleAccount
*account
;
96 PurpleProtocol
*protocol
;
98 PurpleProxyType new_proxy_type
;
100 GList
*user_split_entries
;
101 GList
*protocol_opt_entries
;
108 GtkWidget
*ok_button
;
109 GtkWidget
*register_button
;
112 GtkWidget
*login_frame
;
113 GtkWidget
*protocol_menu
;
114 GtkWidget
*password_box
;
116 GtkWidget
*username_entry
;
117 GdkRGBA username_entry_hint_color
;
118 GtkWidget
*password_entry
;
119 GtkWidget
*alias_entry
;
120 GtkWidget
*remember_pass_check
;
123 GtkWidget
*user_frame
;
124 GtkWidget
*new_mail_check
;
125 GtkWidget
*icon_hbox
;
126 GtkWidget
*icon_check
;
127 GtkWidget
*icon_entry
;
128 GtkFileChooserNative
*icon_filesel
;
129 GtkWidget
*icon_preview
;
130 GtkWidget
*icon_text
;
131 PurpleImage
*icon_img
;
133 /* Protocol Options */
134 GtkWidget
*protocol_frame
;
137 GtkWidget
*proxy_frame
;
138 GtkWidget
*proxy_vbox
;
139 GtkWidget
*proxy_dropdown
;
140 GtkWidget
*proxy_host_entry
;
141 GtkWidget
*proxy_port_entry
;
142 GtkWidget
*proxy_user_entry
;
143 GtkWidget
*proxy_pass_entry
;
145 /* Voice & Video Options*/
146 GtkWidget
*voice_frame
;
147 GtkWidget
*suppression_check
;
149 } AccountPrefsDialog
;
151 static AccountsWindow
*accounts_window
= NULL
;
152 static GHashTable
*account_pref_wins
;
154 static void add_account_to_liststore(PurpleAccount
*account
, gpointer user_data
);
155 static void set_account(GtkListStore
*store
, GtkTreeIter
*iter
,
156 PurpleAccount
*account
, GdkPixbuf
*global_buddyicon
);
158 /**************************************************************************
159 * Add/Modify Account dialog
160 **************************************************************************/
161 static void add_login_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
);
162 static void add_user_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
);
163 static void add_account_options(AccountPrefsDialog
*dialog
);
164 static void add_proxy_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
);
165 static void add_voice_options(AccountPrefsDialog
*dialog
);
168 add_pref_box(AccountPrefsDialog
*dialog
, GtkWidget
*parent
,
169 const char *text
, GtkWidget
*widget
)
171 return pidgin_add_widget_to_vbox(GTK_BOX(parent
), text
, dialog
->sg
, widget
, TRUE
, NULL
);
175 set_dialog_icon(AccountPrefsDialog
*dialog
, gpointer data
, size_t len
, gchar
*new_icon_path
)
177 GdkPixbuf
*pixbuf
= NULL
;
178 PurpleBuddyIconSpec
*icon_spec
= NULL
;
180 if (dialog
->icon_img
) {
181 g_object_unref(dialog
->icon_img
);
182 dialog
->icon_img
= NULL
;
185 if (new_icon_path
!= NULL
) {
186 dialog
->icon_img
= purple_image_new_from_file(new_icon_path
, NULL
);
187 purple_debug_warning("gtkaccount", "data was not necessary");
189 } else if (data
!= NULL
) {
191 dialog
->icon_img
= purple_image_new_take_data(data
, len
);
196 if (dialog
->icon_img
!= NULL
) {
197 pixbuf
= pidgin_pixbuf_from_image(dialog
->icon_img
);
200 if (dialog
->protocol
)
201 icon_spec
= purple_protocol_get_icon_spec(dialog
->protocol
);
203 if (pixbuf
&& icon_spec
&& (icon_spec
->scale_rules
& PURPLE_ICON_SCALE_DISPLAY
))
205 /* Scale the icon to something reasonable */
209 pidgin_buddy_icon_get_scale_size(pixbuf
, icon_spec
,
210 PURPLE_ICON_SCALE_DISPLAY
, &width
, &height
);
211 scale
= gdk_pixbuf_scale_simple(pixbuf
, width
, height
, GDK_INTERP_BILINEAR
);
213 g_object_unref(G_OBJECT(pixbuf
));
219 /* Show a placeholder icon */
220 gtk_image_set_from_icon_name(GTK_IMAGE(dialog
->icon_entry
),
221 "select-avatar", GTK_ICON_SIZE_LARGE_TOOLBAR
);
223 gtk_image_set_from_pixbuf(GTK_IMAGE(dialog
->icon_entry
), pixbuf
);
224 g_object_unref(G_OBJECT(pixbuf
));
229 set_account_protocol_cb(GtkWidget
*widget
, const char *id
,
230 AccountPrefsDialog
*dialog
)
232 PurpleProtocol
*new_protocol
;
234 new_protocol
= purple_protocols_find(id
);
236 dialog
->protocol
= new_protocol
;
238 if (dialog
->protocol
!= NULL
)
240 PurpleProtocol
*old_protocol
= NULL
;
242 if (dialog
->protocol_id
)
243 old_protocol
= purple_protocols_find(dialog
->protocol_id
);
245 if (old_protocol
!= new_protocol
) {
246 g_free(dialog
->protocol_id
);
247 dialog
->protocol_id
= g_strdup(purple_protocol_get_id(dialog
->protocol
));
251 if (dialog
->account
!= NULL
)
252 purple_account_clear_settings(dialog
->account
);
254 add_login_options(dialog
, dialog
->top_vbox
);
255 add_user_options(dialog
, dialog
->top_vbox
);
256 add_account_options(dialog
);
257 add_voice_options(dialog
);
259 gtk_widget_grab_focus(dialog
->protocol_menu
);
261 if (!dialog
->protocol
|| !PURPLE_PROTOCOL_IMPLEMENTS(dialog
->protocol
, SERVER
, register_user
)) {
262 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
263 dialog
->register_button
), FALSE
);
264 gtk_widget_hide(dialog
->register_button
);
266 if (purple_protocol_get_options(dialog
->protocol
) &
267 OPT_PROTO_REGISTER_NOSCREENNAME
) {
268 gtk_widget_set_sensitive(dialog
->register_button
, TRUE
);
270 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(
271 dialog
->register_button
), FALSE
);
272 gtk_widget_set_sensitive(dialog
->register_button
, FALSE
);
274 gtk_widget_show(dialog
->register_button
);
279 username_changed_cb(GtkEntry
*entry
, AccountPrefsDialog
*dialog
)
281 gboolean opt_noscreenname
= (dialog
->protocol
!= NULL
&&
282 (purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_REGISTER_NOSCREENNAME
));
283 gboolean username_valid
= purple_validate(dialog
->protocol
,
284 gtk_entry_get_text(entry
));
286 if (dialog
->ok_button
) {
287 if (opt_noscreenname
&& dialog
->register_button
&&
288 gtk_toggle_button_get_active(
289 GTK_TOGGLE_BUTTON(dialog
->register_button
)))
290 gtk_widget_set_sensitive(dialog
->ok_button
, TRUE
);
292 gtk_widget_set_sensitive(dialog
->ok_button
,
296 if (dialog
->register_button
) {
297 if (opt_noscreenname
)
298 gtk_widget_set_sensitive(dialog
->register_button
, TRUE
);
300 gtk_widget_set_sensitive(dialog
->register_button
,
306 register_button_cb(GtkWidget
*checkbox
, AccountPrefsDialog
*dialog
)
308 int register_checked
= gtk_toggle_button_get_active(
309 GTK_TOGGLE_BUTTON(dialog
->register_button
));
310 int opt_noscreenname
= (dialog
->protocol
!= NULL
&&
311 (purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_REGISTER_NOSCREENNAME
));
312 int register_noscreenname
= (opt_noscreenname
&& register_checked
);
314 if (register_noscreenname
) {
315 gtk_entry_set_text(GTK_ENTRY(dialog
->username_entry
), "");
316 gtk_entry_set_text(GTK_ENTRY(dialog
->password_entry
), "");
317 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->remember_pass_check
), FALSE
);
319 gtk_widget_set_sensitive(dialog
->username_entry
, !register_noscreenname
);
320 gtk_widget_set_sensitive(dialog
->password_entry
, !register_noscreenname
);
321 gtk_widget_set_sensitive(dialog
->remember_pass_check
, !register_noscreenname
);
323 if (dialog
->ok_button
) {
324 gtk_widget_set_sensitive(dialog
->ok_button
,
325 (opt_noscreenname
&& register_checked
) ||
326 *gtk_entry_get_text(GTK_ENTRY(dialog
->username_entry
))
332 icon_filesel_choose_cb(const char *filename
, gpointer data
)
334 AccountPrefsDialog
*dialog
= data
;
336 if (filename
!= NULL
)
339 gpointer data
= pidgin_convert_buddy_icon(dialog
->protocol
, filename
, &len
);
340 set_dialog_icon(dialog
, data
, len
, g_strdup(filename
));
343 g_clear_object(&dialog
->icon_filesel
);
347 icon_select_cb(GtkWidget
*button
, AccountPrefsDialog
*dialog
)
349 dialog
->icon_filesel
= pidgin_buddy_icon_chooser_new(GTK_WINDOW(dialog
->window
), icon_filesel_choose_cb
, dialog
);
350 gtk_native_dialog_show(GTK_NATIVE_DIALOG(dialog
->icon_filesel
));
354 icon_reset_cb(GtkWidget
*button
, AccountPrefsDialog
*dialog
)
356 set_dialog_icon(dialog
, NULL
, 0, NULL
);
360 account_dnd_recv(GtkWidget
*widget
, GdkDragContext
*dc
, gint x
, gint y
,
361 GtkSelectionData
*sd
, guint info
, guint t
, AccountPrefsDialog
*dialog
)
363 const gchar
*name
= (gchar
*)gtk_selection_data_get_data(sd
);
364 gint length
= gtk_selection_data_get_length(sd
);
365 gint format
= gtk_selection_data_get_format(sd
);
367 if ((length
>= 0) && (format
== 8)) {
368 /* Well, it looks like the drag event was cool.
369 * Let's do something with it */
370 if (!g_ascii_strncasecmp(name
, "file://", 7)) {
371 GError
*converr
= NULL
;
376 /* It looks like we're dealing with a local file. */
377 if(!(tmp
= g_filename_from_uri(name
, NULL
, &converr
))) {
378 purple_debug(PURPLE_DEBUG_ERROR
, "buddyicon", "%s\n",
379 (converr
? converr
->message
:
380 "g_filename_from_uri error"));
383 if ((rtmp
= strchr(tmp
, '\r')) || (rtmp
= strchr(tmp
, '\n')))
386 data
= pidgin_convert_buddy_icon(dialog
->protocol
, tmp
, &len
);
387 /* This takes ownership of tmp */
388 set_dialog_icon(dialog
, data
, len
, tmp
);
390 gtk_drag_finish(dc
, TRUE
, FALSE
, t
);
392 gtk_drag_finish(dc
, FALSE
, FALSE
, t
);
396 update_editable(PurpleConnection
*gc
, AccountPrefsDialog
*dialog
)
398 GtkStyleContext
*style
;
402 if (dialog
->account
== NULL
)
405 if (gc
!= NULL
&& dialog
->account
!= purple_connection_get_account(gc
))
408 set
= !(purple_account_is_connected(dialog
->account
) || purple_account_is_connecting(dialog
->account
));
409 gtk_widget_set_sensitive(dialog
->protocol_menu
, set
);
410 gtk_editable_set_editable(GTK_EDITABLE(dialog
->username_entry
), set
);
411 style
= gtk_widget_get_style_context(dialog
->username_entry
);
414 gtk_style_context_remove_class(style
, "copyable-insensitive");
416 gtk_style_context_add_class(style
, "copyable-insensitive");
419 for (l
= dialog
->user_split_entries
; l
!= NULL
; l
= l
->next
) {
422 if (GTK_IS_EDITABLE(l
->data
)) {
423 gtk_editable_set_editable(GTK_EDITABLE(l
->data
), set
);
424 style
= gtk_widget_get_style_context(GTK_WIDGET(l
->data
));
426 gtk_style_context_remove_class(style
,
427 "copyable-insensitive");
429 gtk_style_context_add_class(style
,
430 "copyable-insensitive");
433 gtk_widget_set_sensitive(GTK_WIDGET(l
->data
), set
);
439 add_login_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
)
447 char *username
= NULL
;
448 GtkCssProvider
*entry_css
;
449 const gchar entry_style
[] =
450 "entry.copyable-insensitive {"
451 "color: @insensitive_fg_color;"
452 "background-color: @insensitive_bg_color;"
455 entry_css
= gtk_css_provider_new();
456 gtk_css_provider_load_from_data(entry_css
, entry_style
, -1, NULL
);
458 if (dialog
->protocol_menu
!= NULL
)
460 g_object_ref(G_OBJECT(dialog
->protocol_menu
));
461 hbox
= g_object_get_data(G_OBJECT(dialog
->protocol_menu
), "container");
462 gtk_container_remove(GTK_CONTAINER(hbox
), dialog
->protocol_menu
);
465 if (dialog
->login_frame
!= NULL
)
466 gtk_widget_destroy(dialog
->login_frame
);
468 /* Build the login options frame. */
469 frame
= pidgin_make_frame(parent
, _("Login Options"));
472 dialog
->login_frame
= gtk_widget_get_parent(gtk_widget_get_parent(frame
));
474 gtk_box_reorder_child(GTK_BOX(parent
), dialog
->login_frame
, 0);
475 gtk_widget_show(dialog
->login_frame
);
478 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BOX_SPACE
);
479 gtk_container_add(GTK_CONTAINER(frame
), vbox
);
480 gtk_widget_show(vbox
);
483 if (dialog
->protocol_menu
== NULL
)
485 dialog
->protocol_menu
= pidgin_protocol_option_menu_new(
486 dialog
->protocol_id
, G_CALLBACK(set_account_protocol_cb
), dialog
);
487 g_object_ref(G_OBJECT(dialog
->protocol_menu
));
490 hbox
= add_pref_box(dialog
, vbox
, _("Pro_tocol:"), dialog
->protocol_menu
);
491 g_object_set_data(G_OBJECT(dialog
->protocol_menu
), "container", hbox
);
493 g_object_unref(G_OBJECT(dialog
->protocol_menu
));
496 dialog
->username_entry
= gtk_entry_new();
497 gtk_style_context_add_provider(
498 gtk_widget_get_style_context(dialog
->username_entry
),
499 GTK_STYLE_PROVIDER(entry_css
),
500 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
501 g_object_set(G_OBJECT(dialog
->username_entry
), "truncate-multiline", TRUE
, NULL
);
503 add_pref_box(dialog
, vbox
, _("_Username:"), dialog
->username_entry
);
505 if (dialog
->account
!= NULL
)
506 username
= g_strdup(purple_account_get_username(dialog
->account
));
508 if (!username
&& dialog
->protocol
509 && PURPLE_PROTOCOL_IMPLEMENTS(dialog
->protocol
, CLIENT
, get_account_text_table
)) {
512 table
= purple_protocol_client_iface_get_account_text_table(dialog
->protocol
, NULL
);
513 label
= g_hash_table_lookup(table
, "login_label");
515 gtk_entry_set_placeholder_text(GTK_ENTRY(dialog
->username_entry
), label
);
517 g_hash_table_destroy(table
);
520 g_signal_connect(G_OBJECT(dialog
->username_entry
), "changed",
521 G_CALLBACK(username_changed_cb
), dialog
);
523 /* Do the user split thang */
524 if (dialog
->protocol
== NULL
)
527 user_splits
= purple_protocol_get_user_splits(dialog
->protocol
);
529 if (dialog
->user_split_entries
!= NULL
) {
530 g_list_free(dialog
->user_split_entries
);
531 dialog
->user_split_entries
= NULL
;
534 for (l
= user_splits
; l
!= NULL
; l
= l
->next
) {
535 PurpleAccountUserSplit
*split
= l
->data
;
538 if (purple_account_user_split_is_constant(split
))
541 buf
= g_strdup_printf("_%s:", purple_account_user_split_get_text(split
));
542 entry
= gtk_entry_new();
543 gtk_style_context_add_provider(
544 gtk_widget_get_style_context(entry
),
545 GTK_STYLE_PROVIDER(entry_css
),
546 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
);
547 add_pref_box(dialog
, vbox
, buf
, entry
);
551 dialog
->user_split_entries
=
552 g_list_append(dialog
->user_split_entries
, entry
);
555 for (l
= g_list_last(dialog
->user_split_entries
),
556 l2
= g_list_last(user_splits
);
557 l
!= NULL
&& l2
!= NULL
;
558 l
= l
->prev
, l2
= l2
->prev
) {
560 GtkWidget
*entry
= l
->data
;
561 PurpleAccountUserSplit
*split
= l2
->data
;
562 const char *value
= NULL
;
565 if (dialog
->account
!= NULL
&& username
!= NULL
) {
566 if(purple_account_user_split_get_reverse(split
))
567 c
= strrchr(username
,
568 purple_account_user_split_get_separator(split
));
571 purple_account_user_split_get_separator(split
));
581 value
= purple_account_user_split_get_default_value(split
);
583 if (value
!= NULL
&& entry
!= NULL
)
584 gtk_entry_set_text(GTK_ENTRY(entry
), value
);
587 if (username
!= NULL
)
588 gtk_entry_set_text(GTK_ENTRY(dialog
->username_entry
), username
);
594 dialog
->password_entry
= gtk_entry_new();
595 gtk_entry_set_visibility(GTK_ENTRY(dialog
->password_entry
), FALSE
);
596 dialog
->password_box
= add_pref_box(dialog
, vbox
, _("_Password:"),
597 dialog
->password_entry
);
599 /* Remember Password */
600 dialog
->remember_pass_check
=
601 gtk_check_button_new_with_mnemonic(_("Remember pass_word"));
602 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->remember_pass_check
),
604 gtk_box_pack_start(GTK_BOX(vbox
), dialog
->remember_pass_check
,
606 gtk_widget_show(dialog
->remember_pass_check
);
608 /* Set the fields. */
609 if (dialog
->account
!= NULL
) {
610 if (dialog
->password
&& purple_account_get_remember_password(
612 gtk_entry_set_text(GTK_ENTRY(dialog
->password_entry
),
616 gtk_toggle_button_set_active(
617 GTK_TOGGLE_BUTTON(dialog
->remember_pass_check
),
618 purple_account_get_remember_password(dialog
->account
));
621 if (dialog
->protocol
!= NULL
&&
622 (purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_NO_PASSWORD
)) {
624 gtk_widget_hide(dialog
->password_box
);
625 gtk_widget_hide(dialog
->remember_pass_check
);
628 /* Do not let the user change the protocol/username while connected. */
629 update_editable(NULL
, dialog
);
630 purple_signal_connect(purple_connections_get_handle(), "signing-on", dialog
,
631 G_CALLBACK(update_editable
), dialog
);
632 purple_signal_connect(purple_connections_get_handle(), "signed-off", dialog
,
633 G_CALLBACK(update_editable
), dialog
);
635 g_object_unref(entry_css
);
639 icon_check_cb(GtkWidget
*checkbox
, AccountPrefsDialog
*dialog
)
641 gtk_widget_set_sensitive(dialog
->icon_hbox
, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
)));
645 add_user_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
)
655 if (dialog
->user_frame
!= NULL
)
656 gtk_widget_destroy(dialog
->user_frame
);
658 /* Build the user options frame. */
659 frame
= pidgin_make_frame(parent
, _("User Options"));
660 dialog
->user_frame
= gtk_widget_get_parent(gtk_widget_get_parent(frame
));
662 gtk_box_reorder_child(GTK_BOX(parent
), dialog
->user_frame
, 1);
663 gtk_widget_show(dialog
->user_frame
);
666 vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BOX_SPACE
);
667 gtk_container_add(GTK_CONTAINER(frame
), vbox
);
668 gtk_widget_show(vbox
);
671 dialog
->alias_entry
= gtk_entry_new();
672 add_pref_box(dialog
, vbox
, _("_Local alias:"), dialog
->alias_entry
);
674 /* New mail notifications */
675 dialog
->new_mail_check
=
676 gtk_check_button_new_with_mnemonic(_("New _mail notifications"));
677 gtk_box_pack_start(GTK_BOX(vbox
), dialog
->new_mail_check
, FALSE
, FALSE
, 0);
678 gtk_widget_show(dialog
->new_mail_check
);
681 dialog
->icon_check
= gtk_check_button_new_with_mnemonic(_("Use this buddy _icon for this account:"));
682 g_signal_connect(G_OBJECT(dialog
->icon_check
), "toggled", G_CALLBACK(icon_check_cb
), dialog
);
683 gtk_widget_show(dialog
->icon_check
);
684 gtk_box_pack_start(GTK_BOX(vbox
), dialog
->icon_check
, FALSE
, FALSE
, 0);
686 dialog
->icon_hbox
= hbox
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, PIDGIN_HIG_BOX_SPACE
);
687 gtk_widget_set_sensitive(hbox
, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
)));
688 gtk_box_pack_start(GTK_BOX(vbox
), hbox
, FALSE
, FALSE
, 0);
689 gtk_widget_show(hbox
);
691 label
= gtk_label_new(" ");
692 gtk_box_pack_start(GTK_BOX(hbox
), label
, FALSE
, FALSE
, 0);
693 gtk_widget_show(label
);
695 button
= gtk_button_new();
696 gtk_box_pack_start(GTK_BOX(hbox
), button
, FALSE
, FALSE
, 0);
697 gtk_widget_show(button
);
698 g_signal_connect(G_OBJECT(button
), "clicked",
699 G_CALLBACK(icon_select_cb
), dialog
);
701 dialog
->icon_entry
= gtk_image_new();
702 gtk_container_add(GTK_CONTAINER(button
), dialog
->icon_entry
);
703 gtk_widget_show(dialog
->icon_entry
);
704 /* TODO: Uh, isn't this next line pretty useless? */
705 pidgin_set_accessible_label(dialog
->icon_entry
, GTK_LABEL(label
));
706 if (dialog
->icon_img
) {
707 g_object_unref(dialog
->icon_img
);
708 dialog
->icon_img
= NULL
;
711 vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, 0);
712 gtk_box_pack_start(GTK_BOX(hbox
), vbox2
, TRUE
, TRUE
, 0);
713 gtk_widget_show(vbox2
);
715 hbox2
= gtk_box_new(GTK_ORIENTATION_HORIZONTAL
, PIDGIN_HIG_BOX_SPACE
);
716 gtk_box_pack_start(GTK_BOX(vbox2
), hbox2
, FALSE
, FALSE
, PIDGIN_HIG_BORDER
);
717 gtk_widget_show(hbox2
);
719 button
= gtk_button_new_with_mnemonic(_("_Remove"));
720 g_signal_connect(G_OBJECT(button
), "clicked",
721 G_CALLBACK(icon_reset_cb
), dialog
);
722 gtk_box_pack_start(GTK_BOX(hbox2
), button
, FALSE
, FALSE
, 0);
723 gtk_widget_show(button
);
725 if (dialog
->protocol
!= NULL
) {
726 PurpleBuddyIconSpec
*icon_spec
= purple_protocol_get_icon_spec(dialog
->protocol
);
727 if (!(purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_MAIL_CHECK
))
728 gtk_widget_hide(dialog
->new_mail_check
);
730 if (!icon_spec
|| icon_spec
->format
== NULL
) {
731 gtk_widget_hide(dialog
->icon_check
);
732 gtk_widget_hide(dialog
->icon_hbox
);
736 if (dialog
->account
!= NULL
) {
738 gpointer data
= NULL
;
741 if (purple_account_get_private_alias(dialog
->account
))
742 gtk_entry_set_text(GTK_ENTRY(dialog
->alias_entry
),
743 purple_account_get_private_alias(dialog
->account
));
745 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->new_mail_check
),
746 purple_account_get_check_mail(dialog
->account
));
748 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
),
749 !purple_account_get_bool(dialog
->account
, "use-global-buddyicon",
752 img
= purple_buddy_icons_find_account_icon(dialog
->account
);
755 len
= purple_image_get_data_size(img
);
756 data
= g_memdup(purple_image_get_data(img
), len
);
758 set_dialog_icon(dialog
, data
, len
,
759 g_strdup(purple_account_get_buddy_icon_path(dialog
->account
)));
761 set_dialog_icon(dialog
, NULL
, 0, NULL
);
765 if (!dialog
->protocol
||
766 (!(purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_MAIL_CHECK
) &&
767 (purple_protocol_get_icon_spec(dialog
->protocol
).format
== NULL
))) {
769 /* Nothing to see :( aww. */
770 gtk_widget_hide(dialog
->user_frame
);
776 add_account_options(AccountPrefsDialog
*dialog
)
778 PurpleAccountOption
*option
;
779 PurpleAccount
*account
;
780 GtkWidget
*vbox
, *check
, *entry
, *combo
;
782 gint i
, idx
, int_value
;
785 GtkCellRenderer
*renderer
;
786 PurpleKeyValuePair
*kvp
;
790 const char *str_value
;
792 ProtocolOptEntry
*opt_entry
;
793 const GSList
*str_hints
;
795 if (dialog
->protocol_frame
!= NULL
) {
796 gtk_notebook_remove_page (GTK_NOTEBOOK(dialog
->notebook
), 1);
797 dialog
->protocol_frame
= NULL
;
800 while (dialog
->protocol_opt_entries
!= NULL
) {
801 ProtocolOptEntry
*opt_entry
= dialog
->protocol_opt_entries
->data
;
802 g_free(opt_entry
->setting
);
804 dialog
->protocol_opt_entries
= g_list_delete_link(dialog
->protocol_opt_entries
, dialog
->protocol_opt_entries
);
807 if (dialog
->protocol
== NULL
||
808 purple_protocol_get_account_options(dialog
->protocol
) == NULL
)
811 account
= dialog
->account
;
814 dialog
->protocol_frame
= vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BOX_SPACE
);
815 gtk_container_set_border_width(GTK_CONTAINER(vbox
), PIDGIN_HIG_BORDER
);
816 gtk_notebook_insert_page(GTK_NOTEBOOK(dialog
->notebook
), vbox
,
817 gtk_label_new_with_mnemonic(_("Ad_vanced")), 1);
818 gtk_widget_show(vbox
);
820 for (l
= purple_protocol_get_account_options(dialog
->protocol
); l
!= NULL
; l
= l
->next
)
822 option
= (PurpleAccountOption
*)l
->data
;
824 opt_entry
= g_new0(ProtocolOptEntry
, 1);
825 opt_entry
->type
= purple_account_option_get_pref_type(option
);
826 opt_entry
->setting
= g_strdup(purple_account_option_get_setting(option
));
828 switch (opt_entry
->type
)
830 case PURPLE_PREF_BOOLEAN
:
831 if (account
== NULL
||
832 !purple_strequal(purple_account_get_protocol_id(account
),
833 dialog
->protocol_id
))
835 bool_value
= purple_account_option_get_default_bool(option
);
839 bool_value
= purple_account_get_bool(account
,
840 purple_account_option_get_setting(option
),
841 purple_account_option_get_default_bool(option
));
844 tmp
= g_strconcat("_", purple_account_option_get_text(option
), NULL
);
845 opt_entry
->widget
= check
= gtk_check_button_new_with_mnemonic(tmp
);
848 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check
),
851 gtk_box_pack_start(GTK_BOX(vbox
), check
, FALSE
, FALSE
, 0);
852 gtk_widget_show(check
);
855 case PURPLE_PREF_INT
:
856 if (account
== NULL
||
857 !purple_strequal(purple_account_get_protocol_id(account
),
858 dialog
->protocol_id
))
860 int_value
= purple_account_option_get_default_int(option
);
864 int_value
= purple_account_get_int(account
,
865 purple_account_option_get_setting(option
),
866 purple_account_option_get_default_int(option
));
869 g_snprintf(buf
, sizeof(buf
), "%d", int_value
);
871 opt_entry
->widget
= entry
= gtk_entry_new();
872 gtk_entry_set_text(GTK_ENTRY(entry
), buf
);
874 title
= g_strdup_printf("_%s:",
875 purple_account_option_get_text(option
));
876 add_pref_box(dialog
, vbox
, title
, entry
);
880 case PURPLE_PREF_STRING
:
881 if (account
== NULL
||
882 !purple_strequal(purple_account_get_protocol_id(account
),
883 dialog
->protocol_id
))
885 str_value
= purple_account_option_get_default_string(option
);
889 str_value
= purple_account_get_string(account
,
890 purple_account_option_get_setting(option
),
891 purple_account_option_get_default_string(option
));
894 str_hints
= purple_account_option_string_get_hints(option
);
897 const GSList
*hint_it
= str_hints
;
898 entry
= gtk_combo_box_text_new_with_entry();
901 const gchar
*hint
= hint_it
->data
;
902 hint_it
= g_slist_next(hint_it
);
903 gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(entry
),
908 entry
= gtk_entry_new();
910 opt_entry
->widget
= entry
;
911 if (purple_account_option_string_get_masked(option
) && str_hints
)
913 else if (purple_account_option_string_get_masked(option
))
915 gtk_entry_set_visibility(GTK_ENTRY(entry
), FALSE
);
918 if (str_value
!= NULL
&& str_hints
)
919 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(entry
))),
922 gtk_entry_set_text(GTK_ENTRY(entry
), str_value
? str_value
: "");
924 title
= g_strdup_printf("_%s:",
925 purple_account_option_get_text(option
));
926 add_pref_box(dialog
, vbox
, title
, entry
);
930 case PURPLE_PREF_STRING_LIST
:
934 if (account
== NULL
||
935 !purple_strequal(purple_account_get_protocol_id(account
),
936 dialog
->protocol_id
))
938 str_value
= purple_account_option_get_default_list_value(option
);
942 str_value
= purple_account_get_string(account
,
943 purple_account_option_get_setting(option
),
944 purple_account_option_get_default_list_value(option
));
947 list
= purple_account_option_get_list(option
);
948 model
= gtk_list_store_new(2, G_TYPE_STRING
, G_TYPE_POINTER
);
949 opt_entry
->widget
= combo
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(model
));
951 /* Loop through list of PurpleKeyValuePair items */
952 for (node
= list
; node
!= NULL
; node
= node
->next
) {
953 if (node
->data
!= NULL
) {
954 kvp
= (PurpleKeyValuePair
*) node
->data
;
955 if ((kvp
->value
!= NULL
) && (str_value
!= NULL
) &&
956 !g_utf8_collate(kvp
->value
, str_value
))
959 gtk_list_store_append(model
, &iter
);
960 gtk_list_store_set(model
, &iter
,
970 gtk_combo_box_set_active(GTK_COMBO_BOX(combo
), idx
);
972 /* Define renderer */
973 renderer
= gtk_cell_renderer_text_new();
974 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo
), renderer
,
976 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo
),
977 renderer
, "text", 0, NULL
);
979 title
= g_strdup_printf("_%s:",
980 purple_account_option_get_text(option
));
981 add_pref_box(dialog
, vbox
, title
, combo
);
986 purple_debug_error("gtkaccount", "Invalid Account Option pref type (%d)\n",
988 g_free(opt_entry
->setting
);
993 dialog
->protocol_opt_entries
=
994 g_list_append(dialog
->protocol_opt_entries
, opt_entry
);
1000 make_proxy_dropdown(void)
1002 GtkWidget
*dropdown
;
1003 GtkListStore
*model
;
1005 GtkCellRenderer
*renderer
;
1007 model
= gtk_list_store_new(2, G_TYPE_STRING
, G_TYPE_INT
);
1008 dropdown
= gtk_combo_box_new_with_model(GTK_TREE_MODEL(model
));
1010 gtk_list_store_append(model
, &iter
);
1011 gtk_list_store_set(model
, &iter
,
1012 0, purple_running_gnome() ? _("Use GNOME Proxy Settings")
1013 :_("Use Global Proxy Settings"),
1014 1, PURPLE_PROXY_USE_GLOBAL
,
1017 gtk_list_store_append(model
, &iter
);
1018 gtk_list_store_set(model
, &iter
,
1020 1, PURPLE_PROXY_NONE
,
1023 gtk_list_store_append(model
, &iter
);
1024 gtk_list_store_set(model
, &iter
,
1026 1, PURPLE_PROXY_SOCKS4
,
1029 gtk_list_store_append(model
, &iter
);
1030 gtk_list_store_set(model
, &iter
,
1032 1, PURPLE_PROXY_SOCKS5
,
1035 gtk_list_store_append(model
, &iter
);
1036 gtk_list_store_set(model
, &iter
,
1037 0, _("Tor/Privacy (SOCKS5)"),
1038 1, PURPLE_PROXY_TOR
,
1041 gtk_list_store_append(model
, &iter
);
1042 gtk_list_store_set(model
, &iter
,
1044 1, PURPLE_PROXY_HTTP
,
1047 gtk_list_store_append(model
, &iter
);
1048 gtk_list_store_set(model
, &iter
,
1049 0, _("Use Environmental Settings"),
1050 1, PURPLE_PROXY_USE_ENVVAR
,
1053 renderer
= gtk_cell_renderer_text_new();
1054 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(dropdown
), renderer
, TRUE
);
1055 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(dropdown
), renderer
,
1062 proxy_type_changed_cb(GtkWidget
*menu
, AccountPrefsDialog
*dialog
)
1066 if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(menu
), &iter
)) {
1068 gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(menu
)), &iter
,
1070 dialog
->new_proxy_type
= int_value
;
1073 if (dialog
->new_proxy_type
== PURPLE_PROXY_USE_GLOBAL
||
1074 dialog
->new_proxy_type
== PURPLE_PROXY_NONE
||
1075 dialog
->new_proxy_type
== PURPLE_PROXY_USE_ENVVAR
) {
1077 gtk_widget_hide(dialog
->proxy_vbox
);
1080 gtk_widget_show_all(dialog
->proxy_vbox
);
1084 port_popup_cb(GtkWidget
*w
, GtkMenu
*menu
, gpointer data
)
1089 /* This is an easter egg.
1090 It means one of two things, both intended as humourus:
1091 A) your network is really slow and you have nothing better to do than
1092 look at butterflies.
1093 B)You are looking really closely at something that shouldn't matter. */
1094 item1
= gtk_menu_item_new_with_label(_("If you look real closely"));
1096 /* This is an easter egg. See the comment on the previous line in the source. */
1097 item2
= gtk_menu_item_new_with_label(_("you can see the butterflies mating"));
1099 gtk_widget_show(item1
);
1100 gtk_widget_show(item2
);
1102 /* Prepend these in reverse order so they appear correctly. */
1103 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu
), item2
);
1104 gtk_menu_shell_prepend(GTK_MENU_SHELL(menu
), item1
);
1108 add_proxy_options(AccountPrefsDialog
*dialog
, GtkWidget
*parent
)
1110 PurpleProxyInfo
*proxy_info
;
1114 GtkTreeModel
*proxy_model
;
1116 if (dialog
->proxy_frame
!= NULL
)
1117 gtk_widget_destroy(dialog
->proxy_frame
);
1120 dialog
->proxy_frame
= vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BOX_SPACE
);
1121 gtk_container_add(GTK_CONTAINER(parent
), vbox
);
1122 gtk_widget_show(vbox
);
1124 /* Proxy Type drop-down. */
1125 dialog
->proxy_dropdown
= make_proxy_dropdown();
1127 add_pref_box(dialog
, vbox
, _("Proxy _type:"), dialog
->proxy_dropdown
);
1129 /* Setup the second vbox, which may be hidden at times. */
1130 dialog
->proxy_vbox
= vbox2
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BOX_SPACE
);
1131 gtk_box_pack_start(GTK_BOX(vbox
), vbox2
, FALSE
, FALSE
, PIDGIN_HIG_BORDER
);
1132 gtk_widget_show(vbox2
);
1135 dialog
->proxy_host_entry
= gtk_entry_new();
1136 add_pref_box(dialog
, vbox2
, _("_Host:"), dialog
->proxy_host_entry
);
1139 dialog
->proxy_port_entry
= gtk_entry_new();
1140 add_pref_box(dialog
, vbox2
, _("_Port:"), dialog
->proxy_port_entry
);
1142 g_signal_connect(G_OBJECT(dialog
->proxy_port_entry
), "populate-popup",
1143 G_CALLBACK(port_popup_cb
), NULL
);
1146 dialog
->proxy_user_entry
= gtk_entry_new();
1148 add_pref_box(dialog
, vbox2
, _("_Username:"), dialog
->proxy_user_entry
);
1151 dialog
->proxy_pass_entry
= gtk_entry_new();
1152 gtk_entry_set_visibility(GTK_ENTRY(dialog
->proxy_pass_entry
), FALSE
);
1153 add_pref_box(dialog
, vbox2
, _("Pa_ssword:"), dialog
->proxy_pass_entry
);
1155 if (dialog
->account
!= NULL
&&
1156 (proxy_info
= purple_account_get_proxy_info(dialog
->account
)) != NULL
) {
1160 dialog
->new_proxy_type
= purple_proxy_info_get_proxy_type(proxy_info
);
1162 if ((value
= purple_proxy_info_get_host(proxy_info
)) != NULL
)
1163 gtk_entry_set_text(GTK_ENTRY(dialog
->proxy_host_entry
), value
);
1165 if ((int_val
= purple_proxy_info_get_port(proxy_info
)) != 0) {
1168 g_snprintf(buf
, sizeof(buf
), "%d", int_val
);
1170 gtk_entry_set_text(GTK_ENTRY(dialog
->proxy_port_entry
), buf
);
1173 if ((value
= purple_proxy_info_get_username(proxy_info
)) != NULL
)
1174 gtk_entry_set_text(GTK_ENTRY(dialog
->proxy_user_entry
), value
);
1176 if ((value
= purple_proxy_info_get_password(proxy_info
)) != NULL
)
1177 gtk_entry_set_text(GTK_ENTRY(dialog
->proxy_pass_entry
), value
);
1180 dialog
->new_proxy_type
= PURPLE_PROXY_USE_GLOBAL
;
1182 proxy_model
= gtk_combo_box_get_model(
1183 GTK_COMBO_BOX(dialog
->proxy_dropdown
));
1184 if (gtk_tree_model_get_iter_first(proxy_model
, &iter
)) {
1187 gtk_tree_model_get(proxy_model
, &iter
, 1, &int_val
, -1);
1188 if (int_val
== dialog
->new_proxy_type
) {
1189 gtk_combo_box_set_active_iter(
1190 GTK_COMBO_BOX(dialog
->proxy_dropdown
), &iter
);
1193 } while(gtk_tree_model_iter_next(proxy_model
, &iter
));
1196 proxy_type_changed_cb(dialog
->proxy_dropdown
, dialog
);
1198 /* Connect signals. */
1199 g_signal_connect(G_OBJECT(dialog
->proxy_dropdown
), "changed",
1200 G_CALLBACK(proxy_type_changed_cb
), dialog
);
1204 add_voice_options(AccountPrefsDialog
*dialog
)
1207 if (!dialog
->protocol
|| !PURPLE_PROTOCOL_IMPLEMENTS(dialog
->protocol
, MEDIA
, initiate_session
)) {
1208 if (dialog
->voice_frame
) {
1209 gtk_widget_destroy(dialog
->voice_frame
);
1210 dialog
->voice_frame
= NULL
;
1211 dialog
->suppression_check
= NULL
;
1216 if (!dialog
->voice_frame
) {
1217 dialog
->voice_frame
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BORDER
);
1218 gtk_container_set_border_width(GTK_CONTAINER(dialog
->voice_frame
),
1221 dialog
->suppression_check
=
1222 gtk_check_button_new_with_mnemonic(_("Use _silence suppression"));
1223 gtk_box_pack_start(GTK_BOX(dialog
->voice_frame
), dialog
->suppression_check
,
1226 gtk_notebook_append_page(GTK_NOTEBOOK(dialog
->notebook
),
1227 dialog
->voice_frame
, gtk_label_new_with_mnemonic(_("_Voice and Video")));
1228 gtk_widget_show_all(dialog
->voice_frame
);
1231 if (dialog
->account
) {
1232 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->suppression_check
),
1233 purple_account_get_silence_suppression(dialog
->account
));
1235 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dialog
->suppression_check
), FALSE
);
1241 account_win_destroy_cb(GtkWidget
*w
, GdkEvent
*event
,
1242 AccountPrefsDialog
*dialog
)
1244 g_hash_table_remove(account_pref_wins
, dialog
->account
);
1246 gtk_widget_destroy(dialog
->window
);
1248 g_list_free(dialog
->user_split_entries
);
1249 while (dialog
->protocol_opt_entries
!= NULL
) {
1250 ProtocolOptEntry
*opt_entry
= dialog
->protocol_opt_entries
->data
;
1251 g_free(opt_entry
->setting
);
1253 dialog
->protocol_opt_entries
= g_list_delete_link(dialog
->protocol_opt_entries
, dialog
->protocol_opt_entries
);
1255 g_free(dialog
->protocol_id
);
1256 g_object_unref(dialog
->sg
);
1258 if (dialog
->icon_img
)
1259 g_object_unref(dialog
->icon_img
);
1261 g_clear_object(&dialog
->icon_filesel
);
1263 purple_signals_disconnect_by_handle(dialog
);
1265 purple_str_wipe(dialog
->password
);
1272 cancel_account_prefs_cb(GtkWidget
*w
, AccountPrefsDialog
*dialog
)
1274 account_win_destroy_cb(NULL
, NULL
, dialog
);
1278 account_register_cb(PurpleAccount
*account
, gboolean succeeded
, void *user_data
)
1282 const PurpleSavedStatus
*saved_status
= purple_savedstatus_get_current();
1283 purple_signal_emit(pidgin_accounts_get_handle(), "account-modified", account
);
1285 if (saved_status
!= NULL
&& purple_account_get_remember_password(account
)) {
1286 purple_savedstatus_activate_for_account(saved_status
, account
);
1287 purple_account_set_enabled(account
, PIDGIN_UI
, TRUE
);
1291 purple_accounts_delete(account
);
1295 ok_account_prefs_cb(GtkWidget
*w
, AccountPrefsDialog
*dialog
)
1297 PurpleProxyInfo
*proxy_info
= NULL
;
1302 gboolean new_acct
= FALSE
, icon_change
= FALSE
;
1303 PurpleAccount
*account
;
1305 PurpleBuddyIconSpec
*icon_spec
= NULL
;
1307 /* Build the username string. */
1308 username
= g_strdup(gtk_entry_get_text(GTK_ENTRY(dialog
->username_entry
)));
1310 if (dialog
->protocol
!= NULL
)
1312 for (l
= purple_protocol_get_user_splits(dialog
->protocol
),
1313 l2
= dialog
->user_split_entries
;
1314 l
!= NULL
&& l2
!= NULL
;
1315 l
= l
->next
, l2
= l2
->next
)
1317 PurpleAccountUserSplit
*split
= l
->data
;
1318 GtkEntry
*entry
= l2
->data
;
1321 value
= entry
? gtk_entry_get_text(entry
) : "";
1325 *sep
= purple_account_user_split_get_separator(split
);
1327 tmp
= g_strconcat(username
, sep
,
1329 purple_account_user_split_get_default_value(split
)),
1337 if (dialog
->account
== NULL
)
1339 if (purple_accounts_find(username
, dialog
->protocol_id
) != NULL
) {
1340 purple_debug_warning("gtkaccount", "Trying to add a duplicate %s account (%s).\n",
1341 dialog
->protocol_id
, username
);
1343 purple_notify_error(NULL
, NULL
, _("Unable to save new account"),
1344 _("An account already exists with the specified criteria."), NULL
);
1350 if (purple_accounts_get_all() == NULL
) {
1351 /* We're adding our first account. Be polite and show the buddy list */
1352 PidginBuddyList
*blist
=
1353 pidgin_blist_get_default_gtk_blist();
1354 if (blist
!= NULL
&& blist
->window
!= NULL
) {
1355 gtk_window_present(GTK_WINDOW(blist
->window
));
1359 account
= purple_account_new(username
, dialog
->protocol_id
);
1364 account
= dialog
->account
;
1367 purple_account_set_protocol_id(account
, dialog
->protocol_id
);
1371 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->alias_entry
));
1374 purple_account_set_private_alias(account
, value
);
1376 purple_account_set_private_alias(account
, NULL
);
1379 if (dialog
->protocol
!= NULL
)
1380 icon_spec
= purple_protocol_get_icon_spec(dialog
->protocol
);
1382 if (icon_spec
&& icon_spec
->format
!= NULL
)
1384 const char *filename
;
1386 if (new_acct
|| purple_account_get_bool(account
, "use-global-buddyicon", TRUE
) ==
1387 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
)))
1391 purple_account_set_bool(account
, "use-global-buddyicon", !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
)));
1393 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->icon_check
)))
1395 if (dialog
->icon_img
)
1397 size_t len
= purple_image_get_data_size(dialog
->icon_img
);
1398 purple_buddy_icons_set_account_icon(account
,
1399 g_memdup(purple_image_get_data(dialog
->icon_img
), len
), len
);
1400 purple_account_set_buddy_icon_path(account
,
1401 purple_image_get_path(dialog
->icon_img
));
1405 purple_buddy_icons_set_account_icon(account
, NULL
, 0);
1406 purple_account_set_buddy_icon_path(account
, NULL
);
1409 else if ((filename
= purple_prefs_get_path(PIDGIN_PREFS_ROOT
"/accounts/buddyicon")) && icon_change
)
1412 gpointer data
= pidgin_convert_buddy_icon(dialog
->protocol
, filename
, &len
);
1413 purple_account_set_buddy_icon_path(account
, filename
);
1414 purple_buddy_icons_set_account_icon(account
, data
, len
);
1419 /* Remember Password */
1420 remember
= gtk_toggle_button_get_active(
1421 GTK_TOGGLE_BUTTON(dialog
->remember_pass_check
));
1423 purple_keyring_set_password(account
, NULL
, NULL
, NULL
);
1425 purple_account_set_remember_password(account
, remember
);
1428 if (dialog
->protocol
&& purple_protocol_get_options(dialog
->protocol
) & OPT_PROTO_MAIL_CHECK
)
1429 purple_account_set_check_mail(account
,
1430 gtk_toggle_button_get_active(
1431 GTK_TOGGLE_BUTTON(dialog
->new_mail_check
)));
1434 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->password_entry
));
1437 * We set the password if this is a new account because new accounts
1438 * will be set to online, and if the user has entered a password into
1439 * the account editor (but has not checked the 'save' box), then we
1440 * don't want to prompt them.
1442 if ((purple_account_get_remember_password(account
) || new_acct
) && (*value
!= '\0'))
1443 purple_account_set_password(account
, value
, NULL
, NULL
);
1445 purple_account_set_password(account
, NULL
, NULL
, NULL
);
1447 purple_account_set_username(account
, username
);
1450 /* Add the protocol settings */
1451 if (dialog
->protocol
) {
1452 ProtocolOptEntry
*opt_entry
;
1456 gboolean bool_value
;
1458 for (l2
= dialog
->protocol_opt_entries
; l2
; l2
= l2
->next
) {
1460 opt_entry
= l2
->data
;
1462 switch (opt_entry
->type
) {
1463 case PURPLE_PREF_STRING
:
1464 if (GTK_IS_COMBO_BOX(opt_entry
->widget
))
1465 value
= gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(opt_entry
->widget
));
1467 value
= gtk_entry_get_text(GTK_ENTRY(opt_entry
->widget
));
1468 purple_account_set_string(account
, opt_entry
->setting
, value
);
1471 case PURPLE_PREF_INT
:
1472 int_value
= atoi(gtk_entry_get_text(GTK_ENTRY(opt_entry
->widget
)));
1473 purple_account_set_int(account
, opt_entry
->setting
, int_value
);
1476 case PURPLE_PREF_BOOLEAN
:
1478 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(opt_entry
->widget
));
1479 purple_account_set_bool(account
, opt_entry
->setting
, bool_value
);
1482 case PURPLE_PREF_STRING_LIST
:
1484 if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(opt_entry
->widget
), &iter
))
1485 gtk_tree_model_get(gtk_combo_box_get_model(GTK_COMBO_BOX(opt_entry
->widget
)), &iter
, 1, &value2
, -1);
1486 purple_account_set_string(account
, opt_entry
->setting
, value2
);
1495 /* Set the proxy stuff. */
1496 proxy_info
= purple_account_get_proxy_info(account
);
1498 /* Create the proxy info if it doesn't exist. */
1499 if (proxy_info
== NULL
) {
1500 proxy_info
= purple_proxy_info_new();
1501 purple_account_set_proxy_info(account
, proxy_info
);
1504 /* Set the proxy info type. */
1505 purple_proxy_info_set_proxy_type(proxy_info
, dialog
->new_proxy_type
);
1508 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->proxy_host_entry
));
1511 purple_proxy_info_set_host(proxy_info
, value
);
1513 purple_proxy_info_set_host(proxy_info
, NULL
);
1516 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->proxy_port_entry
));
1519 purple_proxy_info_set_port(proxy_info
, atoi(value
));
1521 purple_proxy_info_set_port(proxy_info
, 0);
1524 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->proxy_user_entry
));
1527 purple_proxy_info_set_username(proxy_info
, value
);
1529 purple_proxy_info_set_username(proxy_info
, NULL
);
1532 value
= gtk_entry_get_text(GTK_ENTRY(dialog
->proxy_pass_entry
));
1535 purple_proxy_info_set_password(proxy_info
, value
);
1537 purple_proxy_info_set_password(proxy_info
, NULL
);
1539 /* If there are no values set then proxy_info NULL */
1540 if ((purple_proxy_info_get_proxy_type(proxy_info
) == PURPLE_PROXY_USE_GLOBAL
) &&
1541 (purple_proxy_info_get_host(proxy_info
) == NULL
) &&
1542 (purple_proxy_info_get_port(proxy_info
) == 0) &&
1543 (purple_proxy_info_get_username(proxy_info
) == NULL
) &&
1544 (purple_proxy_info_get_password(proxy_info
) == NULL
))
1546 purple_account_set_proxy_info(account
, NULL
);
1550 /* Voice and Video settings */
1551 if (dialog
->voice_frame
) {
1552 purple_account_set_silence_suppression(account
,
1553 gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->suppression_check
)));
1556 /* If this is a new account, add it to our list */
1558 purple_accounts_add(account
);
1560 purple_signal_emit(pidgin_accounts_get_handle(), "account-modified", account
);
1562 /* If this is a new account, then sign on! */
1563 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog
->register_button
))) {
1564 purple_account_set_register_callback(account
, account_register_cb
, NULL
);
1565 purple_account_register(account
);
1566 } else if (new_acct
) {
1567 const PurpleSavedStatus
*saved_status
;
1569 saved_status
= purple_savedstatus_get_current();
1570 if (saved_status
!= NULL
) {
1571 purple_savedstatus_activate_for_account(saved_status
, account
);
1572 purple_account_set_enabled(account
, PIDGIN_UI
, TRUE
);
1576 /* We no longer need the data from the dialog window */
1577 account_win_destroy_cb(NULL
, NULL
, dialog
);
1581 static const GtkTargetEntry dnd_targets
[] = {
1582 {"text/plain", 0, 0},
1583 {"text/uri-list", 0, 1},
1588 pidgin_account_dialog_show_continue(PurpleAccount
*account
,
1589 const gchar
*password
, GError
*error
, gpointer _type
)
1591 PidginAccountDialogType type
= GPOINTER_TO_INT(_type
);
1592 AccountPrefsDialog
*dialog
;
1594 GtkWidget
*main_vbox
;
1597 GtkWidget
*notebook
;
1600 if (accounts_window
!= NULL
&& account
!= NULL
&&
1601 (dialog
= g_hash_table_lookup(account_pref_wins
, account
)) != NULL
)
1603 gtk_window_present(GTK_WINDOW(dialog
->window
));
1607 dialog
= g_new0(AccountPrefsDialog
, 1);
1609 if (account
== NULL
) {
1610 /* Select the first protocol in the list*/
1611 GList
*protocol_list
= purple_protocols_get_all();
1612 if (protocol_list
!= NULL
) {
1613 dialog
->protocol_id
= g_strdup(purple_protocol_get_id(PURPLE_PROTOCOL(protocol_list
->data
)));
1614 g_list_free(protocol_list
);
1619 dialog
->protocol_id
=
1620 g_strdup(purple_account_get_protocol_id(account
));
1623 /* TODO if no protocols are loaded, this should inform the user that
1624 protocols need to be loaded instead of just doing nothing */
1625 if (!dialog
->protocol_id
) {
1630 if (accounts_window
!= NULL
&& account
!= NULL
)
1632 g_hash_table_insert(account_pref_wins
, account
, dialog
);
1635 dialog
->account
= account
;
1636 dialog
->password
= g_strdup(password
);
1637 dialog
->type
= type
;
1638 dialog
->sg
= gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL
);
1639 dialog
->protocol
= purple_protocols_find(dialog
->protocol_id
);
1641 dialog
->window
= win
= pidgin_create_dialog((type
== PIDGIN_ADD_ACCOUNT_DIALOG
) ? _("Add Account") : _("Modify Account"),
1642 PIDGIN_HIG_BOX_SPACE
, "account", FALSE
);
1644 g_signal_connect(G_OBJECT(win
), "delete_event",
1645 G_CALLBACK(account_win_destroy_cb
), dialog
);
1647 /* Setup the vbox */
1648 main_vbox
= pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(win
), FALSE
, PIDGIN_HIG_BOX_SPACE
);
1650 dialog
->notebook
= notebook
= gtk_notebook_new();
1651 gtk_box_pack_start(GTK_BOX(main_vbox
), notebook
, FALSE
, FALSE
, 0);
1652 gtk_widget_show(GTK_WIDGET(notebook
));
1654 /* Setup the inner vbox */
1655 dialog
->top_vbox
= vbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BORDER
);
1656 gtk_container_set_border_width(GTK_CONTAINER(vbox
), PIDGIN_HIG_BORDER
);
1657 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), vbox
,
1658 gtk_label_new_with_mnemonic(_("_Basic")));
1659 gtk_widget_show(vbox
);
1661 /* Setup the top frames. */
1662 add_login_options(dialog
, vbox
);
1663 add_user_options(dialog
, vbox
);
1665 button
= gtk_check_button_new_with_mnemonic(
1666 _("Create _this new account on the server"));
1667 gtk_box_pack_start(GTK_BOX(main_vbox
), button
, FALSE
, FALSE
, 0);
1668 gtk_widget_show(button
);
1669 dialog
->register_button
= button
;
1670 g_signal_connect(G_OBJECT(dialog
->register_button
), "toggled", G_CALLBACK(register_button_cb
), dialog
);
1671 if (dialog
->account
== NULL
)
1672 gtk_widget_set_sensitive(button
, FALSE
);
1674 if (!dialog
->protocol
|| !PURPLE_PROTOCOL_IMPLEMENTS(dialog
->protocol
, SERVER
, register_user
))
1675 gtk_widget_hide(button
);
1677 /* Setup the page with 'Advanced' (protocol options). */
1678 add_account_options(dialog
);
1680 /* Setup the page with 'Proxy'. */
1681 dbox
= gtk_box_new(GTK_ORIENTATION_VERTICAL
, PIDGIN_HIG_BORDER
);
1682 gtk_container_set_border_width(GTK_CONTAINER(dbox
), PIDGIN_HIG_BORDER
);
1683 gtk_notebook_append_page(GTK_NOTEBOOK(notebook
), dbox
,
1684 gtk_label_new_with_mnemonic(_("P_roxy")));
1685 gtk_widget_show(dbox
);
1686 add_proxy_options(dialog
, dbox
);
1688 add_voice_options(dialog
);
1691 pidgin_dialog_add_button(GTK_DIALOG(win
), _("_Cancel"),
1692 G_CALLBACK(cancel_account_prefs_cb
), dialog
);
1695 button
= pidgin_dialog_add_button(GTK_DIALOG(win
),
1696 (type
== PIDGIN_ADD_ACCOUNT_DIALOG
) ? _("_Add") : _("_Save"),
1697 G_CALLBACK(ok_account_prefs_cb
),
1699 if (dialog
->account
== NULL
)
1700 gtk_widget_set_sensitive(button
, FALSE
);
1701 dialog
->ok_button
= button
;
1704 gtk_drag_dest_set(dialog
->window
,
1705 GTK_DEST_DEFAULT_MOTION
|
1706 GTK_DEST_DEFAULT_DROP
,
1708 sizeof(dnd_targets
) / sizeof(GtkTargetEntry
),
1711 g_signal_connect(G_OBJECT(dialog
->window
), "drag_data_received",
1712 G_CALLBACK(account_dnd_recv
), dialog
);
1714 /* Show the window. */
1715 gtk_widget_show(win
);
1717 gtk_widget_grab_focus(dialog
->protocol_menu
);
1721 pidgin_account_dialog_show(PidginAccountDialogType type
, PurpleAccount
*account
)
1723 /* this is to make sure the password will be cached */
1724 purple_account_get_password(account
,
1725 pidgin_account_dialog_show_continue
, GINT_TO_POINTER(type
));
1728 /**************************************************************************
1730 **************************************************************************/
1732 signed_on_off_cb(PurpleConnection
*gc
, gpointer user_data
)
1734 PurpleAccount
*account
;
1735 GtkTreeModel
*model
;
1740 /* Don't need to do anything if the accounts window is not visible */
1741 if (accounts_window
== NULL
)
1744 account
= purple_connection_get_account(gc
);
1745 model
= GTK_TREE_MODEL(accounts_window
->model
);
1746 index
= g_list_index(purple_accounts_get_all(), account
);
1748 if (gtk_tree_model_iter_nth_child(model
, &iter
, NULL
, index
))
1750 pixbuf
= pidgin_create_protocol_icon(account
, PIDGIN_PROTOCOL_ICON_MEDIUM
);
1751 if ((pixbuf
!= NULL
) && purple_account_is_disconnected(account
))
1752 gdk_pixbuf_saturate_and_pixelate(pixbuf
, pixbuf
, 0.0, FALSE
);
1754 gtk_list_store_set(accounts_window
->model
, &iter
,
1755 COLUMN_ICON
, pixbuf
,
1759 g_object_unref(G_OBJECT(pixbuf
));
1764 * Get the GtkTreeIter of the specified account in the
1768 accounts_window_find_account_in_treemodel(GtkTreeIter
*iter
, PurpleAccount
*account
)
1770 GtkTreeModel
*model
;
1773 g_return_val_if_fail(account
!= NULL
, FALSE
);
1774 g_return_val_if_fail(accounts_window
!= NULL
, FALSE
);
1776 model
= GTK_TREE_MODEL(accounts_window
->model
);
1778 if (!gtk_tree_model_get_iter_first(model
, iter
))
1781 gtk_tree_model_get(model
, iter
, COLUMN_DATA
, &cur
, -1);
1785 while (gtk_tree_model_iter_next(model
, iter
))
1787 gtk_tree_model_get(model
, iter
, COLUMN_DATA
, &cur
, -1);
1796 account_removed_cb(PurpleAccount
*account
, gpointer user_data
)
1798 AccountPrefsDialog
*dialog
;
1801 /* If the account was being modified, close the edit window */
1802 if ((dialog
= g_hash_table_lookup(account_pref_wins
, account
)) != NULL
)
1803 account_win_destroy_cb(NULL
, NULL
, dialog
);
1805 if (accounts_window
== NULL
)
1808 /* Remove the account from the GtkListStore */
1809 if (accounts_window_find_account_in_treemodel(&iter
, account
))
1810 gtk_list_store_remove(accounts_window
->model
, &iter
);
1812 if (purple_accounts_get_all() == NULL
)
1813 gtk_notebook_set_current_page(GTK_NOTEBOOK(accounts_window
->notebook
), 0);
1817 account_abled_cb(PurpleAccount
*account
, gpointer user_data
)
1821 if (accounts_window
== NULL
)
1824 /* update the account in the GtkListStore */
1825 if (accounts_window_find_account_in_treemodel(&iter
, account
))
1826 gtk_list_store_set(accounts_window
->model
, &iter
,
1827 COLUMN_ENABLED
, GPOINTER_TO_INT(user_data
),
1832 drag_data_get_cb(GtkWidget
*widget
, GdkDragContext
*ctx
,
1833 GtkSelectionData
*data
, guint info
, guint time
,
1834 AccountsWindow
*dialog
)
1836 GdkAtom target
= gtk_selection_data_get_target(data
);
1838 if (target
== gdk_atom_intern("PURPLE_ACCOUNT", FALSE
)) {
1839 GtkTreeRowReference
*ref
;
1840 GtkTreePath
*source_row
;
1842 PurpleAccount
*account
= NULL
;
1845 ref
= g_object_get_data(G_OBJECT(ctx
), "gtk-tree-view-source-row");
1846 source_row
= gtk_tree_row_reference_get_path(ref
);
1848 if (source_row
== NULL
)
1851 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog
->model
), &iter
,
1854 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog
->model
), &iter
,
1857 dialog
->drag_iter
= iter
;
1859 account
= g_value_get_pointer(&val
);
1861 gtk_selection_data_set(data
, gdk_atom_intern("PURPLE_ACCOUNT", FALSE
),
1862 8, (void *)&account
, sizeof(account
));
1864 gtk_tree_path_free(source_row
);
1869 move_account_after(GtkListStore
*store
, GtkTreeIter
*iter
,
1870 GtkTreeIter
*position
)
1872 GtkTreeIter new_iter
;
1873 PurpleAccount
*account
;
1875 gtk_tree_model_get(GTK_TREE_MODEL(store
), iter
,
1876 COLUMN_DATA
, &account
,
1879 gtk_list_store_insert_after(store
, &new_iter
, position
);
1881 set_account(store
, &new_iter
, account
, NULL
);
1883 gtk_list_store_remove(store
, iter
);
1887 move_account_before(GtkListStore
*store
, GtkTreeIter
*iter
,
1888 GtkTreeIter
*position
)
1890 GtkTreeIter new_iter
;
1891 PurpleAccount
*account
;
1893 gtk_tree_model_get(GTK_TREE_MODEL(store
), iter
,
1894 COLUMN_DATA
, &account
,
1897 gtk_list_store_insert_before(store
, &new_iter
, position
);
1899 set_account(store
, &new_iter
, account
, NULL
);
1901 gtk_list_store_remove(store
, iter
);
1905 drag_data_received_cb(GtkWidget
*widget
, GdkDragContext
*ctx
,
1906 guint x
, guint y
, GtkSelectionData
*sd
,
1907 guint info
, guint t
, AccountsWindow
*dialog
)
1909 GdkAtom target
= gtk_selection_data_get_target(sd
);
1910 const guchar
*data
= gtk_selection_data_get_data(sd
);
1912 if (target
== gdk_atom_intern("PURPLE_ACCOUNT", FALSE
) && data
) {
1914 PurpleAccount
*a
= NULL
;
1915 GtkTreePath
*path
= NULL
;
1916 GtkTreeViewDropPosition position
;
1918 memcpy(&a
, data
, sizeof(a
));
1920 if (gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(widget
), x
, y
,
1921 &path
, &position
)) {
1924 PurpleAccount
*account
;
1927 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog
->model
), &iter
, path
);
1929 gtk_tree_model_get_value(GTK_TREE_MODEL(dialog
->model
), &iter
,
1932 account
= g_value_get_pointer(&val
);
1935 case GTK_TREE_VIEW_DROP_AFTER
:
1936 case GTK_TREE_VIEW_DROP_INTO_OR_AFTER
:
1937 move_account_after(dialog
->model
, &dialog
->drag_iter
,
1939 dest_index
= g_list_index(purple_accounts_get_all(),
1943 case GTK_TREE_VIEW_DROP_BEFORE
:
1944 case GTK_TREE_VIEW_DROP_INTO_OR_BEFORE
:
1945 dest_index
= g_list_index(purple_accounts_get_all(),
1948 move_account_before(dialog
->model
, &dialog
->drag_iter
,
1956 if (dest_index
>= 0)
1957 purple_accounts_reorder(a
, dest_index
);
1963 accedit_win_destroy_cb(GtkWidget
*w
, GdkEvent
*event
, AccountsWindow
*dialog
)
1965 dialog
->window
= NULL
;
1967 pidgin_accounts_window_hide();
1973 add_account_cb(GtkWidget
*w
, AccountsWindow
*dialog
)
1975 pidgin_account_dialog_show(PIDGIN_ADD_ACCOUNT_DIALOG
, NULL
);
1979 modify_account_sel(GtkTreeModel
*model
, GtkTreePath
*path
,
1980 GtkTreeIter
*iter
, gpointer data
)
1982 PurpleAccount
*account
;
1984 gtk_tree_model_get(model
, iter
, COLUMN_DATA
, &account
, -1);
1986 if (account
!= NULL
)
1987 pidgin_account_dialog_show(PIDGIN_MODIFY_ACCOUNT_DIALOG
, account
);
1991 modify_account_cb(GtkWidget
*w
, AccountsWindow
*dialog
)
1993 GtkTreeSelection
*selection
;
1995 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog
->treeview
));
1997 gtk_tree_selection_selected_foreach(selection
, modify_account_sel
, dialog
);
2001 delete_account_cb(PurpleAccount
*account
)
2003 purple_accounts_delete(account
);
2007 ask_delete_account_sel(GtkTreeModel
*model
, GtkTreePath
*path
,
2008 GtkTreeIter
*iter
, gpointer data
)
2010 PurpleAccount
*account
;
2012 gtk_tree_model_get(model
, iter
, COLUMN_DATA
, &account
, -1);
2014 if (account
!= NULL
) {
2017 buf
= g_strdup_printf(_("Are you sure you want to delete %s?"),
2018 purple_account_get_username(account
));
2020 purple_request_close_with_handle(account
);
2021 purple_request_action(account
, NULL
, buf
, NULL
,
2022 PURPLE_DEFAULT_ACTION_NONE
,
2023 purple_request_cpar_from_account(account
), account
, 2,
2024 _("Delete"), delete_account_cb
, _("Cancel"), NULL
);
2030 ask_delete_account_cb(GtkWidget
*w
, AccountsWindow
*dialog
)
2032 GtkTreeSelection
*selection
;
2034 selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog
->treeview
));
2036 gtk_tree_selection_selected_foreach(selection
, ask_delete_account_sel
,
2041 close_accounts_cb(GtkWidget
*w
, AccountsWindow
*dialog
)
2043 pidgin_accounts_window_hide();
2048 enabled_cb(GtkCellRendererToggle
*renderer
, gchar
*path_str
,
2051 AccountsWindow
*dialog
= (AccountsWindow
*)data
;
2052 PurpleAccount
*account
;
2053 GtkTreeModel
*model
= GTK_TREE_MODEL(dialog
->model
);
2056 const PurpleSavedStatus
*saved_status
;
2058 gtk_tree_model_get_iter_from_string(model
, &iter
, path_str
);
2059 gtk_tree_model_get(model
, &iter
,
2060 COLUMN_DATA
, &account
,
2061 COLUMN_ENABLED
, &enabled
,
2065 * If we just enabled the account, then set the statuses
2066 * to the current status.
2070 saved_status
= purple_savedstatus_get_current();
2071 purple_savedstatus_activate_for_account(saved_status
, account
);
2074 purple_account_set_enabled(account
, PIDGIN_UI
, !enabled
);
2078 add_columns(GtkWidget
*treeview
, AccountsWindow
*dialog
)
2080 GtkCellRenderer
*renderer
;
2081 GtkTreeViewColumn
*column
;
2084 renderer
= gtk_cell_renderer_toggle_new();
2086 g_signal_connect(G_OBJECT(renderer
), "toggled",
2087 G_CALLBACK(enabled_cb
), dialog
);
2089 column
= gtk_tree_view_column_new_with_attributes(_("Enabled"),
2090 renderer
, "active", COLUMN_ENABLED
, NULL
);
2092 gtk_tree_view_column_set_resizable(column
, FALSE
);
2093 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview
), column
);
2095 /* Username column */
2096 column
= gtk_tree_view_column_new();
2097 gtk_tree_view_column_set_title(column
, _("Username"));
2098 gtk_tree_view_column_set_resizable(column
, TRUE
);
2099 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview
), column
);
2102 renderer
= gtk_cell_renderer_pixbuf_new();
2103 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2104 gtk_tree_view_column_add_attribute(column
, renderer
,
2105 "pixbuf", COLUMN_BUDDYICON
);
2108 renderer
= gtk_cell_renderer_text_new();
2109 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2110 gtk_tree_view_column_add_attribute(column
, renderer
,
2111 "text", COLUMN_USERNAME
);
2112 dialog
->username_col
= column
;
2116 column
= gtk_tree_view_column_new();
2117 gtk_tree_view_column_set_title(column
, _("Protocol"));
2118 gtk_tree_view_column_set_resizable(column
, FALSE
);
2119 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview
), column
);
2122 renderer
= gtk_cell_renderer_pixbuf_new();
2123 gtk_tree_view_column_pack_start(column
, renderer
, FALSE
);
2124 gtk_tree_view_column_add_attribute(column
, renderer
,
2125 "pixbuf", COLUMN_ICON
);
2127 renderer
= gtk_cell_renderer_text_new();
2128 gtk_tree_view_column_pack_start(column
, renderer
, TRUE
);
2129 gtk_tree_view_column_add_attribute(column
, renderer
,
2130 "text", COLUMN_PROTOCOL
);
2134 set_account(GtkListStore
*store
, GtkTreeIter
*iter
, PurpleAccount
*account
, GdkPixbuf
*global_buddyicon
)
2136 GdkPixbuf
*pixbuf
, *buddyicon
= NULL
;
2137 PurpleImage
*img
= NULL
;
2138 PurpleProtocol
*protocol
= NULL
;
2139 PurpleBuddyIconSpec
*icon_spec
= NULL
;
2141 pixbuf
= pidgin_create_protocol_icon(account
, PIDGIN_PROTOCOL_ICON_MEDIUM
);
2142 if ((pixbuf
!= NULL
) && purple_account_is_disconnected(account
))
2143 gdk_pixbuf_saturate_and_pixelate(pixbuf
, pixbuf
, 0.0, FALSE
);
2145 protocol
= purple_protocols_find(purple_account_get_protocol_id(account
));
2146 if (protocol
!= NULL
)
2147 icon_spec
= purple_protocol_get_icon_spec(protocol
);
2149 if (icon_spec
!= NULL
&& icon_spec
->format
!= NULL
) {
2150 if (purple_account_get_bool(account
, "use-global-buddyicon", TRUE
)) {
2151 if (global_buddyicon
!= NULL
)
2152 buddyicon
= GDK_PIXBUF(g_object_ref(G_OBJECT(global_buddyicon
)));
2154 /* This is for when set_account() is called for a single account */
2156 path
= purple_prefs_get_path(PIDGIN_PREFS_ROOT
"/accounts/buddyicon");
2157 if ((path
!= NULL
) && (*path
!= '\0')) {
2158 img
= purple_image_new_from_file(path
, NULL
);
2162 img
= purple_buddy_icons_find_account_icon(account
);
2167 GdkPixbuf
*buddyicon_pixbuf
;
2168 buddyicon_pixbuf
= pidgin_pixbuf_from_image(img
);
2169 g_object_unref(img
);
2171 if (buddyicon_pixbuf
!= NULL
) {
2172 buddyicon
= gdk_pixbuf_scale_simple(buddyicon_pixbuf
, 22, 22, GDK_INTERP_HYPER
);
2173 g_object_unref(G_OBJECT(buddyicon_pixbuf
));
2177 gtk_list_store_set(store
, iter
,
2178 COLUMN_ICON
, pixbuf
,
2179 COLUMN_BUDDYICON
, buddyicon
,
2180 COLUMN_USERNAME
, purple_account_get_username(account
),
2181 COLUMN_ENABLED
, purple_account_get_enabled(account
, PIDGIN_UI
),
2182 COLUMN_PROTOCOL
, purple_account_get_protocol_name(account
),
2183 COLUMN_DATA
, account
,
2187 g_object_unref(G_OBJECT(pixbuf
));
2188 if (buddyicon
!= NULL
)
2189 g_object_unref(G_OBJECT(buddyicon
));
2193 add_account_to_liststore(PurpleAccount
*account
, gpointer user_data
)
2196 GdkPixbuf
*global_buddyicon
= user_data
;
2198 if (accounts_window
== NULL
)
2201 gtk_list_store_append(accounts_window
->model
, &iter
);
2202 gtk_notebook_set_current_page(GTK_NOTEBOOK(accounts_window
->notebook
),1);
2204 set_account(accounts_window
->model
, &iter
, account
, global_buddyicon
);
2208 populate_accounts_list(AccountsWindow
*dialog
)
2211 gboolean ret
= FALSE
;
2212 GdkPixbuf
*global_buddyicon
= NULL
;
2215 gtk_list_store_clear(dialog
->model
);
2217 if ((path
= purple_prefs_get_path(PIDGIN_PREFS_ROOT
"/accounts/buddyicon")) != NULL
) {
2218 GdkPixbuf
*pixbuf
= pidgin_pixbuf_new_from_file(path
);
2219 if (pixbuf
!= NULL
) {
2220 global_buddyicon
= gdk_pixbuf_scale_simple(pixbuf
, 22, 22, GDK_INTERP_HYPER
);
2221 g_object_unref(G_OBJECT(pixbuf
));
2225 for (l
= purple_accounts_get_all(); l
!= NULL
; l
= l
->next
) {
2227 add_account_to_liststore((PurpleAccount
*)l
->data
, global_buddyicon
);
2230 if (global_buddyicon
!= NULL
)
2231 g_object_unref(G_OBJECT(global_buddyicon
));
2237 account_selected_cb(GtkTreeSelection
*sel
, AccountsWindow
*dialog
)
2239 gboolean selected
= FALSE
;
2241 selected
= (gtk_tree_selection_count_selected_rows(sel
) > 0);
2243 gtk_widget_set_sensitive(dialog
->modify_button
, selected
);
2244 gtk_widget_set_sensitive(dialog
->delete_button
, selected
);
2248 account_treeview_double_click_cb(GtkTreeView
*treeview
, GdkEventButton
*event
, gpointer user_data
)
2250 AccountsWindow
*dialog
;
2252 GtkTreeViewColumn
*column
;
2254 PurpleAccount
*account
;
2256 dialog
= (AccountsWindow
*)user_data
;
2258 if (event
->window
!= gtk_tree_view_get_bin_window(treeview
))
2261 /* Figure out which node was clicked */
2262 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(dialog
->treeview
), event
->x
, event
->y
, &path
, &column
, NULL
, NULL
))
2264 if (column
== gtk_tree_view_get_column(treeview
, 0)) {
2265 gtk_tree_path_free(path
);
2269 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog
->model
), &iter
, path
);
2270 gtk_tree_path_free(path
);
2271 gtk_tree_model_get(GTK_TREE_MODEL(dialog
->model
), &iter
, COLUMN_DATA
, &account
, -1);
2273 if ((account
!= NULL
) && (event
->button
== GDK_BUTTON_PRIMARY
) &&
2274 (event
->type
== GDK_2BUTTON_PRESS
))
2276 pidgin_account_dialog_show(PIDGIN_MODIFY_ACCOUNT_DIALOG
, account
);
2284 create_accounts_list(AccountsWindow
*dialog
)
2288 GtkWidget
*treeview
;
2289 GtkTreeSelection
*sel
;
2290 GtkTargetEntry gte
[] = {{"PURPLE_ACCOUNT", GTK_TARGET_SAME_APP
, 0}};
2293 frame
= gtk_frame_new(NULL
);
2294 gtk_frame_set_shadow_type(GTK_FRAME(frame
), GTK_SHADOW_IN
);
2296 accounts_window
->notebook
= gtk_notebook_new();
2297 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(accounts_window
->notebook
), FALSE
);
2298 gtk_notebook_set_show_border(GTK_NOTEBOOK(accounts_window
->notebook
), FALSE
);
2299 gtk_container_add(GTK_CONTAINER(frame
), accounts_window
->notebook
);
2301 /* Create a helpful first-time-use label */
2302 label
= gtk_label_new(NULL
);
2303 /* Translators: Please maintain the use of ⇦ or ⇨ to represent the menu hierarchy */
2304 text
= g_strdup_printf(_(
2305 "<span size='larger' weight='bold'>Welcome to %s!</span>\n\n"
2307 "You have no IM accounts configured. To start connecting with %s "
2308 "press the <b>Add...</b> button below and configure your first "
2309 "account. If you want %s to connect to multiple IM accounts, "
2310 "press <b>Add...</b> again to configure them all.\n\n"
2312 "You can come back to this window to add, edit, or remove "
2313 "accounts from <b>Accounts⇨Manage Accounts</b> in the Buddy "
2314 "List window"), PIDGIN_NAME
, PIDGIN_NAME
, PIDGIN_NAME
);
2315 gtk_label_set_markup(GTK_LABEL(label
), text
);
2318 gtk_label_set_line_wrap(GTK_LABEL(label
), TRUE
);
2319 gtk_widget_show(label
);
2321 gtk_notebook_append_page(GTK_NOTEBOOK(accounts_window
->notebook
), label
, NULL
);
2323 /* Create the list model. */
2324 dialog
->model
= gtk_list_store_new(NUM_COLUMNS
,
2325 GDK_TYPE_PIXBUF
, /* COLUMN_ICON */
2326 GDK_TYPE_PIXBUF
, /* COLUMN_BUDDYICON */
2327 G_TYPE_STRING
, /* COLUMN_USERNAME */
2328 G_TYPE_BOOLEAN
, /* COLUMN_ENABLED */
2329 G_TYPE_STRING
, /* COLUMN_PROTOCOL */
2330 G_TYPE_POINTER
/* COLUMN_DATA */
2333 /* And now the actual treeview */
2334 treeview
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog
->model
));
2335 dialog
->treeview
= treeview
;
2336 g_object_unref(G_OBJECT(dialog
->model
));
2338 sel
= gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview
));
2339 gtk_tree_selection_set_mode(sel
, GTK_SELECTION_MULTIPLE
);
2340 g_signal_connect(G_OBJECT(sel
), "changed",
2341 G_CALLBACK(account_selected_cb
), dialog
);
2343 /* Handle double-clicking */
2344 g_signal_connect(G_OBJECT(treeview
), "button_press_event",
2345 G_CALLBACK(account_treeview_double_click_cb
), dialog
);
2347 gtk_notebook_append_page(GTK_NOTEBOOK(accounts_window
->notebook
),
2348 pidgin_make_scrollable(treeview
, GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
, GTK_SHADOW_NONE
, -1, -1),
2351 add_columns(treeview
, dialog
);
2352 gtk_tree_view_columns_autosize(GTK_TREE_VIEW(treeview
));
2354 if (populate_accounts_list(dialog
))
2355 gtk_notebook_set_current_page(GTK_NOTEBOOK(accounts_window
->notebook
), 1);
2357 gtk_notebook_set_current_page(GTK_NOTEBOOK(accounts_window
->notebook
), 0);
2359 /* Setup DND. I wanna be an orc! */
2360 gtk_tree_view_enable_model_drag_source(
2361 GTK_TREE_VIEW(treeview
), GDK_BUTTON1_MASK
, gte
,
2362 1, GDK_ACTION_COPY
);
2363 gtk_tree_view_enable_model_drag_dest(
2364 GTK_TREE_VIEW(treeview
), gte
, 1,
2365 GDK_ACTION_COPY
| GDK_ACTION_MOVE
);
2367 g_signal_connect(G_OBJECT(treeview
), "drag-data-received",
2368 G_CALLBACK(drag_data_received_cb
), dialog
);
2369 g_signal_connect(G_OBJECT(treeview
), "drag-data-get",
2370 G_CALLBACK(drag_data_get_cb
), dialog
);
2372 gtk_widget_show_all(frame
);
2377 account_modified_cb(PurpleAccount
*account
, AccountsWindow
*window
)
2381 if (!accounts_window_find_account_in_treemodel(&iter
, account
))
2384 set_account(window
->model
, &iter
, account
, NULL
);
2388 global_buddyicon_changed(const char *name
, PurplePrefType type
,
2389 gconstpointer value
, gpointer window
)
2392 for (list
= purple_accounts_get_all(); list
; list
= list
->next
) {
2393 account_modified_cb(list
->data
, window
);
2398 pidgin_accounts_window_show(void)
2400 AccountsWindow
*dialog
;
2407 if (accounts_window
!= NULL
) {
2408 gtk_window_present(GTK_WINDOW(accounts_window
->window
));
2412 accounts_window
= dialog
= g_new0(AccountsWindow
, 1);
2414 width
= purple_prefs_get_int(PIDGIN_PREFS_ROOT
"/accounts/dialog/width");
2415 height
= purple_prefs_get_int(PIDGIN_PREFS_ROOT
"/accounts/dialog/height");
2417 dialog
->window
= win
= pidgin_create_dialog(_("Accounts"), 0, "accounts", TRUE
);
2418 gtk_window_set_default_size(GTK_WINDOW(win
), width
, height
);
2420 g_signal_connect(G_OBJECT(win
), "delete_event",
2421 G_CALLBACK(accedit_win_destroy_cb
), accounts_window
);
2423 /* Setup the vbox */
2424 vbox
= pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(win
), FALSE
, PIDGIN_HIG_BORDER
);
2426 /* Setup the scrolled window that will contain the list of accounts. */
2427 sw
= create_accounts_list(dialog
);
2428 gtk_box_pack_start(GTK_BOX(vbox
), sw
, TRUE
, TRUE
, 0);
2429 gtk_widget_show(sw
);
2432 pidgin_dialog_add_button(GTK_DIALOG(win
), _("_Add..."),
2433 G_CALLBACK(add_account_cb
), dialog
);
2436 button
= pidgin_dialog_add_button(GTK_DIALOG(win
), _("_Modify..."),
2437 G_CALLBACK(modify_account_cb
), dialog
);
2438 dialog
->modify_button
= button
;
2439 gtk_widget_set_sensitive(button
, FALSE
);
2442 button
= pidgin_dialog_add_button(GTK_DIALOG(win
), _("_Delete"),
2443 G_CALLBACK(ask_delete_account_cb
), dialog
);
2444 dialog
->delete_button
= button
;
2445 gtk_widget_set_sensitive(button
, FALSE
);
2448 pidgin_dialog_add_button(GTK_DIALOG(win
), _("_Close"),
2449 G_CALLBACK(close_accounts_cb
), dialog
);
2451 purple_signal_connect(pidgin_accounts_get_handle(), "account-modified",
2453 PURPLE_CALLBACK(account_modified_cb
), accounts_window
);
2454 purple_prefs_connect_callback(accounts_window
,
2455 PIDGIN_PREFS_ROOT
"/accounts/buddyicon",
2456 global_buddyicon_changed
, accounts_window
);
2458 gtk_widget_show(win
);
2462 pidgin_accounts_window_hide(void)
2464 if (accounts_window
== NULL
)
2467 if (accounts_window
->window
!= NULL
)
2468 gtk_widget_destroy(accounts_window
->window
);
2470 purple_signals_disconnect_by_handle(accounts_window
);
2471 purple_prefs_disconnect_by_handle(accounts_window
);
2473 g_free(accounts_window
);
2474 accounts_window
= NULL
;
2478 free_add_user_data(PidginAccountAddUserData
*data
)
2480 g_free(data
->username
);
2481 g_free(data
->alias
);
2486 add_user_cb(PidginAccountAddUserData
*data
)
2488 PurpleConnection
*gc
= purple_account_get_connection(data
->account
);
2490 if (g_list_find(purple_connections_get_all(), gc
))
2492 purple_blist_request_add_buddy(data
->account
, data
->username
,
2496 free_add_user_data(data
);
2500 make_info(PurpleAccount
*account
, PurpleConnection
*gc
, const char *remote_user
,
2501 const char *id
, const char *alias
, const char *msg
)
2503 if (msg
!= NULL
&& *msg
== '\0')
2506 return g_strdup_printf(_("%s%s%s%s has made %s his or her buddy%s%s"),
2508 (alias
!= NULL
? " (" : ""),
2509 (alias
!= NULL
? alias
: ""),
2510 (alias
!= NULL
? ")" : ""),
2513 : (purple_connection_get_display_name(gc
) != NULL
2514 ? purple_connection_get_display_name(gc
)
2515 : purple_account_get_username(account
))),
2516 (msg
!= NULL
? ": " : "."),
2517 (msg
!= NULL
? msg
: ""));
2521 pidgin_accounts_notify_added(PurpleAccount
*account
, const char *remote_user
,
2522 const char *id
, const char *alias
,
2526 PurpleConnection
*gc
;
2529 gc
= purple_account_get_connection(account
);
2531 buffer
= make_info(account
, gc
, remote_user
, id
, alias
, msg
);
2532 alert
= pidgin_make_mini_dialog(gc
, "dialog-information", buffer
,
2533 NULL
, NULL
, _("Close"), NULL
, NULL
);
2534 pidgin_blist_add_alert(alert
);
2540 pidgin_accounts_request_add(PurpleAccount
*account
, const char *remote_user
,
2541 const char *id
, const char *alias
,
2545 PurpleConnection
*gc
;
2546 PidginAccountAddUserData
*data
;
2549 gc
= purple_account_get_connection(account
);
2551 data
= g_new0(PidginAccountAddUserData
, 1);
2552 data
->account
= account
;
2553 data
->username
= g_strdup(remote_user
);
2554 data
->alias
= g_strdup(alias
);
2556 buffer
= make_info(account
, gc
, remote_user
, id
, alias
, msg
);
2557 alert
= pidgin_make_mini_dialog(gc
, "dialog-question",
2558 _("Add buddy to your list?"), buffer
, data
,
2559 _("Add"), G_CALLBACK(add_user_cb
),
2560 _("Cancel"), G_CALLBACK(free_add_user_data
), NULL
);
2561 pidgin_blist_add_alert(alert
);
2568 PurpleAccountRequestAuthorizationCb auth_cb
;
2569 PurpleAccountRequestAuthorizationCb deny_cb
;
2573 PurpleAccount
*account
;
2574 gboolean add_buddy_after_auth
;
2578 free_auth_request(struct auth_request
*ar
)
2580 g_free(ar
->username
);
2586 authorize_and_add_cb(struct auth_request
*ar
, const char *message
)
2588 ar
->auth_cb(message
, ar
->data
);
2589 if (ar
->add_buddy_after_auth
) {
2590 purple_blist_request_add_buddy(ar
->account
, ar
->username
, NULL
, ar
->alias
);
2595 authorize_noreason_cb(struct auth_request
*ar
)
2597 authorize_and_add_cb(ar
, NULL
);
2601 authorize_reason_cb(struct auth_request
*ar
)
2603 const char *protocol_id
;
2604 PurpleProtocol
*protocol
= NULL
;
2606 protocol_id
= purple_account_get_protocol_id(ar
->account
);
2607 protocol
= purple_protocols_find(protocol_id
);
2609 if (protocol
&& (purple_protocol_get_options(protocol
) & OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE
)) {
2610 /* Duplicate information because ar is freed by closing minidialog */
2611 struct auth_request
*aa
= g_new0(struct auth_request
, 1);
2612 aa
->auth_cb
= ar
->auth_cb
;
2613 aa
->deny_cb
= ar
->deny_cb
;
2614 aa
->data
= ar
->data
;
2615 aa
->account
= ar
->account
;
2616 aa
->username
= g_strdup(ar
->username
);
2617 aa
->alias
= g_strdup(ar
->alias
);
2618 aa
->add_buddy_after_auth
= ar
->add_buddy_after_auth
;
2619 purple_request_input(ar
->account
, NULL
, _("Authorization acceptance message:"),
2620 NULL
, _("No reason given."), TRUE
, FALSE
, NULL
,
2621 _("OK"), G_CALLBACK(authorize_and_add_cb
),
2622 _("Cancel"), G_CALLBACK(authorize_noreason_cb
),
2623 purple_request_cpar_from_account(ar
->account
),
2625 /* FIXME: aa is going to leak now. */
2627 authorize_noreason_cb(ar
);
2632 deny_no_add_cb(struct auth_request
*ar
, const char *message
)
2634 ar
->deny_cb(message
, ar
->data
);
2638 deny_noreason_cb(struct auth_request
*ar
)
2640 ar
->deny_cb(NULL
, ar
->data
);
2644 deny_reason_cb(struct auth_request
*ar
)
2646 const char *protocol_id
;
2647 PurpleProtocol
*protocol
= NULL
;
2649 protocol_id
= purple_account_get_protocol_id(ar
->account
);
2650 protocol
= purple_protocols_find(protocol_id
);
2652 if (protocol
&& (purple_protocol_get_options(protocol
) & OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE
)) {
2653 /* Duplicate information because ar is freed by closing minidialog */
2654 struct auth_request
*aa
= g_new0(struct auth_request
, 1);
2655 aa
->auth_cb
= ar
->auth_cb
;
2656 aa
->deny_cb
= ar
->deny_cb
;
2657 aa
->data
= ar
->data
;
2658 aa
->add_buddy_after_auth
= ar
->add_buddy_after_auth
;
2659 purple_request_input(ar
->account
, NULL
, _("Authorization denied message:"),
2660 NULL
, _("No reason given."), TRUE
, FALSE
, NULL
,
2661 _("OK"), G_CALLBACK(deny_no_add_cb
),
2662 _("Cancel"), G_CALLBACK(deny_noreason_cb
),
2663 purple_request_cpar_from_account(ar
->account
),
2665 /* FIXME: aa is going to leak now. */
2667 deny_noreason_cb(ar
);
2672 get_user_info_cb(GtkWidget
*label
,
2676 struct auth_request
*ar
= data
;
2677 if (purple_strequal(uri
, "viewinfo")) {
2678 pidgin_retrieve_user_info(purple_account_get_connection(ar
->account
), ar
->username
);
2685 send_im_cb(PidginMiniDialog
*mini_dialog
,
2689 struct auth_request
*ar
= data
;
2690 pidgin_dialogs_im_with_user(ar
->account
, ar
->username
);
2694 pidgin_accounts_request_authorization(PurpleAccount
*account
,
2695 const char *remote_user
,
2698 const char *message
,
2700 PurpleAccountRequestAuthorizationCb auth_cb
,
2701 PurpleAccountRequestAuthorizationCb deny_cb
,
2705 PurpleConnection
*gc
;
2707 PidginMiniDialog
*dialog
;
2708 GdkPixbuf
*protocol_icon
;
2709 struct auth_request
*aa
;
2710 const char *our_name
;
2711 gboolean have_valid_alias
;
2712 char *escaped_remote_user
;
2713 char *escaped_alias
;
2714 char *escaped_our_name
;
2715 char *escaped_message
;
2717 gc
= purple_account_get_connection(account
);
2718 if (message
!= NULL
&& *message
!= '\0')
2719 escaped_message
= g_markup_escape_text(message
, -1);
2721 escaped_message
= g_strdup("");
2723 our_name
= (id
!= NULL
) ? id
:
2724 (purple_connection_get_display_name(gc
) != NULL
) ? purple_connection_get_display_name(gc
) :
2725 purple_account_get_username(account
);
2726 escaped_our_name
= g_markup_escape_text(our_name
, -1);
2728 escaped_remote_user
= g_markup_escape_text(remote_user
, -1);
2730 have_valid_alias
= alias
&& *alias
;
2731 escaped_alias
= have_valid_alias
? g_markup_escape_text(alias
, -1) : g_strdup("");
2733 buffer
= g_strdup_printf(_("<a href=\"viewinfo\">%s</a>%s%s%s wants to add you (%s) to his or her buddy list%s%s"),
2734 escaped_remote_user
,
2735 (have_valid_alias
? " (" : ""),
2737 (have_valid_alias
? ")" : ""),
2739 (*escaped_message
? ": " : "."),
2742 g_free(escaped_remote_user
);
2743 g_free(escaped_alias
);
2744 g_free(escaped_our_name
);
2745 g_free(escaped_message
);
2747 protocol_icon
= pidgin_create_protocol_icon(account
, PIDGIN_PROTOCOL_ICON_SMALL
);
2749 aa
= g_new0(struct auth_request
, 1);
2750 aa
->auth_cb
= auth_cb
;
2751 aa
->deny_cb
= deny_cb
;
2752 aa
->data
= user_data
;
2753 aa
->username
= g_strdup(remote_user
);
2754 aa
->alias
= g_strdup(alias
);
2755 aa
->account
= account
;
2756 aa
->add_buddy_after_auth
= !on_list
;
2758 alert
= pidgin_make_mini_dialog_with_custom_icon(
2760 _("Authorize buddy?"), NULL
, aa
,
2761 _("Authorize"), authorize_reason_cb
,
2762 _("Deny"), deny_reason_cb
,
2765 dialog
= PIDGIN_MINI_DIALOG(alert
);
2766 pidgin_mini_dialog_enable_description_markup(dialog
);
2767 pidgin_mini_dialog_set_link_callback(dialog
, G_CALLBACK(get_user_info_cb
), aa
);
2768 pidgin_mini_dialog_set_description(dialog
, buffer
);
2769 pidgin_mini_dialog_add_non_closing_button(dialog
, _("Send Instant Message"), send_im_cb
, aa
);
2771 g_signal_connect_swapped(G_OBJECT(alert
), "destroy", G_CALLBACK(free_auth_request
), aa
);
2772 g_signal_connect(G_OBJECT(alert
), "destroy", G_CALLBACK(purple_account_request_close
), NULL
);
2773 pidgin_blist_add_alert(alert
);
2781 pidgin_accounts_request_close(void *ui_handle
)
2783 gtk_widget_destroy(GTK_WIDGET(ui_handle
));
2786 static PurpleAccountUiOps ui_ops
=
2788 pidgin_accounts_notify_added
,
2790 pidgin_accounts_request_add
,
2791 pidgin_accounts_request_authorization
,
2792 pidgin_accounts_request_close
,
2797 NULL
, NULL
, NULL
, NULL
2800 PurpleAccountUiOps
*
2801 pidgin_accounts_get_ui_ops(void)
2807 pidgin_accounts_get_handle(void) {
2814 pidgin_accounts_init(void)
2816 char *default_avatar
= NULL
;
2817 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/accounts");
2818 purple_prefs_add_none(PIDGIN_PREFS_ROOT
"/accounts/dialog");
2819 purple_prefs_add_int(PIDGIN_PREFS_ROOT
"/accounts/dialog/width", 520);
2820 purple_prefs_add_int(PIDGIN_PREFS_ROOT
"/accounts/dialog/height", 321);
2821 default_avatar
= g_build_filename(g_get_home_dir(), ".face.icon", NULL
);
2822 if (!g_file_test(default_avatar
, G_FILE_TEST_EXISTS
)) {
2823 g_free(default_avatar
);
2824 default_avatar
= g_build_filename(g_get_home_dir(), ".face", NULL
);
2825 if (!g_file_test(default_avatar
, G_FILE_TEST_EXISTS
)) {
2826 g_free(default_avatar
);
2827 default_avatar
= NULL
;
2831 purple_prefs_add_path(PIDGIN_PREFS_ROOT
"/accounts/buddyicon", default_avatar
);
2832 g_free(default_avatar
);
2834 purple_signal_register(pidgin_accounts_get_handle(), "account-modified",
2835 purple_marshal_VOID__POINTER
, G_TYPE_NONE
, 1,
2836 PURPLE_TYPE_ACCOUNT
);
2838 /* Setup some purple signal handlers. */
2839 purple_signal_connect(purple_connections_get_handle(), "signed-on",
2840 pidgin_accounts_get_handle(),
2841 PURPLE_CALLBACK(signed_on_off_cb
), NULL
);
2842 purple_signal_connect(purple_connections_get_handle(), "signed-off",
2843 pidgin_accounts_get_handle(),
2844 PURPLE_CALLBACK(signed_on_off_cb
), NULL
);
2845 purple_signal_connect(purple_accounts_get_handle(), "account-added",
2846 pidgin_accounts_get_handle(),
2847 PURPLE_CALLBACK(add_account_to_liststore
), NULL
);
2848 purple_signal_connect(purple_accounts_get_handle(), "account-removed",
2849 pidgin_accounts_get_handle(),
2850 PURPLE_CALLBACK(account_removed_cb
), NULL
);
2851 purple_signal_connect(purple_accounts_get_handle(), "account-disabled",
2852 pidgin_accounts_get_handle(),
2853 PURPLE_CALLBACK(account_abled_cb
), GINT_TO_POINTER(FALSE
));
2854 purple_signal_connect(purple_accounts_get_handle(), "account-enabled",
2855 pidgin_accounts_get_handle(),
2856 PURPLE_CALLBACK(account_abled_cb
), GINT_TO_POINTER(TRUE
));
2859 g_hash_table_new_full(g_direct_hash
, g_direct_equal
, NULL
, NULL
);
2863 pidgin_accounts_uninit(void)
2866 * TODO: Need to free all the dialogs in here. Could probably create
2867 * a callback function to use for the free-some-data-function
2868 * parameter of g_hash_table_new_full, above.
2870 g_hash_table_destroy(account_pref_wins
);
2872 purple_signals_disconnect_by_handle(pidgin_accounts_get_handle());
2873 purple_signals_unregister_by_instance(pidgin_accounts_get_handle());