# HG changeset patch
# Node ID a629b967f2d6
# Parent c51a28d28a2d
diff --git a/pidgin/glade/pidgin3.xml.in b/pidgin/glade/pidgin3.xml.in
--- a/pidgin/glade/pidgin3.xml.in
+++ b/pidgin/glade/pidgin3.xml.in
@@ -17,6 +17,7 @@
+
@@ -39,6 +40,7 @@
+
diff --git a/pidgin/meson.build b/pidgin/meson.build
--- a/pidgin/meson.build
+++ b/pidgin/meson.build
@@ -19,6 +19,7 @@
'minidialog.c',
'pidginabout.c',
'pidginaccountchooser.c',
+ 'pidginaccounteditor.c',
'pidginaccountfilterconnected.c',
'pidginaccountfilterprotocol.c',
'pidginaccountmanager.c',
@@ -93,6 +94,7 @@
'minidialog.h',
'pidginabout.h',
'pidginaccountchooser.h',
+ 'pidginaccounteditor.h',
'pidginaccountfilterconnected.h',
'pidginaccountfilterprotocol.h',
'pidginaccountmanager.h',
diff --git a/pidgin/pidginaccounteditor.h b/pidgin/pidginaccounteditor.h
new file mode 100644
--- /dev/null
+++ b/pidgin/pidginaccounteditor.h
@@ -0,0 +1,75 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#if !defined(PIDGIN_GLOBAL_HEADER_INSIDE) && !defined(PIDGIN_COMPILATION)
+# error "only may be included directly"
+#endif
+
+#ifndef PIDGIN_ACCOUNT_EDITOR_H
+#define PIDGIN_ACCOUNT_EDITOR_H
+
+#include
+
+#include
+
+/**
+ * PidginAccountEditor:
+ *
+ * #PidginAccountEditor is a dialog that allows you to edit an account.
+ *
+ * Since: 3.0.0
+ */
+
+G_BEGIN_DECLS
+
+#define PIDGIN_TYPE_ACCOUNT_EDITOR pidgin_account_editor_get_type()
+G_DECLARE_FINAL_TYPE(PidginAccountEditor, pidgin_account_editor, PIDGIN,
+ ACCOUNT_EDITOR, GtkDialog)
+
+/**
+ * pidgin_account_editor_new:
+ * @account: (nullable): The [class@Purple.Account] to edit.
+ *
+ * Creates a new #PidginAccountEditor for @account. If @account is %NULL, the
+ * editor will create a new account.
+ *
+ * Returns: (transfer full): The new instance.
+ *
+ * Since: 3.0.0
+ */
+GtkWidget *pidgin_account_editor_new(PurpleAccount *account);
+
+/**
+ * pidgin_account_editor_get_account:
+ * @editor: The instance.
+ *
+ * Gets the [class@Purple.Account] that @editor is modifying.
+ *
+ * Returns: (transfer none): The [class@Purple.Account] or %NULL.
+ *
+ * Since: 3.0.0
+ */
+PurpleAccount *pidgin_account_editor_get_account(PidginAccountEditor *editor);
+
+G_END_DECLS
+
+#endif /* PIDGIN_ACCOUNT_EDITOR_H */
diff --git a/pidgin/pidginaccounteditor.c b/pidgin/pidginaccounteditor.c
new file mode 100644
--- /dev/null
+++ b/pidgin/pidginaccounteditor.c
@@ -0,0 +1,217 @@
+/*
+ * Pidgin - Internet Messenger
+ * Copyright (C) Pidgin Developers
+ *
+ * Pidgin is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include
+
+#include "pidginaccounteditor.h"
+
+#include "pidginproxyoptions.h"
+
+struct _PidginAccountEditor {
+ GtkDialog parent;
+
+ PurpleAccount *account;
+
+ GtkWidget *notebook;
+ GtkWidget *proxy_options;
+};
+
+enum {
+ PROP_0,
+ PROP_ACCOUNT,
+ N_PROPERTIES,
+};
+static GParamSpec *properties[N_PROPERTIES] = {NULL, };
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static void
+pidgin_account_editor_set_account(PidginAccountEditor *editor,
+ PurpleAccount *account)
+{
+ if(g_set_object(&editor->account, account)) {
+ PurpleProxyInfo *proxy_info = NULL;
+
+ if(PURPLE_IS_ACCOUNT(account)) {
+ proxy_info = purple_account_get_proxy_info(account);
+ }
+
+ pidgin_proxy_options_set_info(PIDGIN_PROXY_OPTIONS(editor->proxy_options),
+ proxy_info);
+
+ g_object_notify_by_pspec(G_OBJECT(editor), properties[PROP_ACCOUNT]);
+ }
+}
+
+static void
+pidgin_account_editor_save_account(PidginAccountEditor *editor) {
+ PurpleAccountManager *manager = NULL;
+ PurpleProxyInfo *info = NULL;
+ gboolean new_account = FALSE;
+
+ manager = purple_account_manager_get_default();
+
+ if(!PURPLE_IS_ACCOUNT(editor->account)) {
+ editor->account = purple_account_new("undefined", "undefined");
+ new_account = TRUE;
+ }
+
+ info = pidgin_proxy_options_get_info(PIDGIN_PROXY_OPTIONS(editor->proxy_options));
+ purple_account_set_proxy_info(editor->account, info);
+
+ /* If this is a new account, add it to the account manager and bring it
+ * online.
+ */
+ if(new_account) {
+ const PurpleSavedStatus *saved_status;
+
+ purple_account_manager_add(manager, editor->account);
+
+ saved_status = purple_savedstatus_get_current();
+ if (saved_status != NULL) {
+ purple_savedstatus_activate_for_account(saved_status,
+ editor->account);
+ purple_account_set_enabled(editor->account, TRUE);
+ }
+ }
+}
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static void
+pidgin_account_editor_response_cb(GtkDialog *dialog, gint response_id,
+ G_GNUC_UNUSED gpointer data)
+{
+ if(response_id == GTK_RESPONSE_APPLY) {
+ pidgin_account_editor_save_account(PIDGIN_ACCOUNT_EDITOR(dialog));
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(dialog));
+}
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+G_DEFINE_TYPE(PidginAccountEditor, pidgin_account_editor, GTK_TYPE_DIALOG)
+
+static void
+pidgin_account_editor_get_property(GObject *obj, guint param_id, GValue *value,
+ GParamSpec *pspec)
+{
+ PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
+
+ switch(param_id) {
+ case PROP_ACCOUNT:
+ g_value_set_object(value,
+ pidgin_account_editor_get_account(editor));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+pidgin_account_editor_set_property(GObject *obj, guint param_id,
+ const GValue *value, GParamSpec *pspec)
+{
+ PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
+
+ switch(param_id) {
+ case PROP_ACCOUNT:
+ pidgin_account_editor_set_account(editor,
+ g_value_get_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
+ break;
+ }
+}
+
+static void
+pidgin_account_editor_dispose(GObject *obj) {
+ PidginAccountEditor *editor = PIDGIN_ACCOUNT_EDITOR(obj);
+
+ g_clear_object(&editor->account);
+
+ G_OBJECT_CLASS(pidgin_account_editor_parent_class)->dispose(obj);
+}
+
+static void
+pidgin_account_editor_init(PidginAccountEditor *account_editor) {
+ GtkWidget *widget = GTK_WIDGET(account_editor);
+
+ gtk_widget_init_template(widget);
+}
+
+static void
+pidgin_account_editor_class_init(PidginAccountEditorClass *klass) {
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+ GObjectClass *obj_class = G_OBJECT_CLASS(klass);
+
+ obj_class->get_property = pidgin_account_editor_get_property;
+ obj_class->set_property = pidgin_account_editor_set_property;
+ obj_class->dispose = pidgin_account_editor_dispose;
+
+ /**
+ * PidginAccountEditor::account:
+ *
+ * The account that this editor is modifying.
+ *
+ * Since: 3.0.0
+ */
+ properties[PROP_ACCOUNT] = g_param_spec_object(
+ "account", "account",
+ "The account to modify",
+ PURPLE_TYPE_ACCOUNT,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+
+ g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
+
+ gtk_widget_class_set_template_from_resource(widget_class,
+ "/im/pidgin/Pidgin3/Accounts/editor.ui");
+
+ gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
+ notebook);
+ gtk_widget_class_bind_template_child(widget_class, PidginAccountEditor,
+ proxy_options);
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ pidgin_account_editor_response_cb);
+}
+
+/******************************************************************************
+ * API
+ *****************************************************************************/
+GtkWidget *
+pidgin_account_editor_new(PurpleAccount *account) {
+ return g_object_new(PIDGIN_TYPE_ACCOUNT_EDITOR, "account", account, NULL);
+}
+
+PurpleAccount *
+pidgin_account_editor_get_account(PidginAccountEditor *editor) {
+ g_return_val_if_fail(PIDGIN_IS_ACCOUNT_EDITOR(editor), NULL);
+
+ return editor->account;
+}
diff --git a/pidgin/pidginaccountmanager.c b/pidgin/pidginaccountmanager.c
--- a/pidgin/pidginaccountmanager.c
+++ b/pidgin/pidginaccountmanager.c
@@ -28,6 +28,7 @@
#include "gtkaccount.h"
#include "pidgincore.h"
+#include "pidginaccounteditor.h"
struct _PidginAccountManager {
GtkDialog parent;
@@ -42,7 +43,9 @@
enum {
RESPONSE_ADD,
RESPONSE_MODIFY,
- RESPONSE_REMOVE
+ RESPONSE_REMOVE,
+ RESPONSE_ADD_OLD,
+ RESPONSE_MODIFY_OLD
};
enum {
@@ -209,14 +212,27 @@
{
PidginAccountManager *manager = PIDGIN_ACCOUNT_MANAGER(dialog);
PurpleAccount *account = NULL;
+ GtkWidget *editor = NULL;
switch(response_id) {
case RESPONSE_ADD:
+ editor = pidgin_account_editor_new(NULL);
+ gtk_widget_show_all(editor);
+ break;
+ case RESPONSE_ADD_OLD:
pidgin_account_dialog_show(PIDGIN_ADD_ACCOUNT_DIALOG, NULL);
break;
case RESPONSE_MODIFY:
account = pidgin_account_manager_get_selected_account(manager);
+ editor = pidgin_account_editor_new(account);
+ gtk_widget_show_all(editor);
+
+ g_clear_object(&account);
+ break;
+ case RESPONSE_MODIFY_OLD:
+ account = pidgin_account_manager_get_selected_account(manager);
+
pidgin_account_dialog_show(PIDGIN_MODIFY_ACCOUNT_DIALOG, account);
g_clear_object(&account);
diff --git a/pidgin/pidginproxyoptions.h b/pidgin/pidginproxyoptions.h
--- a/pidgin/pidginproxyoptions.h
+++ b/pidgin/pidginproxyoptions.h
@@ -95,7 +95,7 @@
/**
* pidgin_proxy_options_set_info:
* @options: The instance.
- * @info: The [class@Purple.ProxyInfo] to set.
+ * @info: (nullable): The [class@Purple.ProxyInfo] to set.
*
* The proxy info that will be configured.
*
diff --git a/pidgin/resources/Accounts/editor.ui b/pidgin/resources/Accounts/editor.ui
new file mode 100644
--- /dev/null
+++ b/pidgin/resources/Accounts/editor.ui
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+ False
+ dialog
+
+
+
+
+
+ button1
+ button2
+
+
+
diff --git a/pidgin/resources/Accounts/manager.ui b/pidgin/resources/Accounts/manager.ui
--- a/pidgin/resources/Accounts/manager.ui
+++ b/pidgin/resources/Accounts/manager.ui
@@ -16,6 +16,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, see .
+
-->
@@ -56,6 +57,42 @@
False
end
+
+ τ
+ True
+ True
+ True
+
+
+
+ True
+ True
+ 0
+ True
+
+
+
+
+ π
+ True
+ True
+ False
+ True
+ none
+
+
+
+ True
+ True
+ 1
+ True
+
+
+
_Add...
True
@@ -66,7 +103,7 @@
True
True
- 0
+ 2
@@ -81,7 +118,7 @@
True
True
- 1
+ 3
@@ -96,7 +133,7 @@
True
True
- 2
+ 4
@@ -110,7 +147,7 @@
True
True
- 3
+ 5
@@ -197,8 +234,10 @@
- button3
- modify_button
+ button1
+ praetorians
+ button3
+ modify_button
remove_button
button2
diff --git a/pidgin/resources/pidgin.gresource.xml b/pidgin/resources/pidgin.gresource.xml
--- a/pidgin/resources/pidgin.gresource.xml
+++ b/pidgin/resources/pidgin.gresource.xml
@@ -6,6 +6,7 @@
About/about.md
About/credits.json
Accounts/chooser.ui
+ Accounts/editor.ui
Accounts/entry.css
Accounts/manager.ui
Avatar/avatar.ui
diff --git a/po/POTFILES.in b/po/POTFILES.in
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -335,6 +335,7 @@
pidgin/minidialog.c
pidgin/pidginabout.c
pidgin/pidginaccountchooser.c
+pidgin/pidginaccounteditor.c
pidgin/pidginaccountfilterconnected.c
pidgin/pidginaccountfilterprotocol.c
pidgin/pidginaccountmanager.c
@@ -397,6 +398,7 @@
pidgin/prefs/pidginvvprefs.c
pidgin/resources/About/about.ui
pidgin/resources/Accounts/chooser.ui
+pidgin/resources/Accounts/editor.ui
pidgin/resources/Accounts/manager.ui
pidgin/resources/Avatar/avatar.ui
pidgin/resources/Avatar/menu.ui