pidgin/pidginaccounteditor.c

Wed, 26 Oct 2022 02:58:05 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Wed, 26 Oct 2022 02:58:05 -0500
changeset 41840
fe350460fb1c
parent 41816
f6baa88826a7
child 41858
38e61d11b89f
permissions
-rw-r--r--

Remove C99-obsoleted constructs

See [this development thread for a future Fedora change](https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/thread/CJXKTLXJUPZ4F2C2VQOTNMEA5JAUPMBD/) or [the proposed change page](https://fedoraproject.org/wiki/Changes/PortingToModernC). These may be made stronger errors in GCC 14.

Testing Done:
Configured with `-Dc_args='-Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -Werror=strict-prototypes -Werror=old-style-definition'` and compiled.

Reviewed at https://reviews.imfreedom.org/r/1974/

41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include <glib/gi18n-lib.h>
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
25 #include <adwaita.h>
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
26
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "pidginaccounteditor.h"
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
29 #include "pidginprotocolchooser.h"
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 struct _PidginAccountEditor {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 GtkDialog parent;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PurpleAccount *account;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
36 /* Login Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
37 GtkWidget *login_options;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
38 GtkWidget *protocol;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
39 GtkWidget *username;
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
40 GtkWidget *user_splits;
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
41 GtkWidget *require_password_row;
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
42 GtkWidget *require_password;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
43
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
44 GList *user_split_entries;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
45 GList *user_split_rows;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
46
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
47 /* User Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
48 GtkWidget *alias;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
49
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
50 GtkFileChooserNative *avatar_dialog;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
51 GdkPixbuf *avatar_pixbuf;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
52 GtkWidget *avatar_row;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
53 GtkWidget *use_custom_avatar;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
54 GtkWidget *avatar;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
55
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
56 /* Advanced Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
57 GtkWidget *advanced_group;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
58 GtkWidget *advanced_toggle;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
59
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
60 GList *advanced_entries;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
61 GList *advanced_rows;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
62
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
63 /* Proxy Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
64 GtkWidget *proxy_type;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 GtkWidget *proxy_options;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
66 GtkWidget *proxy_host;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
67 GtkWidget *proxy_port;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
68 GtkWidget *proxy_username;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
69 GtkWidget *proxy_password;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 };
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 enum {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 PROP_0,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 PROP_ACCOUNT,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 N_PROPERTIES,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 };
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
79 /******************************************************************************
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
80 * Prototypes
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
81 *****************************************************************************/
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
82 static void pidgin_account_editor_connection_changed_cb(GObject *obj,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
83 GParamSpec *pspec,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
84 gpointer data);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
85
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 /******************************************************************************
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 * Helpers
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 *****************************************************************************/
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 static void
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
90 pidgin_account_editor_add_user_split(gpointer data, gpointer user_data) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
91 PurpleAccountUserSplit *split = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
92 PidginAccountEditor *editor = user_data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
93 GtkWidget *entry = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
94
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
95 if(!purple_account_user_split_is_constant(split)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
96 GtkWidget *row = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
97
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
98 row = adw_action_row_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
99 editor->user_split_rows = g_list_append(editor->user_split_rows, row);
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
100 gtk_list_box_append(GTK_LIST_BOX(editor->user_splits), row);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
101
41780
1247cc856233 Remove extra focus targets from Account Editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41779
diff changeset
102 gtk_widget_set_focusable(row, FALSE);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
103 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
104 purple_account_user_split_get_text(split));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
105
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
106 entry = gtk_entry_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
107 gtk_widget_set_hexpand(entry, TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
108 gtk_widget_set_valign(entry, GTK_ALIGN_CENTER);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
109 adw_action_row_add_suffix(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
110 adw_action_row_set_activatable_widget(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
111 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
112
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
113 editor->user_split_entries = g_list_append(editor->user_split_entries,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
114 entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
115 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
116
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
117 static gboolean
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
118 pidgin_account_editor_update_login_options(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
119 PurpleProtocol *protocol)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
120 {
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
121 PurpleProtocolOptions options;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
122 GList *user_splits = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
123 GList *split_item = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
124 GList *entry_item = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
125 gchar *username = NULL;
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
126 gboolean require_password = FALSE;
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
127 gboolean ret = FALSE;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
128
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
129 /* Clear out the old user splits from our list. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
130 g_clear_pointer(&editor->user_split_entries, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
131
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
132 /* Now remove the rows we added to the preference group for each non
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
133 * constant user split.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
134 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
135 while(editor->user_split_rows != NULL) {
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
136 gtk_list_box_remove(GTK_LIST_BOX(editor->user_splits),
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
137 editor->user_split_rows->data);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
138
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
139 editor->user_split_rows = g_list_delete_link(editor->user_split_rows,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
140 editor->user_split_rows);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
141 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
142
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
143 /* Add the user splits for the protocol. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
144 user_splits = purple_protocol_get_user_splits(protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
145 g_list_foreach(user_splits, pidgin_account_editor_add_user_split, editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
146
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
147 /* If we have an account, populate its values. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
148 if(PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
149 /* The username will be split apart below and eventually set as the text
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
150 * in the username entry.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
151 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
152 username = g_strdup(purple_account_get_username(editor->account));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
153 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
154
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
155 /* Filling out the user splits is a pain. If we have an account, we created
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
156 * a copy of the username above. We then iterate the user splits backwards
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
157 * so we can insert a null terminator at the start of each split we find in
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
158 * the username.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
159 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
160 split_item = g_list_last(user_splits);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
161 entry_item = g_list_last(editor->user_split_entries);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
162 while(split_item != NULL && entry_item != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
163 GtkWidget *entry = entry_item->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
164 PurpleAccountUserSplit *split = split_item->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
165 gchar *ptr = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
166 const gchar *value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
167
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
168 if(username != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
169 gchar sep = purple_account_user_split_get_separator(split);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
170
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
171 if(purple_account_user_split_get_reverse(split)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
172 ptr = strrchr(username, sep);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
173 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
174 ptr = strchr(username, sep);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
175 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
176
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
177 if(ptr != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
178 /* Insert a null terminator in place of the separator. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
179 *ptr = '\0';
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
180
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
181 /* Set the value to the first byte after the separator. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
182 value = ptr + 1;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
183 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
184 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
185
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
186 if(value == NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
187 value = purple_account_user_split_get_default_value(split);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
188 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
189
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
190 if(value != NULL && GTK_IS_ENTRY(entry)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
191 gtk_editable_set_text(GTK_EDITABLE(entry), value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
192 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
193
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
194 split_item = split_item->prev;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
195 entry_item = entry_item->prev;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
196 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
197
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
198 /* Free the user splits. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
199 g_list_free_full(user_splits,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
200 (GDestroyNotify)purple_account_user_split_destroy);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
201
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
202 /* Set the username entry to the remaining text in username and free our
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
203 * copy of said username.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
204 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
205 if(username != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
206 gtk_editable_set_text(GTK_EDITABLE(editor->username), username);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
207 g_free(username);
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
208 ret = TRUE;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
209 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
210
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
211 options = purple_protocol_get_options(protocol);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
212 gtk_widget_set_visible(editor->require_password_row,
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
213 options & OPT_PROTO_PASSWORD_OPTIONAL);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
214
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
215 if(PURPLE_IS_ACCOUNT(editor->account)) {
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
216 require_password = purple_account_get_require_password(editor->account);
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
217 }
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
218 gtk_switch_set_active(GTK_SWITCH(editor->require_password),
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
219 require_password);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
220
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
221 return ret;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
222 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
223
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
224 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
225 pidgin_account_editor_update_user_options(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
226 PurpleProtocol *protocol)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
227 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
228 PurpleBuddyIconSpec *icon_spec = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
229 PurpleImage *image = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
230 gboolean show_avatar_opts = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
231 const gchar *svalue = "";
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
232 gboolean use_global = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
233
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
234 /* Check if the protocol supports avatars. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
235 icon_spec = purple_protocol_get_icon_spec(protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
236 show_avatar_opts = (icon_spec != NULL && icon_spec->format != NULL);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
237 purple_buddy_icon_spec_free(icon_spec);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
238
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
239 gtk_widget_set_visible(editor->avatar_row, show_avatar_opts);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
240
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
241 /* Determine our values. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
242 if(editor->account != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
243 svalue = purple_account_get_private_alias(editor->account);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
244 image = purple_buddy_icons_find_account_icon(editor->account);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
245 use_global = purple_account_get_bool(editor->account,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
246 "use-global-buddyicon", TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
247 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
248
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
249 if(svalue == NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
250 svalue = "";
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
251 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
252
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
253 gtk_editable_set_text(GTK_EDITABLE(editor->alias), svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
254 gtk_switch_set_active(GTK_SWITCH(editor->use_custom_avatar), !use_global);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
255
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
256 g_clear_object(&editor->avatar_pixbuf);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
257 if(PURPLE_IS_IMAGE(image)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
258 editor->avatar_pixbuf = purple_gdk_pixbuf_from_image(image);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
259 gtk_image_set_from_pixbuf(GTK_IMAGE(editor->avatar),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
260 editor->avatar_pixbuf);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
261 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
262 gtk_image_set_from_icon_name(GTK_IMAGE(editor->avatar),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
263 "select-avatar");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
264 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
265 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
266
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
267 static gboolean
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
268 pidgin_account_editor_advanced_option_use_default(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
269 PurpleProtocol *protocol = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
270
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
271 /* If this is the new dialog, use the default value. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
272 if(!PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
273 return TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
274 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
275
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
276 /* If we have an existing account, check if the protocol has changed. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
277 protocol = pidgin_protocol_chooser_get_protocol(PIDGIN_PROTOCOL_CHOOSER(editor->protocol));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
278 if(protocol != purple_account_get_protocol(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
279 return TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
280 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
281
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
282 return FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
283 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
284
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
285 static GtkWidget *
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
286 pidgin_account_editor_add_advanced_boolean(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
287 PurpleAccountOption *option)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
288 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
289 GtkWidget *row = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
290 GtkWidget *toggle = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
291 gboolean value = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
292 gchar *title = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
293
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
294 if(pidgin_account_editor_advanced_option_use_default(editor)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
295 value = purple_account_option_get_default_bool(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
296 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
297 const gchar *setting = purple_account_option_get_setting(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
298 gboolean def_value = purple_account_option_get_default_bool(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
299
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
300 value = purple_account_get_bool(editor->account, setting, def_value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
301 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
302
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
303 /* Create the row and set its title with a mnemonic. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
304 row = adw_action_row_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
305 g_object_bind_property(editor->advanced_toggle, "active", row, "visible",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
306 G_BINDING_SYNC_CREATE);
41780
1247cc856233 Remove extra focus targets from Account Editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41779
diff changeset
307 gtk_widget_set_focusable(row, FALSE);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
308 adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
309 title = g_strdup_printf("_%s", purple_account_option_get_text(option));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
310 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
311 g_free(title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
312
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
313 adw_preferences_group_add(ADW_PREFERENCES_GROUP(editor->advanced_group),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
314 row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
315
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
316 /* Add the row to the editor's list of advanced rows. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
317 editor->advanced_rows = g_list_append(editor->advanced_rows, row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
318
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
319 /* Create the input widget. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
320 toggle = gtk_switch_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
321 gtk_switch_set_active(GTK_SWITCH(toggle), value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
322 gtk_widget_set_valign(toggle, GTK_ALIGN_CENTER);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
323 adw_action_row_add_suffix(ADW_ACTION_ROW(row), toggle);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
324 adw_action_row_set_activatable_widget(ADW_ACTION_ROW(row), toggle);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
325
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
326 return toggle;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
327 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
328
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
329 static GtkWidget *
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
330 pidgin_account_editor_add_advanced_int(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
331 PurpleAccountOption *option)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
332 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
333 GtkWidget *row = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
334 GtkWidget *entry = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
335 gint value = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
336 gchar *title = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
337 gchar *svalue = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
338
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
339 if(pidgin_account_editor_advanced_option_use_default(editor)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
340 value = purple_account_option_get_default_int(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
341 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
342 const gchar *setting = purple_account_option_get_setting(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
343 gint def_value = purple_account_option_get_default_int(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
344
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
345 value = purple_account_get_int(editor->account, setting, def_value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
346 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
347
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
348 /* Create the row and set its title with a mnemonic. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
349 row = adw_action_row_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
350 g_object_bind_property(editor->advanced_toggle, "active", row, "visible",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
351 G_BINDING_SYNC_CREATE);
41780
1247cc856233 Remove extra focus targets from Account Editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41779
diff changeset
352 gtk_widget_set_focusable(row, FALSE);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
353 adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
354 title = g_strdup_printf("_%s", purple_account_option_get_text(option));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
355 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
356 g_free(title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
357
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
358 adw_preferences_group_add(ADW_PREFERENCES_GROUP(editor->advanced_group),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
359 row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
360
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
361 /* Add the row to the editor's list of advanced rows. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
362 editor->advanced_rows = g_list_append(editor->advanced_rows, row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
363
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
364 /* Create the input widget. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
365 entry = gtk_entry_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
366 gtk_entry_set_input_purpose(GTK_ENTRY(entry), GTK_INPUT_PURPOSE_DIGITS);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
367 svalue = g_strdup_printf("%d", value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
368 gtk_editable_set_text(GTK_EDITABLE(entry), svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
369 g_free(svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
370
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
371 gtk_widget_set_hexpand(entry, TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
372 gtk_widget_set_valign(entry, GTK_ALIGN_CENTER);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
373 adw_action_row_add_suffix(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
374 adw_action_row_set_activatable_widget(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
375
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
376 return entry;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
377 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
378
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
379 static GtkWidget *
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
380 pidgin_account_editor_add_advanced_string(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
381 PurpleAccountOption *option)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
382 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
383 GtkWidget *row = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
384 GtkWidget *entry = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
385 gchar *title = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
386 const gchar *value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
387
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
388 if(pidgin_account_editor_advanced_option_use_default(editor)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
389 value = purple_account_option_get_default_string(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
390 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
391 const gchar *setting = purple_account_option_get_setting(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
392 const gchar *def_value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
393
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
394 def_value = purple_account_option_get_default_string(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
395
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
396 value = purple_account_get_string(editor->account, setting, def_value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
397 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
398
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
399 /* Create the row and set its title with a mnemonic. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
400 row = adw_action_row_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
401 g_object_bind_property(editor->advanced_toggle, "active", row, "visible",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
402 G_BINDING_SYNC_CREATE);
41780
1247cc856233 Remove extra focus targets from Account Editor
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41779
diff changeset
403 gtk_widget_set_focusable(row, FALSE);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
404 adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
405 title = g_strdup_printf("_%s", purple_account_option_get_text(option));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
406 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
407 g_free(title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
408
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
409 adw_preferences_group_add(ADW_PREFERENCES_GROUP(editor->advanced_group),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
410 row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
411
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
412 /* Add the row to the editor's list of advanced rows. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
413 editor->advanced_rows = g_list_append(editor->advanced_rows, row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
414
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
415 /* Create the input widget. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
416 if(purple_account_option_string_get_masked(option)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
417 entry = gtk_password_entry_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
418 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
419 entry = gtk_entry_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
420 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
421
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
422 if(value != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
423 gtk_editable_set_text(GTK_EDITABLE(entry), value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
424 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
425 gtk_widget_set_hexpand(entry, TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
426 gtk_widget_set_valign(entry, GTK_ALIGN_CENTER);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
427 adw_action_row_add_suffix(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
428 adw_action_row_set_activatable_widget(ADW_ACTION_ROW(row), entry);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
429
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
430 return entry;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
431 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
432
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
433 static GtkWidget *
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
434 pidgin_account_editor_add_advanced_list(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
435 PurpleAccountOption *option)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
436 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
437 GtkWidget *row = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
438 GtkStringList *model = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
439 GList *data = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
440 GList *items = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
441 gchar *title = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
442 const gchar *value = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
443 guint index = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
444 guint position = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
445
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
446 if(pidgin_account_editor_advanced_option_use_default(editor)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
447 value = purple_account_option_get_default_list_value(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
448 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
449 const gchar *setting = purple_account_option_get_setting(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
450 const gchar *def_value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
451
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
452 def_value = purple_account_option_get_default_list_value(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
453
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
454 value = purple_account_get_string(editor->account, setting, def_value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
455 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
456
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
457 /* Create the row and set its title with a mnemonic. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
458 row = adw_combo_row_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
459 g_object_bind_property(editor->advanced_toggle, "active", row, "visible",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
460 G_BINDING_SYNC_CREATE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
461 adw_preferences_row_set_use_underline(ADW_PREFERENCES_ROW(row), TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
462 adw_combo_row_set_use_subtitle(ADW_COMBO_ROW(row), TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
463 title = g_strdup_printf("_%s", purple_account_option_get_text(option));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
464 adw_preferences_row_set_title(ADW_PREFERENCES_ROW(row), title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
465 g_free(title);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
466
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
467 adw_preferences_group_add(ADW_PREFERENCES_GROUP(editor->advanced_group),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
468 row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
469
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
470 /* Add the row to the editor's list of advanced rows. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
471 editor->advanced_rows = g_list_append(editor->advanced_rows, row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
472
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
473 /* Create the model and data for the expression. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
474 items = purple_account_option_get_list(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
475 model = gtk_string_list_new(NULL);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
476
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
477 for(GList *l = items; l != NULL; l = l->next) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
478 PurpleKeyValuePair *kvp = l->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
479
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
480 if(kvp != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
481 if(purple_strequal(kvp->value, value)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
482 position = index;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
483 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
484
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
485 data = g_list_append(data, kvp->value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
486 gtk_string_list_append(model, kvp->key);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
487 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
488
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
489 index++;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
490 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
491
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
492 adw_combo_row_set_model(ADW_COMBO_ROW(row), G_LIST_MODEL(model));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
493 adw_combo_row_set_selected(ADW_COMBO_ROW(row), position);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
494 g_object_set_data_full(G_OBJECT(row), "keys", data,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
495 (GDestroyNotify)g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
496
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
497 return row;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
498 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
499
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
500 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
501 pidgin_account_editor_add_advanced_option(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
502 PurpleAccountOption *option)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
503 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
504 PurplePrefType type;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
505 GtkWidget *widget = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
506
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
507 type = purple_account_option_get_pref_type(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
508 switch(type) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
509 case PURPLE_PREF_BOOLEAN:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
510 widget = pidgin_account_editor_add_advanced_boolean(editor, option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
511 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
512 case PURPLE_PREF_INT:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
513 widget = pidgin_account_editor_add_advanced_int(editor, option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
514 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
515 case PURPLE_PREF_STRING:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
516 widget = pidgin_account_editor_add_advanced_string(editor, option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
517 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
518 case PURPLE_PREF_STRING_LIST:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
519 widget = pidgin_account_editor_add_advanced_list(editor, option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
520 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
521 default:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
522 purple_debug_error("PidginAccountEditor",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
523 "Invalid Account Option pref type (%d)", type);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
524 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
525 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
526
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
527 if(GTK_IS_WIDGET(widget)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
528 g_object_set_data_full(G_OBJECT(widget), "option", option,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
529 (GDestroyNotify)purple_account_option_destroy);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
530
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
531 editor->advanced_entries = g_list_append(editor->advanced_entries,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
532 widget);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
533 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
534 purple_account_option_destroy(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
535 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
536 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
537
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
538 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
539 pidgin_account_editor_update_advanced_options(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
540 PurpleProtocol *protocol)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
541 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
542 GList *options = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
543
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
544 g_clear_pointer(&editor->advanced_entries, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
545 while(editor->advanced_rows != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
546 adw_preferences_group_remove(ADW_PREFERENCES_GROUP(editor->advanced_group),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
547 GTK_WIDGET(editor->advanced_rows->data));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
548
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
549 editor->advanced_rows = g_list_delete_link(editor->advanced_rows,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
550 editor->advanced_rows);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
551 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
552
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
553 if(!PURPLE_IS_PROTOCOL(protocol)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
554 gtk_widget_set_visible(editor->advanced_group, FALSE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
555
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
556 return;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
557 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
558
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
559 options = purple_protocol_get_account_options(protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
560 if(options == NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
561 gtk_widget_set_visible(editor->advanced_group, FALSE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
562
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
563 return;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
564 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
565
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
566 /* Iterate the options and call our helper which will take ownership of the
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
567 * option itself, but we'll delete the list item as we go.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
568 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
569 while(options != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
570 pidgin_account_editor_add_advanced_option(editor, options->data);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
571
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
572 options = g_list_delete_link(options, options);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
573 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
574
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
575 gtk_widget_set_visible(editor->advanced_group, TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
576 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
577
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
578 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
579 pidgin_account_editor_update_proxy_options(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
580 PurpleProxyInfo *info = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
581 GListModel *model = NULL;
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
582 const char *type = "global";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
583 const char *hostname = NULL;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
584 const char *username = NULL;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
585 const char *password = NULL;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
586 int port = 8080;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
587 guint position = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
588
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
589 if(!PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
590 return;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
591 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
592
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
593 info = purple_account_get_proxy_info(editor->account);
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
594 if(PURPLE_IS_PROXY_INFO(info)) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
595 switch(purple_proxy_info_get_proxy_type(info)) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
596 case PURPLE_PROXY_TYPE_USE_GLOBAL:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
597 type = "global";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
598 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
599 case PURPLE_PROXY_TYPE_NONE:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
600 type = "none";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
601 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
602 case PURPLE_PROXY_TYPE_SOCKS4:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
603 type = "socks4";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
604 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
605 case PURPLE_PROXY_TYPE_SOCKS5:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
606 type = "socks5";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
607 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
608 case PURPLE_PROXY_TYPE_TOR:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
609 type = "tor";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
610 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
611 case PURPLE_PROXY_TYPE_HTTP:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
612 type = "http";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
613 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
614 case PURPLE_PROXY_TYPE_USE_ENVVAR:
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
615 type = "envvar";
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
616 break;
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
617 }
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
618
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
619 hostname = purple_proxy_info_get_hostname(info);
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
620 port = purple_proxy_info_get_port(info);
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
621 username = purple_proxy_info_get_username(info);
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
622 password = purple_proxy_info_get_password(info);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
623 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
624
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
625 model = adw_combo_row_get_model(ADW_COMBO_ROW(editor->proxy_type));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
626 for(guint i = 0; i < g_list_model_get_n_items(model); i++) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
627 GtkStringObject *obj = g_list_model_get_item(model, i);
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
628 if(purple_strequal(type, gtk_string_object_get_string(obj))) {
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
629 position = i;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
630 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
631 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
632 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
633 adw_combo_row_set_selected(ADW_COMBO_ROW(editor->proxy_type), position);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
634
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
635 if(hostname == NULL) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
636 hostname = "";
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
637 }
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
638 gtk_editable_set_text(GTK_EDITABLE(editor->proxy_host), hostname);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
639
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
640 gtk_spin_button_set_value(GTK_SPIN_BUTTON(editor->proxy_port),
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
641 (gdouble)port);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
642
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
643 if(username == NULL) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
644 username = "";
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
645 }
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
646 gtk_editable_set_text(GTK_EDITABLE(editor->proxy_username), username);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
647
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
648 if(password == NULL) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
649 password = "";
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
650 }
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
651 gtk_editable_set_text(GTK_EDITABLE(editor->proxy_password), password);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
652 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
653
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
654 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
655 pidgin_account_editor_update(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
656 PurpleProtocol *protocol = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
657 gboolean sensitive = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
658
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
659 if(PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
660 PurpleConnection *connection = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
661
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
662 connection = purple_account_get_connection(editor->account);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
663 if(PURPLE_IS_CONNECTION(connection)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
664 gtk_widget_set_sensitive(editor->protocol, FALSE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
665 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
666 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
667
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
668 protocol = pidgin_protocol_chooser_get_protocol(PIDGIN_PROTOCOL_CHOOSER(editor->protocol));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
669
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
670 sensitive = pidgin_account_editor_update_login_options(editor, protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
671 pidgin_account_editor_update_user_options(editor, protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
672 pidgin_account_editor_update_advanced_options(editor, protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
673 pidgin_account_editor_update_proxy_options(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
674
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
675 gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), GTK_RESPONSE_APPLY,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
676 sensitive);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
677 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
678
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
679 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
680 pidgin_account_editor_login_options_update_editable(PidginAccountEditor *editor)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
681 {
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
682 PidginProtocolChooser *chooser = NULL;
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
683 PurpleProtocol *selected_protocol = NULL;
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
684 PurpleProtocolOptions options;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
685 gboolean editable = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
686
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
687 chooser = PIDGIN_PROTOCOL_CHOOSER(editor->protocol);
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
688 selected_protocol = pidgin_protocol_chooser_get_protocol(chooser);
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
689
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
690 if(PURPLE_IS_ACCOUNT(editor->account)) {
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
691 PurpleConnection *connection = NULL;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
692
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
693 connection = purple_account_get_connection(editor->account);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
694
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
695 /* If we have an active connection, we need to disable everything
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
696 * related to the protocol and username.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
697 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
698 if(PURPLE_IS_CONNECTION(connection)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
699 PurpleProtocol *connected_protocol = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
700 editable = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
701
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
702 /* Check if the user changed the protocol. If they did, switch it
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
703 * back and update the editor to reflect what settings are active.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
704 */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
705 connected_protocol = purple_connection_get_protocol(connection);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
706
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
707 if(connected_protocol != selected_protocol) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
708 pidgin_protocol_chooser_set_protocol(chooser, connected_protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
709 pidgin_account_editor_update(editor);
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
710 selected_protocol = connected_protocol;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
711 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
712 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
713 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
714
41779
4e2314e70a03 Fix warnings when adding new account
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41776
diff changeset
715 options = purple_protocol_get_options(selected_protocol);
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
716 gtk_widget_set_visible(editor->require_password_row,
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
717 options & OPT_PROTO_PASSWORD_OPTIONAL);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
718
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
719 gtk_widget_set_sensitive(editor->protocol, editable);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
720 gtk_editable_set_editable(GTK_EDITABLE(editor->username), editable);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
721 for(GList *l = editor->user_split_entries; l != NULL; l = l->next) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
722 GtkWidget *widget = l->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
723
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
724 gtk_editable_set_editable(GTK_EDITABLE(widget), editable);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
725 }
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
726 gtk_widget_set_sensitive(editor->require_password, editable);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
727 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
728
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
729 static void
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
730 pidgin_account_editor_set_account(PidginAccountEditor *editor,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
731 PurpleAccount *account)
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
732 {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
733 if(g_set_object(&editor->account, account)) {
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
734 if(PURPLE_IS_ACCOUNT(account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
735 g_signal_connect(account, "notify::connection",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
736 G_CALLBACK(pidgin_account_editor_connection_changed_cb),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
737 editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
738 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
739
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
740 g_object_notify_by_pspec(G_OBJECT(editor), properties[PROP_ACCOUNT]);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
741 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
742
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
743 pidgin_account_editor_update(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
744 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
745
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
746 static gboolean
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
747 pidgin_account_editor_save_login_options(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
748 PurpleProtocol *protocol = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
749 GList *split_item = NULL, *entry_item = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
750 GString *username = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
751 const gchar *protocol_id = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
752 gboolean new_account = FALSE;
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
753 gboolean require_password = FALSE;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
754
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
755 protocol = pidgin_protocol_chooser_get_protocol(PIDGIN_PROTOCOL_CHOOSER(editor->protocol));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
756 protocol_id = purple_protocol_get_id(protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
757
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
758 username = g_string_new(gtk_editable_get_text(GTK_EDITABLE(editor->username)));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
759
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
760 split_item = purple_protocol_get_user_splits(protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
761 entry_item = editor->user_split_entries;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
762 while(split_item != NULL && entry_item != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
763 PurpleAccountUserSplit *split = split_item->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
764 GtkEntry *entry = entry_item->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
765 const gchar *value = "";
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
766 gchar sep = '\0';
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
767
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
768 sep = purple_account_user_split_get_separator(split);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
769 g_string_append_c(username, sep);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
770
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
771 if(GTK_IS_ENTRY(entry)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
772 value = gtk_editable_get_text(GTK_EDITABLE(entry));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
773 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
774
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
775 if(value == NULL || *value == '\0') {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
776 value = purple_account_user_split_get_default_value(split);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
777 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
778
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
779 g_string_append(username, value);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
780
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
781 split_item = split_item->next;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
782 entry_item = entry_item->next;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
783 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
784
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
785 if(!PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
786 editor->account = purple_account_new(username->str, protocol_id);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
787 new_account = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
788 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
789 purple_account_set_username(editor->account, username->str);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
790 purple_account_set_protocol_id(editor->account, protocol_id);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
791 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
792
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
793 g_string_free(username, TRUE);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
794
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
795 require_password = gtk_switch_get_active(GTK_SWITCH(editor->require_password));
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
796 purple_account_set_require_password(editor->account, require_password);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
797
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
798 return new_account;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
799 }
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
800
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
801 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
802 pidgin_account_editor_save_user_options(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
803 const gchar *svalue = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
804 gboolean bvalue = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
805
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
806 /* Set the alias. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
807 svalue = gtk_editable_get_text(GTK_EDITABLE(editor->alias));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
808 if(*svalue == '\0') {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
809 svalue = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
810 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
811 purple_account_set_private_alias(editor->account, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
812
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
813 /* Set whether or not to use the global avatar. */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
814 bvalue = gtk_switch_get_active(GTK_SWITCH(editor->use_custom_avatar));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
815 purple_account_set_bool(editor->account, "use-global-buddyicon", !bvalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
816
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
817 if(bvalue) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
818 if(GDK_IS_PIXBUF(editor->avatar_pixbuf)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
819 # warning implement this when buddy icons do not suck so bad.
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
820 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
821 purple_buddy_icons_set_account_icon(editor->account, NULL, 0);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
822 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
823 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
824 # warning set the global buddy icon when buddy icons do not suck so bad.
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
825 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
826 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
827
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
828 static void
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
829 pidgin_account_editor_save_advanced_options(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
830 for(GList *l = editor->advanced_entries; l != NULL; l = l->next) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
831 GtkWidget *widget = l->data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
832 PurpleAccountOption *option = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
833 GList *keys = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
834 const gchar *setting = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
835 const gchar *svalue = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
836 gboolean bvalue = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
837 gint ivalue = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
838 guint selected = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
839
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
840 option = g_object_get_data(G_OBJECT(widget), "option");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
841 setting = purple_account_option_get_setting(option);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
842
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
843 switch(purple_account_option_get_pref_type(option)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
844 case PURPLE_PREF_STRING:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
845 svalue = gtk_editable_get_text(GTK_EDITABLE(widget));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
846 purple_account_set_string(editor->account, setting, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
847 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
848 case PURPLE_PREF_INT:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
849 svalue = gtk_editable_get_text(GTK_EDITABLE(widget));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
850 ivalue = atoi(svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
851 purple_account_set_int(editor->account, setting, ivalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
852 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
853 case PURPLE_PREF_BOOLEAN:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
854 bvalue = gtk_switch_get_active(GTK_SWITCH(widget));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
855 purple_account_set_bool(editor->account, setting, bvalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
856 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
857 case PURPLE_PREF_STRING_LIST:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
858 keys = g_object_get_data(G_OBJECT(widget), "keys");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
859 selected = adw_combo_row_get_selected(ADW_COMBO_ROW(widget));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
860 svalue = g_list_nth_data(keys, selected);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
861 purple_account_set_string(editor->account, setting, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
862 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
863 default:
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
864 break;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
865 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
866 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
867 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
868
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
869 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
870 pidgin_account_editor_save_proxy(PidginAccountEditor *editor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
871 gboolean new_account)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
872 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
873 PurpleProxyInfo *info = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
874 PurpleProxyType type = PURPLE_PROXY_TYPE_NONE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
875 GObject *item = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
876 const gchar *svalue = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
877 gint ivalue = 0;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
878
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
879 /* Build the ProxyInfo object */
41816
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
880 if(!new_account) {
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
881 info = purple_account_get_proxy_info(editor->account);
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
882 }
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
883
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
884 /* If this is a new account, or the account's proxy info is null, create a
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
885 * new instance, and set it on the account.
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
886 */
f6baa88826a7 Fix a bunch of g_warnings in the account editor
Gary Kramlich <grim@reaperworld.com>
parents: 41780
diff changeset
887 if(new_account || !PURPLE_IS_PROXY_INFO(info)) {
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
888 info = purple_proxy_info_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
889 purple_account_set_proxy_info(editor->account, info);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
890 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
891
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
892 item = adw_combo_row_get_selected_item(ADW_COMBO_ROW(editor->proxy_type));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
893 svalue = gtk_string_object_get_string(GTK_STRING_OBJECT(item));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
894 if(purple_strequal(svalue, "global")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
895 type = PURPLE_PROXY_TYPE_USE_GLOBAL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
896 } else if(purple_strequal(svalue, "none")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
897 type = PURPLE_PROXY_TYPE_NONE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
898 } else if(purple_strequal(svalue, "socks4")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
899 type = PURPLE_PROXY_TYPE_SOCKS4;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
900 } else if(purple_strequal(svalue, "socks5")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
901 type = PURPLE_PROXY_TYPE_SOCKS5;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
902 } else if(purple_strequal(svalue, "tor")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
903 type = PURPLE_PROXY_TYPE_TOR;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
904 } else if(purple_strequal(svalue, "http")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
905 type = PURPLE_PROXY_TYPE_HTTP;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
906 } else if(purple_strequal(svalue, "envvar")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
907 type = PURPLE_PROXY_TYPE_USE_ENVVAR;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
908 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
909 purple_proxy_info_set_proxy_type(info, type);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
910
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
911 svalue = gtk_editable_get_text(GTK_EDITABLE(editor->proxy_host));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
912 purple_proxy_info_set_hostname(info, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
913
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
914 ivalue = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(editor->proxy_port));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
915 purple_proxy_info_set_port(info, ivalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
916
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
917 svalue = gtk_editable_get_text(GTK_EDITABLE(editor->proxy_username));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
918 purple_proxy_info_set_username(info, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
919
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
920 svalue = gtk_editable_get_text(GTK_EDITABLE(editor->proxy_password));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
921 purple_proxy_info_set_password(info, svalue);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
922 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
923
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
924 static void
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
925 pidgin_account_editor_save_account(PidginAccountEditor *editor) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
926 gboolean new_account = FALSE;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
927
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
928 new_account = pidgin_account_editor_save_login_options(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
929 pidgin_account_editor_save_user_options(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
930 pidgin_account_editor_save_advanced_options(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
931 pidgin_account_editor_save_proxy(editor, new_account);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
932
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
933 /* If this is a new account, add it to the account manager and bring it
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
934 * online.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
935 */
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
936 if(new_account) {
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
937 PurpleAccountManager *manager = NULL;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
938 const PurpleSavedStatus *saved_status;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
939
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
940 manager = purple_account_manager_get_default();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
941
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
942 purple_account_manager_add(manager, editor->account);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
943
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
944 saved_status = purple_savedstatus_get_current();
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
945 if (saved_status != NULL) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
946 purple_savedstatus_activate_for_account(saved_status,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
947 editor->account);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
948 purple_account_set_enabled(editor->account, TRUE);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
949 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
950 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
951 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
952
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
953 /******************************************************************************
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
954 * Callbacks
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
955 *****************************************************************************/
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
956 static void
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
957 pidgin_account_editor_connection_changed_cb(G_GNUC_UNUSED GObject *obj,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
958 G_GNUC_UNUSED GParamSpec *pspec,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
959 gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
960 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
961 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
962
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
963 pidgin_account_editor_login_options_update_editable(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
964 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
965
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
966 static void
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
967 pidgin_account_editor_response_cb(GtkDialog *dialog, gint response_id,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
968 G_GNUC_UNUSED gpointer data)
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
969 {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
970 if(response_id == GTK_RESPONSE_APPLY) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
971 pidgin_account_editor_save_account(PIDGIN_ACCOUNT_EDITOR(dialog));
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
972 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
973
41560
2579a5138f0c A bunch of random fixes for the the gtk4 branch
Gary Kramlich <grim@reaperworld.com>
parents: 41483
diff changeset
974 gtk_window_destroy(GTK_WINDOW(dialog));
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
975 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
976
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
977 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
978 pidgin_account_editor_protocol_changed_cb(G_GNUC_UNUSED GObject *obj,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
979 G_GNUC_UNUSED GParamSpec *pspec,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
980 gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
981 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
982 pidgin_account_editor_update(data);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
983 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
984
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
985 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
986 pidgin_account_editor_username_changed_cb(GtkEditable *self, gpointer data) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
987 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
988 const gchar *text = gtk_editable_get_text(self);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
989 gboolean sensitive = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
990
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
991 if(text != NULL && *text != '\0') {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
992 sensitive = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
993 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
994
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
995 gtk_dialog_set_response_sensitive(GTK_DIALOG(editor), GTK_RESPONSE_APPLY,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
996 sensitive);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
997 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
998
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
999 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1000 pidgin_account_editor_avatar_response_cb(GtkNativeDialog *self,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1001 gint response_id, gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1002 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1003 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1004
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1005 if(response_id == GTK_RESPONSE_ACCEPT) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1006 GError *error = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1007 GFile *file = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1008 gchar *filename = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1009
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1010 file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(self));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1011 filename = g_file_get_path(file);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1012
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1013 g_clear_object(&editor->avatar_pixbuf);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1014 editor->avatar_pixbuf = gdk_pixbuf_new_from_file(filename, &error);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1015 if(error != NULL) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1016 g_warning("Failed to create pixbuf from file %s: %s", filename,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1017 error->message);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1018 g_clear_error(&error);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1019 } else {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1020 gtk_image_set_from_pixbuf(GTK_IMAGE(editor->avatar),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1021 editor->avatar_pixbuf);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1022 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1023
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1024 g_free(filename);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1025 g_object_unref(file);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1026 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1027
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1028 g_clear_object(&editor->avatar_dialog);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1029 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1030
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1031 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1032 pidgin_account_editor_avatar_set_clicked_cb(G_GNUC_UNUSED GtkButton *self,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1033 gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1034 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1035 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1036
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1037 editor->avatar_dialog = gtk_file_chooser_native_new(_("Buddy Icon"),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1038 GTK_WINDOW(editor),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1039 GTK_FILE_CHOOSER_ACTION_OPEN,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1040 _("_Open"),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1041 _("_Cancel"));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1042 gtk_native_dialog_set_transient_for(GTK_NATIVE_DIALOG(editor->avatar_dialog),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1043 GTK_WINDOW(editor));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1044
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1045 g_signal_connect(G_OBJECT(editor->avatar_dialog), "response",
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1046 G_CALLBACK(pidgin_account_editor_avatar_response_cb),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1047 editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1048
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1049 gtk_native_dialog_show(GTK_NATIVE_DIALOG(editor->avatar_dialog));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1050 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1051
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1052 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1053 pidgin_account_editor_avatar_remove_clicked_cb(G_GNUC_UNUSED GtkButton *self,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1054 gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1055 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1056 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1057
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1058 gtk_image_set_from_icon_name(GTK_IMAGE(editor->avatar), "select-avatar");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1059
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1060 g_clear_object(&editor->avatar_pixbuf);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1061 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1062
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1063 static gchar *
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1064 pidgin_account_editor_proxy_type_expression_cb(GObject *self,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1065 G_GNUC_UNUSED gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1066 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1067 const gchar *text = "";
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1068 const gchar *value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1069
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1070 value = gtk_string_object_get_string(GTK_STRING_OBJECT(self));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1071 if(purple_strequal(value, "global")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1072 text = _("Use Global Proxy Settings");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1073 } else if(purple_strequal(value, "none")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1074 text = _("No proxy");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1075 } else if(purple_strequal(value, "socks4")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1076 text = _("SOCKS 4");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1077 } else if(purple_strequal(value, "socks5")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1078 text = _("SOCKS 5");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1079 } else if(purple_strequal(value, "tor")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1080 text = _("Tor/Privacy (SOCKS 5)");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1081 } else if(purple_strequal(value, "http")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1082 text = _("HTTP");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1083 } else if(purple_strequal(value, "envvar")) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1084 text = _("Use Environmental Settings");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1085 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1086
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1087 return g_strdup(text);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1088 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1089
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1090 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1091 pidgin_account_editor_proxy_type_changed_cb(G_GNUC_UNUSED GObject *obj,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1092 G_GNUC_UNUSED GParamSpec *pspec,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1093 gpointer data)
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1094 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1095 PidginAccountEditor *editor = data;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1096 GObject *selected = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1097 gboolean show_options = TRUE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1098 const gchar *value = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1099
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1100 selected = adw_combo_row_get_selected_item(ADW_COMBO_ROW(editor->proxy_type));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1101 value = gtk_string_object_get_string(GTK_STRING_OBJECT(selected));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1102
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1103 if(purple_strequal(value, "global") || purple_strequal(value, "none") ||
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1104 purple_strequal(value, "envvar"))
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1105 {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1106 show_options = FALSE;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1107 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1108
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1109 gtk_widget_set_visible(editor->proxy_options, show_options);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1110 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1111
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1112 /******************************************************************************
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1113 * GObject Implementation
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1114 *****************************************************************************/
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1115 G_DEFINE_TYPE(PidginAccountEditor, pidgin_account_editor, GTK_TYPE_DIALOG)
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1116
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1117 static void
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1118 pidgin_account_editor_get_property(GObject *obj, guint param_id, GValue *value,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1119 GParamSpec *pspec)
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1120 {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1121 PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1122
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1123 switch(param_id) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1124 case PROP_ACCOUNT:
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1125 g_value_set_object(value,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1126 pidgin_account_editor_get_account(editor));
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1127 break;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1128 default:
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1129 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1130 break;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1131 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1132 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1133
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1134 static void
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1135 pidgin_account_editor_set_property(GObject *obj, guint param_id,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1136 const GValue *value, GParamSpec *pspec)
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1137 {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1138 PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1139
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1140 switch(param_id) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1141 case PROP_ACCOUNT:
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1142 pidgin_account_editor_set_account(editor,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1143 g_value_get_object(value));
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1144 break;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1145 default:
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1146 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1147 break;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1148 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1149 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1150
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1151 static void
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1152 pidgin_account_editor_dispose(GObject *obj) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1153 PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1154
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1155 g_clear_object(&editor->account);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1156 g_clear_object(&editor->avatar_dialog);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1157 g_clear_object(&editor->avatar_pixbuf);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1158
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1159 G_OBJECT_CLASS(pidgin_account_editor_parent_class)->dispose(obj);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1160 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1161
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1162 static void
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1163 pidgin_account_editor_init(PidginAccountEditor *editor) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1164 GtkCssProvider *css_provider = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1165 GtkStyleContext *context = NULL;
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1166 GtkWidget *widget = GTK_WIDGET(editor);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1167
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1168 gtk_widget_init_template(widget);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1169
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1170 css_provider = gtk_css_provider_new();
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1171 gtk_css_provider_load_from_resource(css_provider,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1172 "/im/pidgin/Pidgin3/Accounts/entry.css");
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1173
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1174 context = gtk_widget_get_style_context(GTK_WIDGET(editor));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1175 gtk_style_context_add_provider(context,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1176 GTK_STYLE_PROVIDER(css_provider),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1177 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1178
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1179 g_clear_object(&css_provider);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1180
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1181 pidgin_account_editor_proxy_type_changed_cb(NULL, NULL, editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1182 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1183
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1184 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1185 pidgin_account_editor_constructed(GObject *obj) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1186 PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1187
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1188 G_OBJECT_CLASS(pidgin_account_editor_parent_class)->constructed(obj);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1189
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1190 if(PURPLE_IS_ACCOUNT(editor->account)) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1191 pidgin_protocol_chooser_set_protocol(PIDGIN_PROTOCOL_CHOOSER(editor->protocol),
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1192 purple_account_get_protocol(editor->account));
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1193 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1194
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1195 pidgin_account_editor_update(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1196 pidgin_account_editor_login_options_update_editable(editor);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1197 }
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1198
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1199 static void
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1200 pidgin_account_editor_finalize(GObject *obj) {
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1201 PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1202
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1203 g_clear_pointer(&editor->user_split_entries, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1204 g_clear_pointer(&editor->user_split_rows, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1205
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1206 g_clear_pointer(&editor->advanced_entries, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1207 g_clear_pointer(&editor->advanced_rows, g_list_free);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1208
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1209 G_OBJECT_CLASS(pidgin_account_editor_parent_class)->finalize(obj);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1210 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1211
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1212 static void
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1213 pidgin_account_editor_class_init(PidginAccountEditorClass *klass) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1214 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1215 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1216
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1217 obj_class->get_property = pidgin_account_editor_get_property;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1218 obj_class->set_property = pidgin_account_editor_set_property;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1219 obj_class->constructed = pidgin_account_editor_constructed;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1220 obj_class->dispose = pidgin_account_editor_dispose;
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1221 obj_class->finalize = pidgin_account_editor_finalize;
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1222
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1223 /**
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1224 * PidginAccountEditor::account:
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1225 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1226 * The account that this editor is modifying.
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1227 *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1228 * Since: 3.0.0
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1229 */
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1230 properties[PROP_ACCOUNT] = g_param_spec_object(
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1231 "account", "account",
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1232 "The account to modify",
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1233 PURPLE_TYPE_ACCOUNT,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1234 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1235
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1236 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1237
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1238 gtk_widget_class_set_template_from_resource(widget_class,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1239 "/im/pidgin/Pidgin3/Accounts/editor.ui");
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1240
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1241 /* Dialog */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1242 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1243 pidgin_account_editor_response_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1244
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1245 /* Login Options */
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1246 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1247 login_options);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1248 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1249 protocol);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1250 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1251 username);
41776
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1252 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1253 user_splits);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1254 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1255 require_password_row);
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1256 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
3dc254c25eeb Add the require password option to PidginAccountEditor
Gary Kramlich <grim@reaperworld.com>
parents: 41688
diff changeset
1257 require_password);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1258
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1259 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1260 pidgin_account_editor_protocol_changed_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1261 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1262 pidgin_account_editor_username_changed_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1263
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1264 /* User Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1265 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1266 alias);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1267 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1268 avatar_row);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1269 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1270 use_custom_avatar);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1271 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1272 avatar);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1273
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1274 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1275 pidgin_account_editor_avatar_set_clicked_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1276 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1277 pidgin_account_editor_avatar_remove_clicked_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1278
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1279 /* Advanced Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1280 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1281 advanced_group);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1282 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1283 advanced_toggle);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1284
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1285 /* Proxy Options */
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1286 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1287 proxy_type);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1288 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1289 proxy_options);
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1290 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1291 proxy_host);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1292 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1293 proxy_port);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1294 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1295 proxy_username);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1296 gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1297 proxy_password);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1298
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1299 gtk_widget_class_bind_template_callback(widget_class,
41688
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1300 pidgin_account_editor_proxy_type_expression_cb);
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1301 gtk_widget_class_bind_template_callback(widget_class,
6ccdb4116ca2 Modernize the AccountEditor.
Gary Kramlich <grim@reaperworld.com>
parents: 41560
diff changeset
1302 pidgin_account_editor_proxy_type_changed_cb);
41483
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1303 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1304
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1305 /******************************************************************************
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1306 * API
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1307 *****************************************************************************/
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1308 GtkWidget *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1309 pidgin_account_editor_new(PurpleAccount *account) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1310 return g_object_new(PIDGIN_TYPE_ACCOUNT_EDITOR, "account", account, NULL);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1311 }
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1312
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1313 PurpleAccount *
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1314 pidgin_account_editor_get_account(PidginAccountEditor *editor) {
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1315 g_return_val_if_fail(PIDGIN_IS_ACCOUNT_EDITOR(editor), NULL);
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1316
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1317 return editor->account;
e3bd18c1769d The start of the new account editor.
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1318 }

mercurial