From 1ce2aa6b4cf7d049fd3c51784ff447d608cd1084 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 16 Sep 2011 14:23:13 +0200 Subject: avatar-chooser: disable 'take picture' button if there is no camera connected https://bugzilla.gnome.org/show_bug.cgi?id=652985 --- libempathy-gtk/empathy-avatar-chooser.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libempathy-gtk') diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index 62ff491ea..0fe972481 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -923,6 +924,10 @@ avatar_chooser_clicked_cb (GtkWidget *button, const gchar *default_dir = DEFAULT_DIR; const gchar *pics_dir; GtkFileFilter *filter; +#ifdef HAVE_CHEESE + GtkWidget *picture_button; + EmpathyCameraMonitor *monitor; +#endif if (self->priv->chooser_dialog != NULL) { @@ -937,8 +942,18 @@ avatar_chooser_clicked_cb (GtkWidget *button, NULL, NULL)); #ifdef HAVE_CHEESE - gtk_dialog_add_button (GTK_DIALOG (self->priv->chooser_dialog), + picture_button = gtk_dialog_add_button ( + GTK_DIALOG (self->priv->chooser_dialog), _("Take a picture..."), EMPATHY_AVATAR_CHOOSER_RESPONSE_WEBCAM); + + /* Button is sensitive only if there is one camera connected */ + monitor = empathy_camera_monitor_dup_singleton (); + + g_object_set_data_full (G_OBJECT (picture_button), + "monitor", monitor, g_object_unref); + + g_object_bind_property (monitor, "available", picture_button, "sensitive", + G_BINDING_SYNC_CREATE); #endif gtk_dialog_add_buttons (GTK_DIALOG (self->priv->chooser_dialog), -- cgit v1.2.3