aboutsummaryrefslogtreecommitdiffstats
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-04-13 14:24:21 +0800
commit5fc3d08d0a34b639f169e537f00fde363d296379 (patch)
tree5cc63d650036b240151eb6dbafda12d8af24c145
parenta44e407f8d3a7d5d59a95295ae4df4a4742d2ac1 (diff)
downloadgsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar.gz
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar.bz2
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar.lz
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar.xz
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.tar.zst
gsoc2013-empathy-5fc3d08d0a34b639f169e537f00fde363d296379.zip
Only set the SMS button sensitive if we have SMS capability
-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 a704212c8..1fe935d4e 100644
--- a/libempathy-gtk/empathy-new-message-dialog.c
+++ b/libempathy-gtk/empathy-new-message-dialog.c
@@ -177,6 +177,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,
@@ -232,8 +289,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"));