[gnome-builder] buffer: allow passing IdeNotification
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] buffer: allow passing IdeNotification
- Date: Tue, 12 Mar 2019 21:49:57 +0000 (UTC)
commit 7d7416d5cf8f3694f164602decdd96403a199258
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 12 14:15:34 2019 -0700
buffer: allow passing IdeNotification
This avoids using out parameters for async operations, which is
not supported by Vala and other G-I based bindings.
src/libide/code/ide-buffer-manager.c | 17 +++++++----------
src/libide/code/ide-buffer-manager.h | 2 +-
src/libide/code/ide-buffer-private.h | 2 +-
src/libide/code/ide-buffer.c | 8 ++------
src/libide/editor/ide-editor-page-actions.c | 7 +++++--
src/plugins/editor/gbp-editor-session-addin.c | 2 +-
src/plugins/editor/gbp-editor-workbench-addin.c | 2 +-
7 files changed, 18 insertions(+), 22 deletions(-)
---
diff --git a/src/libide/code/ide-buffer-manager.c b/src/libide/code/ide-buffer-manager.c
index 4235cca5f..37d1321c4 100644
--- a/src/libide/code/ide-buffer-manager.c
+++ b/src/libide/code/ide-buffer-manager.c
@@ -575,8 +575,8 @@ ide_buffer_manager_load_file_cb (GObject *object,
* @self: an #IdeBufferManager
* @file: (nullable): a #GFile
* @flags: optional flags for loading the buffer
+ * @notif: (nullable): a location for an #IdeNotification, or %NULL
* @cancellable: (nullable): a #GCancellable or %NULL
- * @notif: (out) (optional): a location for an #IdeNotification, or %NULL
* @callback: a callback to execute upon completion of the operation
* @user_data: closure data for @callback
*
@@ -595,9 +595,8 @@ ide_buffer_manager_load_file_cb (GObject *object,
* If a buffer is currently loading for @file, the operation will complete
* using that existing buffer after it has completed loading.
*
- * If @notif is non-NULL, it will be set to a new #IdeNotification which should
- * be freed with g_object_unref() when no longer in use. It will be kept up to
- * date with loading progress as the file is loaded.
+ * If @notif is non-NULL, it will be updated with status information while
+ * loading the document.
*
* Since: 3.32
*/
@@ -605,8 +604,8 @@ void
ide_buffer_manager_load_file_async (IdeBufferManager *self,
GFile *file,
IdeBufferOpenFlags flags,
+ IdeNotification *notif,
GCancellable *cancellable,
- IdeNotification **notif,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -622,11 +621,9 @@ ide_buffer_manager_load_file_async (IdeBufferManager *self,
g_return_if_fail (IDE_IS_MAIN_THREAD ());
g_return_if_fail (IDE_IS_BUFFER_MANAGER (self));
g_return_if_fail (!file || G_IS_FILE (file));
+ g_return_if_fail (!notif || IDE_IS_NOTIFICATION (notif));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
- if (notif != NULL)
- *notif = NULL;
-
if (file == NULL)
file = temp_file = ide_buffer_manager_next_temp_file (self);
@@ -684,8 +681,8 @@ ide_buffer_manager_load_file_async (IdeBufferManager *self,
/* Now we can load the buffer asynchronously */
_ide_buffer_load_file_async (buffer,
- cancellable,
notif,
+ cancellable,
ide_buffer_manager_load_file_cb,
g_steal_pointer (&task));
@@ -1173,8 +1170,8 @@ ide_buffer_manager_apply_edits_async (IdeBufferManager *self,
ide_buffer_manager_load_file_async (self,
file,
IDE_BUFFER_OPEN_FLAGS_NO_VIEW,
- cancellable,
NULL,
+ cancellable,
ide_buffer_manager_apply_edits_buffer_loaded_cb,
g_object_ref (task));
}
diff --git a/src/libide/code/ide-buffer-manager.h b/src/libide/code/ide-buffer-manager.h
index df9eda338..f58513d07 100644
--- a/src/libide/code/ide-buffer-manager.h
+++ b/src/libide/code/ide-buffer-manager.h
@@ -77,8 +77,8 @@ IDE_AVAILABLE_IN_3_32
void ide_buffer_manager_load_file_async (IdeBufferManager *self,
GFile *file,
IdeBufferOpenFlags flags,
+ IdeNotification *notif,
GCancellable *cancellable,
- IdeNotification **notif,
GAsyncReadyCallback callback,
gpointer user_data);
IDE_AVAILABLE_IN_3_32
diff --git a/src/libide/code/ide-buffer-private.h b/src/libide/code/ide-buffer-private.h
index 56e969916..a11df0f62 100644
--- a/src/libide/code/ide-buffer-private.h
+++ b/src/libide/code/ide-buffer-private.h
@@ -42,8 +42,8 @@ IdeBuffer *_ide_buffer_new (IdeBufferManager
void _ide_buffer_attach (IdeBuffer *self,
IdeObject *parent);
void _ide_buffer_load_file_async (IdeBuffer *self,
+ IdeNotification *notif,
GCancellable *cancellable,
- IdeNotification **notif,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean _ide_buffer_load_file_finish (IdeBuffer *self,
diff --git a/src/libide/code/ide-buffer.c b/src/libide/code/ide-buffer.c
index 3d0e60489..dfa5504c9 100644
--- a/src/libide/code/ide-buffer.c
+++ b/src/libide/code/ide-buffer.c
@@ -1271,8 +1271,8 @@ ide_buffer_load_file_cb (GObject *object,
void
_ide_buffer_load_file_async (IdeBuffer *self,
+ IdeNotification *notif,
GCancellable *cancellable,
- IdeNotification **notif,
GAsyncReadyCallback callback,
gpointer user_data)
{
@@ -1286,7 +1286,6 @@ _ide_buffer_load_file_async (IdeBuffer *self,
g_return_if_fail (IDE_IS_BUFFER (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
g_return_if_fail (ide_buffer_get_file (self) != NULL);
- ide_clear_param (notif, NULL);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, _ide_buffer_load_file_async);
@@ -1303,7 +1302,7 @@ _ide_buffer_load_file_async (IdeBuffer *self,
state = g_slice_new0 (LoadState);
state->file = g_object_ref (ide_buffer_get_file (self));
- state->notif = ide_notification_new ();
+ state->notif = notif ? g_object_ref (notif) : ide_notification_new ();
state->highlight_syntax = gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (self));
ide_task_set_task_data (task, state, load_state_free);
@@ -1330,9 +1329,6 @@ _ide_buffer_load_file_async (IdeBuffer *self,
*/
ide_buffer_reload_file_settings (self);
- if (notif != NULL)
- *notif = g_object_ref (state->notif);
-
IDE_EXIT;
}
diff --git a/src/libide/editor/ide-editor-page-actions.c b/src/libide/editor/ide-editor-page-actions.c
index 37a238df1..9f64bd543 100644
--- a/src/libide/editor/ide-editor-page-actions.c
+++ b/src/libide/editor/ide-editor-page-actions.c
@@ -86,15 +86,18 @@ ide_editor_page_actions_reload (GSimpleAction *action,
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (self->progress_bar), 0.0);
gtk_widget_show (GTK_WIDGET (self->progress_bar));
+ notif = ide_notification_new ();
+
ide_buffer_manager_load_file_async (bufmgr,
file,
IDE_BUFFER_OPEN_FLAGS_FORCE_RELOAD,
+ notif,
NULL,
- ¬if,
ide_editor_page_actions_reload_cb,
g_object_ref (self));
- g_object_bind_property (notif, "progress", self->progress_bar, "fraction",
+ g_object_bind_property (notif, "progress",
+ self->progress_bar, "fraction",
G_BINDING_SYNC_CREATE);
}
diff --git a/src/plugins/editor/gbp-editor-session-addin.c b/src/plugins/editor/gbp-editor-session-addin.c
index c758defa9..234d0a42d 100644
--- a/src/plugins/editor/gbp-editor-session-addin.c
+++ b/src/plugins/editor/gbp-editor-session-addin.c
@@ -372,8 +372,8 @@ restore_file (GObject *source,
ide_buffer_manager_load_file_async (bufmgr,
file,
IDE_BUFFER_OPEN_FLAGS_NO_VIEW,
- ide_task_get_cancellable (task),
NULL,
+ ide_task_get_cancellable (task),
gbp_editor_session_addin_load_file_cb,
g_object_ref (task));
}
diff --git a/src/plugins/editor/gbp-editor-workbench-addin.c b/src/plugins/editor/gbp-editor-workbench-addin.c
index b2170c48d..571ab118c 100644
--- a/src/plugins/editor/gbp-editor-workbench-addin.c
+++ b/src/plugins/editor/gbp-editor-workbench-addin.c
@@ -250,8 +250,8 @@ gbp_editor_workbench_addin_open_at_async (IdeWorkbenchAddin *addin,
ide_buffer_manager_load_file_async (buffer_manager,
file,
state->flags,
- cancellable,
NULL,
+ cancellable,
gbp_editor_workbench_addin_open_at_cb,
g_steal_pointer (&task));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]