[empathy] avatar-chooser: disable 'take picture' button if there is no camera connected



commit 1ce2aa6b4cf7d049fd3c51784ff447d608cd1084
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Fri Sep 16 14:23:13 2011 +0200

    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 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index 62ff491..0fe9724 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -28,6 +28,7 @@
 #include <gtk/gtk.h>
 #include <gio/gio.h>
 
+#include <libempathy/empathy-camera-monitor.h>
 #include <libempathy/empathy-gsettings.h>
 #include <libempathy/empathy-utils.h>
 
@@ -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),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]