[gnome-builder] GbDocument: pass toplevel (workbench) to save_async() functions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] GbDocument: pass toplevel (workbench) to save_async() functions
- Date: Wed, 17 Dec 2014 22:05:14 +0000 (UTC)
commit ef2819bd8857f49987e46c6389cae955a4f5377a
Author: Christian Hergert <christian hergert me>
Date: Wed Dec 17 14:05:05 2014 -0800
GbDocument: pass toplevel (workbench) to save_async() functions
This allows them to display a GtkDialog with proper transient-for when
necessary. Some might think that this is leaking UI into the buffer
management, and to them I say, GtkTextBuffer can already store widgets.
C'est la vie
src/documents/gb-document-stack.c | 4 +++-
src/documents/gb-document.c | 8 ++++----
src/documents/gb-document.h | 2 ++
src/editor/gb-editor-document.c | 6 +++---
src/workbench/gb-workbench.c | 4 +++-
5 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/src/documents/gb-document-stack.c b/src/documents/gb-document-stack.c
index 2e83cc8..70892c5 100644
--- a/src/documents/gb-document-stack.c
+++ b/src/documents/gb-document-stack.c
@@ -455,6 +455,7 @@ gb_document_stack_save_activate (GSimpleAction *action,
{
GbDocumentStackPrivate *priv;
GbDocumentStack *stack = user_data;
+ GtkWidget *toplevel;
g_return_if_fail (GB_IS_DOCUMENT_STACK (stack));
@@ -464,12 +465,13 @@ gb_document_stack_save_activate (GSimpleAction *action,
{
GbDocument *document;
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (stack));
document = gb_document_view_get_document (priv->active_view);
if (document)
{
if (gb_document_get_modified (document))
- gb_document_save_async (document, NULL, NULL, NULL);
+ gb_document_save_async (document, toplevel, NULL, NULL, NULL);
}
}
}
diff --git a/src/documents/gb-document.c b/src/documents/gb-document.c
index 940726d..4bd74dd 100644
--- a/src/documents/gb-document.c
+++ b/src/documents/gb-document.c
@@ -120,18 +120,18 @@ gb_document_create_view (GbDocument *document)
void
gb_document_save_async (GbDocument *document,
+ GtkWidget *toplevel,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (GB_IS_DOCUMENT (document));
+ g_return_if_fail (!toplevel || GTK_IS_WIDGET (toplevel));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
if (GB_DOCUMENT_GET_INTERFACE (document)->save_async)
- GB_DOCUMENT_GET_INTERFACE (document)->save_async (document,
- cancellable,
- callback,
- user_data);
+ GB_DOCUMENT_GET_INTERFACE (document)->
+ save_async (document, toplevel, cancellable, callback, user_data);
}
gboolean
diff --git a/src/documents/gb-document.h b/src/documents/gb-document.h
index 9fe3834..590d345 100644
--- a/src/documents/gb-document.h
+++ b/src/documents/gb-document.h
@@ -43,6 +43,7 @@ struct _GbDocumentInterface
const gchar *(*get_title) (GbDocument *document);
gboolean (*is_untitled) (GbDocument *document);
void (*save_async) (GbDocument *document,
+ GtkWidget *toplevel,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -68,6 +69,7 @@ const gchar *gb_document_get_title (GbDocument *document);
GType gb_document_get_type (void);
gboolean gb_document_is_untitled (GbDocument *document);
void gb_document_save_async (GbDocument *document,
+ GtkWidget *toplevel,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/src/editor/gb-editor-document.c b/src/editor/gb-editor-document.c
index cd677e9..90bad26 100644
--- a/src/editor/gb-editor-document.c
+++ b/src/editor/gb-editor-document.c
@@ -868,6 +868,7 @@ cleanup:
static void
gb_editor_document_save_async (GbDocument *doc,
+ GtkWidget *toplevel,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -888,9 +889,7 @@ gb_editor_document_save_async (GbDocument *doc,
{
GFile *chosen_file;
- /* TODO: Plumb toplevel widget */
-
- chosen_file = gb_editor_document_prompt_save (document, NULL);
+ chosen_file = gb_editor_document_prompt_save (document, toplevel);
if (!chosen_file)
{
@@ -1013,6 +1012,7 @@ gb_editor_document_save_as_async (GbDocument *document,
if (chosen_file)
{
gb_editor_document_save_async (GB_DOCUMENT (self),
+ toplevel,
cancellable,
gb_editor_document_save_as_cb,
task);
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 2d55cd6..af4f636 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -376,7 +376,8 @@ gb_workbench_action_save_all (GSimpleAction *action,
/* This will not save files which do not have location set */
if (gb_document_get_modified (document))
- gb_document_save_async (document, NULL, NULL, NULL);
+ gb_document_save_async (document, GTK_WIDGET (workbench),
+ NULL, NULL, NULL);
}
g_list_free (list);
@@ -463,6 +464,7 @@ gb_workbench_begin_save (GbWorkbench *workbench,
state->outstanding++;
gb_document_save_async (document,
+ GTK_WIDGET (workbench),
state->cancellable,
gb_workbench_save_cb,
state);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]