aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-21 23:56:22 +0800
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>2009-07-22 00:28:00 +0800
commit9c3db97dcf9bd237784d401ae3215326a1d77ae2 (patch)
tree3a850ae3a46e2052a515a3061b8450533c8682e2 /libempathy-gtk
parentaeb06b95274c6c22501c752b9fb8864af6f1bc29 (diff)
downloadgsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar.gz
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar.bz2
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar.lz
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar.xz
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.tar.zst
gsoc2013-empathy-9c3db97dcf9bd237784d401ae3215326a1d77ae2.zip
Port to using EmpathyAccountSettings
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.c61
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.h4
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.c22
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.h4
-rw-r--r--libempathy-gtk/empathy-account-widget.c264
-rw-r--r--libempathy-gtk/empathy-account-widget.h25
6 files changed, 223 insertions, 157 deletions
diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c
index b2383a02a..ae41f1e39 100644
--- a/libempathy-gtk/empathy-account-widget-irc.c
+++ b/libempathy-gtk/empathy-account-widget-irc.c
@@ -41,7 +41,7 @@
#define IRC_NETWORKS_FILENAME "irc-networks.xml"
typedef struct {
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
EmpathyIrcNetworkManager *network_manager;
GtkWidget *vbox_settings;
@@ -59,7 +59,7 @@ account_widget_irc_destroy_cb (GtkWidget *widget,
EmpathyAccountWidgetIrc *settings)
{
g_object_unref (settings->network_manager);
- g_object_unref (settings->account);
+ g_object_unref (settings->settings);
g_slice_free (EmpathyAccountWidgetIrc, settings);
}
@@ -67,9 +67,9 @@ static void
unset_server_params (EmpathyAccountWidgetIrc *settings)
{
DEBUG ("Unset server, port and use-ssl");
- empathy_account_unset_param (settings->account, "server");
- empathy_account_unset_param (settings->account, "port");
- empathy_account_unset_param (settings->account, "use-ssl");
+ empathy_account_settings_unset (settings->settings, "server");
+ empathy_account_settings_unset (settings->settings, "port");
+ empathy_account_settings_unset (settings->settings, "use-ssl");
}
static void
@@ -95,7 +95,7 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
g_object_get (network, "charset", &charset, NULL);
DEBUG ("Setting charset to %s", charset);
- empathy_account_set_param_string (settings->account, "charset", charset);
+ empathy_account_settings_set_string (settings->settings, "charset", charset);
g_free (charset);
servers = empathy_irc_network_get_servers (network);
@@ -114,11 +114,13 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
NULL);
DEBUG ("Setting server to %s", address);
- empathy_account_set_param_string (settings->account, "server", address);
+ empathy_account_settings_set_string (settings->settings,
+ "server", address);
DEBUG ("Setting port to %u", port);
- empathy_account_set_param_int (settings->account, "port", port);
+ empathy_account_settings_set_uint32 (settings->settings, "port", port);
DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
- empathy_account_set_param_boolean (settings->account, "use-ssl", ssl);
+ empathy_account_settings_set_boolean (settings->settings,
+ "use-ssl", ssl);
g_free (address);
}
@@ -329,17 +331,19 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
gboolean ssl = FALSE;
EmpathyIrcNetwork *network = NULL;
- nick = empathy_account_get_param_string (settings->account, "account");
- fullname = empathy_account_get_param_string (settings->account, "fullname");
- server = empathy_account_get_param_string (settings->account, "server");
- charset = empathy_account_get_param_string (settings->account, "charset");
- port = empathy_account_get_param_int (settings->account, "port");
- ssl = empathy_account_get_param_boolean (settings->account, "use-ssl");
+ nick = empathy_account_settings_get_string (settings->settings, "account");
+ fullname = empathy_account_settings_get_string (settings->settings,
+ "fullname");
+ server = empathy_account_settings_get_string (settings->settings, "server");
+ charset = empathy_account_settings_get_string (settings->settings, "charset");
+ port = empathy_account_settings_get_uint32 (settings->settings, "port");
+ ssl = empathy_account_settings_get_boolean (settings->settings, "use-ssl");
if (!nick)
{
nick = g_strdup (g_get_user_name ());
- empathy_account_set_param_string (settings->account, "account", nick);
+ empathy_account_settings_set_string (settings->settings,
+ "account", nick);
}
if (!fullname)
@@ -349,7 +353,8 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
{
fullname = g_strdup (nick);
}
- empathy_account_set_param_string (settings->account, "fullname", fullname);
+ empathy_account_settings_set_string (settings->settings,
+ "fullname", fullname);
}
if (server != NULL)
@@ -406,14 +411,14 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
/**
* empathy_account_widget_irc_new:
- * @account: the #EmpathyAccount to configure
+ * @settings: the #EmpathyAccountSettings to configure
*
* Creates a new IRC account widget to configure a given #EmpathyAccount
*
* Returns: The toplevel container of the configuration widget
*/
GtkWidget *
-empathy_account_widget_irc_new (EmpathyAccount *account)
+empathy_account_widget_irc_new (EmpathyAccountSettings *account_settings)
{
EmpathyAccountWidgetIrc *settings;
gchar *dir, *user_file_with_path, *global_file_with_path;
@@ -423,7 +428,7 @@ empathy_account_widget_irc_new (EmpathyAccount *account)
gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetIrc);
- settings->account = g_object_ref (account);
+ settings->settings = g_object_ref (settings);
dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
@@ -476,7 +481,7 @@ empathy_account_widget_irc_new (EmpathyAccount *account)
account_widget_irc_setup (settings);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (account_settings, gui,
"entry_nick", "account",
"entry_fullname", "fullname",
"entry_password", "password",
@@ -485,13 +490,19 @@ empathy_account_widget_irc_new (EmpathyAccount *account)
empathy_builder_connect (gui, settings,
"vbox_irc_settings", "destroy", account_widget_irc_destroy_cb,
- "button_network", "clicked", account_widget_irc_button_edit_network_clicked_cb,
- "button_add_network", "clicked", account_widget_irc_button_add_network_clicked_cb,
- "button_remove_network", "clicked", account_widget_irc_button_remove_clicked_cb,
- "combobox_network", "changed", account_widget_irc_combobox_network_changed_cb,
+ "button_network", "clicked",
+ account_widget_irc_button_edit_network_clicked_cb,
+ "button_add_network", "clicked",
+ account_widget_irc_button_add_network_clicked_cb,
+ "button_remove_network", "clicked",
+ account_widget_irc_button_remove_clicked_cb,
+ "combobox_network", "changed",
+ account_widget_irc_combobox_network_changed_cb,
NULL);
empathy_account_widget_set_default_focus (gui, "entry_nick");
+ empathy_account_widget_add_apply_button (account_settings,
+ settings->vbox_settings);
return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings);
}
diff --git a/libempathy-gtk/empathy-account-widget-irc.h b/libempathy-gtk/empathy-account-widget-irc.h
index 40e58bbc3..0373238ed 100644
--- a/libempathy-gtk/empathy-account-widget-irc.h
+++ b/libempathy-gtk/empathy-account-widget-irc.h
@@ -22,11 +22,11 @@
#define __EMPATHY_ACCOUNT_WIDGET_IRC_H__
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <libempathy/empathy-account-settings.h>
G_BEGIN_DECLS
-GtkWidget * empathy_account_widget_irc_new (EmpathyAccount *account);
+GtkWidget * empathy_account_widget_irc_new (EmpathyAccountSettings *settings);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c
index ad8cd7d8e..9f08046b7 100644
--- a/libempathy-gtk/empathy-account-widget-sip.c
+++ b/libempathy-gtk/empathy-account-widget-sip.c
@@ -35,7 +35,7 @@
#include "empathy-ui-utils.h"
typedef struct {
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
GtkWidget *vbox_settings;
@@ -48,7 +48,7 @@ static void
account_widget_sip_destroy_cb (GtkWidget *widget,
EmpathyAccountWidgetSip *settings)
{
- g_object_unref (settings->account);
+ g_object_unref (settings->settings);
g_slice_free (EmpathyAccountWidgetSip, settings);
}
@@ -73,14 +73,14 @@ account_widget_sip_discover_stun_toggled_cb (
* Returns: The toplevel container of the configuration widget
*/
GtkWidget *
-empathy_account_widget_sip_new (EmpathyAccount *account)
+empathy_account_widget_sip_new (EmpathyAccountSettings *account_settings)
{
EmpathyAccountWidgetSip *settings;
GtkBuilder *gui;
gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetSip);
- settings->account = g_object_ref (account);
+ settings->settings = g_object_ref (account_settings);
filename = empathy_file_lookup ("empathy-account-widget-sip.ui",
"libempathy-gtk");
@@ -92,7 +92,7 @@ empathy_account_widget_sip_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (account_settings, gui,
"entry_userid", "account",
"entry_password", "password",
"checkbutton_discover-stun", "discover-stun",
@@ -100,19 +100,23 @@ empathy_account_widget_sip_new (EmpathyAccount *account)
"spinbutton_stun-port", "stun-port",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (account_settings, gui,
"button_forget",
"entry_password");
- account_widget_sip_discover_stun_toggled_cb (settings->checkbutton_discover_stun,
- settings);
+ account_widget_sip_discover_stun_toggled_cb (
+ settings->checkbutton_discover_stun,
+ settings);
empathy_builder_connect (gui, settings,
"vbox_sip_settings", "destroy", account_widget_sip_destroy_cb,
- "checkbutton_discover-stun", "toggled", account_widget_sip_discover_stun_toggled_cb,
+ "checkbutton_discover-stun", "toggled",
+ account_widget_sip_discover_stun_toggled_cb,
NULL);
empathy_account_widget_set_default_focus (gui, "entry_userid");
+ empathy_account_widget_add_apply_button (account_settings,
+ settings->vbox_settings);
return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings);
}
diff --git a/libempathy-gtk/empathy-account-widget-sip.h b/libempathy-gtk/empathy-account-widget-sip.h
index 69f60aacc..15dd7244a 100644
--- a/libempathy-gtk/empathy-account-widget-sip.h
+++ b/libempathy-gtk/empathy-account-widget-sip.h
@@ -22,11 +22,11 @@
#define __EMPATHY_ACCOUNT_WIDGET_SIP_H__
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <libempathy/empathy-account-settings.h>
G_BEGIN_DECLS
-GtkWidget * empathy_account_widget_sip_new (EmpathyAccount *account);
+GtkWidget * empathy_account_widget_sip_new (EmpathyAccountSettings *settings);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 783a48a0a..ea0a05b35 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -33,6 +33,7 @@
#include <libempathy/empathy-account.h>
#include <telepathy-glib/connection-manager.h>
+#include <dbus/dbus-protocol.h>
#include "empathy-account-widget.h"
#include "empathy-ui-utils.h"
@@ -43,7 +44,7 @@
static gboolean
account_widget_entry_focus_cb (GtkWidget *widget,
GdkEventFocus *event,
- EmpathyAccount *account)
+ EmpathyAccountSettings *settings)
{
const gchar *str;
const gchar *param_name;
@@ -54,14 +55,14 @@ account_widget_entry_focus_cb (GtkWidget *widget,
if (EMP_STR_EMPTY (str)) {
const gchar *value = NULL;
- empathy_account_unset_param (account, param_name);
- value = empathy_account_get_param_string (account, param_name);
+ empathy_account_settings_unset (settings, param_name);
+ value = empathy_account_settings_get_string (settings, param_name);
DEBUG ("Unset %s and restore to %s", param_name, value);
gtk_entry_set_text (GTK_ENTRY (widget), value ? value : "");
} else {
DEBUG ("Setting %s to %s", param_name,
strstr (param_name, "password") ? "***" : str);
- empathy_account_set_param_string (account, param_name, str);
+ empathy_account_settings_set_string (settings, param_name, str);
}
return FALSE;
@@ -69,28 +70,44 @@ account_widget_entry_focus_cb (GtkWidget *widget,
static void
account_widget_int_changed_cb (GtkWidget *widget,
- EmpathyAccount *account)
+ EmpathyAccountSettings *settings)
{
const gchar *param_name;
gint value;
+ const gchar *signature;
value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
- if (value == 0) {
- empathy_account_unset_param (account, param_name);
- value = empathy_account_get_param_int (account, param_name);
- DEBUG ("Unset %s and restore to %d", param_name, value);
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
- } else {
- DEBUG ("Setting %s to %d", param_name, value);
- empathy_account_set_param_int (account, param_name, value);
- }
+ signature = empathy_settings_get_dbus_signature (settings, param_name);
+ g_return_if_fail (signature != NULL);
+
+ DEBUG ("Setting %s to %d", param_name, value);
+
+ switch ((int)*signature)
+ {
+ case DBUS_TYPE_INT16:
+ case DBUS_TYPE_INT32:
+ empathy_account_settings_set_int32 (settings, param_name, value);
+ break;
+ case DBUS_TYPE_INT64:
+ empathy_account_settings_set_int64 (settings, param_name, value);
+ break;
+ case DBUS_TYPE_UINT16:
+ case DBUS_TYPE_UINT32:
+ empathy_account_settings_set_uint32 (settings, param_name, value);
+ break;
+ case DBUS_TYPE_UINT64:
+ empathy_account_settings_set_uint64 (settings, param_name, value);
+ break;
+ default:
+ g_return_if_reached ();
+ }
}
static void
account_widget_checkbutton_toggled_cb (GtkWidget *widget,
- EmpathyAccount *account)
+ EmpathyAccountSettings *settings)
{
gboolean value;
gboolean default_value;
@@ -102,14 +119,14 @@ account_widget_checkbutton_toggled_cb (GtkWidget *widget,
/* FIXME: This is ugly! checkbox don't have a "not-set" value so we
* always unset the param and set the value if different from the
* default value. */
- empathy_account_unset_param (account, param_name);
- default_value = empathy_account_get_param_boolean (account, param_name);
+ empathy_account_settings_unset (settings, param_name);
+ default_value = empathy_account_settings_get_boolean (settings, param_name);
if (default_value == value) {
DEBUG ("Unset %s and restore to %d", param_name, default_value);
} else {
DEBUG ("Setting %s to %d", param_name, value);
- empathy_account_set_param_boolean (account, param_name, value);
+ empathy_account_settings_set_boolean (settings, param_name, value);
}
}
@@ -117,14 +134,14 @@ static void
account_widget_forget_clicked_cb (GtkWidget *button,
GtkWidget *entry)
{
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
const gchar *param_name;
param_name = g_object_get_data (G_OBJECT (entry), "param_name");
- account = g_object_get_data (G_OBJECT (entry), "account");
+ settings = g_object_get_data (G_OBJECT (entry), "settings");
DEBUG ("Unset %s", param_name);
- empathy_account_unset_param (account, param_name);
+ empathy_account_settings_unset (settings, param_name);
gtk_entry_set_text (GTK_ENTRY (entry), "");
}
@@ -142,13 +159,13 @@ static void
account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
GtkWidget *spinbutton_port)
{
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
gboolean value;
- gint port = 0;
+ gint32 port = 0;
value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
- account = g_object_get_data (G_OBJECT (spinbutton_port), "account");
- port = empathy_account_get_param_int (account, "port");
+ settings = g_object_get_data (G_OBJECT (spinbutton_port), "settings");
+ port = empathy_account_settings_get_uint32 (settings, "port");
if (value) {
if (port == 5222 || port == 0) {
@@ -165,28 +182,51 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
static void
account_widget_setup_widget (GtkWidget *widget,
- EmpathyAccount *account,
+ EmpathyAccountSettings *settings,
const gchar *param_name)
{
g_object_set_data_full (G_OBJECT (widget), "param_name",
g_strdup (param_name), g_free);
- g_object_set_data_full (G_OBJECT (widget), "account",
- g_object_ref (account), g_object_unref);
+ g_object_set_data_full (G_OBJECT (widget), "settings",
+ g_object_ref (settings), g_object_unref);
if (GTK_IS_SPIN_BUTTON (widget)) {
gint value = 0;
+ const gchar *signature;
+
+ signature = empathy_settings_get_dbus_signature (settings, param_name);
+ g_return_if_fail (signature != NULL);
+
+ switch ((int)*signature)
+ {
+ case DBUS_TYPE_INT16:
+ case DBUS_TYPE_INT32:
+ value = empathy_account_settings_get_int32 (settings, param_name);
+ break;
+ case DBUS_TYPE_INT64:
+ value = empathy_account_settings_get_int64 (settings, param_name);
+ break;
+ case DBUS_TYPE_UINT16:
+ case DBUS_TYPE_UINT32:
+ value = empathy_account_settings_get_uint32 (settings, param_name);
+ break;
+ case DBUS_TYPE_UINT64:
+ value = empathy_account_settings_get_uint64 (settings, param_name);
+ break;
+ default:
+ g_return_if_reached ();
+ }
- value = empathy_account_get_param_int (account, param_name);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
g_signal_connect (widget, "value-changed",
G_CALLBACK (account_widget_int_changed_cb),
- account);
+ settings);
}
else if (GTK_IS_ENTRY (widget)) {
const gchar *str = NULL;
- str = empathy_account_get_param_string (account, param_name);
+ str = empathy_account_settings_get_string (settings, param_name);
gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
if (strstr (param_name, "password")) {
@@ -195,17 +235,17 @@ account_widget_setup_widget (GtkWidget *widget,
g_signal_connect (widget, "focus-out-event",
G_CALLBACK (account_widget_entry_focus_cb),
- account);
+ settings);
}
else if (GTK_IS_TOGGLE_BUTTON (widget)) {
gboolean value = FALSE;
- value = empathy_account_get_param_boolean (account, param_name);
+ value = empathy_account_settings_get_boolean (settings, param_name);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
g_signal_connect (widget, "toggled",
G_CALLBACK (account_widget_checkbutton_toggled_cb),
- account);
+ settings);
} else {
DEBUG ("Unknown type of widget for param %s", param_name);
}
@@ -236,14 +276,15 @@ account_widget_generic_format_param_name (const gchar *param_name)
}
static void
-accounts_widget_generic_setup (EmpathyAccount *account,
- TpConnectionManagerParam *params,
+accounts_widget_generic_setup (EmpathyAccountSettings *settings,
GtkWidget *table_common_settings,
GtkWidget *table_advanced_settings)
{
- TpConnectionManagerParam *param;
+ TpConnectionManagerParam *params, *param;
+
+ params = empathy_account_settings_get_tp_params (settings);
- for (param = params; param != NULL; param++) {
+ for (param = params; param != NULL && param->name != NULL; param++) {
GtkWidget *table_settings;
guint n_rows = 0;
GtkWidget *widget = NULL;
@@ -350,7 +391,7 @@ accounts_widget_generic_setup (EmpathyAccount *account,
}
if (widget) {
- account_widget_setup_widget (widget, account, param->name);
+ account_widget_setup_widget (widget, settings, param->name);
}
g_free (param_name_formatted);
@@ -358,7 +399,7 @@ accounts_widget_generic_setup (EmpathyAccount *account,
}
static void
-account_widget_handle_params_valist (EmpathyAccount *account,
+account_widget_handle_params_valist (EmpathyAccountSettings *settings,
GtkBuilder *gui,
const gchar *first_widget,
va_list args)
@@ -377,12 +418,12 @@ account_widget_handle_params_valist (EmpathyAccount *account,
continue;
}
- account_widget_setup_widget (GTK_WIDGET (object), account, param_name);
+ account_widget_setup_widget (GTK_WIDGET (object), settings, param_name);
}
}
void
-empathy_account_widget_handle_params (EmpathyAccount *account,
+empathy_account_widget_handle_params (EmpathyAccountSettings *settings,
GtkBuilder *gui,
const gchar *first_widget,
...)
@@ -392,12 +433,35 @@ empathy_account_widget_handle_params (EmpathyAccount *account,
g_return_if_fail (GTK_IS_BUILDER (gui));
va_start (args, first_widget);
- account_widget_handle_params_valist (account, gui, first_widget, args);
+ account_widget_handle_params_valist (settings, gui, first_widget, args);
va_end (args);
}
+static void
+account_widget_apply_clicked_cb (GtkWidget *button,
+ EmpathyAccountSettings *settings)
+{
+ empathy_account_settings_apply_async (settings, NULL, NULL);
+}
+
+void
+empathy_account_widget_add_apply_button (EmpathyAccountSettings *settings,
+ GtkWidget *vbox)
+{
+ GtkWidget *button;
+
+ button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
+
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 3);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (account_widget_apply_clicked_cb),
+ settings);
+ gtk_widget_show (button);
+}
+
void
-empathy_account_widget_add_forget_button (EmpathyAccount *account,
+empathy_account_widget_add_forget_button (EmpathyAccountSettings *settings,
GtkBuilder *gui,
const gchar *button,
const gchar *entry)
@@ -409,7 +473,7 @@ empathy_account_widget_add_forget_button (EmpathyAccount *account,
button_forget = GTK_WIDGET (gtk_builder_get_object (gui, button));
entry_password = GTK_WIDGET (gtk_builder_get_object (gui, entry));
- password = empathy_account_get_param_string (account, "password");
+ password = empathy_account_settings_get_string (settings, "password");
gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password));
g_signal_connect (button_forget, "clicked",
@@ -433,37 +497,33 @@ empathy_account_widget_set_default_focus (GtkBuilder *gui,
}
static void
-account_widget_tp_cm_ready_cb (TpConnectionManager *cm, const GError *error,
- gpointer user_data, GObject *weak_object)
+account_widget_setup_generic (EmpathyAccountSettings *settings,
+ GtkBuilder *builder)
{
- GtkBuilder *builder;
- EmpathyAccount *account;
GtkWidget *table_common_settings;
GtkWidget *table_advanced_settings;
- const TpConnectionManagerProtocol *protocol;
-
- if (error != NULL) {
- DEBUG ("CM wasn't happy: %s", error->message);
- return;
- }
-
- account = EMPATHY_ACCOUNT (user_data);
- builder = GTK_BUILDER (weak_object);
table_common_settings = GTK_WIDGET (gtk_builder_get_object (builder,
"table_common_settings"));
table_advanced_settings = GTK_WIDGET (gtk_builder_get_object (builder,
"table_advanced_settings"));
- protocol = tp_connection_manager_get_protocol (cm,
- empathy_account_get_protocol (account));
+ accounts_widget_generic_setup (settings, table_common_settings,
+ table_advanced_settings);
+}
- accounts_widget_generic_setup (account, protocol->params,
- table_common_settings, table_advanced_settings);
+static void
+account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
+ GParamSpec *pspec, gpointer user_data)
+{
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+
+ if (empathy_account_settings_is_ready (settings))
+ account_widget_setup_generic (settings, builder);
}
GtkWidget *
-empathy_account_widget_generic_new (EmpathyAccount *account)
+empathy_account_widget_generic_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -475,38 +535,19 @@ empathy_account_widget_generic_new (EmpathyAccount *account)
"vbox_generic_settings", &widget,
NULL);
- /* If the profile isn't installed get_protocol will return NULL with MC4 */
- if (empathy_account_get_protocol (account) != NULL) {
- TpDBusDaemon *dbus;
- TpConnectionManager *cm;
- GError *error;
-
- dbus = tp_dbus_daemon_dup (NULL);
+ if (empathy_account_settings_is_ready (settings))
+ account_widget_setup_generic (settings, gui);
+ else
+ g_signal_connect (settings, "notify::ready",
+ G_CALLBACK (account_widget_settings_ready_cb), gui);
- cm = tp_connection_manager_new (dbus,
- empathy_account_get_connection_manager (account), NULL, &error);
-
- if (cm == NULL) {
- DEBUG ("failed to get the cm: %s", error->message);
- g_error_free (error);
- g_object_unref (gui);
- return NULL;
- }
-
- tp_connection_manager_call_when_ready (cm, account_widget_tp_cm_ready_cb,
- account, g_object_unref, G_OBJECT (gui));
-
- g_object_unref (dbus);
- } else {
- /* no protocol information available :(( */
- return empathy_builder_unref_and_keep_widget (gui, widget);
- }
+ empathy_account_widget_add_apply_button (settings, widget);
return g_object_ref (widget);
}
GtkWidget *
-empathy_account_widget_salut_new (EmpathyAccount *account)
+empathy_account_widget_salut_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -519,7 +560,7 @@ empathy_account_widget_salut_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_published", "published-name",
"entry_nickname", "nickname",
"entry_first_name", "first-name",
@@ -534,7 +575,7 @@ empathy_account_widget_salut_new (EmpathyAccount *account)
}
GtkWidget *
-empathy_account_widget_msn_new (EmpathyAccount *account)
+empathy_account_widget_msn_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -547,14 +588,14 @@ empathy_account_widget_msn_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
@@ -564,7 +605,7 @@ empathy_account_widget_msn_new (EmpathyAccount *account)
}
GtkWidget *
-empathy_account_widget_jabber_new (EmpathyAccount *account)
+empathy_account_widget_jabber_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -581,7 +622,7 @@ empathy_account_widget_jabber_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_id", "account",
"entry_password", "password",
"entry_resource", "resource",
@@ -593,7 +634,7 @@ empathy_account_widget_jabber_new (EmpathyAccount *account)
"checkbutton_encryption", "require-encryption",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
@@ -603,11 +644,13 @@ empathy_account_widget_jabber_new (EmpathyAccount *account)
G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
spinbutton_port);
+ empathy_account_widget_add_apply_button (settings, widget);
+
return empathy_builder_unref_and_keep_widget (gui, widget);
}
GtkWidget *
-empathy_account_widget_icq_new (EmpathyAccount *account)
+empathy_account_widget_icq_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -622,7 +665,7 @@ empathy_account_widget_icq_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_uin", "account",
"entry_password", "password",
"entry_server", "server",
@@ -630,17 +673,19 @@ empathy_account_widget_icq_new (EmpathyAccount *account)
"entry_charset", "charset",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
empathy_account_widget_set_default_focus (gui, "entry_uin");
+ empathy_account_widget_add_apply_button (settings, widget);
+
return empathy_builder_unref_and_keep_widget (gui, widget);
}
GtkWidget *
-empathy_account_widget_aim_new (EmpathyAccount *account)
+empathy_account_widget_aim_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -655,24 +700,25 @@ empathy_account_widget_aim_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_screenname", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
empathy_account_widget_set_default_focus (gui, "entry_screenname");
+ empathy_account_widget_add_apply_button (settings, widget);
return empathy_builder_unref_and_keep_widget (gui, widget);
}
GtkWidget *
-empathy_account_widget_yahoo_new (EmpathyAccount *account)
+empathy_account_widget_yahoo_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -685,7 +731,7 @@ empathy_account_widget_yahoo_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
@@ -696,17 +742,18 @@ empathy_account_widget_yahoo_new (EmpathyAccount *account)
"checkbutton_ignore_invites", "ignore-invites",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
empathy_account_widget_set_default_focus (gui, "entry_id");
+ empathy_account_widget_add_apply_button (settings, widget);
return empathy_builder_unref_and_keep_widget (gui, widget);
}
GtkWidget *
-empathy_account_widget_groupwise_new (EmpathyAccount *account)
+empathy_account_widget_groupwise_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -719,18 +766,19 @@ empathy_account_widget_groupwise_new (EmpathyAccount *account)
NULL);
g_free (filename);
- empathy_account_widget_handle_params (account, gui,
+ empathy_account_widget_handle_params (settings, gui,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- empathy_account_widget_add_forget_button (account, gui,
+ empathy_account_widget_add_forget_button (settings, gui,
"button_forget",
"entry_password");
empathy_account_widget_set_default_focus (gui, "entry_id");
+ empathy_account_widget_add_apply_button (settings, widget);
return empathy_builder_unref_and_keep_widget (gui, widget);
}
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index 7a76db9e0..f05c66012 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -27,28 +27,31 @@
#include <gtk/gtk.h>
-#include <libempathy/empathy-account.h>
+#include <libempathy/empathy-account-settings.h>
G_BEGIN_DECLS
-void empathy_account_widget_handle_params (EmpathyAccount *account,
+void empathy_account_widget_handle_params (EmpathyAccountSettings *settings,
GtkBuilder *gui,
const gchar *first_widget,
...);
-void empathy_account_widget_add_forget_button (EmpathyAccount *account,
+void empathy_account_widget_add_forget_button (EmpathyAccountSettings *settings,
GtkBuilder *gui,
const gchar *button,
const gchar *entry);
+void empathy_account_widget_add_apply_button (EmpathyAccountSettings *settings,
+ GtkWidget *vbox);
+
void empathy_account_widget_set_default_focus (GtkBuilder *gui,
const gchar *entry);
-GtkWidget *empathy_account_widget_generic_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_salut_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_msn_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_jabber_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_icq_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_aim_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_yahoo_new (EmpathyAccount *account);
-GtkWidget *empathy_account_widget_groupwise_new (EmpathyAccount *account);
+GtkWidget *empathy_account_widget_generic_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_salut_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_msn_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_jabber_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_icq_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_aim_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_yahoo_new (EmpathyAccountSettings *settings);
+GtkWidget *empathy_account_widget_groupwise_new (EmpathyAccountSettings *settings);
G_END_DECLS