aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk/empathy-new-message-dialog.c
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-04-13 14:24:21 +0800
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2011-05-05 14:31:27 +0800
commit11e8ca993282f16043b821f00e55f5ebd03fb089 (patch)
treeb7ae03bea5020c3f4f3bc53b22195008b13b46a9 /libempathy-gtk/empathy-new-message-dialog.c
parent73220cb660bf75ac0c57f46ca514146cfa091e4f (diff)
downloadgsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar.gz
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar.bz2
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar.lz
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar.xz
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.tar.zst
gsoc2013-empathy-11e8ca993282f16043b821f00e55f5ebd03fb089.zip
Only set the SMS button sensitive if we have SMS capability
Diffstat (limited to 'libempathy-gtk/empathy-new-message-dialog.c')
-rw-r--r--libempathy-gtk/empathy-new-message-dialog.c65
1 files changed, 63 insertions, 2 deletions
diff --git a/libempathy-gtk/empathy-new-message-dialog.c b/libempathy-gtk/empathy-new-message-dialog.c
index 81b532b37..3d811abbb 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -154,6 +154,63 @@ empathy_new_message_account_filter (EmpathyContactSelectorDialog *dialog,
tp_proxy_prepare_async (connection, features, conn_prepared_cb, cb_data);
}
+static void
+empathy_new_message_dialog_update_sms_button_sensitivity (GtkWidget *widget,
+ GParamSpec *pspec,
+ GtkWidget *button)
+{
+ GtkWidget *self = gtk_widget_get_toplevel (widget);
+ EmpathyContactSelectorDialog *dialog;
+ TpConnection *conn;
+ GPtrArray *rccs;
+ gboolean sensitive = FALSE;
+ guint i;
+
+ g_return_if_fail (EMPATHY_IS_NEW_MESSAGE_DIALOG (self));
+
+ dialog = EMPATHY_CONTACT_SELECTOR_DIALOG (self);
+
+ /* if the Text widget isn't sensitive, don't bother checking the caps */
+ if (!gtk_widget_get_sensitive (dialog->button_action))
+ goto finally;
+
+ empathy_contact_selector_dialog_get_selected (dialog, &conn, NULL);
+
+ if (conn == NULL)
+ goto finally;
+
+ /* iterate the rccs to find if SMS channels are supported, this should
+ * be in tp-glib */
+ rccs = tp_capabilities_get_channel_classes (
+ tp_connection_get_capabilities (conn));
+
+ for (i = 0; i < rccs->len; i++)
+ {
+ GHashTable *fixed;
+ GStrv allowed;
+ const char *type;
+ gboolean sms_channel;
+
+ tp_value_array_unpack (g_ptr_array_index (rccs, i), 2,
+ &fixed,
+ &allowed);
+
+ /* SMS channels are type:Text and sms-channel:True */
+ type = tp_asv_get_string (fixed, TP_PROP_CHANNEL_CHANNEL_TYPE);
+ sms_channel = tp_asv_get_boolean (fixed,
+ TP_PROP_CHANNEL_INTERFACE_SMS_SMS_CHANNEL, NULL);
+
+ sensitive = sms_channel &&
+ !tp_strdiff (type, TP_IFACE_CHANNEL_TYPE_TEXT);
+
+ if (sensitive)
+ break;
+ }
+
+finally:
+ gtk_widget_set_sensitive (button, sensitive);
+}
+
static GObject *
empathy_new_message_dialog_constructor (GType type,
guint n_props,
@@ -209,8 +266,12 @@ empathy_new_message_dialog_init (EmpathyNewMessageDialog *dialog)
/* the parent class will update the sensitivity of button_action, propagate
* it */
- g_object_bind_property (parent->button_action, "sensitive",
- button, "sensitive", G_BINDING_SYNC_CREATE);
+ g_signal_connect (parent->button_action, "notify::sensitive",
+ G_CALLBACK (empathy_new_message_dialog_update_sms_button_sensitivity),
+ button);
+ g_signal_connect (dialog, "notify::selected-account",
+ G_CALLBACK (empathy_new_message_dialog_update_sms_button_sensitivity),
+ button);
/* Tweak the dialog */
gtk_window_set_title (GTK_WINDOW (dialog), _("New Conversation"));