diff options
Diffstat (limited to 'libempathy-gtk')
34 files changed, 1099 insertions, 442 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index c38a96f23..5903efb15 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -54,11 +54,13 @@ libempathy_gtk_handwritten_source = \ empathy-presence-chooser.c \ empathy-profile-chooser.c \ empathy-smiley-manager.c \ + empathy-sound.c \ empathy-spell.c \ empathy-status-preset-dialog.c \ empathy-theme-boxes.c \ empathy-theme-irc.c \ empathy-theme-manager.c \ + empathy-kludge-label.c \ empathy-ui-utils.c libempathy_gtk_la_SOURCES = \ @@ -113,11 +115,13 @@ libempathy_gtk_headers = \ empathy-presence-chooser.h \ empathy-profile-chooser.h \ empathy-smiley-manager.h \ + empathy-sound.h \ empathy-spell.h \ empathy-status-preset-dialog.h \ empathy-theme-boxes.h \ empathy-theme-irc.h \ empathy-theme-manager.h \ + empathy-kludge-label.h \ empathy-ui-utils.h check_c_sources = \ diff --git a/libempathy-gtk/empathy-account-chooser.c b/libempathy-gtk/empathy-account-chooser.c index 488486fdf..7dccb2179 100644 --- a/libempathy-gtk/empathy-account-chooser.c +++ b/libempathy-gtk/empathy-account-chooser.c @@ -65,7 +65,7 @@ typedef struct { typedef struct { EmpathyAccountChooser *chooser; - McAccount *account; + EmpathyAccount *account; gboolean set; } SetAccountData; @@ -88,19 +88,19 @@ static void account_chooser_set_property (GObject GParamSpec *pspec); static void account_chooser_setup (EmpathyAccountChooser *chooser); static void account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser); -static void account_chooser_account_add_foreach (McAccount *account, +static void account_chooser_account_add_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser); static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser); -static void account_chooser_account_remove_foreach (McAccount *account, +static void account_chooser_account_remove_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser); static void account_chooser_update_iter (EmpathyAccountChooser *chooser, GtkTreeIter *iter); static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, TpConnectionStatusReason reason, TpConnectionStatus new_status, TpConnectionStatus old_status, @@ -253,16 +253,16 @@ empathy_account_chooser_new (void) * @chooser: an #EmpathyAccountChooser * * Returns the account which is currently selected in the chooser or %NULL - * if there is no account selected. The #McAccount returned should be + * if there is no account selected. The #EmpathyAccount returned should be * unrefed with g_object_unref() when finished with. * - * Return value: a new ref to the #McAccount currently selected, or %NULL. + * Return value: a new ref to the #EmpathyAccount currently selected, or %NULL. */ -McAccount * +EmpathyAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; - McAccount *account; + EmpathyAccount *account; GtkTreeModel *model; GtkTreeIter iter; @@ -295,7 +295,7 @@ TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) { EmpathyAccountChooserPriv *priv; - McAccount *account; + EmpathyAccount *account; TpConnection *connection; g_return_val_if_fail (EMPATHY_IS_ACCOUNT_CHOOSER (chooser), NULL); @@ -303,7 +303,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) priv = GET_PRIV (chooser); account = empathy_account_chooser_dup_account (chooser); - connection = empathy_account_manager_get_connection (priv->manager, account); + connection = empathy_account_get_connection (account); g_object_unref (account); return connection; @@ -312,7 +312,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) /** * empathy_account_chooser_set_account: * @chooser: an #EmpathyAccountChooser - * @account: an #McAccount + * @account: an #EmpathyAccount * * Sets the currently selected account to @account, if it exists in the list. * @@ -320,7 +320,7 @@ empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser) */ gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account) + EmpathyAccount *account) { GtkComboBox *combobox; GtkTreeModel *model; @@ -457,7 +457,7 @@ account_chooser_setup (EmpathyAccountChooser *chooser) G_TYPE_STRING, /* Image */ G_TYPE_STRING, /* Name */ G_TYPE_BOOLEAN, /* Enabled */ - MC_TYPE_ACCOUNT); + EMPATHY_TYPE_ACCOUNT); gtk_combo_box_set_model (combobox, GTK_TREE_MODEL (store)); @@ -477,25 +477,25 @@ account_chooser_setup (EmpathyAccountChooser *chooser) NULL); /* Populate accounts */ - accounts = mc_accounts_list (); + accounts = empathy_account_manager_dup_accounts (priv->manager); g_list_foreach (accounts, (GFunc) account_chooser_account_add_foreach, chooser); - mc_accounts_list_free (accounts); + g_list_free (accounts); g_object_unref (store); } static void account_chooser_account_created_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser) { account_chooser_account_add_foreach (account, chooser); } static void -account_chooser_account_add_foreach (McAccount *account, +account_chooser_account_add_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser) { GtkListStore *store; @@ -511,18 +511,20 @@ account_chooser_account_add_foreach (McAccount *account, COL_ACCOUNT_POINTER, account, -1); account_chooser_update_iter (chooser, &iter); + /* We got a reffed account and it was reffed by the liststore as well */ + g_object_unref (account); } static void account_chooser_account_deleted_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, EmpathyAccountChooser *chooser) { account_chooser_account_remove_foreach (account, chooser); } typedef struct { - McAccount *account; + EmpathyAccount *account; GtkTreeIter *iter; gboolean found; } FindAccountData; @@ -534,7 +536,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model, gpointer user_data) { FindAccountData *data = user_data; - McAccount *account; + EmpathyAccount *account; gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); @@ -553,7 +555,7 @@ account_chooser_find_account_foreach (GtkTreeModel *model, static gboolean account_chooser_find_account (EmpathyAccountChooser *chooser, - McAccount *account, + EmpathyAccount *account, GtkTreeIter *iter) { GtkListStore *store; @@ -573,7 +575,7 @@ account_chooser_find_account (EmpathyAccountChooser *chooser, } static void -account_chooser_account_remove_foreach (McAccount *account, +account_chooser_account_remove_foreach (EmpathyAccount *account, EmpathyAccountChooser *chooser) { GtkListStore *store; @@ -595,7 +597,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, EmpathyAccountChooserPriv *priv; GtkListStore *store; GtkComboBox *combobox; - McAccount *account; + EmpathyAccount *account; const gchar *icon_name; gboolean is_enabled = TRUE; @@ -615,7 +617,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, gtk_list_store_set (store, iter, COL_ACCOUNT_IMAGE, icon_name, - COL_ACCOUNT_TEXT, mc_account_get_display_name (account), + COL_ACCOUNT_TEXT, empathy_account_get_display_name (account), COL_ACCOUNT_ENABLED, is_enabled, -1); @@ -630,7 +632,7 @@ account_chooser_update_iter (EmpathyAccountChooser *chooser, static void account_chooser_connection_changed_cb (EmpathyAccountManager *manager, - McAccount *account, + EmpathyAccount *account, TpConnectionStatusReason reason, TpConnectionStatus new_status, TpConnectionStatus old_status, @@ -671,7 +673,7 @@ account_chooser_set_account_foreach (GtkTreeModel *model, GtkTreeIter *iter, SetAccountData *data) { - McAccount *account; + EmpathyAccount *account; gboolean equal; gtk_tree_model_get (model, iter, COL_ACCOUNT_POINTER, &account, -1); @@ -744,7 +746,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, /** * EmpathyAccountChooserFilterFunc: - * @account: an #McAccount + * @account: an #EmpathyAccount * @user_data: user data, or %NULL * * A function which decides whether the account indicated by @account @@ -755,7 +757,7 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, /** * empathy_account_chooser_filter_is_connected: - * @account: an #McAccount + * @account: an #EmpathyAccount * @user_data: user data or %NULL * * A useful #EmpathyAccountChooserFilterFunc that one could pass into @@ -764,17 +766,12 @@ empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, * Return value: Whether @account is connected */ gboolean -empathy_account_chooser_filter_is_connected (McAccount *account, +empathy_account_chooser_filter_is_connected (EmpathyAccount *account, gpointer user_data) { - MissionControl *mc; TpConnectionStatus status; - g_return_val_if_fail (MC_IS_ACCOUNT (account), FALSE); - - mc = empathy_mission_control_dup_singleton (); - status = mission_control_get_connection_status (mc, account, NULL); - g_object_unref (mc); + g_object_get (account, "status", &status, NULL); return status == TP_CONNECTION_STATUS_CONNECTED; } diff --git a/libempathy-gtk/empathy-account-chooser.h b/libempathy-gtk/empathy-account-chooser.h index c2105406a..255b6841f 100644 --- a/libempathy-gtk/empathy-account-chooser.h +++ b/libempathy-gtk/empathy-account-chooser.h @@ -27,7 +27,7 @@ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS @@ -38,7 +38,7 @@ G_BEGIN_DECLS #define EMPATHY_IS_ACCOUNT_CHOOSER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_ACCOUNT_CHOOSER)) #define EMPATHY_ACCOUNT_CHOOSER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_ACCOUNT_CHOOSER, EmpathyAccountChooserClass)) -typedef gboolean (* EmpathyAccountChooserFilterFunc) (McAccount *account, +typedef gboolean (* EmpathyAccountChooserFilterFunc) (EmpathyAccount *account, gpointer user_data); @@ -58,17 +58,17 @@ struct _EmpathyAccountChooserClass { GType empathy_account_chooser_get_type (void) G_GNUC_CONST; GtkWidget * empathy_account_chooser_new (void); -McAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser); +EmpathyAccount * empathy_account_chooser_dup_account (EmpathyAccountChooser *chooser); TpConnection * empathy_account_chooser_get_connection (EmpathyAccountChooser *chooser); gboolean empathy_account_chooser_set_account (EmpathyAccountChooser *chooser, - McAccount *account); + EmpathyAccount *account); gboolean empathy_account_chooser_get_has_all_option (EmpathyAccountChooser *chooser); void empathy_account_chooser_set_has_all_option (EmpathyAccountChooser *chooser, gboolean has_all_option); void empathy_account_chooser_set_filter (EmpathyAccountChooser *chooser, EmpathyAccountChooserFilterFunc filter, gpointer user_data); -gboolean empathy_account_chooser_filter_is_connected (McAccount *account, +gboolean empathy_account_chooser_filter_is_connected (EmpathyAccount *account, gpointer user_data); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget-irc.c b/libempathy-gtk/empathy-account-widget-irc.c index 1306f517f..688a3e0e6 100644 --- a/libempathy-gtk/empathy-account-widget-irc.c +++ b/libempathy-gtk/empathy-account-widget-irc.c @@ -27,7 +27,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> @@ -44,7 +43,7 @@ #define IRC_NETWORKS_FILENAME "irc-networks.xml" typedef struct { - McAccount *account; + EmpathyAccount *account; EmpathyIrcNetworkManager *network_manager; GtkWidget *vbox_settings; @@ -70,9 +69,9 @@ static void unset_server_params (EmpathyAccountWidgetIrc *settings) { DEBUG ("Unset server, port and use-ssl"); - mc_account_unset_param (settings->account, "server"); - mc_account_unset_param (settings->account, "port"); - mc_account_unset_param (settings->account, "use-ssl"); + empathy_account_unset_param (settings->account, "server"); + empathy_account_unset_param (settings->account, "port"); + empathy_account_unset_param (settings->account, "use-ssl"); } static void @@ -98,7 +97,7 @@ update_server_params (EmpathyAccountWidgetIrc *settings) g_object_get (network, "charset", &charset, NULL); DEBUG ("Setting charset to %s", charset); - mc_account_set_param_string (settings->account, "charset", charset); + empathy_account_set_param_string (settings->account, "charset", charset); g_free (charset); servers = empathy_irc_network_get_servers (network); @@ -117,11 +116,11 @@ update_server_params (EmpathyAccountWidgetIrc *settings) NULL); DEBUG ("Setting server to %s", address); - mc_account_set_param_string (settings->account, "server", address); + empathy_account_set_param_string (settings->account, "server", address); DEBUG ("Setting port to %u", port); - mc_account_set_param_int (settings->account, "port", port); + empathy_account_set_param_int (settings->account, "port", port); DEBUG ("Setting use-ssl to %s", ssl ? "TRUE": "FALSE" ); - mc_account_set_param_boolean (settings->account, "use-ssl", ssl); + empathy_account_set_param_boolean (settings->account, "use-ssl", ssl); g_free (address); } @@ -332,17 +331,17 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) gboolean ssl = FALSE; EmpathyIrcNetwork *network = NULL; - mc_account_get_param_string (settings->account, "account", &nick); - mc_account_get_param_string (settings->account, "fullname", &fullname); - mc_account_get_param_string (settings->account, "server", &server); - mc_account_get_param_string (settings->account, "charset", &charset); - mc_account_get_param_int (settings->account, "port", &port); - mc_account_get_param_boolean (settings->account, "use-ssl", &ssl); + 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"); if (!nick) { nick = g_strdup (g_get_user_name ()); - mc_account_set_param_string (settings->account, "account", nick); + empathy_account_set_param_string (settings->account, "account", nick); } if (!fullname) @@ -352,7 +351,7 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) { fullname = g_strdup (nick); } - mc_account_set_param_string (settings->account, "fullname", fullname); + empathy_account_set_param_string (settings->account, "fullname", fullname); } if (server != NULL) @@ -414,14 +413,14 @@ account_widget_irc_setup (EmpathyAccountWidgetIrc *settings) /** * empathy_account_widget_irc_new: - * @account: the #McAccount to configure + * @account: the #EmpathyAccount to configure * - * Creates a new IRC account widget to configure a given #McAccount + * 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 (McAccount *account) +empathy_account_widget_irc_new (EmpathyAccount *account) { EmpathyAccountWidgetIrc *settings; gchar *dir, *user_file_with_path, *global_file_with_path; diff --git a/libempathy-gtk/empathy-account-widget-irc.h b/libempathy-gtk/empathy-account-widget-irc.h index a89081fc0..40e58bbc3 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 <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_account_widget_irc_new (McAccount *account); +GtkWidget * empathy_account_widget_irc_new (EmpathyAccount *account); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget-sip.c b/libempathy-gtk/empathy-account-widget-sip.c index da6082495..05e917e53 100644 --- a/libempathy-gtk/empathy-account-widget-sip.c +++ b/libempathy-gtk/empathy-account-widget-sip.c @@ -28,7 +28,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> @@ -38,7 +37,7 @@ #include "empathy-ui-utils.h" typedef struct { - McAccount *account; + EmpathyAccount *account; GtkWidget *vbox_settings; @@ -69,14 +68,14 @@ account_widget_sip_discover_stun_toggled_cb ( /** * empathy_account_widget_sip_new: - * @account: the #McAccount to configure + * @account: the #EmpathyAccount to configure * - * Creates a new SIP account widget to configure a given #McAccount + * 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 (McAccount *account) +empathy_account_widget_sip_new (EmpathyAccount *account) { EmpathyAccountWidgetSip *settings; GtkBuilder *gui; diff --git a/libempathy-gtk/empathy-account-widget-sip.h b/libempathy-gtk/empathy-account-widget-sip.h index 9187c1e0c..69f60aacc 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 <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_account_widget_sip_new (McAccount *account); +GtkWidget * empathy_account_widget_sip_new (EmpathyAccount *account); G_END_DECLS diff --git a/libempathy-gtk/empathy-account-widget.c b/libempathy-gtk/empathy-account-widget.c index b0d7f8de5..f602cd8bd 100644 --- a/libempathy-gtk/empathy-account-widget.c +++ b/libempathy-gtk/empathy-account-widget.c @@ -29,10 +29,10 @@ #include <gtk/gtk.h> #include <glib/gi18n-lib.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-account-widget.h" #include "empathy-ui-utils.h" @@ -43,7 +43,7 @@ static gboolean account_widget_entry_focus_cb (GtkWidget *widget, GdkEventFocus *event, - McAccount *account) + EmpathyAccount *account) { const gchar *str; const gchar *param_name; @@ -54,8 +54,8 @@ account_widget_entry_focus_cb (GtkWidget *widget, if (EMP_STR_EMPTY (str)) { gchar *value = NULL; - mc_account_unset_param (account, param_name); - mc_account_get_param_string (account, param_name, &value); + empathy_account_unset_param (account, param_name); + value = empathy_account_get_param_string (account, param_name); DEBUG ("Unset %s and restore to %s", param_name, value); gtk_entry_set_text (GTK_ENTRY (widget), value ? value : ""); g_free (value); @@ -64,7 +64,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, const gchar *domain = NULL; gchar *dup_str = NULL; - profile = mc_account_get_profile (account); + 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); @@ -78,7 +78,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, } DEBUG ("Setting %s to %s", param_name, strstr (param_name, "password") ? "***" : str); - mc_account_set_param_string (account, param_name, str); + empathy_account_set_param_string (account, param_name, str); g_free (dup_str); g_object_unref (profile); } @@ -88,7 +88,7 @@ account_widget_entry_focus_cb (GtkWidget *widget, static void account_widget_int_changed_cb (GtkWidget *widget, - McAccount *account) + EmpathyAccount *account) { const gchar *param_name; gint value; @@ -97,19 +97,19 @@ account_widget_int_changed_cb (GtkWidget *widget, param_name = g_object_get_data (G_OBJECT (widget), "param_name"); if (value == 0) { - mc_account_unset_param (account, param_name); - mc_account_get_param_int (account, param_name, &value); + 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); - mc_account_set_param_int (account, param_name, value); + empathy_account_set_param_int (account, param_name, value); } } static void account_widget_checkbutton_toggled_cb (GtkWidget *widget, - McAccount *account) + EmpathyAccount *account) { gboolean value; gboolean default_value; @@ -121,14 +121,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. */ - mc_account_unset_param (account, param_name); - mc_account_get_param_boolean (account, param_name, &default_value); + empathy_account_unset_param (account, param_name); + default_value = empathy_account_get_param_boolean (account, 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); - mc_account_set_param_boolean (account, param_name, value); + empathy_account_set_param_boolean (account, param_name, value); } } @@ -136,14 +136,14 @@ static void account_widget_forget_clicked_cb (GtkWidget *button, GtkWidget *entry) { - McAccount *account; + EmpathyAccount *account; const gchar *param_name; param_name = g_object_get_data (G_OBJECT (entry), "param_name"); account = g_object_get_data (G_OBJECT (entry), "account"); DEBUG ("Unset %s", param_name); - mc_account_unset_param (account, param_name); + empathy_account_unset_param (account, param_name); gtk_entry_set_text (GTK_ENTRY (entry), ""); } @@ -161,13 +161,13 @@ static void account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, GtkWidget *spinbutton_port) { - McAccount *account; + EmpathyAccount *account; gboolean value; gint port = 0; value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl)); account = g_object_get_data (G_OBJECT (spinbutton_port), "account"); - mc_account_get_param_int (account, "port", &port); + port = empathy_account_get_param_int (account, "port"); if (value) { if (port == 5222 || port == 0) { @@ -184,7 +184,7 @@ account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl, static void account_widget_setup_widget (GtkWidget *widget, - McAccount *account, + EmpathyAccount *account, const gchar *param_name) { g_object_set_data_full (G_OBJECT (widget), "param_name", @@ -195,7 +195,7 @@ account_widget_setup_widget (GtkWidget *widget, if (GTK_IS_SPIN_BUTTON (widget)) { gint value = 0; - mc_account_get_param_int (account, param_name, &value); + 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", @@ -205,7 +205,7 @@ account_widget_setup_widget (GtkWidget *widget, else if (GTK_IS_ENTRY (widget)) { gchar *str = NULL; - mc_account_get_param_string (account, param_name, &str); + str = empathy_account_get_param_string (account, param_name); gtk_entry_set_text (GTK_ENTRY (widget), str ? str : ""); g_free (str); @@ -220,7 +220,7 @@ account_widget_setup_widget (GtkWidget *widget, else if (GTK_IS_TOGGLE_BUTTON (widget)) { gboolean value = FALSE; - mc_account_get_param_boolean (account, param_name, &value); + value = empathy_account_get_param_boolean (account, param_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value); g_signal_connect (widget, "toggled", @@ -256,7 +256,7 @@ account_widget_generic_format_param_name (const gchar *param_name) } static void -accounts_widget_generic_setup (McAccount *account, +accounts_widget_generic_setup (EmpathyAccount *account, GtkWidget *table_common_settings, GtkWidget *table_advanced_settings) { @@ -264,7 +264,7 @@ accounts_widget_generic_setup (McAccount *account, McProfile *profile; GSList *params, *l; - profile = mc_account_get_profile (account); + profile = empathy_account_get_profile (account); protocol = mc_profile_get_protocol (profile); if (!protocol) { @@ -400,7 +400,7 @@ accounts_widget_generic_setup (McAccount *account, } static void -account_widget_handle_params_valist (McAccount *account, +account_widget_handle_params_valist (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, va_list args) @@ -424,14 +424,13 @@ account_widget_handle_params_valist (McAccount *account, } void -empathy_account_widget_handle_params (McAccount *account, +empathy_account_widget_handle_params (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, ...) { va_list args; - g_return_if_fail (MC_IS_ACCOUNT (account)); g_return_if_fail (GTK_IS_BUILDER (gui)); va_start (args, first_widget); @@ -440,7 +439,7 @@ empathy_account_widget_handle_params (McAccount *account, } void -empathy_account_widget_add_forget_button (McAccount *account, +empathy_account_widget_add_forget_button (EmpathyAccount *account, GtkBuilder *gui, const gchar *button, const gchar *entry) @@ -452,7 +451,7 @@ empathy_account_widget_add_forget_button (McAccount *account, button_forget = GTK_WIDGET (gtk_builder_get_object (gui, button)); entry_password = GTK_WIDGET (gtk_builder_get_object (gui, entry)); - mc_account_get_param_string (account, "password", &password); + password = empathy_account_get_param_string (account, "password"); gtk_widget_set_sensitive (button_forget, !EMP_STR_EMPTY (password)); g_free (password); @@ -477,7 +476,7 @@ empathy_account_widget_set_default_focus (GtkBuilder *gui, } GtkWidget * -empathy_account_widget_generic_new (McAccount *account) +empathy_account_widget_generic_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -485,8 +484,6 @@ empathy_account_widget_generic_new (McAccount *account) GtkWidget *table_advanced_settings; gchar *filename; - g_return_val_if_fail (MC_IS_ACCOUNT (account), NULL); - filename = empathy_file_lookup ("empathy-account-widget-generic.ui", "libempathy-gtk"); gui = empathy_builder_get_file (filename, @@ -502,7 +499,7 @@ empathy_account_widget_generic_new (McAccount *account) } GtkWidget * -empathy_account_widget_salut_new (McAccount *account) +empathy_account_widget_salut_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -530,7 +527,7 @@ empathy_account_widget_salut_new (McAccount *account) } GtkWidget * -empathy_account_widget_msn_new (McAccount *account) +empathy_account_widget_msn_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -560,7 +557,7 @@ empathy_account_widget_msn_new (McAccount *account) } GtkWidget * -empathy_account_widget_jabber_new (McAccount *account) +empathy_account_widget_jabber_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -603,7 +600,7 @@ empathy_account_widget_jabber_new (McAccount *account) } GtkWidget * -empathy_account_widget_icq_new (McAccount *account) +empathy_account_widget_icq_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -636,7 +633,7 @@ empathy_account_widget_icq_new (McAccount *account) } GtkWidget * -empathy_account_widget_aim_new (McAccount *account) +empathy_account_widget_aim_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -668,7 +665,7 @@ empathy_account_widget_aim_new (McAccount *account) } GtkWidget * -empathy_account_widget_yahoo_new (McAccount *account) +empathy_account_widget_yahoo_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; @@ -702,7 +699,7 @@ empathy_account_widget_yahoo_new (McAccount *account) } GtkWidget * -empathy_account_widget_groupwise_new (McAccount *account) +empathy_account_widget_groupwise_new (EmpathyAccount *account) { GtkBuilder *gui; GtkWidget *widget; diff --git a/libempathy-gtk/empathy-account-widget.h b/libempathy-gtk/empathy-account-widget.h index 7287f5675..7a76db9e0 100644 --- a/libempathy-gtk/empathy-account-widget.h +++ b/libempathy-gtk/empathy-account-widget.h @@ -27,28 +27,28 @@ #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -void empathy_account_widget_handle_params (McAccount *account, +void empathy_account_widget_handle_params (EmpathyAccount *account, GtkBuilder *gui, const gchar *first_widget, ...); -void empathy_account_widget_add_forget_button (McAccount *account, +void empathy_account_widget_add_forget_button (EmpathyAccount *account, GtkBuilder *gui, const gchar *button, const gchar *entry); void empathy_account_widget_set_default_focus (GtkBuilder *gui, const gchar *entry); -GtkWidget *empathy_account_widget_generic_new (McAccount *account); -GtkWidget *empathy_account_widget_salut_new (McAccount *account); -GtkWidget *empathy_account_widget_msn_new (McAccount *account); -GtkWidget *empathy_account_widget_jabber_new (McAccount *account); -GtkWidget *empathy_account_widget_icq_new (McAccount *account); -GtkWidget *empathy_account_widget_aim_new (McAccount *account); -GtkWidget *empathy_account_widget_yahoo_new (McAccount *account); -GtkWidget *empathy_account_widget_groupwise_new (McAccount *account); +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); G_END_DECLS diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index 83475b565..af96885e4 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -786,24 +786,24 @@ avatar_chooser_drag_data_received_cb (GtkWidget *widget, gchar *target_type; gboolean handled = FALSE; - target_type = gdk_atom_name (selection_data->target); + target_type = gdk_atom_name (gtk_selection_data_get_target (selection_data)); if (!strcmp (target_type, URI_LIST_TYPE)) { GFile *file; GFileInputStream *input_stream; gchar *nl; gchar *data = NULL; - nl = strstr (selection_data->data, "\r\n"); + nl = strstr (gtk_selection_data_get_data (selection_data), "\r\n"); if (nl) { gchar *uri; - uri = g_strndup (selection_data->data, - nl - (gchar *) selection_data->data); + uri = g_strndup (gtk_selection_data_get_data (selection_data), + nl - (gchar *) gtk_selection_data_get_data (selection_data)); file = g_file_new_for_uri (uri); g_free (uri); } else { - file = g_file_new_for_uri (selection_data->data); + file = g_file_new_for_uri (gtk_selection_data_get_data (selection_data)); } input_stream = g_file_read (file, NULL, NULL); diff --git a/libempathy-gtk/empathy-avatar-image.c b/libempathy-gtk/empathy-avatar-image.c index d430c0fa6..f7898e1bd 100644 --- a/libempathy-gtk/empathy-avatar-image.c +++ b/libempathy-gtk/empathy-avatar-image.c @@ -232,7 +232,7 @@ avatar_image_button_press_event (GtkWidget *widget, GdkEventButton *event) gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); g_object_unref (pixbuf); - gdk_window_get_origin (priv->image->window, &x, &y); + gdk_window_get_origin (gtk_widget_get_window (priv->image), &x, &y); x = x - (popup_width - width) / 2; y = y - (popup_height - height) / 2; diff --git a/libempathy-gtk/empathy-cell-renderer-expander.c b/libempathy-gtk/empathy-cell-renderer-expander.c index 6fb7cfded..bd5c89f19 100644 --- a/libempathy-gtk/empathy-cell-renderer-expander.c +++ b/libempathy-gtk/empathy-cell-renderer-expander.c @@ -101,9 +101,11 @@ empathy_cell_renderer_expander_init (EmpathyCellRendererExpander *expander) priv->activatable = TRUE; priv->animation_node = NULL; - GTK_CELL_RENDERER (expander)->xpad = 2; - GTK_CELL_RENDERER (expander)->ypad = 2; - GTK_CELL_RENDERER (expander)->mode = GTK_CELL_RENDERER_MODE_ACTIVATABLE; + g_object_set (expander, + "xpad", 2, + "ypad", 2, + "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, + NULL); } static void @@ -252,18 +254,27 @@ empathy_cell_renderer_expander_get_size (GtkCellRenderer *cell, { EmpathyCellRendererExpander *expander; EmpathyCellRendererExpanderPriv *priv; + gfloat xalign, yalign; + guint xpad, ypad; expander = (EmpathyCellRendererExpander *) cell; priv = GET_PRIV (expander); + g_object_get (cell, + "xalign", &xalign, + "yalign", &yalign, + "xpad", &xpad, + "ypad", &ypad, + NULL); + if (cell_area) { if (x_offset) { - *x_offset = cell->xalign * (cell_area->width - (priv->expander_size + (2 * cell->xpad))); + *x_offset = xalign * (cell_area->width - (priv->expander_size + (2 * xpad))); *x_offset = MAX (*x_offset, 0); } if (y_offset) { - *y_offset = cell->yalign * (cell_area->height - (priv->expander_size + (2 * cell->ypad))); + *y_offset = yalign * (cell_area->height - (priv->expander_size + (2 * ypad))); *y_offset = MAX (*y_offset, 0); } } else { @@ -275,10 +286,10 @@ empathy_cell_renderer_expander_get_size (GtkCellRenderer *cell, } if (width) - *width = cell->xpad * 2 + priv->expander_size; + *width = xpad * 2 + priv->expander_size; if (height) - *height = cell->ypad * 2 + priv->expander_size; + *height = ypad * 2 + priv->expander_size; } static void @@ -294,6 +305,8 @@ empathy_cell_renderer_expander_render (GtkCellRenderer *cell, EmpathyCellRendererExpanderPriv *priv; GtkExpanderStyle expander_style; gint x_offset, y_offset; + guint xpad, ypad; + expander = (EmpathyCellRendererExpander *) cell; priv = GET_PRIV (expander); @@ -319,14 +332,19 @@ empathy_cell_renderer_expander_render (GtkCellRenderer *cell, &x_offset, &y_offset, NULL, NULL); - gtk_paint_expander (widget->style, + g_object_get (cell, + "xpad", &xpad, + "ypad", &ypad, + NULL); + + gtk_paint_expander (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL, expose_area, widget, "treeview", - cell_area->x + x_offset + cell->xpad + priv->expander_size / 2, - cell_area->y + y_offset + cell->ypad + priv->expander_size / 2, + cell_area->x + x_offset + xpad + priv->expander_size / 2, + cell_area->y + y_offset + ypad + priv->expander_size / 2, expander_style); } diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c index c47b5474f..d7ebda647 100644 --- a/libempathy-gtk/empathy-chat-text-view.c +++ b/libempathy-gtk/empathy-chat-text-view.c @@ -34,9 +34,9 @@ #include <gtk/gtk.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-account.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-chat-text-view.h" #include "empathy-chat.h" @@ -495,7 +495,9 @@ chat_text_view_size_allocate (GtkWidget *widget, GtkAdjustment *adj; adj = GTK_TEXT_VIEW (widget)->vadjustment; - gtk_adjustment_set_value (adj, adj->upper - adj->page_size); + gtk_adjustment_set_value (adj, + gtk_adjustment_get_upper (adj) - + gtk_adjustment_get_page_size (adj)); } } @@ -652,7 +654,7 @@ chat_text_view_scroll_cb (EmpathyChatTextView *view) priv = GET_PRIV (view); adj = GTK_TEXT_VIEW (view)->vadjustment; - max_val = adj->upper - adj->page_size; + max_val = gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj); g_return_val_if_fail (priv->scroll_time != NULL, FALSE); @@ -817,6 +819,10 @@ chat_text_view_clear (EmpathyChatView *view) priv = GET_PRIV (view); priv->last_timestamp = 0; + if (priv->last_contact) { + g_object_unref (priv->last_contact); + priv->last_contact = NULL; + } } static gboolean diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index 9c5e47b0e..a8ca745e2 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -64,7 +64,7 @@ #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyChat) typedef struct { EmpathyTpChat *tp_chat; - McAccount *account; + EmpathyAccount *account; gchar *id; gchar *name; gchar *subject; @@ -201,7 +201,7 @@ chat_new_connection_cb (EmpathyAccountManager *manager, EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); - McAccount *account; + EmpathyAccount *account; account = empathy_account_manager_get_account (manager, connection); if (!priv->tp_chat && empathy_account_equal (account, priv->account) && @@ -748,13 +748,14 @@ chat_input_key_press_event_cb (GtkWidget *widget, if (!(event->state & GDK_CONTROL_MASK) && event->keyval == GDK_Page_Up) { adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (text_view_sw)); - gtk_adjustment_set_value (adj, adj->value - adj->page_size); + gtk_adjustment_set_value (adj, gtk_adjustment_get_value (adj) - gtk_adjustment_get_page_size (adj)); return TRUE; } if ((event->state & GDK_CONTROL_MASK) != GDK_CONTROL_MASK && event->keyval == GDK_Page_Down) { adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (text_view_sw)); - val = MIN (adj->value + adj->page_size, adj->upper - adj->page_size); + val = MIN (gtk_adjustment_get_value (adj) + gtk_adjustment_get_page_size (adj), + gtk_adjustment_get_upper (adj) - gtk_adjustment_get_page_size (adj)); gtk_adjustment_set_value (adj, val); return TRUE; } @@ -1161,6 +1162,56 @@ chat_contacts_completion_func (const gchar *s1, return ret; } +static gchar * +build_part_message (guint reason, + const gchar *name, + EmpathyContact *actor, + const gchar *message) +{ + GString *s = g_string_new (""); + const gchar *actor_name = NULL; + + if (actor != NULL) { + actor_name = empathy_contact_get_name (actor); + } + + /* Having an actor only really makes sense for a few actions... */ + switch (reason) { + case TP_CHANNEL_GROUP_CHANGE_REASON_OFFLINE: + g_string_append_printf (s, _("%s has disconnected"), name); + break; + case TP_CHANNEL_GROUP_CHANGE_REASON_KICKED: + if (actor_name != NULL) { + g_string_append_printf (s, _("%s was kicked by %s"), + name, actor_name); + } else { + g_string_append_printf (s, _("%s was kicked"), name); + } + break; + case TP_CHANNEL_GROUP_CHANGE_REASON_BANNED: + if (actor_name != NULL) { + g_string_append_printf (s, _("%s was banned by %s"), + name, actor_name); + } else { + g_string_append_printf (s, _("%s was banned"), name); + } + break; + default: + g_string_append_printf (s, _("%s has left the room"), name); + } + + if (!EMP_STR_EMPTY (message)) { + /* Note to translators: this string is appended to + * notifications like "foo has left the room", with the message + * given by the user living the room. If this poses a problem, + * please let us know. :-) + */ + g_string_append_printf (s, _(" (%s)"), message); + } + + return g_string_free (s, FALSE); +} + static void chat_members_changed_cb (EmpathyTpChat *tp_chat, EmpathyContact *contact, @@ -1171,20 +1222,21 @@ chat_members_changed_cb (EmpathyTpChat *tp_chat, EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); + const gchar *name = empathy_contact_get_name (contact); + gchar *str; - if (priv->block_events_timeout_id == 0) { - gchar *str; + if (priv->block_events_timeout_id != 0) + return; - if (is_member) { - str = g_strdup_printf (_("%s has joined the room"), - empathy_contact_get_name (contact)); - } else { - str = g_strdup_printf (_("%s has left the room"), - empathy_contact_get_name (contact)); - } - empathy_chat_view_append_event (chat->view, str); - g_free (str); + if (is_member) { + str = g_strdup_printf (_("%s has joined the room"), + name); + } else { + str = build_part_message (reason, name, actor, message); } + + empathy_chat_view_append_event (chat->view, str); + g_free (str); } static gboolean @@ -1427,15 +1479,18 @@ chat_size_request (GtkWidget *widget, GtkRequisition *requisition) { GtkBin *bin = GTK_BIN (widget); + GtkWidget *child; + + requisition->width = gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2; + requisition->height = gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2; - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; + child = gtk_bin_get_child (bin); - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + if (child && GTK_WIDGET_VISIBLE (child)) { GtkRequisition child_requisition; - gtk_widget_size_request (bin->child, &child_requisition); + gtk_widget_size_request (child, &child_requisition); requisition->width += child_requisition.width; requisition->height += child_requisition.height; @@ -1448,17 +1503,20 @@ chat_size_allocate (GtkWidget *widget, { GtkBin *bin = GTK_BIN (widget); GtkAllocation child_allocation; + GtkWidget *child; widget->allocation = *allocation; - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) + child = gtk_bin_get_child (bin); + + if (child && GTK_WIDGET_VISIBLE (child)) { - child_allocation.x = allocation->x + GTK_CONTAINER (widget)->border_width; - child_allocation.y = allocation->y + GTK_CONTAINER (widget)->border_width; - child_allocation.width = MAX (allocation->width - GTK_CONTAINER (widget)->border_width * 2, 0); - child_allocation.height = MAX (allocation->height - GTK_CONTAINER (widget)->border_width * 2, 0); + child_allocation.x = allocation->x + gtk_container_get_border_width (GTK_CONTAINER (widget)); + child_allocation.y = allocation->y + gtk_container_get_border_width (GTK_CONTAINER (widget)); + child_allocation.width = MAX (allocation->width - gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0); + child_allocation.height = MAX (allocation->height - gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2, 0); - gtk_widget_size_allocate (bin->child, &child_allocation); + gtk_widget_size_allocate (child, &child_allocation); } } @@ -1562,7 +1620,7 @@ empathy_chat_class_init (EmpathyChatClass *klass) g_param_spec_object ("account", "Account of the chat", "The account of the chat", - MC_TYPE_ACCOUNT, + EMPATHY_TYPE_ACCOUNT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (object_class, @@ -1753,7 +1811,7 @@ empathy_chat_set_tp_chat (EmpathyChat *chat, show_pending_messages (chat); } -McAccount * +EmpathyAccount * empathy_chat_get_account (EmpathyChat *chat) { EmpathyChatPriv *priv = GET_PRIV (chat); diff --git a/libempathy-gtk/empathy-chat.h b/libempathy-gtk/empathy-chat.h index c38fd64a6..c7158759a 100644 --- a/libempathy-gtk/empathy-chat.h +++ b/libempathy-gtk/empathy-chat.h @@ -66,7 +66,7 @@ EmpathyChat * empathy_chat_new (EmpathyTpChat *tp_chat); EmpathyTpChat * empathy_chat_get_tp_chat (EmpathyChat *chat); void empathy_chat_set_tp_chat (EmpathyChat *chat, EmpathyTpChat *tp_chat); -McAccount * empathy_chat_get_account (EmpathyChat *chat); +EmpathyAccount * empathy_chat_get_account (EmpathyChat *chat); const gchar * empathy_chat_get_id (EmpathyChat *chat); const gchar * empathy_chat_get_name (EmpathyChat *chat); const gchar * empathy_chat_get_subject (EmpathyChat *chat); diff --git a/libempathy-gtk/empathy-contact-dialogs.c b/libempathy-gtk/empathy-contact-dialogs.c index 39edbf579..d271cdd28 100644 --- a/libempathy-gtk/empathy-contact-dialogs.c +++ b/libempathy-gtk/empathy-contact-dialogs.c @@ -193,7 +193,7 @@ empathy_contact_information_dialog_show (EmpathyContact *contact, EMPATHY_CONTACT_WIDGET_SHOW_LOCATION | EMPATHY_CONTACT_WIDGET_EDIT_NONE); gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), contact_widget, TRUE, TRUE, 0); gtk_widget_show (contact_widget); @@ -252,7 +252,7 @@ empathy_contact_edit_dialog_show (EmpathyContact *contact, EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), contact_widget, TRUE, TRUE, 0); gtk_widget_show (contact_widget); @@ -304,7 +304,7 @@ empathy_contact_personal_dialog_show (GtkWindow *parent) EMPATHY_CONTACT_WIDGET_EDIT_ALIAS | EMPATHY_CONTACT_WIDGET_EDIT_AVATAR); gtk_container_set_border_width (GTK_CONTAINER (contact_widget), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (personal_dialog)->vbox), + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (personal_dialog))), contact_widget, TRUE, TRUE, 0); empathy_contact_widget_set_account_filter (contact_widget, @@ -328,26 +328,20 @@ empathy_contact_personal_dialog_show (GtkWindow *parent) */ static gboolean -can_add_contact_to_account (McAccount *account, +can_add_contact_to_account (EmpathyAccount *account, gpointer user_data) { - EmpathyAccountManager *account_manager; EmpathyContactManager *contact_manager; TpConnection *connection; gboolean result; - account_manager = empathy_account_manager_dup_singleton (); - connection = empathy_account_manager_get_connection (account_manager, - account); - if (!connection) { - g_object_unref (account_manager); + connection = empathy_account_get_connection (account); + if (connection == NULL) return FALSE; - } contact_manager = empathy_contact_manager_dup_singleton (); result = empathy_contact_manager_can_add (contact_manager, connection); g_object_unref (contact_manager); - g_object_unref (account_manager); return result; } @@ -413,7 +407,7 @@ empathy_new_contact_dialog_show (GtkWindow *parent) EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT | EMPATHY_CONTACT_WIDGET_EDIT_ID | EMPATHY_CONTACT_WIDGET_EDIT_GROUPS); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), contact_widget, TRUE, TRUE, 0); empathy_contact_widget_set_account_filter (contact_widget, diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c index 61db60cdf..9cebe1daa 100644 --- a/libempathy-gtk/empathy-contact-list-view.c +++ b/libempathy-gtk/empathy-contact-list-view.c @@ -32,7 +32,6 @@ #include <gtk/gtk.h> #include <telepathy-glib/util.h> -#include <libmissioncontrol/mc-account.h> #include <libempathy/empathy-account-manager.h> #include <libempathy/empathy-call-factory.h> @@ -247,7 +246,7 @@ contact_list_view_drag_data_received (GtkWidget *view, EmpathyContactListViewPriv *priv; EmpathyAccountManager *account_manager; EmpathyTpContactFactory *factory = NULL; - McAccount *account; + EmpathyAccount *account; GtkTreeModel *model; GtkTreeViewDropPosition position; GtkTreePath *path; @@ -293,7 +292,7 @@ contact_list_view_drag_data_received (GtkWidget *view, goto OUT; } - id = (const gchar*) selection->data; + id = (const gchar*) gtk_selection_data_get_data (selection); DEBUG ("Received %s%s drag & drop contact from roster with id:'%s'", context->action == GDK_ACTION_MOVE ? "move" : "", context->action == GDK_ACTION_COPY ? "copy" : "", @@ -302,19 +301,17 @@ contact_list_view_drag_data_received (GtkWidget *view, strv = g_strsplit (id, "/", 2); account_id = strv[0]; contact_id = strv[1]; - account = mc_account_lookup (account_id); + account_manager = empathy_account_manager_dup_singleton (); + account = empathy_account_manager_lookup (account_manager, account_id); if (account) { TpConnection *connection; - /* FIXME: We assume we have already an account manager */ - account_manager = empathy_account_manager_dup_singleton (); - connection = empathy_account_manager_get_connection (account_manager, - account); + connection = empathy_account_get_connection (account); if (connection) { factory = empathy_tp_contact_factory_dup_singleton (connection); } - g_object_unref (account_manager); } + g_object_unref (account_manager); if (!factory) { DEBUG ("Failed to get factory for account '%s'", account_id); @@ -451,7 +448,7 @@ contact_list_view_drag_data_get (GtkWidget *widget, GtkTreeIter iter; GtkTreeModel *model; EmpathyContact *contact; - McAccount *account; + EmpathyAccount *account; const gchar *contact_id; const gchar *account_id; gchar *str; @@ -481,7 +478,7 @@ contact_list_view_drag_data_get (GtkWidget *widget, } account = empathy_contact_get_account (contact); - account_id = mc_account_get_unique_name (account); + account_id = empathy_account_get_unique_name (account); contact_id = empathy_contact_get_id (contact); g_object_unref (contact); str = g_strconcat (account_id, "/", contact_id, NULL); @@ -854,7 +851,7 @@ contact_list_view_expander_cell_data_func (GtkTreeViewColumn *column, gboolean row_expanded; path = gtk_tree_model_get_path (model, iter); - row_expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (column->tree_view), path); + row_expanded = gtk_tree_view_row_expanded (GTK_TREE_VIEW (gtk_tree_view_column_get_tree_view (column)), path); gtk_tree_path_free (path); g_object_set (cell, diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c index 12a139303..f078f5248 100644 --- a/libempathy-gtk/empathy-contact-widget.c +++ b/libempathy-gtk/empathy-contact-widget.c @@ -32,7 +32,6 @@ #include <champlain-gtk/champlain-gtk.h> #endif -#include <libmissioncontrol/mc-account.h> #include <telepathy-glib/util.h> #include <libempathy/empathy-tp-contact-factory.h> @@ -41,12 +40,14 @@ #include <libempathy/empathy-location.h> #include <libempathy/empathy-time.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include "empathy-contact-widget.h" #include "empathy-account-chooser.h" #include "empathy-avatar-chooser.h" #include "empathy-avatar-image.h" #include "empathy-ui-utils.h" +#include "empathy-kludge-label.h" #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include <libempathy/empathy-debug.h> @@ -219,7 +220,6 @@ empathy_contact_widget_new (EmpathyContact *contact, "hbox_presence", &information->hbox_presence, "label_alias", &information->label_alias, "image_state", &information->image_state, - "label_status", &information->label_status, "table_contact", &information->table_contact, "vbox_avatar", &information->vbox_avatar, "vbox_location", &information->vbox_location, @@ -587,6 +587,12 @@ update_avatar_chooser_account_cb (EmpathyAccountChooser *account_chooser, static void contact_widget_contact_setup (EmpathyContactWidget *information) { + /* Setup label_status as a KludgeLabel */ + information->label_status = empathy_kludge_label_new (""); + gtk_box_pack_start (GTK_BOX (information->hbox_presence), + information->label_status, TRUE, TRUE, 0); + gtk_widget_show (information->label_status); + /* Setup account label/chooser */ if (information->flags & EMPATHY_CONTACT_WIDGET_EDIT_ACCOUNT) { @@ -697,7 +703,7 @@ contact_widget_contact_setup (EmpathyContactWidget *information) static void contact_widget_contact_update (EmpathyContactWidget *information) { - McAccount *account = NULL; + EmpathyAccount *account = NULL; const gchar *id = NULL; /* Connect and get info from new contact */ @@ -737,7 +743,7 @@ contact_widget_contact_update (EmpathyContactWidget *information) { const gchar *name; - name = mc_account_get_display_name (account); + name = empathy_account_get_display_name (account); gtk_label_set_label (GTK_LABEL (information->widget_account), name); } } diff --git a/libempathy-gtk/empathy-contact-widget.ui b/libempathy-gtk/empathy-contact-widget.ui index c5bbd5bbe..5737b7d71 100644 --- a/libempathy-gtk/empathy-contact-widget.ui +++ b/libempathy-gtk/empathy-contact-widget.ui @@ -112,17 +112,7 @@ </packing> </child> <child> - <object class="GtkLabel" id="label_status"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="xalign">0</property> - <property name="use_markup">True</property> - <property name="wrap">True</property> - <property name="selectable">True</property> - </object> - <packing> - <property name="position">1</property> - </packing> + <placeholder/> </child> </object> <packing> diff --git a/libempathy-gtk/empathy-irc-network-dialog.c b/libempathy-gtk/empathy-irc-network-dialog.c index 63222badc..e6b4a6f7f 100644 --- a/libempathy-gtk/empathy-irc-network-dialog.c +++ b/libempathy-gtk/empathy-irc-network-dialog.c @@ -27,10 +27,10 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-protocol.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #include <libempathy/empathy-irc-network-manager.h> #include "empathy-ui-utils.h" diff --git a/libempathy-gtk/empathy-kludge-label.c b/libempathy-gtk/empathy-kludge-label.c new file mode 100644 index 000000000..f4a29dec2 --- /dev/null +++ b/libempathy-gtk/empathy-kludge-label.c @@ -0,0 +1,89 @@ +/* vim: set ts=4 sts=4 sw=4 et: */ +/* + * Copyright (C) 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: Davyd Madeley <davyd.madeley@collabora.co.uk> + */ + +#include "empathy-kludge-label.h" + +G_DEFINE_TYPE (EmpathyKludgeLabel, empathy_kludge_label, GTK_TYPE_LABEL); + +static void +empathy_kludge_label_size_allocate (GtkWidget *self, + GtkAllocation *allocation) +{ + PangoLayout *layout; + + GTK_WIDGET_CLASS (empathy_kludge_label_parent_class)->size_allocate ( + self, allocation); + + /* force the width of the PangoLayout to be the width of the allocation */ + layout = gtk_label_get_layout (GTK_LABEL (self)); + pango_layout_set_width (layout, allocation->width * PANGO_SCALE); +} + +static gboolean +empathy_kludge_label_expose_event (GtkWidget *self, + GdkEventExpose *event) +{ + PangoLayout *layout; + PangoRectangle rect; + GtkAllocation real_allocation; + gboolean r; + + layout = gtk_label_get_layout (GTK_LABEL (self)); + pango_layout_get_pixel_extents (layout, NULL, &rect); + + /* this is mind-bendingly evil: + * get_layout_location() is going to remove rect.x from the position of the + * layout when painting it. This really sucks. We're going to compensate by + * adding this value to the allocation. + */ + real_allocation = self->allocation; + self->allocation.x += rect.x; + + r = GTK_WIDGET_CLASS (empathy_kludge_label_parent_class)->expose_event ( + self, event); + + self->allocation = real_allocation; + + return r; +} + +static void +empathy_kludge_label_class_init (EmpathyKludgeLabelClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + widget_class->size_allocate = empathy_kludge_label_size_allocate; + widget_class->expose_event = empathy_kludge_label_expose_event; +} + +static void +empathy_kludge_label_init (EmpathyKludgeLabel *self) +{ +} + +GtkWidget * +empathy_kludge_label_new (const char *str) +{ + return g_object_new (EMPATHY_TYPE_KLUDGE_LABEL, + "label", str, + "xalign", 0., + NULL); +} diff --git a/libempathy-gtk/empathy-kludge-label.h b/libempathy-gtk/empathy-kludge-label.h new file mode 100644 index 000000000..f2ea1e938 --- /dev/null +++ b/libempathy-gtk/empathy-kludge-label.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 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: Davyd Madeley <davyd.madeley@collabora.co.uk> + */ + +#ifndef __EMPATHY_KLUDGE_LABEL_H__ +#define __EMPATHY_KLUDGE_LABEL_H__ + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define EMPATHY_TYPE_KLUDGE_LABEL (empathy_kludge_label_get_type ()) +#define EMPATHY_KLUDGE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EMPATHY_TYPE_KLUDGE_LABEL, EmpathyKludgeLabel)) +#define EMPATHY_KLUDGE_LABEL_CLASS(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), EMPATHY_TYPE_KLUDGE_LABEL, EmpathyKludgeLabelClass)) +#define EMPATHY_IS_KLUDGE_LABEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EMPATHY_TYPE_KLUDGE_LABEL)) +#define EMPATHY_IS_KLUDGE_LABEL_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE ((obj), EMPATHY_TYPE_KLUDGE_LABEL)) +#define EMPATHY_KLUDGE_LABEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EMPATHY_TYPE_KLUDGE_LABEL, EmpathyKludgeLabelClass)) + +typedef struct _EmpathyKludgeLabel EmpathyKludgeLabel; +typedef struct _EmpathyKludgeLabelClass EmpathyKludgeLabelClass; + +struct _EmpathyKludgeLabel +{ + GtkLabel parent; +}; + +struct _EmpathyKludgeLabelClass +{ + GtkLabelClass parent_class; +}; + +GType empathy_kludge_label_get_type (void); +GtkWidget *empathy_kludge_label_new (const char *str); + +G_END_DECLS + +#endif diff --git a/libempathy-gtk/empathy-log-window.c b/libempathy-gtk/empathy-log-window.c index 21d73f8ea..f05017c9c 100644 --- a/libempathy-gtk/empathy-log-window.c +++ b/libempathy-gtk/empathy-log-window.c @@ -31,6 +31,7 @@ #include <gtk/gtk.h> #include <libempathy/empathy-log-manager.h> +#include <libempathy/empathy-account-manager.h> #include <libempathy/empathy-chatroom-manager.h> #include <libempathy/empathy-chatroom.h> #include <libempathy/empathy-message.h> @@ -94,11 +95,11 @@ static void log_window_chats_setup (EmpathyLogWindow *wi static void log_window_chats_accounts_changed_cb (GtkWidget *combobox, EmpathyLogWindow *window); static void log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom); static gboolean log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, + EmpathyAccount **account, gchar **chat_id, gboolean *is_chatroom); static void log_window_chats_get_messages (EmpathyLogWindow *window, @@ -134,14 +135,14 @@ enum { }; GtkWidget * -empathy_log_window_show (McAccount *account, +empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom, GtkWindow *parent) { static EmpathyLogWindow *window = NULL; EmpathyAccountChooser *account_chooser; - GList *accounts; + EmpathyAccountManager *account_manager; gint account_num; GtkBuilder *gui; gchar *filename; @@ -228,9 +229,9 @@ empathy_log_window_show (McAccount *account, window); /* Populate */ - accounts = mc_accounts_list (); - account_num = g_list_length (accounts); - mc_accounts_list_free (accounts); + account_manager = empathy_account_manager_dup_singleton (); + account_num = empathy_account_manager_get_count (account_manager); + g_object_unref (account_manager); if (account_num > 1) { gtk_widget_show (window->vbox_chats); @@ -301,7 +302,7 @@ log_window_find_changed_cb (GtkTreeSelection *selection, GtkTreeView *view; GtkTreeModel *model; GtkTreeIter iter; - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; gchar *date; @@ -417,7 +418,7 @@ log_window_find_populate (EmpathyLogWindow *window, } date_readable = empathy_log_manager_get_date_readable (hit->date); - account_name = mc_account_get_display_name (hit->account); + account_name = empathy_account_get_display_name (hit->account); account_icon = empathy_icon_name_from_account (hit->account); gtk_list_store_append (store, &iter); @@ -464,7 +465,7 @@ log_window_find_setup (EmpathyLogWindow *window) store = gtk_list_store_new (COL_FIND_COUNT, G_TYPE_STRING, /* account icon name */ G_TYPE_STRING, /* account name */ - MC_TYPE_ACCOUNT, /* account */ + EMPATHY_TYPE_ACCOUNT, /* account */ G_TYPE_STRING, /* chat name */ G_TYPE_STRING, /* chat id */ G_TYPE_BOOLEAN, /* is chatroom */ @@ -608,7 +609,7 @@ static void log_window_chats_populate (EmpathyLogWindow *window) { EmpathyAccountChooser *account_chooser; - McAccount *account; + EmpathyAccount *account; GList *chats, *l; GtkTreeView *view; @@ -684,11 +685,11 @@ log_window_chats_setup (EmpathyLogWindow *window) /* new store */ store = gtk_list_store_new (COL_CHAT_COUNT, - G_TYPE_STRING, /* icon */ - G_TYPE_STRING, /* name */ - MC_TYPE_ACCOUNT, /* account */ - G_TYPE_STRING, /* id */ - G_TYPE_BOOLEAN); /* is chatroom */ + G_TYPE_STRING, /* icon */ + G_TYPE_STRING, /* name */ + EMPATHY_TYPE_ACCOUNT, /* account */ + G_TYPE_STRING, /* id */ + G_TYPE_BOOLEAN); /* is chatroom */ model = GTK_TREE_MODEL (store); sortable = GTK_TREE_SORTABLE (store); @@ -739,7 +740,7 @@ log_window_chats_accounts_changed_cb (GtkWidget *combobox, static void log_window_chats_set_selected (EmpathyLogWindow *window, - McAccount *account, + EmpathyAccount *account, const gchar *chat_id, gboolean is_chatroom) { @@ -763,7 +764,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window, } for (ok = TRUE; ok; ok = gtk_tree_model_iter_next (model, &iter)) { - McAccount *this_account; + EmpathyAccount *this_account; gchar *this_chat_id; gboolean this_is_chatroom; @@ -792,7 +793,7 @@ log_window_chats_set_selected (EmpathyLogWindow *window, static gboolean log_window_chats_get_selected (EmpathyLogWindow *window, - McAccount **account, + EmpathyAccount **account, gchar **chat_id, gboolean *is_chatroom) { @@ -801,7 +802,7 @@ log_window_chats_get_selected (EmpathyLogWindow *window, GtkTreeSelection *selection; GtkTreeIter iter; gchar *id = NULL; - McAccount *acc = NULL; + EmpathyAccount *acc = NULL; gboolean room = FALSE; view = GTK_TREE_VIEW (window->treeview_chats); @@ -839,7 +840,7 @@ static void log_window_chats_get_messages (EmpathyLogWindow *window, const gchar *date_to_show) { - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; EmpathyMessage *message; @@ -999,7 +1000,7 @@ static void log_window_calendar_chats_month_changed_cb (GtkWidget *calendar, EmpathyLogWindow *window) { - McAccount *account; + EmpathyAccount *account; gchar *chat_id; gboolean is_chatroom; guint year_selected; diff --git a/libempathy-gtk/empathy-log-window.h b/libempathy-gtk/empathy-log-window.h index 6dd8c0303..298d96099 100644 --- a/libempathy-gtk/empathy-log-window.h +++ b/libempathy-gtk/empathy-log-window.h @@ -25,11 +25,11 @@ #ifndef __EMPATHY_LOG_WINDOW_H__ #define __EMPATHY_LOG_WINDOW_H__ -#include <libmissioncontrol/mc-account.h> +#include <libempathy/empathy-account.h> G_BEGIN_DECLS -GtkWidget * empathy_log_window_show (McAccount *account, +GtkWidget * empathy_log_window_show (EmpathyAccount *account, const gchar *chat_id, gboolean chatroom, GtkWindow *parent); diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c index 9aee42913..77b368bd9 100644 --- a/libempathy-gtk/empathy-new-message-dialog.c +++ b/libempathy-gtk/empathy-new-message-dialog.c @@ -27,7 +27,6 @@ #include <gtk/gtk.h> #include <glib/gi18n-lib.h> -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mission-control.h> #include <libempathy/empathy-call-factory.h> @@ -35,6 +34,7 @@ #include <libempathy/empathy-contact-manager.h> #include <libempathy/empathy-dispatcher.h> #include <libempathy/empathy-utils.h> +#include <libempathy/empathy-account.h> #define DEBUG_FLAG EMPATHY_DEBUG_CONTACT #include <libempathy/empathy-debug.h> diff --git a/libempathy-gtk/empathy-sound.c b/libempathy-gtk/empathy-sound.c new file mode 100644 index 000000000..d97f72bef --- /dev/null +++ b/libempathy-gtk/empathy-sound.c @@ -0,0 +1,385 @@ +/* + * empathy-sound.c - Various sound related utility functions. + * Copyright (C) 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 + */ + +#include <config.h> + +#include "empathy-sound.h" + +#include <canberra-gtk.h> +#include <glib/gi18n-lib.h> +#include <gtk/gtk.h> + +#define DEBUG_FLAG EMPATHY_DEBUG_OTHER +#include <libempathy/empathy-debug.h> +#include <libempathy/empathy-utils.h> + +#include "empathy-conf.h" + +typedef struct { + EmpathySound sound_id; + const char * event_ca_id; + const char * event_ca_description; + const char * gconf_key; +} EmpathySoundEntry; + +typedef struct { + GtkWidget *widget; + gint sound_id; + guint play_interval; + guint replay_timeout_id; +} EmpathyRepeatableSound; + +/* NOTE: these entries MUST be in the same order than EmpathySound enum */ +static EmpathySoundEntry sound_entries[LAST_EMPATHY_SOUND] = { + { EMPATHY_SOUND_MESSAGE_INCOMING, "message-new-instant", + N_("Received an instant message"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE } , + { EMPATHY_SOUND_MESSAGE_OUTGOING, "message-sent-instant", + N_("Sent an instant message"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE } , + { EMPATHY_SOUND_CONVERSATION_NEW, "message-new-instant", + N_("Incoming chat request"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION }, + { EMPATHY_SOUND_CONTACT_CONNECTED, "service-login", + N_("Contact connected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN }, + { EMPATHY_SOUND_CONTACT_DISCONNECTED, "service-logout", + N_("Contact disconnected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT }, + { EMPATHY_SOUND_ACCOUNT_CONNECTED, "service-login", + N_("Connected to server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN }, + { EMPATHY_SOUND_ACCOUNT_DISCONNECTED, "service-logout", + N_("Disconnected from server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }, + { EMPATHY_SOUND_PHONE_INCOMING, "phone-incoming-call", + N_("Incoming voice call"), NULL }, + { EMPATHY_SOUND_PHONE_OUTGOING, "phone-outgoing-calling", + N_("Outgoing voice call"), NULL }, + { EMPATHY_SOUND_PHONE_HANGUP, "phone-hangup", + N_("Voice call ended"), NULL }, +}; + +/* An hash table containing currently repeating sounds. The format is the + * following: + * Key: An EmpathySound + * Value : The EmpathyRepeatableSound associated with that EmpathySound. */ +static GHashTable *repeating_sounds; + +static gboolean +empathy_sound_pref_is_enabled (EmpathySound sound_id) +{ + EmpathySoundEntry *entry; + EmpathyConf *conf; + gboolean res; + + entry = &(sound_entries[sound_id]); + g_return_val_if_fail (entry->sound_id == sound_id, FALSE); + + if (entry->gconf_key == NULL) + return TRUE; + + conf = empathy_conf_get (); + res = FALSE; + + empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_ENABLED, &res); + + if (!res) + return FALSE; + + if (!empathy_check_available_state ()) + { + empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY, &res); + + if (res) + return FALSE; + } + + empathy_conf_get_bool (conf, entry->gconf_key, &res); + + return res; +} + +/** + * empathy_sound_stop: + * @sound_id: The #EmpathySound to stop playing. + * + * Stop playing a sound. If it has been stated in loop with + * empathy_sound_start_playing(), it will also stop replaying. + */ +void +empathy_sound_stop (EmpathySound sound_id) +{ + EmpathySoundEntry *entry; + + g_return_if_fail (sound_id < LAST_EMPATHY_SOUND); + + entry = &(sound_entries[sound_id]); + g_return_if_fail (entry->sound_id == sound_id); + + if (repeating_sounds != NULL) + { + EmpathyRepeatableSound *repeatable_sound; + + repeatable_sound = g_hash_table_lookup (repeating_sounds, + GINT_TO_POINTER (sound_id)); + if (repeatable_sound != NULL) + { + /* The sound must be stopped... If it is waiting for replay, remove + * it from hash table to cancel. Otherwise we'll cancel the sound + * being played. */ + if (repeatable_sound->replay_timeout_id != 0) + { + g_hash_table_remove (repeating_sounds, GINT_TO_POINTER (sound_id)); + return; + } + } + } + + ca_context_cancel (ca_gtk_context_get (), entry->sound_id); +} + +static gboolean +empathy_sound_play_internal (GtkWidget *widget, EmpathySound sound_id, + ca_finish_callback_t callback, gpointer user_data) +{ + EmpathySoundEntry *entry; + ca_context *c; + ca_proplist *p = NULL; + + entry = &(sound_entries[sound_id]); + g_return_val_if_fail (entry->sound_id == sound_id, FALSE); + + c = ca_gtk_context_get (); + ca_context_cancel (c, entry->sound_id); + + DEBUG ("Play sound \"%s\" (%s)", + entry->event_ca_id, + entry->event_ca_description); + + if (ca_proplist_create (&p) < 0) + goto failed; + + if (ca_proplist_sets (p, CA_PROP_EVENT_ID, entry->event_ca_id) < 0) + goto failed; + + if (ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, + gettext (entry->event_ca_id)) < 0) + goto failed; + + if (ca_gtk_proplist_set_for_widget (p, widget) < 0) + goto failed; + + ca_context_play_full (ca_gtk_context_get (), entry->sound_id, p, callback, + user_data); + + ca_proplist_destroy (p); + + return TRUE; + +failed: + if (p != NULL) + ca_proplist_destroy (p); + + return FALSE; +} + +/** + * empathy_sound_play_full: + * @widget: The #GtkWidget from which the sound is originating. + * @sound_id: The #EmpathySound to play. + * @callback: The #ca_finish_callback_t function that will be called when the + * sound has stopped playing. + * @user_data: user data to pass to the function. + * + * Plays a sound. + * + * Returns %TRUE if the sound has successfully started playing, otherwise + * returning %FALSE and @callback won't be called. + * + * This function returns %FALSE if the sound is already playing in loop using + * %empathy_sound_start_playing. + * + * This function returns %FALSE if the sound is disabled in empathy preferences. + * + * Return value: %TRUE if the sound has successfully started playing, %FALSE + * otherwise. + */ +gboolean +empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, + ca_finish_callback_t callback, gpointer user_data) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); + + if (!empathy_sound_pref_is_enabled (sound_id)) + return FALSE; + + /* The sound might already be playing repeatedly. If it's the case, we + * immediadely return since there's no need to make it play again */ + if (repeating_sounds != NULL && + g_hash_table_lookup (repeating_sounds, GINT_TO_POINTER (sound_id)) != NULL) + return FALSE; + + return empathy_sound_play_internal (widget, sound_id, callback, user_data); +} + +/** + * empathy_sound_play: + * @widget: The #GtkWidget from which the sound is originating. + * @sound_id: The #EmpathySound to play. + * + * Plays a sound. See %empathy_sound_play_full for details.' + * + * Return value: %TRUE if the sound has successfully started playing, %FALSE + * otherwise. + */ +gboolean +empathy_sound_play (GtkWidget *widget, EmpathySound sound_id) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); + + return empathy_sound_play_full (widget, sound_id, NULL, NULL); +} + +static void playing_finished_cb (ca_context *c, guint id, int error_code, + gpointer user_data); + +static gboolean +playing_timeout_cb (gpointer data) +{ + EmpathyRepeatableSound *repeatable_sound = data; + gboolean playing; + + repeatable_sound->replay_timeout_id = 0; + + playing = empathy_sound_play_internal (repeatable_sound->widget, + repeatable_sound->sound_id, playing_finished_cb, data); + + if (!playing) + { + DEBUG ("Failed to replay sound, stop repeating"); + g_hash_table_remove (repeating_sounds, + GINT_TO_POINTER (repeatable_sound->sound_id)); + } + + return FALSE; +} + +static void +playing_finished_cb (ca_context *c, guint id, int error_code, + gpointer user_data) +{ + EmpathyRepeatableSound *repeatable_sound = user_data; + + if (error_code != CA_SUCCESS) + { + DEBUG ("Error: %s", ca_strerror (error_code)); + g_hash_table_remove (repeating_sounds, + GINT_TO_POINTER (repeatable_sound->sound_id)); + return; + } + + repeatable_sound->replay_timeout_id = g_timeout_add ( + repeatable_sound->play_interval, playing_timeout_cb, user_data); +} + +static void +empathy_sound_widget_destroyed_cb (GtkWidget *widget, gpointer user_data) +{ + EmpathyRepeatableSound *repeatable_sound = user_data; + + /* The sound must be stopped... If it is waiting for replay, remove + * it from hash table to cancel. Otherwise playing_finished_cb will be + * called with an error. */ + if (repeatable_sound->replay_timeout_id != 0) + { + g_hash_table_remove (repeating_sounds, + GINT_TO_POINTER (repeatable_sound->sound_id)); + } +} + +static void +repeating_sounds_item_delete (gpointer data) +{ + EmpathyRepeatableSound *repeatable_sound = data; + + if (repeatable_sound->replay_timeout_id != 0) + g_source_remove (repeatable_sound->replay_timeout_id); + + g_signal_handlers_disconnect_by_func (repeatable_sound->widget, + empathy_sound_widget_destroyed_cb, repeatable_sound); + + g_slice_free (EmpathyRepeatableSound, repeatable_sound); +} + +/** + * empathy_sound_start_playing: + * @widget: The #GtkWidget from which the sound is originating. + * @sound_id: The #EmpathySound to play. + * @timeout_before_replay: The amount of time, in milliseconds, between two + * consecutive play. + * + * Start playing a sound in loop. To stop the sound, call empathy_call_stop () + * by passing it the same @sound_id. Note that if you start playing a sound + * multiple times, you'll have to call %empathy_sound_stop the same number of + * times. + * + * Return value: %TRUE if the sound has successfully started playing. + */ +gboolean +empathy_sound_start_playing (GtkWidget *widget, EmpathySound sound_id, + guint timeout_before_replay) +{ + EmpathyRepeatableSound *repeatable_sound; + gboolean playing = FALSE; + + g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); + g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); + + if (!empathy_sound_pref_is_enabled (sound_id)) + return FALSE; + + if (repeating_sounds == NULL) + { + repeating_sounds = g_hash_table_new_full (g_direct_hash, g_direct_equal, + NULL, repeating_sounds_item_delete); + } + else if (g_hash_table_lookup (repeating_sounds, + GINT_TO_POINTER (sound_id)) != NULL) + { + /* The sound is already playing in loop. No need to continue. */ + return FALSE; + } + + repeatable_sound = g_slice_new0 (EmpathyRepeatableSound); + repeatable_sound->widget = widget; + repeatable_sound->sound_id = sound_id; + repeatable_sound->play_interval = timeout_before_replay; + repeatable_sound->replay_timeout_id = 0; + + g_hash_table_insert (repeating_sounds, GINT_TO_POINTER (sound_id), + repeatable_sound); + + g_signal_connect (G_OBJECT (widget), "destroy", + G_CALLBACK (empathy_sound_widget_destroyed_cb), + repeatable_sound); + + playing = empathy_sound_play_internal (widget, sound_id, playing_finished_cb, + repeatable_sound); + + if (!playing) + g_hash_table_remove (repeating_sounds, GINT_TO_POINTER (sound_id)); + + return playing; +} diff --git a/libempathy-gtk/empathy-sound.h b/libempathy-gtk/empathy-sound.h new file mode 100644 index 000000000..f65f6260e --- /dev/null +++ b/libempathy-gtk/empathy-sound.h @@ -0,0 +1,56 @@ +/* + * empathy-sound.h - Various sound related utility functions. + * Copyright (C) 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 + */ + + +#ifndef __EMPATHY_SOUND_H__ +#define __EMPATHY_SOUND_H__ + +#include <gtk/gtk.h> + +#include <canberra-gtk.h> + +G_BEGIN_DECLS + +/* NOTE: Keep this sync with sound_entries in empathy-sound.c */ +typedef enum { + EMPATHY_SOUND_MESSAGE_INCOMING = 0, + EMPATHY_SOUND_MESSAGE_OUTGOING, + EMPATHY_SOUND_CONVERSATION_NEW, + EMPATHY_SOUND_CONTACT_CONNECTED, + EMPATHY_SOUND_CONTACT_DISCONNECTED, + EMPATHY_SOUND_ACCOUNT_CONNECTED, + EMPATHY_SOUND_ACCOUNT_DISCONNECTED, + EMPATHY_SOUND_PHONE_INCOMING, + EMPATHY_SOUND_PHONE_OUTGOING, + EMPATHY_SOUND_PHONE_HANGUP, + LAST_EMPATHY_SOUND, +} EmpathySound; + +gboolean empathy_sound_play (GtkWidget *widget, EmpathySound sound_id); +void empathy_sound_stop (EmpathySound sound_id); + +gboolean empathy_sound_start_playing (GtkWidget *widget, EmpathySound sound_id, + guint timeout_before_replay); + +gboolean empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, + ca_finish_callback_t callback, gpointer user_data); + +G_END_DECLS + +#endif /* #ifndef __EMPATHY_SOUND_H__*/ diff --git a/libempathy-gtk/empathy-status-preset-dialog.c b/libempathy-gtk/empathy-status-preset-dialog.c index 7ac13ad38..802d116e7 100644 --- a/libempathy-gtk/empathy-status-preset-dialog.c +++ b/libempathy-gtk/empathy-status-preset-dialog.c @@ -559,8 +559,8 @@ empathy_status_preset_dialog_init (EmpathyStatusPresetDialog *self) status_preset_dialog_setup_presets_treeview (self); status_preset_dialog_setup_add_combobox (self); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (self)->vbox), toplevel_vbox, - TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), + toplevel_vbox, TRUE, TRUE, 0); g_object_unref (gui); } diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c index d5ea2ed52..3b4a895e4 100644 --- a/libempathy-gtk/empathy-theme-adium.c +++ b/libempathy-gtk/empathy-theme-adium.c @@ -52,6 +52,7 @@ typedef struct { EmpathySmileyManager *smiley_manager; EmpathyContact *last_contact; time_t last_timestamp; + gboolean last_is_backlog; gboolean page_loaded; GList *message_queue; gchar *hovered_uri; @@ -67,12 +68,20 @@ struct _EmpathyAdiumData { gchar *template_html; gchar *in_content_html; gsize in_content_len; + gchar *in_context_html; + gsize in_context_len; gchar *in_nextcontent_html; gsize in_nextcontent_len; + gchar *in_nextcontext_html; + gsize in_nextcontext_len; gchar *out_content_html; gsize out_content_len; + gchar *out_context_html; + gsize out_context_len; gchar *out_nextcontent_html; gsize out_nextcontent_len; + gchar *out_nextcontext_html; + gsize out_nextcontext_len; gchar *status_html; gsize status_len; GHashTable *info; @@ -474,7 +483,7 @@ theme_adium_append_message (EmpathyChatView *view, EmpathyThemeAdium *theme = EMPATHY_THEME_ADIUM (view); EmpathyThemeAdiumPriv *priv = GET_PRIV (theme); EmpathyContact *sender; - McAccount *account; + EmpathyAccount *account; McProfile *account_profile; gchar *dup_body = NULL; const gchar *body; @@ -487,7 +496,8 @@ theme_adium_append_message (EmpathyChatView *view, gsize len = 0; const gchar *func; const gchar *service_name; - const gchar *message_classes = NULL; + GString *message_classes = NULL; + gboolean is_backlog; if (!priv->page_loaded) { priv->message_queue = g_list_prepend (priv->message_queue, @@ -498,7 +508,7 @@ theme_adium_append_message (EmpathyChatView *view, /* Get information */ sender = empathy_message_get_sender (msg); account = empathy_contact_get_account (sender); - account_profile = mc_account_get_profile (account); + account_profile = empathy_account_get_profile (account); service_name = mc_profile_get_display_name (account_profile); timestamp = empathy_message_get_timestamp (msg); body = empathy_message_get_body (msg); @@ -541,45 +551,102 @@ theme_adium_append_message (EmpathyChatView *view, } } + is_backlog = empathy_message_is_backlog (msg); + /* Get the right html/func to add the message */ func = "appendMessage"; + + message_classes = g_string_new ("message"); + + /* eventually append the "history" class */ + if (is_backlog) { + g_string_append (message_classes, " history"); + } + + /* check the sender of the message and append the appropriate class */ + if (empathy_contact_is_user (sender)) { + g_string_append (message_classes, " outgoing"); + } + else { + g_string_append (message_classes, " incoming"); + } + /* * To mimick Adium's behavior, we only want to join messages - * sent within a 5 minute time frame. + * sent by the same contact within a 5 minute time frame. */ if (empathy_contact_equal (priv->last_contact, sender) && - (timestamp - priv->last_timestamp < MESSAGE_JOIN_PERIOD)) { + (timestamp - priv->last_timestamp < MESSAGE_JOIN_PERIOD) && + (is_backlog == priv->last_is_backlog)) { + /* the messages can be appended */ func = "appendNextMessage"; + g_string_append (message_classes, " consecutive"); + + /* check who is the sender of the message to use the correct html file */ if (empathy_contact_is_user (sender)) { - message_classes = "consecutive incoming message"; - html = priv->data->out_nextcontent_html; - len = priv->data->out_nextcontent_len; + /* check if this is a backlog message and use NextContext.html */ + if (is_backlog) { + html = priv->data->out_nextcontext_html; + len = priv->data->out_nextcontext_len; + } + + /* + * html is null if this is not a backlog message or + * if we have to fallback (NextContext.html missing). + * use NextContent.html + */ + if (html == NULL) { + html = priv->data->out_nextcontent_html; + len = priv->data->out_nextcontent_len; + } } - if (!html) { - message_classes = "consecutive message outgoing"; - html = priv->data->in_nextcontent_html; - len = priv->data->in_nextcontent_len; + else { + if (is_backlog) { + html = priv->data->in_nextcontext_html; + len = priv->data->in_nextcontext_len; + } + + if (html == NULL) { + html = priv->data->in_nextcontent_html; + len = priv->data->in_nextcontent_len; + } } } - if (!html) { + + /* + * we have html == NULL here if: + * 1. the message didn't have to be appended because + * the sender was different or the timestamp was too far + * 2. NextContent.html file does not exist, so we must + * not forget to fallback to the correct Content.html + */ + if (html == NULL) { if (empathy_contact_is_user (sender)) { - if (!message_classes) { - message_classes = "incoming message"; + if (is_backlog) { + html = priv->data->out_context_html; + len = priv->data->out_context_len; + } + + if (html == NULL) { + html = priv->data->out_content_html; + len = priv->data->out_content_len; } - html = priv->data->out_content_html; - len = priv->data->out_content_len; } - if (!html) { - if (!message_classes) { - message_classes = "message outgoing"; + else { + if (is_backlog) { + html = priv->data->in_context_html; + len = priv->data->in_context_len; + } + + if (html == NULL) { + html = priv->data->in_content_html; + len = priv->data->in_content_len; } - html = priv->data->in_content_html; - len = priv->data->in_content_len; } } theme_adium_append_html (theme, func, html, len, body, avatar_filename, - name, contact_id, service_name, message_classes, + name, contact_id, service_name, message_classes->str, timestamp); /* Keep the sender of the last displayed message */ @@ -588,8 +655,10 @@ theme_adium_append_message (EmpathyChatView *view, } priv->last_contact = g_object_ref (sender); priv->last_timestamp = timestamp; + priv->last_is_backlog = is_backlog; g_free (dup_body); + g_string_free (message_classes, TRUE); } static void @@ -646,6 +715,13 @@ theme_adium_clear (EmpathyChatView *view) priv->data->template_html, basedir_uri); g_free (basedir_uri); + + /* Clear last contact to avoid trying to add a 'joined' + * message when we don't have an insertion point. */ + if (priv->last_contact) { + g_object_unref (priv->last_contact); + priv->last_contact = NULL; + } } static gboolean @@ -899,6 +975,15 @@ empathy_adium_path_is_valid (const gchar *path) gboolean ret; gchar *file; + /* The theme is not valid if there is no Info.plist */ + file = g_build_filename (path, "Contents", "Info.plist", + NULL); + ret = g_file_test (file, G_FILE_TEST_EXISTS); + g_free (file); + + if (ret == FALSE) + return ret; + /* We ship a default Template.html as fallback if there is any problem * with the one inside the theme. The only other required file is * Content.html for incoming messages (outgoing fallback to use @@ -924,10 +1009,15 @@ empathy_adium_info_new (const gchar *path) value = empathy_plist_parse_from_file (file); g_free (file); - if (value) { - info = g_value_dup_boxed (value); - tp_g_value_slice_free (value); - } + if (value == NULL) + return NULL; + + info = g_value_dup_boxed (value); + tp_g_value_slice_free (value); + + /* Insert the theme's path into the hash table, + * keys have to be dupped */ + tp_asv_set_string (info, g_strdup ("path"), path); return info; } @@ -980,6 +1070,14 @@ empathy_adium_data_new_with_info (const gchar *path, GHashTable *info) g_file_get_contents (file, &data->in_nextcontent_html, &data->in_nextcontent_len, NULL); g_free (file); + file = g_build_filename (data->basedir, "Incoming", "Context.html", NULL); + g_file_get_contents (file, &data->in_context_html, &data->in_context_len, NULL); + g_free (file); + + file = g_build_filename (data->basedir, "Incoming", "NextContext.html", NULL); + g_file_get_contents (file, &data->in_nextcontext_html, &data->in_nextcontext_len, NULL); + g_free (file); + file = g_build_filename (data->basedir, "Outgoing", "Content.html", NULL); g_file_get_contents (file, &data->out_content_html, &data->out_content_len, NULL); g_free (file); @@ -988,6 +1086,14 @@ empathy_adium_data_new_with_info (const gchar *path, GHashTable *info) g_file_get_contents (file, &data->out_nextcontent_html, &data->out_nextcontent_len, NULL); g_free (file); + file = g_build_filename (data->basedir, "Outgoing", "Context.html", NULL); + g_file_get_contents (file, &data->out_context_html, &data->out_context_len, NULL); + g_free (file); + + file = g_build_filename (data->basedir, "Outgoing", "NextContext.html", NULL); + g_file_get_contents (file, &data->out_nextcontext_html, &data->out_nextcontext_len, NULL); + g_free (file); + file = g_build_filename (data->basedir, "Status.html", NULL); g_file_get_contents (file, &data->status_html, &data->status_len, NULL); g_free (file); @@ -1091,7 +1197,7 @@ empathy_adium_data_ref (EmpathyAdiumData *data) { g_return_val_if_fail (data != NULL, NULL); - data->ref_count++; + g_atomic_int_inc (&data->ref_count); return data; } @@ -1101,15 +1207,18 @@ empathy_adium_data_unref (EmpathyAdiumData *data) { g_return_if_fail (data != NULL); - data->ref_count--; - if (data->ref_count == 0) { + if (g_atomic_int_dec_and_test (&data->ref_count)) { g_free (data->path); g_free (data->basedir); g_free (data->template_html); g_free (data->in_content_html); g_free (data->in_nextcontent_html); + g_free (data->in_context_html); + g_free (data->in_nextcontext_html); g_free (data->out_content_html); g_free (data->out_nextcontent_html); + g_free (data->out_context_html); + g_free (data->out_nextcontext_html); g_free (data->default_avatar_filename); g_free (data->default_incoming_avatar_filename); g_free (data->default_outgoing_avatar_filename); diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index ba3d48e68..fea2eca51 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -26,6 +26,7 @@ #include <string.h> #include <glib/gi18n-lib.h> +#include <telepathy-glib/dbus.h> #include <gtk/gtk.h> #include <telepathy-glib/util.h> @@ -67,9 +68,6 @@ static const gchar *themes[] = { "simple", N_("Simple"), "clean", N_("Clean"), "blue", N_("Blue"), -#ifdef HAVE_WEBKIT - "adium", N_("Adium"), -#endif NULL }; @@ -378,6 +376,10 @@ theme_manager_ensure_theme_exists (const gchar *name) return FALSE; } + if (strcmp ("adium", name) == 0) { + return TRUE; + } + for (i = 0; themes[i]; i += 2) { if (strcmp (themes[i], name) == 0) { return TRUE; @@ -534,3 +536,62 @@ empathy_theme_manager_get_themes (void) return themes; } +#ifdef HAVE_WEBKIT +static void +find_themes (GList **list, const gchar *dirpath) +{ + GDir *dir; + GError *error = NULL; + const gchar *name = NULL; + GHashTable *info = NULL; + + dir = g_dir_open (dirpath, 0, &error); + if (dir != NULL) { + name = g_dir_read_name (dir); + while (name != NULL) { + gchar *path; + + path = g_build_path (G_DIR_SEPARATOR_S, dirpath, name, NULL); + if (empathy_adium_path_is_valid (path)) { + info = empathy_adium_info_new (path); + if (info != NULL) { + *list = g_list_prepend (*list, info); + } + } + g_free (path); + name = g_dir_read_name (dir); + } + g_dir_close (dir); + } else { + DEBUG ("Error opening %s: %s\n", dirpath, error->message); + g_error_free (error); + } +} +#endif /* HAVE_WEBKIT */ + +GList * +empathy_theme_manager_get_adium_themes (void) +{ +#ifdef HAVE_WEBKIT + GList *themes = NULL; + gchar *userpath = NULL; + const gchar *const *paths = NULL; + gint i = 0; + + userpath = g_build_path (G_DIR_SEPARATOR_S, g_get_user_data_dir (), "adium/message-styles", NULL); + find_themes (&themes, userpath); + g_free (userpath); + + paths = g_get_system_data_dirs (); + for (i = 0; paths[i] != NULL; i++) { + userpath = g_build_path (G_DIR_SEPARATOR_S, paths[i], + "adium/message-styles", NULL); + find_themes (&themes, userpath); + g_free (userpath); + } + + return themes; +#else + return NULL; +#endif /* HAVE_WEBKIT */ +} diff --git a/libempathy-gtk/empathy-theme-manager.h b/libempathy-gtk/empathy-theme-manager.h index 99c96d784..a459b43cb 100644 --- a/libempathy-gtk/empathy-theme-manager.h +++ b/libempathy-gtk/empathy-theme-manager.h @@ -51,6 +51,7 @@ struct _EmpathyThemeManagerClass { GType empathy_theme_manager_get_type (void) G_GNUC_CONST; EmpathyThemeManager * empathy_theme_manager_get (void); const gchar ** empathy_theme_manager_get_themes (void); +GList * empathy_theme_manager_get_adium_themes (void); EmpathyChatView * empathy_theme_manager_create_view (EmpathyThemeManager *manager); G_END_DECLS diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c index 902bcb3e6..e91ac6291 100644 --- a/libempathy-gtk/empathy-ui-utils.c +++ b/libempathy-gtk/empathy-ui-utils.c @@ -37,7 +37,6 @@ #include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include <gio/gio.h> -#include <canberra-gtk.h> #include <libmissioncontrol/mc-profile.h> @@ -184,11 +183,11 @@ empathy_builder_unref_and_keep_widget (GtkBuilder *gui, } const gchar * -empathy_icon_name_from_account (McAccount *account) +empathy_icon_name_from_account (EmpathyAccount *account) { McProfile *profile; - profile = mc_account_get_profile (account); + profile = empathy_account_get_profile (account); return mc_profile_get_icon_name (profile); } @@ -1251,7 +1250,7 @@ empathy_window_get_is_visible (GtkWindow *window) g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); - gdk_window = GTK_WIDGET (window)->window; + gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); if (!gdk_window) { return FALSE; } @@ -1273,7 +1272,7 @@ empathy_window_iconify (GtkWindow *window, GtkStatusIcon *status_icon) GdkWindow *gdk_window; gtk_status_icon_get_geometry (status_icon, NULL, &icon_location, NULL); - gdk_window = GTK_WIDGET (window)->window; + gdk_window = gtk_widget_get_window (GTK_WIDGET (window)); dpy = gdk_x11_drawable_get_xdisplay (gdk_window); data[0] = icon_location.x; @@ -1540,140 +1539,4 @@ empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler) G_CALLBACK (file_manager_receive_file_response_cb), handler); gtk_widget_show (widget); -} - -typedef struct { - EmpathySound sound_id; - const char * event_ca_id; - const char * event_ca_description; - const char * gconf_key; -} EmpathySoundEntry; - -/* NOTE: these entries MUST be in the same order than EmpathySound enum */ -static EmpathySoundEntry sound_entries[LAST_EMPATHY_SOUND] = { - { EMPATHY_SOUND_MESSAGE_INCOMING, "message-new-instant", - N_("Received an instant message"), EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE } , - { EMPATHY_SOUND_MESSAGE_OUTGOING, "message-sent-instant", - N_("Sent an instant message"), EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE } , - { EMPATHY_SOUND_CONVERSATION_NEW, "message-new-instant", - N_("Incoming chat request"), EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION }, - { EMPATHY_SOUND_CONTACT_CONNECTED, "service-login", - N_("Contact connected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN }, - { EMPATHY_SOUND_CONTACT_DISCONNECTED, "service-logout", - N_("Contact disconnected"), EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT }, - { EMPATHY_SOUND_ACCOUNT_CONNECTED, "service-login", - N_("Connected to server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN }, - { EMPATHY_SOUND_ACCOUNT_DISCONNECTED, "service-logout", - N_("Disconnected from server"), EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT }, - { EMPATHY_SOUND_PHONE_INCOMING, "phone-incoming-call", - N_("Incoming voice call"), NULL }, - { EMPATHY_SOUND_PHONE_OUTGOING, "phone-outgoing-calling", - N_("Outgoing voice call"), NULL }, - { EMPATHY_SOUND_PHONE_HANGUP, "phone-hangup", - N_("Voice call ended"), NULL }, -}; - - -static gboolean -empathy_sound_pref_is_enabled (const char *key) -{ - EmpathyConf *conf; - gboolean res; - - conf = empathy_conf_get (); - res = FALSE; - - empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_ENABLED, &res); - - if (!res) { - return FALSE; - } - - if (!empathy_check_available_state ()) { - empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY, - &res); - if (res) { - return FALSE; - } - } - - empathy_conf_get_bool (conf, key, &res); - - return res; -} - -void -empathy_sound_stop (EmpathySound sound_id) -{ - EmpathySoundEntry *entry; - - g_return_if_fail (sound_id < LAST_EMPATHY_SOUND); - - entry = &(sound_entries[sound_id]); - g_return_if_fail (entry->sound_id == sound_id); - - ca_context_cancel (ca_gtk_context_get (), entry->sound_id); -} - - -gboolean -empathy_sound_play_full (GtkWidget *widget, EmpathySound sound_id, - ca_finish_callback_t callback, gpointer user_data) -{ - EmpathySoundEntry *entry; - gboolean should_play = TRUE; - ca_proplist *p = NULL; - ca_context *c; - - g_return_val_if_fail (sound_id < LAST_EMPATHY_SOUND, FALSE); - - entry = &(sound_entries[sound_id]); - g_return_val_if_fail (entry->sound_id == sound_id, FALSE); - - if (entry->gconf_key != NULL) { - should_play = empathy_sound_pref_is_enabled (entry->gconf_key); - } - - if (!should_play) - return FALSE; - - c = ca_gtk_context_get (); - ca_context_cancel (c, entry->sound_id); - - DEBUG ("Play sound \"%s\" (%s)", - entry->event_ca_id, - entry->event_ca_description); - - if (ca_proplist_create (&p) < 0) - goto failed; - - if (ca_proplist_sets (p, CA_PROP_EVENT_ID, entry->event_ca_id) < 0) - goto failed; - - if (ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION, - gettext (entry->event_ca_id)) < 0) - goto failed; - - if (ca_gtk_proplist_set_for_widget (p, widget) < 0) - goto failed; - - ca_context_play_full (ca_gtk_context_get (), entry->sound_id, - p, callback, user_data); - - ca_proplist_destroy (p); - - return TRUE; - -failed: - if (p != NULL) - ca_proplist_destroy (p); - - return FALSE; -} - -void -empathy_sound_play (GtkWidget *widget, EmpathySound sound_id) -{ - empathy_sound_play_full (widget, sound_id, NULL, NULL); -} - +}
\ No newline at end of file diff --git a/libempathy-gtk/empathy-ui-utils.h b/libempathy-gtk/empathy-ui-utils.h index 60d48f3c4..10f889b0c 100644 --- a/libempathy-gtk/empathy-ui-utils.h +++ b/libempathy-gtk/empathy-ui-utils.h @@ -34,33 +34,16 @@ #include <gtk/gtk.h> -#include <canberra-gtk.h> - -#include <libmissioncontrol/mc-account.h> #include <libmissioncontrol/mc-profile.h> #include <libempathy/empathy-contact.h> +#include <libempathy/empathy-account.h> #include <libempathy/empathy-ft-handler.h> #include "empathy-chat-view.h" G_BEGIN_DECLS -/* NOTE: Keep this sync with sound_entries in empathy-ui-utils.c */ -typedef enum { - EMPATHY_SOUND_MESSAGE_INCOMING = 0, - EMPATHY_SOUND_MESSAGE_OUTGOING, - EMPATHY_SOUND_CONVERSATION_NEW, - EMPATHY_SOUND_CONTACT_CONNECTED, - EMPATHY_SOUND_CONTACT_DISCONNECTED, - EMPATHY_SOUND_ACCOUNT_CONNECTED, - EMPATHY_SOUND_ACCOUNT_DISCONNECTED, - EMPATHY_SOUND_PHONE_INCOMING, - EMPATHY_SOUND_PHONE_OUTGOING, - EMPATHY_SOUND_PHONE_HANGUP, - LAST_EMPATHY_SOUND, -} EmpathySound; - void empathy_gtk_init (void); GRegex * empathy_uri_regex_dup_singleton (void); @@ -76,7 +59,7 @@ GtkWidget *empathy_builder_unref_and_keep_widget (GtkBuilder *gui, GtkWidget *root); /* Pixbufs */ -const gchar * empathy_icon_name_from_account (McAccount *account); +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, @@ -129,15 +112,6 @@ GtkWidget * empathy_link_button_new (const gchar *url, void empathy_send_file_with_file_chooser (EmpathyContact *contact); void empathy_receive_file_with_file_chooser (EmpathyFTHandler *handler); -/* Sounds */ -void empathy_sound_play (GtkWidget *widget, - EmpathySound sound_id); -gboolean empathy_sound_play_full (GtkWidget *widget, - EmpathySound sound_id, - ca_finish_callback_t callback, - gpointer user_data); -void empathy_sound_stop (EmpathySound sound_id); - G_END_DECLS #endif /* __EMPATHY_UI_UTILS_H__ */ diff --git a/libempathy-gtk/empathy-video-widget.c b/libempathy-gtk/empathy-video-widget.c index 79f27814f..0f62496de 100644 --- a/libempathy-gtk/empathy-video-widget.c +++ b/libempathy-gtk/empathy-video-widget.c @@ -403,7 +403,7 @@ empathy_video_widget_sync_message_cb (GstBus *bus, GstMessage *message, { g_assert (GTK_WIDGET_REALIZED (GTK_WIDGET (self))); gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (priv->overlay), - GDK_WINDOW_XID (GTK_WIDGET (self)->window)); + GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (self)))); } } @@ -418,13 +418,13 @@ empathy_video_widget_expose_event (GtkWidget *widget, GdkEventExpose *event) if (priv->overlay == NULL) { - gdk_window_clear_area (widget->window, 0, 0, + gdk_window_clear_area (gtk_widget_get_window (widget), 0, 0, widget->allocation.width, widget->allocation.height); return TRUE; } gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (priv->overlay), - GDK_WINDOW_XID (widget->window)); + GDK_WINDOW_XID (gtk_widget_get_window (widget))); gst_x_overlay_expose (GST_X_OVERLAY (priv->overlay)); |