diff options
-rw-r--r-- | endless/eoswindow.c | 17 | ||||
-rw-r--r-- | test/test-window.c | 31 |
2 files changed, 36 insertions, 12 deletions
diff --git a/endless/eoswindow.c b/endless/eoswindow.c index d726c53..d2c3ea9 100644 --- a/endless/eoswindow.c +++ b/endless/eoswindow.c @@ -169,6 +169,9 @@ update_page_background (EosWindow *self) { EosPageManager *pm = EOS_PAGE_MANAGER (self->priv->page_manager); GtkWidget *page = self->priv->current_page; + // If no page set, no override + if (page == NULL) + return; const gchar *next_background_uri = eos_page_manager_get_page_background_uri (pm, page); // If backgrounds are the same, do not transition. @@ -192,9 +195,8 @@ update_page_background (EosWindow *self) background_css, -1, &error); gtk_style_context_add_provider_for_screen (screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); - p_stack_set_visible_child (P_STACK (self->priv->background_stack), - self->priv->next_background); + self->priv->next_background); // Swap our background frames for next animation GtkWidget *temp = self->priv->next_background; self->priv->next_background = self->priv->current_background; @@ -483,7 +485,6 @@ eos_window_init (EosWindow *self) self->priv = WINDOW_PRIVATE (self); self->priv->background_provider = gtk_css_provider_new (); - self->priv->current_background_uri = ""; self->priv->top_bar = eos_top_bar_new (); gtk_widget_set_parent (self->priv->top_bar, GTK_WIDGET (self)); @@ -494,14 +495,16 @@ eos_window_init (EosWindow *self) self->priv->background_stack = p_stack_new (); gtk_container_add (GTK_CONTAINER (self->priv->overlay), self->priv->background_stack); - gchar *background_name0 = g_strdup_printf (BACKGROUND_FRAME_NAME_TEMPLATE, 0); - self->priv->current_background = g_object_new (GTK_TYPE_FRAME, "name", background_name0, NULL); - gtk_container_add (GTK_CONTAINER (self->priv->background_stack), self->priv->current_background); - gchar *background_name1 = g_strdup_printf (BACKGROUND_FRAME_NAME_TEMPLATE, 1); self->priv->next_background = g_object_new (GTK_TYPE_FRAME, "name", background_name1, NULL); gtk_container_add (GTK_CONTAINER (self->priv->background_stack), self->priv->next_background); + // Add the current background to the stack second. I think the latest added + // will be the first visible page in the stack + gchar *background_name0 = g_strdup_printf (BACKGROUND_FRAME_NAME_TEMPLATE, 0); + self->priv->current_background = g_object_new (GTK_TYPE_FRAME, "name", background_name0, NULL); + gtk_container_add (GTK_CONTAINER (self->priv->background_stack), self->priv->current_background); + self->priv->main_area = eos_main_area_new (); gtk_overlay_add_overlay (GTK_OVERLAY (self->priv->overlay), self->priv->main_area); diff --git a/test/test-window.c b/test/test-window.c index cf854b1..1ca81ea 100644 --- a/test/test-window.c +++ b/test/test-window.c @@ -99,7 +99,7 @@ test_has_top_bar (GApplication *app) gtk_widget_destroy (win); } -/* Query all the children of win, including the internal children, to find the +/* Query all the children of overlay, including the internal children, to find the main area */ static void find_main_area (GtkWidget *widget, @@ -109,15 +109,36 @@ find_main_area (GtkWidget *widget, *main_area_return_location = widget; } +/* Query all the children of win, including the internal children, to find the +gtk overlay */ static void -test_has_main_area (GApplication *app) +find_overlay (GtkWidget *widget, + GtkWidget **overlay_return_location) { - GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); + if (GTK_IS_OVERLAY (widget)) + *overlay_return_location = widget; +} + +static GtkWidget * +get_main_area (GtkWidget *window) +{ + GtkWidget *overlay = NULL; GtkWidget *main_area = NULL; - gtk_container_forall (GTK_CONTAINER (win), (GtkCallback)find_main_area, + gtk_container_forall (GTK_CONTAINER (window), (GtkCallback)find_overlay, + &overlay); + g_assert (overlay != NULL); + gtk_container_forall (GTK_CONTAINER (overlay), (GtkCallback)find_main_area, &main_area); g_assert (main_area != NULL); + return main_area; +} + +static void +test_has_main_area (GApplication *app) +{ + GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); + GtkWidget *main_area = get_main_area (win); g_assert (EOS_IS_MAIN_AREA (main_area)); gtk_widget_destroy (win); @@ -176,7 +197,7 @@ test_main_area_widgets_visibility (GApplication *app) { GtkWidget *win = eos_window_new (EOS_APPLICATION (app)); EosPageManager *pm = eos_window_get_page_manager (EOS_WINDOW (win)); - GtkWidget *main_area = NULL; + GtkWidget *main_area = get_main_area (win); gtk_container_forall (GTK_CONTAINER (win), (GtkCallback)find_main_area, &main_area); |