Commit cac52ec1 authored by Christian Hergert's avatar Christian Hergert
Browse files

suggestion: improves on the popup_requested case

This ensures that we also handle some other variants like when the model
is set or when we have signal ordering that could perhaps keep us from
having widgets created by models yet.
parent a742e2ee
......@@ -56,10 +56,10 @@ struct _DzlSuggestionPopover
gulong items_changed_handler;
gulong destroy_handler;
gboolean popup_requested;
PangoEllipsizeMode subtitle_ellipsize;
PangoEllipsizeMode title_ellipsize;
guint popup_requested : 1;
};
enum {
......@@ -697,11 +697,11 @@ dzl_suggestion_popover_popup (DzlSuggestionPopover *self)
g_assert (DZL_IS_SUGGESTION_POPOVER (self));
if (self->model == NULL || 0 == (n_items = g_list_model_get_n_items (self->model))) {
self->popup_requested = TRUE;
return;
}
if (self->model == NULL || 0 == (n_items = g_list_model_get_n_items (self->model)))
{
self->popup_requested = TRUE;
return;
}
if (self->relative_to != NULL)
{
......@@ -809,7 +809,7 @@ dzl_suggestion_popover_connect (DzlSuggestionPopover *self)
"items-changed",
G_CALLBACK (dzl_suggestion_popover_items_changed),
self,
G_CONNECT_SWAPPED);
G_CONNECT_AFTER | G_CONNECT_SWAPPED);
if (g_list_model_get_n_items (self->model) == 0)
{
......@@ -864,8 +864,13 @@ dzl_suggestion_popover_set_model (DzlSuggestionPopover *self,
{
self->model = g_object_ref (model);
dzl_suggestion_popover_connect (self);
if (self->popup_requested)
dzl_suggestion_popover_popup (self);
}
self->popup_requested = FALSE;
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_MODEL]);
}
}
......
Supports Markdown
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