aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am4
-rw-r--r--libempathy-gtk/empathy-account-chooser.c6
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.c83
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.h4
-rw-r--r--libempathy-gtk/empathy-account-widget-irc.ui339
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.c24
-rw-r--r--libempathy-gtk/empathy-account-widget-sip.h4
-rw-r--r--libempathy-gtk/empathy-account-widget.c322
-rw-r--r--libempathy-gtk/empathy-account-widget.h25
-rw-r--r--libempathy-gtk/empathy-contact-dialogs.c2
-rw-r--r--libempathy-gtk/empathy-irc-network-dialog.c2
-rw-r--r--libempathy-gtk/empathy-log-window.c2
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c2
-rw-r--r--libempathy-gtk/empathy-profile-chooser.c324
-rw-r--r--libempathy-gtk/empathy-profile-chooser.h69
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.c339
-rw-r--r--libempathy-gtk/empathy-protocol-chooser.h70
-rw-r--r--libempathy-gtk/empathy-theme-adium.c6
-rw-r--r--libempathy-gtk/empathy-ui-utils.c12
-rw-r--r--libempathy-gtk/empathy-ui-utils.h3
20 files changed, 853 insertions, 789 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 4c80e9f98..7f93accd3 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -53,7 +53,7 @@ libempathy_gtk_handwritten_source = \
empathy-log-window.c \
empathy-new-message-dialog.c \
empathy-presence-chooser.c \
- empathy-profile-chooser.c \
+ empathy-protocol-chooser.c \
empathy-smiley-manager.c \
empathy-sound.c \
empathy-spell.c \
@@ -115,7 +115,7 @@ libempathy_gtk_headers = \
empathy-log-window.h \
empathy-new-message-dialog.h \
empathy-presence-chooser.h \
- empathy-profile-chooser.h \
+ empathy-protocol-chooser.h \
empathy-smiley-manager.h \
empathy-sound.h \
empathy-spell.h \
diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c
index 34ebc7eac..7c6f52fa5 100644
--- a/libempathy-gtk/empathy-account-chooser.c
+++ b/libempathy-gtk/empathy-account-chooser.c
@@ -29,8 +29,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-utils.h>
@@ -617,7 +615,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser,
COL_ACCOUNT_POINTER, &account,
-1);
- icon_name = empathy_icon_name_from_account (account);
+ icon_name = empathy_account_get_icon_name (account);
if (priv->filter) {
is_enabled = priv->filter (account, priv->filter_data);
}
@@ -779,7 +777,7 @@ empathy_account_chooser_filter_is_connected (EmpathyAccount *account,
{
TpConnectionStatus status;
- g_object_get (account, "status", &status, NULL);
+ g_object_get (account, "connection-status", &status, NULL);
return status == TP_CONNECTION_STATUS_CONNECTED;
}
diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c
index c0699b23a..c04f3463d 100644
--- a/libempathy-gtk/empathy-account-widget-irc.c
+++ b/libempathy-gtk/empathy-account-widget-irc.c
@@ -27,8 +27,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-protocol.h>
-
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-irc-network-manager.h>
@@ -43,7 +41,7 @@
#define IRC_NETWORKS_FILENAME "irc-networks.xml"
typedef struct {
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
EmpathyIrcNetworkManager *network_manager;
GtkWidget *vbox_settings;
@@ -61,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);
}
@@ -69,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
@@ -97,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);
@@ -116,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);
}
@@ -323,25 +323,27 @@ fill_networks_model (EmpathyAccountWidgetIrc *settings,
static void
account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
{
- gchar *nick = NULL;
- gchar *fullname = NULL;
- gchar *server = NULL;
+ const gchar *nick = NULL;
+ const gchar *fullname = NULL;
+ const gchar *server = NULL;
gint port = 6667;
- gchar *charset;
+ const gchar *charset;
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)
@@ -351,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)
@@ -404,33 +407,29 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings)
fill_networks_model (settings, network);
-
- g_free (nick);
- g_free (fullname);
- g_free (server);
- g_free (charset);
}
/**
* 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;
GtkBuilder *gui;
+ GtkWidget *widget;
GtkListStore *store;
GtkCellRenderer *renderer;
gchar *filename;
settings = g_slice_new0 (EmpathyAccountWidgetIrc);
- settings->account = g_object_ref (account);
+ settings->settings = g_object_ref (account_settings);
dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);
g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
@@ -456,7 +455,8 @@ empathy_account_widget_irc_new (EmpathyAccount *account)
filename = empathy_file_lookup ("empathy-account-widget-irc.ui",
"libempathy-gtk");
gui = empathy_builder_get_file (filename,
- "vbox_irc_settings", &settings->vbox_settings,
+ "vbox_irc", &widget,
+ "table_irc_settings", &settings->vbox_settings,
"combobox_network", &settings->combobox_network,
NULL);
g_free (filename);
@@ -483,7 +483,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",
@@ -491,14 +491,19 @@ empathy_account_widget_irc_new (EmpathyAccount *account)
NULL);
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,
+ "table_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,
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, settings->vbox_settings);
+ return empathy_builder_unref_and_keep_widget (gui, widget);
}
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-irc.ui b/libempathy-gtk/empathy-account-widget-irc.ui
index abb1c9362..a4f7faa7f 100644
--- a/libempathy-gtk/empathy-account-widget-irc.ui
+++ b/libempathy-gtk/empathy-account-widget-irc.ui
@@ -255,207 +255,216 @@
<action-widget response="-7">button_close</action-widget>
</action-widgets>
</object>
- <object class="GtkTable" id="vbox_irc_settings">
+ <object class="GtkVBox" id="vbox_irc">
<property name="visible">True</property>
- <property name="n_rows">5</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">6</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkEntry" id="entry_quit_message">
+ <object class="GtkTable" id="table_irc_settings">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_quit_message">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Quit message:</property>
- </object>
- <packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry_fullname">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry_password">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="visibility">False</property>
- <property name="invisible_char">&#x25CF;</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_password">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Password:</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_fullname">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Real name:</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="entry_nick">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">&#x25CF;</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_nick">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Nickname:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">entry_nick</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox174">
- <property name="visible">True</property>
- <property name="spacing">2</property>
+ <property name="n_rows">5</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
<child>
- <object class="GtkComboBox" id="combobox_network">
+ <object class="GtkEntry" id="entry_quit_message">
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">&#x25CF;</property>
</object>
<packing>
- <property name="position">0</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button_add_network">
+ <object class="GtkLabel" id="label_quit_message">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Quit message:</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="entry_fullname">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="stock">gtk-add</property>
- </object>
- </child>
+ <property name="invisible_char">&#x25CF;</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button_network">
+ <object class="GtkEntry" id="entry_password">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <child>
- <object class="GtkImage" id="image834">
- <property name="visible">True</property>
- <property name="stock">gtk-edit</property>
- </object>
- </child>
+ <property name="visibility">False</property>
+ <property name="invisible_char">&#x25CF;</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_password">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Password:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_fullname">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Real name:</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
</packing>
</child>
<child>
- <object class="GtkButton" id="button_remove_network">
+ <object class="GtkEntry" id="entry_nick">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="invisible_char">&#x25CF;</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_nick">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Nickname:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">entry_nick</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox174">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <object class="GtkComboBox" id="combobox_network">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_add_network">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="stock">gtk-add</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
<child>
- <object class="GtkImage" id="image835">
+ <object class="GtkButton" id="button_network">
<property name="visible">True</property>
- <property name="stock">gtk-remove</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="image834">
+ <property name="visible">True</property>
+ <property name="stock">gtk-edit</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button_remove_network">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <child>
+ <object class="GtkImage" id="image835">
+ <property name="visible">True</property>
+ <property name="stock">gtk-remove</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">3</property>
+ </packing>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_network2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Network:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
</packing>
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_network2">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Network:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</property>
- <property name="y_options"></property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c
index 05e917e53..9f08046b7 100644
--- a/libempathy-gtk/empathy-account-widget-sip.c
+++ b/libempathy-gtk/empathy-account-widget-sip.c
@@ -28,8 +28,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-protocol.h>
-
#include <libempathy/empathy-utils.h>
#include "empathy-account-widget.h"
@@ -37,7 +35,7 @@
#include "empathy-ui-utils.h"
typedef struct {
- EmpathyAccount *account;
+ EmpathyAccountSettings *settings;
GtkWidget *vbox_settings;
@@ -50,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);
}
@@ -75,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");
@@ -94,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",
@@ -102,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 0c2c35177..21e3d3ee3 100644
--- a/libempathy-gtk/empathy-account-widget.c
+++ b/libempathy-gtk/empathy-account-widget.c
@@ -29,11 +29,12 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libmissioncontrol/mc-protocol.h>
-
#include <libempathy/empathy-utils.h>
#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;
@@ -52,35 +53,16 @@ account_widget_entry_focus_cb (GtkWidget *widget,
param_name = g_object_get_data (G_OBJECT (widget), "param_name");
if (EMP_STR_EMPTY (str)) {
- gchar *value = NULL;
+ 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 : "");
- g_free (value);
} else {
- McProfile *profile;
- const gchar *domain = NULL;
- gchar *dup_str = NULL;
-
- profile = empathy_account_get_profile (account);
- if (mc_profile_get_capabilities (profile) &
- MC_PROFILE_CAPABILITY_SPLIT_ACCOUNT) {
- domain = mc_profile_get_default_account_domain (profile);
- }
-
- if (domain && !strstr (str, "@") &&
- strcmp (param_name, "account") == 0) {
- DEBUG ("Adding @%s suffix to account", domain);
- str = dup_str = g_strconcat (str, "@", domain, NULL);
- gtk_entry_set_text (GTK_ENTRY (widget), str);
- }
DEBUG ("Setting %s to %s", param_name,
strstr (param_name, "password") ? "***" : str);
- empathy_account_set_param_string (account, param_name, str);
- g_free (dup_str);
- g_object_unref (profile);
+ empathy_account_settings_set_string (settings, param_name, str);
}
return FALSE;
@@ -88,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;
@@ -121,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);
}
}
@@ -136,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), "");
}
@@ -161,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) {
@@ -184,30 +182,52 @@ 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)) {
- gchar *str = NULL;
+ 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 : "");
- g_free (str);
if (strstr (param_name, "password")) {
gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
@@ -215,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);
}
@@ -256,38 +276,21 @@ account_widget_generic_format_param_name (const gchar *param_name)
}
static void
-accounts_widget_generic_setup (EmpathyAccount *account,
+accounts_widget_generic_setup (EmpathyAccountSettings *settings,
GtkWidget *table_common_settings,
GtkWidget *table_advanced_settings)
{
- McProtocol *protocol;
- McProfile *profile;
- GSList *params, *l;
-
- profile = empathy_account_get_profile (account);
- protocol = mc_profile_get_protocol (profile);
-
- if (!protocol) {
- /* The CM is not installed, MC shouldn't list them
- * see SF bug #1688779
- * FIXME: We should display something asking the user to
- * install the CM
- */
- g_object_unref (profile);
- return;
- }
+ TpConnectionManagerParam *params, *param;
- params = mc_protocol_get_params (protocol);
+ params = empathy_account_settings_get_tp_params (settings);
- for (l = params; l; l = l->next) {
- McProtocolParam *param;
+ for (param = params; param != NULL && param->name != NULL; param++) {
GtkWidget *table_settings;
guint n_rows = 0;
GtkWidget *widget = NULL;
gchar *param_name_formatted;
- param = l->data;
- if (param->flags & MC_PROTOCOL_PARAM_REQUIRED) {
+ if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED) {
table_settings = table_common_settings;
} else {
table_settings = table_advanced_settings;
@@ -296,7 +299,7 @@ accounts_widget_generic_setup (EmpathyAccount *account,
g_object_get (table_settings, "n-rows", &n_rows, NULL);
gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2);
- if (param->signature[0] == 's') {
+ if (param->dbus_signature[0] == 's') {
gchar *str;
str = g_strdup_printf (_("%s:"), param_name_formatted);
@@ -327,20 +330,20 @@ accounts_widget_generic_setup (EmpathyAccount *account,
gtk_widget_show (widget);
}
/* int types: ynqiuxt. double type is 'd' */
- else if (param->signature[0] == 'y' ||
- param->signature[0] == 'n' ||
- param->signature[0] == 'q' ||
- param->signature[0] == 'i' ||
- param->signature[0] == 'u' ||
- param->signature[0] == 'x' ||
- param->signature[0] == 't' ||
- param->signature[0] == 'd') {
+ else if (param->dbus_signature[0] == 'y' ||
+ param->dbus_signature[0] == 'n' ||
+ param->dbus_signature[0] == 'q' ||
+ param->dbus_signature[0] == 'i' ||
+ param->dbus_signature[0] == 'u' ||
+ param->dbus_signature[0] == 'x' ||
+ param->dbus_signature[0] == 't' ||
+ param->dbus_signature[0] == 'd') {
gchar *str = NULL;
gdouble minint = 0;
gdouble maxint = 0;
gdouble step = 1;
- switch (param->signature[0]) {
+ switch (param->dbus_signature[0]) {
case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
case 'q': minint = 0; maxint = G_MAXUINT16; break;
@@ -373,7 +376,7 @@ accounts_widget_generic_setup (EmpathyAccount *account,
0, 0);
gtk_widget_show (widget);
}
- else if (param->signature[0] == 'b') {
+ else if (param->dbus_signature[0] == 'b') {
widget = gtk_check_button_new_with_label (param_name_formatted);
gtk_table_attach (GTK_TABLE (table_settings),
widget,
@@ -384,23 +387,19 @@ accounts_widget_generic_setup (EmpathyAccount *account,
gtk_widget_show (widget);
} else {
DEBUG ("Unknown signature for param %s: %s",
- param_name_formatted, param->signature);
+ param_name_formatted, param->dbus_signature);
}
if (widget) {
- account_widget_setup_widget (widget, account, param->name);
+ account_widget_setup_widget (widget, settings, param->name);
}
g_free (param_name_formatted);
}
-
- mc_protocol_free_params_list (params);
- g_object_unref (profile);
- g_object_unref (protocol);
}
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)
@@ -419,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,
...)
@@ -434,26 +433,48 @@ 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)
{
GtkWidget *button_forget;
GtkWidget *entry_password;
- gchar *password = NULL;
+ 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_get_param_string (account, "password");
+ password = empathy_account_settings_get_string (settings, "password");
gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password));
- g_free (password);
g_signal_connect (button_forget, "clicked",
G_CALLBACK (account_widget_forget_clicked_cb),
@@ -475,31 +496,58 @@ empathy_account_widget_set_default_focus (GtkBuilder *gui,
NULL);
}
+static void
+account_widget_setup_generic (EmpathyAccountSettings *settings,
+ GtkBuilder *builder)
+{
+ GtkWidget *table_common_settings;
+ GtkWidget *table_advanced_settings;
+
+ 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"));
+
+ accounts_widget_generic_setup (settings, 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;
- GtkWidget *table_common_settings;
- GtkWidget *table_advanced_settings;
gchar *filename;
filename = empathy_file_lookup ("empathy-account-widget-generic.ui",
"libempathy-gtk");
gui = empathy_builder_get_file (filename,
"vbox_generic_settings", &widget,
- "table_common_settings", &table_common_settings,
- "table_advanced_settings", &table_advanced_settings,
NULL);
- g_free (filename);
- accounts_widget_generic_setup (account, table_common_settings, table_advanced_settings);
+ 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);
- 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;
@@ -512,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",
@@ -522,12 +570,13 @@ empathy_account_widget_salut_new (EmpathyAccount *account)
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);
}
GtkWidget *
-empathy_account_widget_msn_new (EmpathyAccount *account)
+empathy_account_widget_msn_new (EmpathyAccountSettings *settings)
{
GtkBuilder *gui;
GtkWidget *widget;
@@ -540,14 +589,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");
@@ -557,7 +606,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;
@@ -574,7 +623,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",
@@ -586,7 +635,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");
@@ -596,11 +645,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;
@@ -615,7 +666,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",
@@ -623,17 +674,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;
@@ -648,24 +701,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;
@@ -678,7 +732,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",
@@ -689,17 +743,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;
@@ -712,18 +767,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
diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c
index 5636714b0..fc1cbbc8e 100644
--- a/libempathy-gtk/empathy-contact-dialogs.c
+++ b/libempathy-gtk/empathy-contact-dialogs.c
@@ -27,8 +27,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-contact-manager.h>
#include <libempathy/empathy-account-manager.h>
#include <libempathy/empathy-contact-list.h>
diff --git a/libempathy-gtk/empathy-irc-network-dialog.c b/libempathy-gtk/empathy-irc-network-dialog.c
index e6b4a6f7f..8d4676417 100644
--- a/libempathy-gtk/empathy-irc-network-dialog.c
+++ b/libempathy-gtk/empathy-irc-network-dialog.c
@@ -27,8 +27,6 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-protocol.h>
-
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-account.h>
diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c
index f05017c9c..7add30136 100644
--- a/libempathy-gtk/empathy-log-window.c
+++ b/libempathy-gtk/empathy-log-window.c
@@ -419,7 +419,7 @@ log_window_find_populate (EmpathyLogWindow *window,
date_readable = empathy_log_manager_get_date_readable (hit->date);
account_name = empathy_account_get_display_name (hit->account);
- account_icon = empathy_icon_name_from_account (hit->account);
+ account_icon = empathy_account_get_icon_name (hit->account);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
index 77b368bd9..66b2adb2d 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -27,8 +27,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
-#include <libmissioncontrol/mission-control.h>
-
#include <libempathy/empathy-call-factory.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-manager.h>
diff --git a/libempathy-gtk/empathy-profile-chooser.c b/libempathy-gtk/empathy-profile-chooser.c
deleted file mode 100644
index b3cbf90d0..000000000
--- a/libempathy-gtk/empathy-profile-chooser.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2007-2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Jonny Lamb <jonny.lamb@collabora.co.uk>
- */
-
-#include <config.h>
-
-#include <string.h>
-
-#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-profile.h>
-#include <libmissioncontrol/mc-protocol.h>
-
-#include <libempathy/empathy-utils.h>
-
-#include "empathy-profile-chooser.h"
-#include "empathy-ui-utils.h"
-
-/**
- * SECTION:empathy-profile-chooser
- * @title: EmpathyProfileChooser
- * @short_description: A widget used to choose from a list of profiles
- * @include: libempathy-gtk/empathy-profile-chooser.h
- *
- * #EmpathyProfileChooser is a widget which extends #GtkComboBox to provides a
- * chooser of available profiles.
- */
-
-/**
- * EmpathyProfileChooser:
- * @parent: parent object
- *
- * Widget which extends #GtkComboBox to provide a chooser of available
- * profiles.
- */
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyProfileChooser)
-typedef struct
-{
- GtkListStore *store;
- gboolean dispose_run;
-} EmpathyProfileChooserPriv;
-
-enum
-{
- COL_ICON,
- COL_LABEL,
- COL_PROFILE,
- COL_COUNT
-};
-
-G_DEFINE_TYPE (EmpathyProfileChooser, empathy_profile_chooser,
- GTK_TYPE_COMBO_BOX);
-
-static gint
-profile_chooser_sort_profile_value (McProfile *profile)
-{
- guint i;
- const gchar *profile_name;
- const gchar *names[] = {
- "jabber",
- "salut",
- "gtalk",
- NULL
- };
-
- profile_name = mc_profile_get_unique_name (profile);
-
- for (i = 0 ; names[i]; i++)
- {
- if (strcmp (profile_name, names[i]) == 0)
- return i;
- }
-
- return i;
-}
-
-static gint
-profile_chooser_sort_func (GtkTreeModel *model,
- GtkTreeIter *iter_a,
- GtkTreeIter *iter_b,
- gpointer user_data)
-{
- McProfile *profile_a;
- McProfile *profile_b;
- gint cmp;
-
- gtk_tree_model_get (model, iter_a,
- COL_PROFILE, &profile_a,
- -1);
- gtk_tree_model_get (model, iter_b,
- COL_PROFILE, &profile_b,
- -1);
-
- cmp = profile_chooser_sort_profile_value (profile_a);
- cmp -= profile_chooser_sort_profile_value (profile_b);
- if (cmp == 0)
- {
- cmp = strcmp (mc_profile_get_display_name (profile_a),
- mc_profile_get_display_name (profile_b));
- }
-
- g_object_unref (profile_a);
- g_object_unref (profile_b);
-
- return cmp;
-}
-
-static void
-profile_chooser_constructed (GObject *object)
-{
- EmpathyProfileChooser *profile_chooser;
- EmpathyProfileChooserPriv *priv;
-
- GList *profiles, *l, *seen;
- GtkCellRenderer *renderer;
- GtkTreeIter iter;
- gboolean iter_set = FALSE;
- McManager *btf_cm;
-
- priv = GET_PRIV (object);
- profile_chooser = EMPATHY_PROFILE_CHOOSER (object);
-
- /* set up combo box with new store */
- priv->store = gtk_list_store_new (COL_COUNT,
- G_TYPE_STRING, /* Icon name */
- G_TYPE_STRING, /* Label */
- MC_TYPE_PROFILE); /* Profile */
-
- gtk_combo_box_set_model (GTK_COMBO_BOX (object),
- GTK_TREE_MODEL (priv->store));
-
- renderer = gtk_cell_renderer_pixbuf_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, FALSE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer,
- "icon-name", COL_ICON,
- NULL);
- g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
-
- renderer = gtk_cell_renderer_text_new ();
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, TRUE);
- gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer,
- "text", COL_LABEL,
- NULL);
-
- btf_cm = mc_manager_lookup ("butterfly");
- profiles = mc_profiles_list ();
- seen = NULL;
- for (l = profiles; l; l = g_list_next (l))
- {
- McProfile *profile;
- McProtocol *protocol;
- const gchar *unique_name;
-
- profile = l->data;
-
- /* Check if the CM is installed, otherwise skip that profile.
- * Workaround SF bug #1688779 */
- protocol = mc_profile_get_protocol (profile);
- if (!protocol)
- continue;
-
- g_object_unref (protocol);
-
- /* Skip MSN-Haze if we have butterfly */
- unique_name = mc_profile_get_unique_name (profile);
- if (btf_cm && strcmp (unique_name, "msn-haze") == 0)
- continue;
-
- if (g_list_find_custom (seen, unique_name, (GCompareFunc) strcmp))
- continue;
-
- seen = g_list_append (seen, (char *) unique_name);
-
- gtk_list_store_insert_with_values (priv->store, &iter, 0,
- COL_ICON, mc_profile_get_icon_name (profile),
- COL_LABEL, mc_profile_get_display_name (profile),
- COL_PROFILE, profile,
- -1);
- iter_set = TRUE;
- }
-
- g_list_free (seen);
-
- if (btf_cm)
- g_object_unref (btf_cm);
-
- /* Set the profile sort function */
- gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->store),
- COL_PROFILE,
- profile_chooser_sort_func,
- NULL, NULL);
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->store),
- COL_PROFILE,
- GTK_SORT_ASCENDING);
-
- if (iter_set)
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (object), &iter);
-
- mc_profiles_free_list (profiles);
-
- if (G_OBJECT_CLASS (empathy_profile_chooser_parent_class)->constructed)
- G_OBJECT_CLASS (empathy_profile_chooser_parent_class)->constructed (object);
-}
-
-static void
-empathy_profile_chooser_init (EmpathyProfileChooser *profile_chooser)
-{
- EmpathyProfileChooserPriv *priv =
- G_TYPE_INSTANCE_GET_PRIVATE (profile_chooser,
- EMPATHY_TYPE_PROFILE_CHOOSER, EmpathyProfileChooserPriv);
-
- priv->dispose_run = FALSE;
-
- profile_chooser->priv = priv;
-}
-
-static void
-profile_chooser_dispose (GObject *object)
-{
- EmpathyProfileChooser *profile_chooser = EMPATHY_PROFILE_CHOOSER (object);
- EmpathyProfileChooserPriv *priv = GET_PRIV (profile_chooser);
-
- if (priv->dispose_run)
- return;
-
- priv->dispose_run = TRUE;
-
- if (priv->store)
- {
- g_object_unref (priv->store);
- priv->store = NULL;
- }
-
- (G_OBJECT_CLASS (empathy_profile_chooser_parent_class)->dispose) (object);
-}
-
-static void
-empathy_profile_chooser_class_init (EmpathyProfileChooserClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->constructed = profile_chooser_constructed;
- object_class->dispose = profile_chooser_dispose;
-
- g_type_class_add_private (object_class, sizeof (EmpathyProfileChooserPriv));
-}
-
-/**
- * empathy_profile_chooser_dup_selected:
- * @profile_chooser: an #EmpathyProfileChooser
- *
- * Returns a new reference to the selected #McProfile in @profile_chooser. The
- * returned #McProfile should be unrefed with g_object_unref() when finished
- * with.
- *
- * Return value: a new reference to the selected #McProfile
- */
-McProfile *
-empathy_profile_chooser_dup_selected (EmpathyProfileChooser *profile_chooser)
-{
- EmpathyProfileChooserPriv *priv = GET_PRIV (profile_chooser);
- GtkTreeIter iter;
- McProfile *profile = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_PROFILE_CHOOSER (profile_chooser), NULL);
-
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (profile_chooser), &iter))
- {
- gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
- COL_PROFILE, &profile,
- -1);
- }
-
- return profile;
-}
-
-/**
- * empathy_profile_chooser_n_profiles:
- * @profile_chooser: an #EmpathyProfileChooser
- *
- * Returns the number of profiles in @profile_chooser.
- *
- * Return value: the number of profiles in @profile_chooser
- */
-gint
-empathy_profile_chooser_n_profiles (EmpathyProfileChooser *profile_chooser)
-{
- EmpathyProfileChooserPriv *priv = GET_PRIV (profile_chooser);
-
- g_return_val_if_fail (EMPATHY_IS_PROFILE_CHOOSER (profile_chooser), 0);
-
- return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), NULL);
-}
-
-/**
- * empathy_profile_chooser_new:
- *
- * Creates a new #EmpathyProfileChooser widget.
- *
- * Return value: a new #EmpathyProfileChooser widget
- */
-GtkWidget *
-empathy_profile_chooser_new (void)
-{
- return GTK_WIDGET (g_object_new (EMPATHY_TYPE_PROFILE_CHOOSER, NULL));
-}
diff --git a/libempathy-gtk/empathy-profile-chooser.h b/libempathy-gtk/empathy-profile-chooser.h
deleted file mode 100644
index 37d7241a9..000000000
--- a/libempathy-gtk/empathy-profile-chooser.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
-/*
- * Copyright (C) 2007-2009 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Authors: Xavier Claessens <xclaesse@gmail.com>
- * Jonny Lamb <jonny.lamb@collabora.co.uk
- */
-
-#ifndef __EMPATHY_PROFILE_CHOOSER_H__
-#define __EMPATHY_PROFILE_CHOOSER_H__
-
-#include <glib-object.h>
-#include <gtk/gtk.h>
-
-#include <libmissioncontrol/mc-profile.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_PROFILE_CHOOSER (empathy_profile_chooser_get_type ())
-#define EMPATHY_PROFILE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
- EMPATHY_TYPE_PROFILE_CHOOSER, EmpathyProfileChooser))
-#define EMPATHY_PROFILE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
- EMPATHY_TYPE_PROFILE_CHOOSER, EmpathyProfileChooserClass))
-#define EMPATHY_IS_PROFILE_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
- EMPATHY_TYPE_PROFILE_CHOOSER))
-#define EMPATHY_IS_PROFILE_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
- EMPATHY_TYPE_PROFILE_CHOOSER))
-#define EMPATHY_PROFILE_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
- EMPATHY_TYPE_PROFILE_CHOOSER, EmpathyProfileChooserClass))
-
-typedef struct _EmpathyProfileChooser EmpathyProfileChooser;
-typedef struct _EmpathyProfileChooserClass EmpathyProfileChooserClass;
-
-struct _EmpathyProfileChooser
-{
- GtkComboBox parent;
-
- /*<private>*/
- gpointer priv;
-};
-
-struct _EmpathyProfileChooserClass
-{
- GtkComboBoxClass parent_class;
-};
-
-GType empathy_profile_chooser_get_type (void) G_GNUC_CONST;
-GtkWidget * empathy_profile_chooser_new (void);
-McProfile * empathy_profile_chooser_dup_selected (
- EmpathyProfileChooser *profile_chooser);
-gint empathy_profile_chooser_n_profiles (
- EmpathyProfileChooser *profile_chooser);
-
-G_END_DECLS
-#endif /* __EMPATHY_PROFILE_CHOOSER_H__ */
diff --git a/libempathy-gtk/empathy-protocol-chooser.c b/libempathy-gtk/empathy-protocol-chooser.c
new file mode 100644
index 000000000..ebb198455
--- /dev/null
+++ b/libempathy-gtk/empathy-protocol-chooser.c
@@ -0,0 +1,339 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/*
+ * Copyright (C) 2007-2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Xavier Claessens <xclaesse@gmail.com>
+ * Jonny Lamb <jonny.lamb@collabora.co.uk>
+ */
+
+#include <config.h>
+
+#include <string.h>
+
+#include <telepathy-glib/util.h>
+
+#include <gtk/gtk.h>
+
+#include <libempathy/empathy-utils.h>
+
+#include "empathy-protocol-chooser.h"
+#include "empathy-ui-utils.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
+#include <libempathy/empathy-debug.h>
+
+/**
+ * SECTION:empathy-protocol-chooser
+ * @title: EmpathyProtocolChooser
+ * @short_description: A widget used to choose from a list of protocols
+ * @include: libempathy-gtk/empathy-protocol-chooser.h
+ *
+ * #EmpathyProtocolChooser is a widget which extends #GtkComboBox to provides a
+ * chooser of available protocols.
+ */
+
+/**
+ * EmpathyProtocolChooser:
+ * @parent: parent object
+ *
+ * Widget which extends #GtkComboBox to provide a chooser of available
+ * protocols.
+ */
+
+#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyProtocolChooser)
+typedef struct
+{
+ GtkListStore *store;
+ gboolean dispose_run;
+
+} EmpathyProtocolChooserPriv;
+
+enum
+{
+ COL_ICON,
+ COL_LABEL,
+ COL_CM,
+ COL_PROTOCOL,
+ COL_COUNT
+};
+
+G_DEFINE_TYPE (EmpathyProtocolChooser, empathy_protocol_chooser,
+ GTK_TYPE_COMBO_BOX);
+
+static gint
+protocol_chooser_sort_protocol_value (TpConnectionManagerProtocol *protocol)
+{
+ guint i;
+ const gchar *names[] = {
+ "jabber",
+ "salut",
+ "gtalk",
+ NULL
+ };
+
+ for (i = 0 ; names[i]; i++)
+ {
+ if (strcmp (protocol->name, names[i]) == 0)
+ return i;
+ }
+
+ return i;
+}
+
+static gint
+protocol_chooser_sort_func (GtkTreeModel *model,
+ GtkTreeIter *iter_a,
+ GtkTreeIter *iter_b,
+ gpointer user_data)
+{
+ TpConnectionManagerProtocol *protocol_a;
+ TpConnectionManagerProtocol *protocol_b;
+ gint cmp;
+
+ gtk_tree_model_get (model, iter_a,
+ COL_PROTOCOL, &protocol_a,
+ -1);
+ gtk_tree_model_get (model, iter_b,
+ COL_PROTOCOL, &protocol_b,
+ -1);
+
+ cmp = protocol_chooser_sort_protocol_value (protocol_a);
+ cmp -= protocol_chooser_sort_protocol_value (protocol_b);
+ if (cmp == 0)
+ {
+ cmp = strcmp (protocol_a->name, protocol_b->name);
+ }
+
+ return cmp;
+}
+
+static void
+protocol_choosers_add_cm (EmpathyProtocolChooser *chooser,
+ TpConnectionManager *cm)
+{
+ EmpathyProtocolChooserPriv *priv = GET_PRIV (chooser);
+ const TpConnectionManagerProtocol * const *iter;
+
+ for (iter = cm->protocols; iter != NULL && *iter != NULL; iter++)
+ {
+ const TpConnectionManagerProtocol *proto = *iter;
+ gchar *icon_name;
+ gchar *display_name;
+
+
+ icon_name = g_strdup_printf ("im-%s", proto->name);
+
+ if (!tp_strdiff (cm->name, "haze"))
+ display_name = g_strdup_printf ("%s (Haze)", proto->name);
+ else
+ display_name = g_strdup (proto->name);
+
+ gtk_list_store_insert_with_values (priv->store, NULL, 0,
+ COL_ICON, icon_name,
+ COL_LABEL, display_name,
+ COL_CM, cm,
+ COL_PROTOCOL, proto,
+ -1);
+
+ g_free (display_name);
+ g_free (icon_name);
+ }
+}
+
+
+static void
+protocol_choosers_cms_listed (TpConnectionManager * const *cms,
+ gsize n_cms,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ TpConnectionManager * const *iter;
+
+ if (error !=NULL)
+ {
+ DEBUG ("Failed to get connection managers: %s", error->message);
+ return;
+ }
+
+ for (iter = cms ; iter != NULL && *iter != NULL; iter++)
+ protocol_choosers_add_cm (EMPATHY_PROTOCOL_CHOOSER (weak_object),
+ *iter);
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (weak_object), 0);
+}
+
+static void
+protocol_chooser_constructed (GObject *object)
+{
+ EmpathyProtocolChooser *protocol_chooser;
+ EmpathyProtocolChooserPriv *priv;
+
+ GtkCellRenderer *renderer;
+ TpDBusDaemon *dbus;
+
+ priv = GET_PRIV (object);
+ protocol_chooser = EMPATHY_PROTOCOL_CHOOSER (object);
+
+ /* set up combo box with new store */
+ priv->store = gtk_list_store_new (COL_COUNT,
+ G_TYPE_STRING, /* Icon name */
+ G_TYPE_STRING, /* Label */
+ G_TYPE_OBJECT, /* CM */
+ G_TYPE_POINTER); /* protocol */
+
+ gtk_combo_box_set_model (GTK_COMBO_BOX (object),
+ GTK_TREE_MODEL (priv->store));
+
+ renderer = gtk_cell_renderer_pixbuf_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, FALSE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer,
+ "icon-name", COL_ICON,
+ NULL);
+ g_object_set (renderer, "stock-size", GTK_ICON_SIZE_BUTTON, NULL);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer,
+ "text", COL_LABEL,
+ NULL);
+
+ dbus = tp_dbus_daemon_dup (NULL);
+ tp_list_connection_managers (dbus, protocol_choosers_cms_listed,
+ NULL, NULL, object);
+ g_object_unref (dbus);
+
+ /* Set the protocol sort function */
+ gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (priv->store),
+ COL_PROTOCOL,
+ protocol_chooser_sort_func,
+ NULL, NULL);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (priv->store),
+ COL_PROTOCOL,
+ GTK_SORT_ASCENDING);
+
+ if (G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->constructed)
+ G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->constructed (object);
+}
+
+static void
+empathy_protocol_chooser_init (EmpathyProtocolChooser *protocol_chooser)
+{
+ EmpathyProtocolChooserPriv *priv =
+ G_TYPE_INSTANCE_GET_PRIVATE (protocol_chooser,
+ EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooserPriv);
+
+ priv->dispose_run = FALSE;
+
+ protocol_chooser->priv = priv;
+}
+
+static void
+protocol_chooser_dispose (GObject *object)
+{
+ EmpathyProtocolChooser *protocol_chooser = EMPATHY_PROTOCOL_CHOOSER (object);
+ EmpathyProtocolChooserPriv *priv = GET_PRIV (protocol_chooser);
+
+ if (priv->dispose_run)
+ return;
+
+ priv->dispose_run = TRUE;
+
+ if (priv->store)
+ {
+ g_object_unref (priv->store);
+ priv->store = NULL;
+ }
+
+ (G_OBJECT_CLASS (empathy_protocol_chooser_parent_class)->dispose) (object);
+}
+
+static void
+empathy_protocol_chooser_class_init (EmpathyProtocolChooserClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = protocol_chooser_constructed;
+ object_class->dispose = protocol_chooser_dispose;
+
+ g_type_class_add_private (object_class, sizeof (EmpathyProtocolChooserPriv));
+}
+
+/**
+ * empathy_protocol_chooser_get_selected_protocol:
+ * @protocol_chooser: an #EmpathyProtocolChooser
+ *
+ * Returns a pointer to the selected #TpConnectionManagerProtocol in
+ * @protocol_chooser.
+ *
+ * Return value: a pointer to the selected #TpConnectionManagerProtocol
+ */
+TpConnectionManager *empathy_protocol_chooser_dup_selected (
+ EmpathyProtocolChooser *protocol_chooser,
+ TpConnectionManagerProtocol **protocol)
+{
+ EmpathyProtocolChooserPriv *priv = GET_PRIV (protocol_chooser);
+ GtkTreeIter iter;
+ TpConnectionManager *cm = NULL;
+
+ g_return_val_if_fail (EMPATHY_IS_PROTOCOL_CHOOSER (protocol_chooser), NULL);
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (protocol_chooser), &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ COL_CM, &cm,
+ -1);
+
+ if (protocol != NULL)
+ gtk_tree_model_get (GTK_TREE_MODEL (priv->store), &iter,
+ COL_PROTOCOL, protocol,
+ -1);
+ }
+
+ return cm;
+}
+
+/**
+ * empathy_protocol_chooser_n_protocols:
+ * @protocol_chooser: an #EmpathyProtocolChooser
+ *
+ * Returns the number of protocols in @protocol_chooser.
+ *
+ * Return value: the number of protocols in @protocol_chooser
+ */
+gint
+empathy_protocol_chooser_n_protocols (EmpathyProtocolChooser *protocol_chooser)
+{
+ EmpathyProtocolChooserPriv *priv = GET_PRIV (protocol_chooser);
+
+ g_return_val_if_fail (EMPATHY_IS_PROTOCOL_CHOOSER (protocol_chooser), 0);
+
+ return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (priv->store), NULL);
+}
+
+/**
+ * empathy_protocol_chooser_new:
+ *
+ * Creates a new #EmpathyProtocolChooser widget.
+ *
+ * Return value: a new #EmpathyProtocolChooser widget
+ */
+GtkWidget *
+empathy_protocol_chooser_new (void)
+{
+ return GTK_WIDGET (g_object_new (EMPATHY_TYPE_PROTOCOL_CHOOSER, NULL));
+}
diff --git a/libempathy-gtk/empathy-protocol-chooser.h b/libempathy-gtk/empathy-protocol-chooser.h
new file mode 100644
index 000000000..75f9343cc
--- /dev/null
+++ b/libempathy-gtk/empathy-protocol-chooser.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2; -*- */
+/*
+ * Copyright (C) 2007-2009 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Xavier Claessens <xclaesse@gmail.com>
+ * Jonny Lamb <jonny.lamb@collabora.co.uk
+ */
+
+#ifndef __EMPATHY_PROTOCOL_CHOOSER_H__
+#define __EMPATHY_PROTOCOL_CHOOSER_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#include <telepathy-glib/connection-manager.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_TYPE_PROTOCOL_CHOOSER (empathy_protocol_chooser_get_type ())
+#define EMPATHY_PROTOCOL_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
+ EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooser))
+#define EMPATHY_PROTOCOL_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), \
+ EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooserClass))
+#define EMPATHY_IS_PROTOCOL_CHOOSER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
+ EMPATHY_TYPE_PROTOCOL_CHOOSER))
+#define EMPATHY_IS_PROTOCOL_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
+ EMPATHY_TYPE_PROTOCOL_CHOOSER))
+#define EMPATHY_PROTOCOL_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
+ EMPATHY_TYPE_PROTOCOL_CHOOSER, EmpathyProtocolChooserClass))
+
+typedef struct _EmpathyProtocolChooser EmpathyProtocolChooser;
+typedef struct _EmpathyProtocolChooserClass EmpathyProtocolChooserClass;
+
+struct _EmpathyProtocolChooser
+{
+ GtkComboBox parent;
+
+ /*<private>*/
+ gpointer priv;
+};
+
+struct _EmpathyProtocolChooserClass
+{
+ GtkComboBoxClass parent_class;
+};
+
+GType empathy_protocol_chooser_get_type (void) G_GNUC_CONST;
+GtkWidget * empathy_protocol_chooser_new (void);
+TpConnectionManager *empathy_protocol_chooser_dup_selected (
+ EmpathyProtocolChooser *protocol_chooser,
+ TpConnectionManagerProtocol **protocol);
+gint empathy_protocol_chooser_n_protocols (
+ EmpathyProtocolChooser *protocol_chooser);
+
+G_END_DECLS
+#endif /* __EMPATHY_PROTOCOL_CHOOSER_H__ */
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index 3fd4932a7..e04771597 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -31,7 +31,6 @@
#include <libempathy/empathy-time.h>
#include <libempathy/empathy-utils.h>
-#include <libmissioncontrol/mc-profile.h>
#include "empathy-theme-adium.h"
#include "empathy-smiley-manager.h"
@@ -472,7 +471,6 @@ theme_adium_append_html (EmpathyThemeAdium *theme,
} else if (theme_adium_match (&cur, "%time")) {
gchar *format = NULL;
gchar *end;
-
/* Time can be in 2 formats:
* %time% or %time{strftime format}%
* Extract the time format if provided. */
@@ -517,7 +515,6 @@ theme_adium_append_message (EmpathyChatView *view,
EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
EmpathyContact *sender;
EmpathyAccount *account;
- McProfile *account_profile;
gchar *dup_body = NULL;
const gchar *body;
const gchar *name;
@@ -541,8 +538,7 @@ theme_adium_append_message (EmpathyChatView *view,
/* Get information */
sender = empathy_message_get_sender (msg);
account = empathy_contact_get_account (sender);
- account_profile = empathy_account_get_profile (account);
- service_name = mc_profile_get_display_name (account_profile);
+ service_name = empathy_account_get_protocol (account);
timestamp = empathy_message_get_timestamp (msg);
body = empathy_message_get_body (msg);
dup_body = theme_adium_parse_body (theme, body);
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 2218533f5..b697b4d0b 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -38,8 +38,6 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
-#include <libmissioncontrol/mc-profile.h>
-
#include "empathy-ui-utils.h"
#include "empathy-images.h"
#include "empathy-conf.h"
@@ -183,16 +181,6 @@ empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
}
const gchar *
-empathy_icon_name_from_account (EmpathyAccount *account)
-{
- McProfile *profile;
-
- profile = empathy_account_get_profile (account);
-
- return mc_profile_get_icon_name (profile);
-}
-
-const gchar *
empathy_icon_name_for_presence (TpConnectionPresenceType presence)
{
switch (presence) {
diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h
index 10f889b0c..312835f0c 100644
--- a/libempathy-gtk/empathy-ui-utils.h
+++ b/libempathy-gtk/empathy-ui-utils.h
@@ -34,8 +34,6 @@
#include <gtk/gtk.h>
-#include <libmissioncontrol/mc-profile.h>
-
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-account.h>
#include <libempathy/empathy-ft-handler.h>
@@ -59,7 +57,6 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui,
GtkWidget *root);
/* Pixbufs */
-const gchar * empathy_icon_name_from_account (EmpathyAccount *account);
const gchar * empathy_icon_name_for_presence (TpConnectionPresenceType presence);
const gchar * empathy_icon_name_for_contact (EmpathyContact *contact);
GdkPixbuf * empathy_pixbuf_from_data (gchar *data,