aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo.cecchi@collabora.co.uk>2009-07-27 06:54:23 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2009-07-30 06:13:20 +0800
commit000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f (patch)
tree69f482485a68ffb3423c9376f853f42c6b19acfa /libempathy-gtk
parenta84e75c56b59533a551a411ff7a2aa7d88659cd4 (diff)
downloadgsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar.gz
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar.bz2
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar.lz
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar.xz
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.tar.zst
gsoc2013-empathy-000a7c0ca4dc343b42e628323ddd1ca0f2a08e3f.zip
First cut at GObject-ifying EmpathyAccountWidget
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am3
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.c79
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.h5
-rw-r--r--libempathy-gtk/empathy-account-widget-local-xmpp.ui (renamed from libempathy-gtk/empathy-account-widget-salut.ui)0
-rw-r--r--libempathy-gtk/empathy-account-widget-private.h47
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.c42
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.h5
-rw-r--r--libempathy-gtk/empathy-account-widget.c642
-rw-r--r--libempathy-gtk/empathy-account-widget.h52
9 files changed, 499 insertions, 376 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 94cc4ee15..4a97761b9 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -68,6 +68,7 @@ libempathy_gtk_la_SOURCES = \
# do not distribute generated files
nodist_libempathy_gtk_la_SOURCES =\
+ empathy-account-widget-private.h \
$(BUILT_SOURCES)
libempathy_gtk_la_LIBADD = \
@@ -141,7 +142,7 @@ ui_DATA = \
empathy-account-widget-jabber.ui \
empathy-account-widget-msn.ui \
empathy-account-widget-sip.ui \
- empathy-account-widget-salut.ui \
+ empathy-account-widget-local-xmpp.ui \
empathy-account-widget-irc.ui \
empathy-account-widget-icq.ui \
empathy-account-widget-yahoo.ui \
diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c
index 4bca91073..425adbcb5 100644
--- a/libempathy-gtk/empathy-account-widget-irc.c
+++ b/libempathy-gtk/empathy-account-widget-irc.c
@@ -32,6 +32,7 @@
#include "empathy-irc-network-dialog.h"
#include "empathy-account-widget.h"
+#include "empathy-account-widget-private.h"
#include "empathy-account-widget-irc.h"
#include "empathy-ui-utils.h"
@@ -41,7 +42,7 @@
#define IRC_NETWORKS_FILENAME "irc-networks.xml"
typedef struct {
- EmpathyAccountSettings *settings;
+ EmpathyAccountWidget *self;
EmpathyIrcNetworkManager *network_manager;
GtkWidget *vbox_settings;
@@ -59,17 +60,19 @@ account_widget_irc_destroy_cb (GtkWidget *widget,
EmpathyAccountWidgetIrc *settings)
{
g_object_unref (settings->network_manager);
- g_object_unref (settings->settings);
g_slice_free (EmpathyAccountWidgetIrc, settings);
}
static void
unset_server_params (EmpathyAccountWidgetIrc *settings)
{
+ EmpathyAccountSettings *ac_settings;
+
+ g_object_get (settings->self, "settings", &ac_settings, NULL);
DEBUG ("Unset server, port and use-ssl");
- empathy_account_settings_unset (settings->settings, "server");
- empathy_account_settings_unset (settings->settings, "port");
- empathy_account_settings_unset (settings->settings, "use-ssl");
+ empathy_account_settings_unset (ac_settings, "server");
+ empathy_account_settings_unset (ac_settings, "port");
+ empathy_account_settings_unset (ac_settings, "use-ssl");
}
static void
@@ -80,6 +83,9 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
EmpathyIrcNetwork *network;
GSList *servers;
gchar *charset;
+ EmpathyAccountSettings *ac_settings;
+
+ g_object_get (settings->self, "settings", &ac_settings, NULL);
if (!gtk_combo_box_get_active_iter (
GTK_COMBO_BOX (settings->combobox_network), &iter))
@@ -95,7 +101,7 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
g_object_get (network, "charset", &charset, NULL);
DEBUG ("Setting charset to %s", charset);
- empathy_account_settings_set_string (settings->settings, "charset", charset);
+ empathy_account_settings_set_string (ac_settings, "charset", charset);
g_free (charset);
servers = empathy_irc_network_get_servers (network);
@@ -114,13 +120,11 @@ update_server_params (EmpathyAccountWidgetIrc *settings)
NULL);
DEBUG ("Setting server to %s", address);
- empathy_account_settings_set_string (settings->settings,
- "server", address);
+ empathy_account_settings_set_string (ac_settings, "server", address);
DEBUG ("Setting port to %u", port);
- empathy_account_settings_set_uint32 (settings->settings, "port", port);
+ empathy_account_settings_set_uint32 (ac_settings, "port", port);
DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" );
- empathy_account_settings_set_boolean (settings->settings,
- "use-ssl", ssl);
+ empathy_account_settings_set_boolean (ac_settings, "use-ssl", ssl);
g_free (address);
}
@@ -330,19 +334,22 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
const gchar *charset;
gboolean ssl = FALSE;
EmpathyIrcNetwork *network = NULL;
+ EmpathyAccountSettings *ac_settings;
- nick = empathy_account_settings_get_string (settings->settings, "account");
- fullname = empathy_account_settings_get_string (settings->settings,
+ g_object_get (settings->self, "settings", &ac_settings, NULL);
+
+ nick = empathy_account_settings_get_string (ac_settings, "account");
+ fullname = empathy_account_settings_get_string (ac_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");
+ server = empathy_account_settings_get_string (ac_settings, "server");
+ charset = empathy_account_settings_get_string (ac_settings, "charset");
+ port = empathy_account_settings_get_uint32 (ac_settings, "port");
+ ssl = empathy_account_settings_get_boolean (ac_settings, "use-ssl");
if (!nick)
{
nick = g_strdup (g_get_user_name ());
- empathy_account_settings_set_string (settings->settings,
+ empathy_account_settings_set_string (ac_settings,
"account", nick);
}
@@ -353,7 +360,7 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
{
fullname = g_strdup (nick);
}
- empathy_account_settings_set_string (settings->settings,
+ empathy_account_settings_set_string (ac_settings,
"fullname", fullname);
}
@@ -409,27 +416,17 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
fill_networks_model (settings, network);
}
-/**
- * empathy_account_widget_irc_new:
- * @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 (EmpathyAccountSettings *account_settings)
+void
+empathy_account_widget_irc_build (EmpathyAccountWidget *self,
+ const char *filename)
{
EmpathyAccountWidgetIrc *settings;
gchar *dir, *user_file_with_path, *global_file_with_path;
- GtkBuilder *gui;
- GtkWidget *widget;
GtkListStore *store;
GtkCellRenderer *renderer;
- gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetIrc);
- settings->settings = g_object_ref (account_settings);
+ settings->self = self;
dir = g_build_filename (g_get_home_dir (), ".gnome2", PACKAGE_NAME, NULL);
g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
@@ -452,14 +449,11 @@ empathy_account_widget_irc_new (EmpathyAccountSettings *account_settings)
g_free (global_file_with_path);
g_free (user_file_with_path);
- filename = empathy_file_lookup ("empathy-account-widget-irc.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_irc", &widget,
+ self->ui_details->gui = empathy_builder_get_file (filename,
+ "vbox_irc", &self->ui_details->widget,
"table_irc_settings", &settings->vbox_settings,
"combobox_network", &settings->combobox_network,
NULL);
- g_free (filename);
/* Fill the networks combobox */
store = gtk_list_store_new (2, G_TYPE_OBJECT, G_TYPE_STRING);
@@ -483,14 +477,14 @@ empathy_account_widget_irc_new (EmpathyAccountSettings *account_settings)
account_widget_irc_setup (settings);
- empathy_account_widget_handle_params (account_settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_nick", "account",
"entry_fullname", "fullname",
"entry_password", "password",
"entry_quit_message", "quit-message",
NULL);
- empathy_builder_connect (gui, settings,
+ empathy_builder_connect (self->ui_details->gui, settings,
"table_irc_settings", "destroy", account_widget_irc_destroy_cb,
"button_network", "clicked",
account_widget_irc_button_edit_network_clicked_cb,
@@ -502,8 +496,5 @@ empathy_account_widget_irc_new (EmpathyAccountSettings *account_settings)
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, widget);
-
- return empathy_builder_unref_and_keep_widget (gui, widget);
+ self->ui_details->default_focus = g_strdup ("entry_nick");
}
diff --git a/libempathy-gtk/empathy-account-widget-irc.h b/libempathy-gtk/empathy-account-widget-irc.h
index 0373238ed..a76787120 100644
--- a/libempathy-gtk/empathy-account-widget-irc.h
+++ b/libempathy-gtk/empathy-account-widget-irc.h
@@ -22,11 +22,12 @@
#define __EMPATHY_ACCOUNT_WIDGET_IRC_H__
#include <gtk/gtk.h>
-#include <libempathy/empathy-account-settings.h>
+#include <libempathy-gtk/empathy-account-widget.h>
G_BEGIN_DECLS
-GtkWidget * empathy_account_widget_irc_new (EmpathyAccountSettings *settings);
+void empathy_account_widget_irc_build (EmpathyAccountWidget *self,
+ const char *filename);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-account-widget-salut.ui b/libempathy-gtk/empathy-account-widget-local-xmpp.ui
index ca633309d..ca633309d 100644
--- a/libempathy-gtk/empathy-account-widget-salut.ui
+++ b/libempathy-gtk/empathy-account-widget-local-xmpp.ui
diff --git a/libempathy-gtk/empathy-account-widget-private.h b/libempathy-gtk/empathy-account-widget-private.h
new file mode 100644
index 000000000..aaa24e58f
--- /dev/null
+++ b/libempathy-gtk/empathy-account-widget-private.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2009 Collabora Ltd.
+ *
+ * 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, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_ACCOUNT_WIDGET_PRIVATE_H__
+#define __EMPATHY_ACCOUNT_WIDGET_PRIVATE_H__
+
+#include <libempathy-gtk/empathy-account-widget.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+struct _EmpathyAccountWidgetUIDetails {
+ GtkWidget *widget;
+
+ GtkBuilder *gui;
+
+ char *default_focus;
+ gboolean add_forget;
+};
+
+
+void empathy_account_widget_handle_params (EmpathyAccountWidget *self,
+ const gchar *first_widget,
+ ...);
+
+G_END_DECLS
+
+#endif /* __EMPATHY_ACCOUNT_WIDGET_PRIVATE_H__ */ \ No newline at end of file
diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c
index 9f08046b7..fedbf2aa6 100644
--- a/libempathy-gtk/empathy-account-widget-sip.c
+++ b/libempathy-gtk/empathy-account-widget-sip.c
@@ -31,12 +31,12 @@
#include <libempathy/empathy-utils.h>
#include "empathy-account-widget.h"
+#include "empathy-account-widget-private.h"
#include "empathy-account-widget-sip.h"
#include "empathy-ui-utils.h"
typedef struct {
- EmpathyAccountSettings *settings;
-
+ EmpathyAccountWidget *self;
GtkWidget *vbox_settings;
GtkWidget *entry_stun_server;
@@ -48,7 +48,6 @@ static void
account_widget_sip_destroy_cb (GtkWidget *widget,
EmpathyAccountWidgetSip *settings)
{
- g_object_unref (settings->settings);
g_slice_free (EmpathyAccountWidgetSip, settings);
}
@@ -64,35 +63,23 @@ account_widget_sip_discover_stun_toggled_cb (
gtk_widget_set_sensitive (settings->spinbutton_stun_part, !active);
}
-/**
- * empathy_account_widget_sip_new:
- * @account: the #EmpathyAccount to configure
- *
- * Creates a new SIP account widget to configure a given #EmpathyAccount
- *
- * Returns: The toplevel container of the configuration widget
- */
-GtkWidget *
-empathy_account_widget_sip_new (EmpathyAccountSettings *account_settings)
+void
+empathy_account_widget_sip_build (EmpathyAccountWidget *self,
+ const char *filename)
{
EmpathyAccountWidgetSip *settings;
- GtkBuilder *gui;
- gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetSip);
- settings->settings = g_object_ref (account_settings);
+ settings->self = self;
- filename = empathy_file_lookup ("empathy-account-widget-sip.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
+ self->ui_details->gui = empathy_builder_get_file (filename,
"vbox_sip_settings", &settings->vbox_settings,
"entry_stun-server", &settings->entry_stun_server,
"spinbutton_stun-port", &settings->spinbutton_stun_part,
"checkbutton_discover-stun", &settings->checkbutton_discover_stun,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (account_settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_userid", "account",
"entry_password", "password",
"checkbutton_discover-stun", "discover-stun",
@@ -100,23 +87,18 @@ empathy_account_widget_sip_new (EmpathyAccountSettings *account_settings)
"spinbutton_stun-port", "stun-port",
NULL);
- 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);
- empathy_builder_connect (gui, settings,
+ empathy_builder_connect (self->ui_details->gui, settings,
"vbox_sip_settings", "destroy", account_widget_sip_destroy_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);
+ self->ui_details->add_forget = TRUE;
+ self->ui_details->default_focus = g_strdup ("entry_userid");
- return empathy_builder_unref_and_keep_widget (gui, settings->vbox_settings);
+ self->ui_details->widget = settings->vbox_settings;
}
diff --git a/libempathy-gtk/empathy-account-widget-sip.h b/libempathy-gtk/empathy-account-widget-sip.h
index 15dd7244a..435ad6ea1 100644
--- a/libempathy-gtk/empathy-account-widget-sip.h
+++ b/libempathy-gtk/empathy-account-widget-sip.h
@@ -22,11 +22,12 @@
#define __EMPATHY_ACCOUNT_WIDGET_SIP_H__
#include <gtk/gtk.h>
-#include <libempathy/empathy-account-settings.h>
+#include <libempathy-gtk/empathy-account-widget.h>
G_BEGIN_DECLS
-GtkWidget * empathy_account_widget_sip_new (EmpathyAccountSettings *settings);
+void empathy_account_widget_sip_build (EmpathyAccountWidget *self,
+ const char *filename);
G_END_DECLS
diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c
index 21e3d3ee3..76145c483 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -33,21 +33,60 @@
#include <libempathy/empathy-account.h>
#include <telepathy-glib/connection-manager.h>
+#include <telepathy-glib/util.h>
#include <dbus/dbus-protocol.h>
#include "empathy-account-widget.h"
+#include "empathy-account-widget-private.h"
+#include "empathy-account-widget-sip.h"
+#include "empathy-account-widget-irc.h"
#include "empathy-ui-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
+G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
+
+typedef struct {
+ GtkWidget *widget;
+
+ char *protocol;
+ EmpathyAccountSettings *settings;
+
+ GtkWidget *apply_button;
+ GtkWidget *entry_password;
+ GtkWidget *button_forget;
+ GtkWidget *spinbutton_port;
+
+ GtkBuilder *gui;
+ char *default_focus;
+ gboolean add_forget;
+} EmpathyAccountWidgetPriv;
+
+enum {
+ PROP_PROTOCOL = 1,
+ PROP_SETTINGS
+};
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
+
+static void
+account_widget_handle_apply_sensitivity (EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ gtk_widget_set_sensitive (priv->apply_button,
+ empathy_account_settings_is_valid (priv->settings));
+}
+
static gboolean
account_widget_entry_focus_cb (GtkWidget *widget,
GdkEventFocus *event,
- EmpathyAccountSettings *settings)
+ EmpathyAccountWidget *self)
{
const gchar *str;
const gchar *param_name;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
str = gtk_entry_get_text (GTK_ENTRY (widget));
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
@@ -55,31 +94,34 @@ account_widget_entry_focus_cb (GtkWidget *widget,
if (EMP_STR_EMPTY (str)) {
const gchar *value = NULL;
- empathy_account_settings_unset (settings, param_name);
- value = empathy_account_settings_get_string (settings, param_name);
+ empathy_account_settings_unset (priv->settings, param_name);
+ value = empathy_account_settings_get_string (priv->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_settings_set_string (settings, param_name, str);
+ empathy_account_settings_set_string (priv->settings, param_name, str);
}
+ account_widget_handle_apply_sensitivity (self);
+
return FALSE;
}
static void
account_widget_int_changed_cb (GtkWidget *widget,
- EmpathyAccountSettings *settings)
+ EmpathyAccountWidget *self)
{
const gchar *param_name;
- gint value;
+ gint value;
const gchar *signature;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
- signature = empathy_settings_get_dbus_signature (settings, param_name);
+ signature = empathy_settings_get_dbus_signature (priv->settings, param_name);
g_return_if_fail (signature != NULL);
DEBUG ("Setting %s to %d", param_name, value);
@@ -88,30 +130,33 @@ account_widget_int_changed_cb (GtkWidget *widget,
{
case DBUS_TYPE_INT16:
case DBUS_TYPE_INT32:
- empathy_account_settings_set_int32 (settings, param_name, value);
+ empathy_account_settings_set_int32 (priv->settings, param_name, value);
break;
case DBUS_TYPE_INT64:
- empathy_account_settings_set_int64 (settings, param_name, value);
+ empathy_account_settings_set_int64 (priv->settings, param_name, value);
break;
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- empathy_account_settings_set_uint32 (settings, param_name, value);
+ empathy_account_settings_set_uint32 (priv->settings, param_name, value);
break;
case DBUS_TYPE_UINT64:
- empathy_account_settings_set_uint64 (settings, param_name, value);
+ empathy_account_settings_set_uint64 (priv->settings, param_name, value);
break;
default:
g_return_if_reached ();
- }
+ }
+
+ account_widget_handle_apply_sensitivity (self);
}
static void
account_widget_checkbutton_toggled_cb (GtkWidget *widget,
- EmpathyAccountSettings *settings)
+ EmpathyAccountWidget *self)
{
gboolean value;
gboolean default_value;
const gchar *param_name;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
@@ -119,30 +164,33 @@ 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_settings_unset (settings, param_name);
- default_value = empathy_account_settings_get_boolean (settings, param_name);
+ empathy_account_settings_unset (priv->settings, param_name);
+ default_value = empathy_account_settings_get_boolean (priv->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_settings_set_boolean (settings, param_name, value);
+ empathy_account_settings_set_boolean (priv->settings, param_name, value);
}
+
+ account_widget_handle_apply_sensitivity (self);
}
static void
account_widget_forget_clicked_cb (GtkWidget *button,
- GtkWidget *entry)
+ EmpathyAccountWidget *self)
{
- EmpathyAccountSettings *settings;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
const gchar *param_name;
- param_name = g_object_get_data (G_OBJECT (entry), "param_name");
- settings = g_object_get_data (G_OBJECT (entry), "settings");
+ param_name = g_object_get_data (G_OBJECT (priv->entry_password), "param_name");
DEBUG ("Unset %s", param_name);
- empathy_account_settings_unset (settings, param_name);
- gtk_entry_set_text (GTK_ENTRY (entry), "");
+ empathy_account_settings_unset (priv->settings, param_name);
+ gtk_entry_set_text (GTK_ENTRY (priv->entry_password), "");
+
+ account_widget_handle_apply_sensitivity (self);
}
static void
@@ -157,15 +205,14 @@ account_widget_password_changed_cb (GtkWidget *entry,
static void
account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
- GtkWidget *spinbutton_port)
+ EmpathyAccountWidget *self)
{
- EmpathyAccountSettings *settings;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
gboolean value;
gint32 port = 0;
value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
- settings = g_object_get_data (G_OBJECT (spinbutton_port), "settings");
- port = empathy_account_settings_get_uint32 (settings, "port");
+ port = empathy_account_settings_get_uint32 (priv->settings, "port");
if (value) {
if (port == 5222 || port == 0) {
@@ -177,41 +224,41 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
}
}
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton_port), port);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
}
static void
-account_widget_setup_widget (GtkWidget *widget,
- EmpathyAccountSettings *settings,
+account_widget_setup_widget (EmpathyAccountWidget *self,
+ GtkWidget *widget,
const gchar *param_name)
{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
g_object_set_data_full (G_OBJECT (widget), "param_name",
g_strdup (param_name), g_free);
- 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);
+ signature = empathy_settings_get_dbus_signature (priv->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);
+ value = empathy_account_settings_get_int32 (priv->settings, param_name);
break;
case DBUS_TYPE_INT64:
- value = empathy_account_settings_get_int64 (settings, param_name);
+ value = empathy_account_settings_get_int64 (priv->settings, param_name);
break;
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
- value = empathy_account_settings_get_uint32 (settings, param_name);
+ value = empathy_account_settings_get_uint32 (priv->settings, param_name);
break;
case DBUS_TYPE_UINT64:
- value = empathy_account_settings_get_uint64 (settings, param_name);
+ value = empathy_account_settings_get_uint64 (priv->settings, param_name);
break;
default:
g_return_if_reached ();
@@ -221,12 +268,12 @@ account_widget_setup_widget (GtkWidget *widget,
g_signal_connect (widget, "value-changed",
G_CALLBACK (account_widget_int_changed_cb),
- settings);
+ self);
}
else if (GTK_IS_ENTRY (widget)) {
const gchar *str = NULL;
- str = empathy_account_settings_get_string (settings, param_name);
+ str = empathy_account_settings_get_string (priv->settings, param_name);
gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
if (strstr (param_name, "password")) {
@@ -235,17 +282,17 @@ account_widget_setup_widget (GtkWidget *widget,
g_signal_connect (widget, "focus-out-event",
G_CALLBACK (account_widget_entry_focus_cb),
- settings);
+ self);
}
else if (GTK_IS_TOGGLE_BUTTON (widget)) {
gboolean value = FALSE;
- value = empathy_account_settings_get_boolean (settings, param_name);
+ value = empathy_account_settings_get_boolean (priv->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),
- settings);
+ self);
} else {
DEBUG ("Unknown type of widget for param %s", param_name);
}
@@ -276,13 +323,14 @@ account_widget_generic_format_param_name (const gchar *param_name)
}
static void
-accounts_widget_generic_setup (EmpathyAccountSettings *settings,
+accounts_widget_generic_setup (EmpathyAccountWidget *self,
GtkWidget *table_common_settings,
GtkWidget *table_advanced_settings)
{
TpConnectionManagerParam *params, *param;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- params = empathy_account_settings_get_tp_params (settings);
+ params = empathy_account_settings_get_tp_params (priv->settings);
for (param = params; param != NULL && param->name != NULL; param++) {
GtkWidget *table_settings;
@@ -391,7 +439,7 @@ accounts_widget_generic_setup (EmpathyAccountSettings *settings,
}
if (widget) {
- account_widget_setup_widget (widget, settings, param->name);
+ account_widget_setup_widget (self, widget, param->name);
}
g_free (param_name_formatted);
@@ -399,168 +447,93 @@ accounts_widget_generic_setup (EmpathyAccountSettings *settings,
}
static void
-account_widget_handle_params_valist (EmpathyAccountSettings *settings,
- GtkBuilder *gui,
+account_widget_handle_params_valist (EmpathyAccountWidget *self,
const gchar *first_widget,
va_list args)
{
GObject *object;
const gchar *name;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
for (name = first_widget; name; name = va_arg (args, const gchar *)) {
const gchar *param_name;
param_name = va_arg (args, const gchar *);
- object = gtk_builder_get_object (gui, name);
+ object = gtk_builder_get_object (priv->gui, name);
if (!object) {
g_warning ("Builder is missing object '%s'.", name);
continue;
}
- account_widget_setup_widget (GTK_WIDGET (object), settings, param_name);
+ account_widget_setup_widget (self, GTK_WIDGET (object), param_name);
}
}
-void
-empathy_account_widget_handle_params (EmpathyAccountSettings *settings,
- GtkBuilder *gui,
- const gchar *first_widget,
- ...)
-{
- va_list args;
-
- g_return_if_fail (GTK_IS_BUILDER (gui));
-
- va_start (args, first_widget);
- account_widget_handle_params_valist (settings, gui, first_widget, args);
- va_end (args);
-}
-
static void
account_widget_apply_clicked_cb (GtkWidget *button,
- EmpathyAccountSettings *settings)
+ EmpathyAccountWidget *self)
{
- 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 (EmpathyAccountSettings *settings,
- GtkBuilder *gui,
- const gchar *button,
- const gchar *entry)
-{
- GtkWidget *button_forget;
- GtkWidget *entry_password;
- const gchar *password = NULL;
-
- button_forget = GTK_WIDGET (gtk_builder_get_object (gui, button));
- entry_password = GTK_WIDGET (gtk_builder_get_object (gui, entry));
-
- password = empathy_account_settings_get_string (settings, "password");
- gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password));
-
- g_signal_connect (button_forget, "clicked",
- G_CALLBACK (account_widget_forget_clicked_cb),
- entry_password);
- g_signal_connect (entry_password, "changed",
- G_CALLBACK (account_widget_password_changed_cb),
- button_forget);
-}
-
-void
-empathy_account_widget_set_default_focus (GtkBuilder *gui,
- const gchar *entry)
-{
- GObject *default_focus_entry;
-
- default_focus_entry = gtk_builder_get_object (gui, entry);
- g_signal_connect (default_focus_entry, "realize",
- G_CALLBACK (gtk_widget_grab_focus),
- NULL);
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ empathy_account_settings_apply_async (priv->settings, NULL, NULL);
}
static void
-account_widget_setup_generic (EmpathyAccountSettings *settings,
- GtkBuilder *builder)
+account_widget_setup_generic (EmpathyAccountWidget *self)
{
GtkWidget *table_common_settings;
GtkWidget *table_advanced_settings;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- table_common_settings = GTK_WIDGET (gtk_builder_get_object (builder,
+ table_common_settings = GTK_WIDGET (gtk_builder_get_object (priv->gui,
"table_common_settings"));
- table_advanced_settings = GTK_WIDGET (gtk_builder_get_object (builder,
+ table_advanced_settings = GTK_WIDGET (gtk_builder_get_object (priv->gui,
"table_advanced_settings"));
- accounts_widget_generic_setup (settings, table_common_settings,
+ accounts_widget_generic_setup (self, table_common_settings,
table_advanced_settings);
}
static void
account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
- GParamSpec *pspec, gpointer user_data)
+ GParamSpec *pspec,
+ gpointer user_data)
{
- GtkBuilder *builder = GTK_BUILDER (user_data);
+ EmpathyAccountWidget *self = user_data;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- if (empathy_account_settings_is_ready (settings))
- account_widget_setup_generic (settings, builder);
+ if (empathy_account_settings_is_ready (priv->settings))
+ account_widget_setup_generic (self);
}
-GtkWidget *
-empathy_account_widget_generic_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_generic (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
- gchar *filename;
-
- filename = empathy_file_lookup ("empathy-account-widget-generic.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_generic_settings", &widget,
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_generic_settings", &self->ui_details->widget,
NULL);
- if (empathy_account_settings_is_ready (settings))
- account_widget_setup_generic (settings, gui);
+ if (empathy_account_settings_is_ready (priv->settings))
+ account_widget_setup_generic (self);
else
- g_signal_connect (settings, "notify::ready",
- G_CALLBACK (account_widget_settings_ready_cb), gui);
-
- empathy_account_widget_add_apply_button (settings, widget);
-
- return g_object_ref (widget);
+ g_signal_connect (priv->settings, "notify::ready",
+ G_CALLBACK (account_widget_settings_ready_cb), self);
}
-GtkWidget *
-empathy_account_widget_salut_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_salut (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
- gchar *filename;
-
- filename = empathy_file_lookup ("empathy-account-widget-salut.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_salut_settings", &widget,
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_salut_settings", &self->ui_details->widget,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_published", "published-name",
"entry_nickname", "nickname",
"entry_first_name", "first-name",
@@ -569,61 +542,44 @@ empathy_account_widget_salut_new (EmpathyAccountSettings *settings)
"entry_jid", "jid",
NULL);
- empathy_account_widget_set_default_focus (gui, "entry_nickname");
- empathy_account_widget_add_apply_button (settings, widget);
-
- return empathy_builder_unref_and_keep_widget (gui, widget);
+ self->ui_details->default_focus = g_strdup ("entry_nickname");
}
-GtkWidget *
-empathy_account_widget_msn_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_msn (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
- gchar *filename;
-
- filename = empathy_file_lookup ("empathy-account-widget-msn.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_msn_settings", &widget,
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_msn_settings", &self->ui_details->widget,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- empathy_account_widget_add_forget_button (settings, gui,
- "button_forget",
- "entry_password");
-
- empathy_account_widget_set_default_focus (gui, "entry_id");
-
- return empathy_builder_unref_and_keep_widget (gui, widget);
+ self->ui_details->default_focus = g_strdup ("entry_id");
+ self->ui_details->add_forget = TRUE;
}
-GtkWidget *
-empathy_account_widget_jabber_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_jabber (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
GtkWidget *spinbutton_port;
GtkWidget *checkbutton_ssl;
- gchar *filename;
- filename = empathy_file_lookup ("empathy-account-widget-jabber.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_jabber_settings", &widget,
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_jabber_settings", &self->ui_details->widget,
"spinbutton_port", &spinbutton_port,
"checkbutton_ssl", &checkbutton_ssl,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_id", "account",
"entry_password", "password",
"entry_resource", "resource",
@@ -635,38 +591,28 @@ empathy_account_widget_jabber_new (EmpathyAccountSettings *settings)
"checkbutton_encryption", "require-encryption",
NULL);
- empathy_account_widget_add_forget_button (settings, gui,
- "button_forget",
- "entry_password");
-
- empathy_account_widget_set_default_focus (gui, "entry_id");
+ self->ui_details->default_focus = g_strdup ("entry_id");
+ self->ui_details->add_forget = TRUE;
+ priv->spinbutton_port = spinbutton_port;
g_signal_connect (checkbutton_ssl, "toggled",
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);
+ self);
}
-GtkWidget *
-empathy_account_widget_icq_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_icq (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
GtkWidget *spinbutton_port;
- gchar *filename;
- filename = empathy_file_lookup ("empathy-account-widget-icq.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_icq_settings", &widget,
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_icq_settings", &self->ui_details->widget,
"spinbutton_port", &spinbutton_port,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_uin", "account",
"entry_password", "password",
"entry_server", "server",
@@ -674,65 +620,44 @@ empathy_account_widget_icq_new (EmpathyAccountSettings *settings)
"entry_charset", "charset",
NULL);
- 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);
+ self->ui_details->default_focus = g_strdup ("entry_uin");
+ self->ui_details->add_forget = TRUE;
}
-GtkWidget *
-empathy_account_widget_aim_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_aim (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
GtkWidget *spinbutton_port;
- gchar *filename;
- filename = empathy_file_lookup ("empathy-account-widget-aim.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_aim_settings", &widget,
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_aim_settings", &self->ui_details->widget,
"spinbutton_port", &spinbutton_port,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_screenname", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- 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);
+ self->ui_details->default_focus = g_strdup ("entry_screenname");
+ self->ui_details->add_forget = TRUE;
}
-GtkWidget *
-empathy_account_widget_yahoo_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_yahoo (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
- gchar *filename;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- filename = empathy_file_lookup ("empathy-account-widget-yahoo.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_yahoo_settings", &widget,
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_yahoo_settings", &self->ui_details->widget,
NULL);
- g_free (filename);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
@@ -743,44 +668,209 @@ empathy_account_widget_yahoo_new (EmpathyAccountSettings *settings)
"checkbutton_ignore_invites", "ignore-invites",
NULL);
- 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);
+ self->ui_details->default_focus = g_strdup ("entry_id");
+ self->ui_details->add_forget = TRUE;
}
-GtkWidget *
-empathy_account_widget_groupwise_new (EmpathyAccountSettings *settings)
+static void
+account_widget_build_groupwise (EmpathyAccountWidget *self,
+ const char *filename)
{
- GtkBuilder *gui;
- GtkWidget *widget;
- gchar *filename;
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
- filename = empathy_file_lookup ("empathy-account-widget-groupwise.ui",
- "libempathy-gtk");
- gui = empathy_builder_get_file (filename,
- "vbox_groupwise_settings", &widget,
- NULL);
- g_free (filename);
+ priv->gui = empathy_builder_get_file (filename,
+ "vbox_groupwise_settings", &self->ui_details->widget,
+ NULL);
- empathy_account_widget_handle_params (settings, gui,
+ empathy_account_widget_handle_params (self,
"entry_id", "account",
"entry_password", "password",
"entry_server", "server",
"spinbutton_port", "port",
NULL);
- empathy_account_widget_add_forget_button (settings, gui,
- "button_forget",
- "entry_password");
+ self->ui_details->default_focus = g_strdup ("entry_id");
+ self->ui_details->add_forget = TRUE;
+}
- empathy_account_widget_set_default_focus (gui, "entry_id");
- empathy_account_widget_add_apply_button (settings, widget);
+static void
+do_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
+
+ switch (prop_id) {
+ case PROP_PROTOCOL:
+ priv->protocol = g_value_dup_string (value);
+ break;
+ case PROP_SETTINGS:
+ priv->settings = g_value_dup_object (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+do_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
+
+ switch (prop_id) {
+ case PROP_PROTOCOL:
+ g_value_set_string (value, priv->protocol);
+ break;
+ case PROP_SETTINGS:
+ g_value_set_object (value, priv->settings);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+do_constructed (GObject *obj)
+{
+ EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
+ EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
+ char *uiname, *filename;
+
+ uiname = g_strconcat ("empathy-account-widget-", priv->protocol,
+ ".ui", NULL);
+ filename = empathy_file_lookup (uiname, "libempathy-gtk");
+
+ if (!tp_strdiff (priv->protocol, "local-xmpp"))
+ account_widget_build_salut (self, filename);
+ else if (!tp_strdiff (priv->protocol, "msn"))
+ account_widget_build_msn (self, filename);
+ else if (!tp_strdiff (priv->protocol, "jabber"))
+ account_widget_build_jabber (self, filename);
+ else if (!tp_strdiff (priv->protocol, "icq"))
+ account_widget_build_icq (self, filename);
+ else if (!tp_strdiff (priv->protocol, "aim"))
+ account_widget_build_aim (self, filename);
+ else if (!tp_strdiff (priv->protocol, "yahoo"))
+ account_widget_build_yahoo (self, filename);
+ else if (!tp_strdiff (priv->protocol, "groupwise"))
+ account_widget_build_groupwise (self, filename);
+ else if (!tp_strdiff (priv->protocol, "irc"))
+ empathy_account_widget_irc_build (self, filename);
+ else if (!tp_strdiff (priv->protocol, "sip"))
+ empathy_account_widget_sip_build (self, filename);
+ else
+ account_widget_build_generic (self, filename);
+
+ g_free (uiname);
+ g_free (filename);
+
+ /* handle default focus */
+ if (self->ui_details->default_focus != NULL)
+ {
+ GObject *default_focus_entry;
+
+ default_focus_entry = gtk_builder_get_object
+ (priv->gui, self->ui_details->default_focus);
+ g_signal_connect (default_focus_entry, "realize",
+ G_CALLBACK (gtk_widget_grab_focus),
+ NULL);
+ }
+
+ /* handle forget button */
+ if (self->ui_details->add_forget)
+ {
+ const gchar *password = NULL;
+
+ priv->button_forget = GTK_WIDGET (gtk_builder_get_object (priv->gui, "button_forget"));
+ priv->entry_password = GTK_WIDGET (gtk_builder_get_object (priv->gui, "entry_password"));
+
+ password = empathy_account_settings_get_string (priv->settings, "password");
+ gtk_widget_set_sensitive (priv->button_forget, !EMP_STR_EMPTY (password));
+
+ g_signal_connect (priv->button_forget, "clicked",
+ G_CALLBACK (account_widget_forget_clicked_cb),
+ self);
+ g_signal_connect (priv->entry_password, "changed",
+ G_CALLBACK (account_widget_password_changed_cb),
+ self);
+ }
+
+ /* handle apply button */
+ priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
+ gtk_box_pack_end (GTK_BOX (self->ui_details->widget), priv->apply_button, FALSE, FALSE, 3);
+
+ g_signal_connect (priv->apply_button, "clicked",
+ G_CALLBACK (account_widget_apply_clicked_cb),
+ self);
+ gtk_widget_show (priv->apply_button);
+}
+
+static void
+empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GParamSpec *param_spec;
+
+ oclass->get_property = do_get_property;
+ oclass->set_property = do_set_property;
+ oclass->constructed = do_constructed;
+
+ param_spec = g_param_spec_string ("protocol",
+ "protocol", "The protocol of the account",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec);
+
+ param_spec = g_param_spec_object ("settings",
+ "settings", "The settings of the account",
+ EMPATHY_TYPE_ACCOUNT_SETTINGS,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
+ g_object_class_install_property (oclass, PROP_SETTINGS, param_spec);
+
+ g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
+}
- return empathy_builder_unref_and_keep_widget (gui, widget);
+static void
+empathy_account_widget_init (EmpathyAccountWidget *self)
+{
+ EmpathyAccountWidgetPriv *priv =
+ G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
+ EmpathyAccountWidgetPriv);
+
+ self->priv = priv;
+ self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
}
+void
+empathy_account_widget_handle_params (EmpathyAccountWidget *self,
+ const gchar *first_widget,
+ ...)
+{
+ va_list args;
+
+ va_start (args, first_widget);
+ account_widget_handle_params_valist (self, first_widget, args);
+ va_end (args);
+}
+
+GtkWidget *
+empathy_account_widget_new_for_protocol (const char *protocol,
+ EmpathyAccountSettings *settings)
+{
+ EmpathyAccountWidget *self;
+ EmpathyAccountWidgetPriv *priv;
+
+ g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
+ g_return_val_if_fail (settings != NULL, NULL);
+
+ self = g_object_new
+ (EMPATHY_TYPE_ACCOUNT_WIDGET, "protocol", protocol,
+ "settings", settings, NULL);
+ priv = GET_PRIV (self);
+
+ return self->ui_details->widget;
+} \ No newline at end of file
diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h
index d3bd171fc..8a5f0f2c2 100644
--- a/libempathy-gtk/empathy-account-widget.h
+++ b/libempathy-gtk/empathy-account-widget.h
@@ -31,27 +31,37 @@
G_BEGIN_DECLS
-void empathy_account_widget_handle_params (EmpathyAccountSettings *settings,
- GtkBuilder *gui,
- const gchar *first_widget,
- ...);
-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 (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);
+#define EMPATHY_TYPE_ACCOUNT_WIDGET empathy_account_widget_get_type()
+#define EMPATHY_ACCOUNT_WIDGET(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_ACCOUNT_WIDGET, EmpathyAccountWidget))
+#define EMPATHY_ACCOUNT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST ((klass), EMPATHY_TYPE_ACCOUNT_WIDGET, EmpathyAccountWidgetClass))
+#define EMPATHY_IS_ACCOUNT_WIDGET(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_ACCOUNT_WIDGET))
+#define EMPATHY_IS_ACCOUNT_WIDGET_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE ((klass), EMPATHY_TYPE_ACCOUNT_WIDGET))
+#define EMPATHY_ACCOUNT_WIDGET_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_ACCOUNT_WIDGET, EmpathyAccountWidgetClass))
+
+typedef struct _EmpathyAccountWidgetUIDetails EmpathyAccountWidgetUIDetails;
+
+typedef struct {
+ GObject parent;
+
+ EmpathyAccountWidgetUIDetails *ui_details;
+
+ /* private */
+ gpointer priv;
+} EmpathyAccountWidget;
+
+typedef struct {
+ GObjectClass parent_class;
+} EmpathyAccountWidgetClass;
+
+GType empathy_account_widget_get_type (void);
+
+GtkWidget *empathy_account_widget_new_for_protocol (const char *protocol,
+ EmpathyAccountSettings *settings);
G_END_DECLS