Commit 1c1b0d8a authored by Stepan Salenikovich's avatar Stepan Salenikovich

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
parent 8eacc9de
......@@ -88,6 +88,7 @@ struct _AvatarManipulationPrivate
GtkWidget *stack_views;
GtkWidget *image_avatar;
GtkWidget *vbox_selector;
GtkWidget *frame_video;
GdkPixbuf *pix_scaled;
/* selector widget properties */
......@@ -142,7 +143,7 @@ avatar_manipulation_dispose(GObject *object)
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 @@ avatar_manipulation_class_init(AvatarManipulationClass *klass)
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 @@ set_state(AvatarManipulation *self, AvatarManipulationState state)
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 @@ set_state(AvatarManipulation *self, AvatarManipulationState state)
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 @@ set_state(AvatarManipulation *self, AvatarManipulationState state)
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;
}
......
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment