diff options
author | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-07-29 17:28:48 +0800 |
---|---|---|
committer | Marco Barisione <marco.barisione@collabora.co.uk> | 2013-08-20 18:03:05 +0800 |
commit | d9f45de3b3da70e5d047313e0abb816d9f2fca3f (patch) | |
tree | df76e046094a94a7bc77d0d17243521846f354ff /libempathy-gtk | |
parent | 59d0c113fdf2e565f512c98334a1808cfd216fa9 (diff) | |
download | gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar.gz gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar.bz2 gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar.lz gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar.xz gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.tar.zst gsoc2013-empathy-d9f45de3b3da70e5d047313e0abb816d9f2fca3f.zip |
contactinfo-utils: move create_channel_list_label to individual-widget
This removed the dependency of contactinfo-utils on
empathy-request-util.h, so it's easier to move tp tp-account-widgets.
https://bugzilla.gnome.org/show_bug.cgi?id=699492
Diffstat (limited to 'libempathy-gtk')
-rw-r--r-- | libempathy-gtk/empathy-contactinfo-utils.c | 65 | ||||
-rw-r--r-- | libempathy-gtk/empathy-contactinfo-utils.h | 4 | ||||
-rw-r--r-- | libempathy-gtk/empathy-individual-widget.c | 68 |
3 files changed, 66 insertions, 71 deletions
diff --git a/libempathy-gtk/empathy-contactinfo-utils.c b/libempathy-gtk/empathy-contactinfo-utils.c index 42d03806d..010580254 100644 --- a/libempathy-gtk/empathy-contactinfo-utils.c +++ b/libempathy-gtk/empathy-contactinfo-utils.c @@ -26,7 +26,6 @@ #include <glib/gi18n-lib.h> #include <tp-account-widgets/tpaw-time.h> -#include "empathy-request-util.h" #include "empathy-string-parser.h" #include "empathy-ui-utils.h" @@ -265,67 +264,3 @@ empathy_contact_info_field_spec_cmp (TpContactInfoFieldSpec *spec1, return contact_info_field_name_cmp (spec1->name, spec2->name); } -static gboolean -channel_name_activated_cb ( - GtkLabel *label, - gchar *uri, - TpAccount *account) -{ - empathy_join_muc (account, uri, empathy_get_current_action_time ()); - return TRUE; -} - -GtkWidget * -empathy_contact_info_create_channel_list_label (TpAccount *account, - GList *info, - guint row) -{ - GtkWidget *label = NULL; - GString *label_markup = g_string_new (""); - guint i; - GPtrArray *channels; - GList *l; - - /* Is there channels? */ - channels = g_ptr_array_new (); - - for (l = info; l != NULL; l = l->next) - { - TpContactInfoField *field = l->data; - - if (!tp_strdiff (field->field_name, "x-irc-channel")) - g_ptr_array_add (channels, (gpointer) field->field_value[0]); - } - - if (channels->len == 0) - goto out; - - for (i = 0; i < channels->len; i++) - { - const gchar *channel_name = g_ptr_array_index (channels, i); - /* We abuse the URI of the link to hold the channel name. It seems to - * be okay to just use it essentially verbatim, rather than trying to - * ensure it's actually a valid URI. */ - gchar *escaped = g_markup_escape_text (channel_name, -1); - - if (i > 0) - g_string_append (label_markup, ", "); - - g_string_append_printf (label_markup, "<a href='%s'>%s</a>", - escaped, escaped); - g_free (escaped); - } - - label = gtk_label_new (NULL); - gtk_label_set_markup (GTK_LABEL (label), label_markup->str); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - - g_signal_connect (label, "activate-link", - (GCallback) channel_name_activated_cb, account); - -out: - g_ptr_array_unref (channels); - g_string_free (label_markup, TRUE); - - return label; -} diff --git a/libempathy-gtk/empathy-contactinfo-utils.h b/libempathy-gtk/empathy-contactinfo-utils.h index 64514f09d..91c3a529b 100644 --- a/libempathy-gtk/empathy-contactinfo-utils.h +++ b/libempathy-gtk/empathy-contactinfo-utils.h @@ -40,10 +40,6 @@ gint empathy_contact_info_field_cmp (TpContactInfoField *field1, gint empathy_contact_info_field_spec_cmp (TpContactInfoFieldSpec *spec1, TpContactInfoFieldSpec *spec2); -GtkWidget * empathy_contact_info_create_channel_list_label (TpAccount *account, - GList *info, - guint row); - G_END_DECLS #endif /* __EMPATHY_UTILS_H__ */ diff --git a/libempathy-gtk/empathy-individual-widget.c b/libempathy-gtk/empathy-individual-widget.c index bf0998ece..8910954f7 100644 --- a/libempathy-gtk/empathy-individual-widget.c +++ b/libempathy-gtk/empathy-individual-widget.c @@ -36,6 +36,7 @@ #include "empathy-groups-widget.h" #include "empathy-gtk-enum-types.h" #include "empathy-location.h" +#include "empathy-request-util.h" #include "empathy-ui-utils.h" #include "empathy-utils.h" @@ -219,6 +220,70 @@ add_row (GtkGrid *grid, gtk_widget_show (value); } +static gboolean +channel_name_activated_cb ( + GtkLabel *label, + gchar *uri, + TpAccount *account) +{ + empathy_join_muc (account, uri, empathy_get_current_action_time ()); + return TRUE; +} + +static GtkWidget * +create_channel_list_label (TpAccount *account, + GList *info, + guint row) +{ + GtkWidget *label = NULL; + GString *label_markup = g_string_new (""); + guint i; + GPtrArray *channels; + GList *l; + + /* Is there channels? */ + channels = g_ptr_array_new (); + + for (l = info; l != NULL; l = l->next) + { + TpContactInfoField *field = l->data; + + if (!tp_strdiff (field->field_name, "x-irc-channel")) + g_ptr_array_add (channels, (gpointer) field->field_value[0]); + } + + if (channels->len == 0) + goto out; + + for (i = 0; i < channels->len; i++) + { + const gchar *channel_name = g_ptr_array_index (channels, i); + /* We abuse the URI of the link to hold the channel name. It seems to + * be okay to just use it essentially verbatim, rather than trying to + * ensure it's actually a valid URI. */ + gchar *escaped = g_markup_escape_text (channel_name, -1); + + if (i > 0) + g_string_append (label_markup, ", "); + + g_string_append_printf (label_markup, "<a href='%s'>%s</a>", + escaped, escaped); + g_free (escaped); + } + + label = gtk_label_new (NULL); + gtk_label_set_markup (GTK_LABEL (label), label_markup->str); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + + g_signal_connect (label, "activate-link", + (GCallback) channel_name_activated_cb, account); + +out: + g_ptr_array_unref (channels); + g_string_free (label_markup, TRUE); + + return label; +} static guint details_update_show (EmpathyIndividualWidget *self, TpContact *contact) @@ -285,8 +350,7 @@ details_update_show (EmpathyIndividualWidget *self, conn = tp_contact_get_connection (contact); account = tp_connection_get_account (conn); - channels_label = empathy_contact_info_create_channel_list_label (account, - info, n_rows); + channels_label = create_channel_list_label (account, info, n_rows); if (channels_label != NULL) { |