app: add gimp_container_editor_bind_to_async_set()

... which takes a GimpAsyncSet and a message, and shows a
GimpBusyBox with that message, instead of the container view, while
the async set is nonempty.

We're going to use this for font-loading indication in font views,
such as in the fonts dialog.
This commit is contained in:
Ell 2018-05-29 10:56:09 -04:00
parent 000fd8e69b
commit 03983f9547
2 changed files with 39 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include "widgets-types.h"
#include "core/gimpasyncset.h"
#include "core/gimpcontext.h"
#include "core/gimplist.h"
#include "core/gimpviewable.h"
@ -65,6 +66,8 @@ struct _GimpContainerEditorPrivate
GimpMenuFactory *menu_factory;
gchar *menu_identifier;
gchar *ui_path;
GtkWidget *busy_box;
GBinding *async_set_binding;
};
@ -269,6 +272,13 @@ gimp_container_editor_constructed (GObject *object)
TRUE, TRUE, 0);
gtk_widget_show (GTK_WIDGET (editor->view));
editor->priv->busy_box = gimp_busy_box_new (NULL);
gtk_box_pack_start (GTK_BOX (editor), editor->priv->busy_box, TRUE, TRUE, 0);
g_object_bind_property (editor->priv->busy_box, "visible",
editor->view, "visible",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
/* Connect "select-item" with G_CONNECT_AFTER because it's a
* RUN_LAST signal and the default handler selecting the row must
* run before signal connections. See bug #784176.
@ -299,6 +309,8 @@ gimp_container_editor_dispose (GObject *object)
{
GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
gimp_container_editor_bind_to_async_set (editor, NULL, NULL);
g_clear_object (&editor->priv->container);
g_clear_object (&editor->priv->context);
g_clear_object (&editor->priv->menu_factory);
@ -529,3 +541,26 @@ gimp_container_editor_get_show_button_bar (GimpDocked *docked)
return gimp_docked_get_show_button_bar (GIMP_DOCKED (editor->view));
}
void
gimp_container_editor_bind_to_async_set (GimpContainerEditor *editor,
GimpAsyncSet *async_set,
const gchar *message)
{
g_return_if_fail (GIMP_IS_CONTAINER_EDITOR (editor));
g_return_if_fail (async_set == NULL || GIMP_IS_ASYNC_SET (async_set));
g_return_if_fail (async_set == NULL || message != NULL);
g_clear_object (&editor->priv->async_set_binding);
if (async_set)
{
gimp_busy_box_set_message (GIMP_BUSY_BOX (editor->priv->busy_box),
message);
editor->priv->async_set_binding = g_object_bind_property (
async_set, "empty",
editor->priv->busy_box, "visible",
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
}
}

View File

@ -61,5 +61,9 @@ GtkSelectionMode gimp_container_editor_get_selection_mode (GimpContainerEditor *
void gimp_container_editor_set_selection_mode (GimpContainerEditor *editor,
GtkSelectionMode mode);
void gimp_container_editor_bind_to_async_set (GimpContainerEditor *editor,
GimpAsyncSet *async_set,
const gchar *message);
#endif /* __GIMP_CONTAINER_EDITOR_H__ */