avatar: fix black camera image

On some systems, when opening the camera to take a new picture for
the avatar, the result is a black image. The log also outputs
"bad dawable". It seems the VideoWidget doesn't like being a page
directly in a GtkStack. Instead we put it in a GtkFrame which does
not get destroyed. This seems to fix the issue.

Change-Id: Ia3796ad3b3f02947619c2b0ba57ad4b54e30552e
Tuleap: #840
diff --git a/src/avatarmanipulation.cpp b/src/avatarmanipulation.cpp
index 35148cd..100153c 100644
--- a/src/avatarmanipulation.cpp
+++ b/src/avatarmanipulation.cpp
@@ -88,6 +88,7 @@
     GtkWidget *stack_views;
     GtkWidget *image_avatar;
     GtkWidget *vbox_selector;
+    GtkWidget *frame_video;
     GdkPixbuf *pix_scaled;
 
     /* selector widget properties */
@@ -142,7 +143,7 @@
     if (priv->video_started_by_avatar_manipulation)
         Video::PreviewManager::instance().stopPreview();
     if (priv->video_widget) {
-        gtk_container_remove(GTK_CONTAINER(priv->stack_views), priv->video_widget);
+        gtk_container_remove(GTK_CONTAINER(priv->frame_video), priv->video_widget);
         priv->video_widget = NULL;
     }
 
@@ -205,6 +206,7 @@
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, button_return_edit);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, stack_views);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, image_avatar);
+    gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, frame_video);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, vbox_selector);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, button_box_current);
     gtk_widget_class_bind_template_child_private(GTK_WIDGET_CLASS (klass), AvatarManipulation, button_box_photo);
@@ -291,7 +293,7 @@
             if (priv->video_started_by_avatar_manipulation)
                 Video::PreviewManager::instance().stopPreview();
             if (priv->video_widget) {
-                gtk_container_remove(GTK_CONTAINER(priv->stack_views), priv->video_widget);
+                gtk_container_remove(GTK_CONTAINER(priv->frame_video), priv->video_widget);
                 priv->video_widget = NULL;
             }
         }
@@ -303,8 +305,8 @@
             g_signal_connect_swapped(priv->video_widget, "snapshot-taken", G_CALLBACK (got_snapshot), self);
             gtk_widget_set_vexpand_set(priv->video_widget, FALSE);
             gtk_widget_set_hexpand_set(priv->video_widget, FALSE);
+            gtk_container_add(GTK_CONTAINER(priv->frame_video), priv->video_widget);
             gtk_widget_set_visible(priv->video_widget, true);
-            gtk_stack_add_named(GTK_STACK(priv->stack_views), priv->video_widget, "page_photobooth");
             gtk_stack_set_visible_child_name(GTK_STACK(priv->stack_views), "page_photobooth");
 
 
@@ -332,7 +334,7 @@
             if (priv->video_started_by_avatar_manipulation)
                 Video::PreviewManager::instance().stopPreview();
             if (priv->video_widget) {
-                gtk_container_remove(GTK_CONTAINER(priv->stack_views), priv->video_widget);
+                gtk_container_remove(GTK_CONTAINER(priv->frame_video), priv->video_widget);
                 priv->video_widget = NULL;
             }
 
diff --git a/ui/avatarmanipulation.ui b/ui/avatarmanipulation.ui
index f54e7f5..741a319 100644
--- a/ui/avatarmanipulation.ui
+++ b/ui/avatarmanipulation.ui
@@ -33,26 +33,31 @@
     <child>
       <object class="GtkBox" id="box_views_and_controls">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">5</property>
         <child>
           <object class="GtkStack" id="stack_views">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <child>
               <object class="GtkImage" id="image_avatar">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
               </object>
               <packing>
                 <property name="name">page_avatar</property>
               </packing>
             </child>
             <child>
+              <object class="GtkFrame" id="frame_video">
+                <property name="visible">True</property>
+                <property name="shadow-type">GTK_SHADOW_NONE</property>
+              </object>
+              <packing>
+                <property name="name">page_photobooth</property>
+              </packing>
+            </child>
+            <child>
               <object class="GtkBox" id="vbox_selector">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
                 <property name="orientation">vertical</property>
                 <property name="valign">center</property>
                 <property name="halign">center</property>