[gnome-builder] build: fix vapigen warnings from poorly implemented G-I
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build: fix vapigen warnings from poorly implemented G-I
- Date: Wed, 30 Sep 2015 02:56:50 +0000 (UTC)
commit a25cb6210936190ccd2fd0fa06c9bd797d60a121
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 29 19:56:11 2015 -0700
build: fix vapigen warnings from poorly implemented G-I
We did a few things that are pariticularly bad for bindings generation.
This fixes up those warnings by making signals match their functions,
use alternate naming where appropriate, etc.
libide/ide-buffer-manager.c | 4 +-
libide/ide-buffer-manager.h | 3 +-
libide/ide-source-snippet-completion-provider.c | 3 +-
libide/ide-source-view.c | 103 ++++++++++++++++-------
libide/ide-source-view.h | 10 +--
plugins/clang/ide-clang-completion-provider.c | 2 +-
plugins/jedi/jedi_plugin.py | 2 +-
src/workbench/gb-workbench.c | 2 +-
8 files changed, 85 insertions(+), 44 deletions(-)
---
diff --git a/libide/ide-buffer-manager.c b/libide/ide-buffer-manager.c
index f14668d..f953221 100644
--- a/libide/ide-buffer-manager.c
+++ b/libide/ide-buffer-manager.c
@@ -1605,7 +1605,7 @@ ide_buffer_manager_set_max_file_size (IdeBufferManager *self,
}
/**
- * ide_buffer_manager_create_buffer:
+ * ide_buffer_manager_create_temporary_buffer:
*
* Creates a new #IdeBuffer that does not yet have a backing file attached to it. Interfaces
* should perform a save-as operation to save the file to a real file.
@@ -1615,7 +1615,7 @@ ide_buffer_manager_set_max_file_size (IdeBufferManager *self,
* Returns: (transfer full): A newly created #IdeBuffer
*/
IdeBuffer *
-ide_buffer_manager_create_buffer (IdeBufferManager *self)
+ide_buffer_manager_create_temporary_buffer (IdeBufferManager *self)
{
IdeBuffer *buffer = NULL;
g_autoptr(IdeFile) file = NULL;
diff --git a/libide/ide-buffer-manager.h b/libide/ide-buffer-manager.h
index 1c37516..04d8de1 100644
--- a/libide/ide-buffer-manager.h
+++ b/libide/ide-buffer-manager.h
@@ -30,7 +30,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeBufferManager, ide_buffer_manager, IDE, BUFFER_MANAGER, IdeObject)
-IdeBuffer *ide_buffer_manager_create_buffer (IdeBufferManager *self);
+IdeBuffer *ide_buffer_manager_create_temporary_buffer
+ (IdeBufferManager *self);
void ide_buffer_manager_load_file_async (IdeBufferManager *self,
IdeFile *file,
gboolean force_reload,
diff --git a/libide/ide-source-snippet-completion-provider.c b/libide/ide-source-snippet-completion-provider.c
index 29b2219..476d4bd 100644
--- a/libide/ide-source-snippet-completion-provider.c
+++ b/libide/ide-source-snippet-completion-provider.c
@@ -376,8 +376,7 @@ provider_activate_proposal (GtkSourceCompletionProvider *provider,
* Now push snippet onto the snippet stack of the view.
*/
snippet = ide_source_snippet_copy (snippet);
- ide_source_view_push_snippet (IDE_SOURCE_VIEW (self->source_view),
- snippet);
+ ide_source_view_push_snippet (IDE_SOURCE_VIEW (self->source_view), snippet, NULL);
g_object_unref (snippet);
return TRUE;
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index c1a892a..4ad431e 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -3564,16 +3564,18 @@ ide_source_view_real_push_selection (IdeSourceView *self)
static void
ide_source_view_real_push_snippet (IdeSourceView *self,
IdeSourceSnippet *snippet,
- IdeSourceSnippetContext *context,
const GtkTextIter *location)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ IdeSourceSnippetContext *context;
IdeFile *file;
GFile *gfile;
g_assert (IDE_IS_SOURCE_VIEW (self));
g_assert (IDE_IS_SOURCE_SNIPPET (snippet));
- g_assert (IDE_IS_SOURCE_SNIPPET_CONTEXT (context));
+ g_assert (location != NULL);
+
+ context = ide_source_snippet_get_context (snippet);
if ((priv->buffer != NULL) &&
(file = ide_buffer_get_file (priv->buffer)) &&
@@ -5311,7 +5313,6 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
klass->paste_clipboard_extended = ide_source_view_real_paste_clipboard_extended;
klass->pop_selection = ide_source_view_real_pop_selection;
klass->push_selection = ide_source_view_real_push_selection;
- klass->push_snippet = ide_source_view_real_push_snippet;
klass->rebuild_highlight = ide_source_view_real_rebuild_highlight;
klass->replay_macro = ide_source_view_real_replay_macro;
klass->reset_font_size = ide_source_view_real_reset_font_size;
@@ -5840,15 +5841,21 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
G_TYPE_NONE,
0);
+ /**
+ * IdeSourceView::pop-snippet:
+ * @self: An #IdeSourceView
+ * @snippet: An #IdeSourceSnippet.
+ *
+ * Pops the current snippet from the sourceview if there is one.
+ */
gSignals [POP_SNIPPET] =
- g_signal_new ("pop-snippet",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IdeSourceViewClass, pop_snippet),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- IDE_TYPE_SOURCE_SNIPPET);
+ g_signal_new_class_handler ("pop-snippet",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ NULL,
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
/**
* IdeSourceView::push-selection:
@@ -5866,17 +5873,25 @@ ide_source_view_class_init (IdeSourceViewClass *klass)
G_TYPE_NONE,
0);
+ /**
+ * IdeSourceView::push-snippet:
+ * @self: An #IdeSourceView
+ * @snippet: An #IdeSourceSnippet.
+ * @iter: (allow-none): The location for the snippet, or %NULL.
+ *
+ * Pushes @snippet onto the snippet stack at either @iter or the insertion
+ * mark if @iter is not provided.
+ */
gSignals [PUSH_SNIPPET] =
- g_signal_new ("push-snippet",
- G_TYPE_FROM_CLASS (klass),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (IdeSourceViewClass, push_snippet),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 3,
- IDE_TYPE_SOURCE_SNIPPET,
- IDE_TYPE_SOURCE_SNIPPET_CONTEXT,
- GTK_TYPE_TEXT_ITER);
+ g_signal_new_class_handler ("push-snippet",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST,
+ G_CALLBACK (ide_source_view_real_push_snippet),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 2,
+ IDE_TYPE_SOURCE_SNIPPET,
+ GTK_TYPE_TEXT_ITER);
gSignals [REBUILD_HIGHLIGHT] =
g_signal_new ("rebuild-highlight",
@@ -6413,15 +6428,23 @@ ide_source_view_clear_snippets (IdeSourceView *self)
ide_source_view_pop_snippet (self);
}
+/**
+ * ide_source_view_push_snippet:
+ * @self: An #IdeSourceView
+ * @snippet: An #IdeSourceSnippet.
+ * @location: (allow-none): A location for the snippet or %NULL.
+ *
+ * Pushes a new snippet onto the source view.
+ */
void
-ide_source_view_push_snippet (IdeSourceView *self,
- IdeSourceSnippet *snippet)
+ide_source_view_push_snippet (IdeSourceView *self,
+ IdeSourceSnippet *snippet,
+ const GtkTextIter *location)
{
IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
IdeSourceSnippetContext *context;
IdeSourceSnippet *previous;
GtkTextBuffer *buffer;
- GtkTextMark *mark;
GtkTextIter iter;
gboolean has_more_tab_stops;
gboolean insert_spaces;
@@ -6430,8 +6453,8 @@ ide_source_view_push_snippet (IdeSourceView *self,
g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
g_return_if_fail (IDE_IS_SOURCE_SNIPPET (snippet));
-
- context = ide_source_snippet_get_context (snippet);
+ g_return_if_fail (!location ||
+ (gtk_text_iter_get_buffer (location) == (void*)priv->buffer));
if ((previous = g_queue_peek_head (priv->snippets)))
ide_source_snippet_pause (previous);
@@ -6439,8 +6462,13 @@ ide_source_view_push_snippet (IdeSourceView *self,
g_queue_push_head (priv->snippets, g_object_ref (snippet));
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (self));
- mark = gtk_text_buffer_get_insert (buffer);
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, mark);
+
+ if (location != NULL)
+ iter = *location;
+ else
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
+
+ context = ide_source_snippet_get_context (snippet);
insert_spaces = gtk_source_view_get_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (self));
ide_source_snippet_context_set_use_spaces (context, insert_spaces);
@@ -6452,7 +6480,7 @@ ide_source_view_push_snippet (IdeSourceView *self,
ide_source_snippet_context_set_line_prefix (context, line_prefix);
g_free (line_prefix);
- g_signal_emit (self, gSignals [PUSH_SNIPPET], 0, snippet, context, &iter);
+ g_signal_emit (self, gSignals [PUSH_SNIPPET], 0, snippet, &iter);
ide_source_view_block_handlers (self);
has_more_tab_stops = ide_source_snippet_begin (snippet, buffer, &iter);
@@ -7422,3 +7450,20 @@ _ide_source_view_get_scroll_mark (IdeSourceView *self)
return priv->scroll_mark;
}
+
+/**
+ * ide_source_view_get_current_snippet:
+ *
+ * Gets the current snippet if there is one, otherwise %NULL.
+ *
+ * Returns: (transfer none) (nullable): An #IdeSourceSnippet or %NULL.
+ */
+IdeSourceSnippet *
+ide_source_view_get_current_snippet (IdeSourceView *self)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_SOURCE_VIEW (self), NULL);
+
+ return g_queue_peek_head (priv->snippets);
+}
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 4fce05d..4359224 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -238,12 +238,6 @@ struct _IdeSourceViewClass
gboolean place_cursor_at_original);
void (*push_selection) (IdeSourceView *self);
void (*pop_selection) (IdeSourceView *self);
- void (*pop_snippet) (IdeSourceView *self,
- IdeSourceSnippet *snippet);
- void (*push_snippet) (IdeSourceView *self,
- IdeSourceSnippet *snippet,
- IdeSourceSnippetContext *context,
- const GtkTextIter *location);
void (*rebuild_highlight) (IdeSourceView *self);
void (*replay_macro) (IdeSourceView *self,
gboolean use_count);
@@ -270,6 +264,7 @@ struct _IdeSourceViewClass
};
void ide_source_view_clear_snippets (IdeSourceView *self);
+IdeSourceSnippet *ide_source_view_get_current_snippet (IdeSourceView *self);
IdeBackForwardList *ide_source_view_get_back_forward_list (IdeSourceView *self);
void ide_source_view_get_visual_position (IdeSourceView *self,
guint *line,
@@ -299,7 +294,8 @@ void ide_source_view_jump (IdeSource
const GtkTextIter *location);
void ide_source_view_pop_snippet (IdeSourceView *self);
void ide_source_view_push_snippet (IdeSourceView *self,
- IdeSourceSnippet *snippet);
+ IdeSourceSnippet *snippet,
+ const GtkTextIter *location);
void ide_source_view_rollback_search (IdeSourceView *self);
void ide_source_view_set_count (IdeSourceView *self,
guint count);
diff --git a/plugins/clang/ide-clang-completion-provider.c b/plugins/clang/ide-clang-completion-provider.c
index 14ab201..f7027ad 100644
--- a/plugins/clang/ide-clang-completion-provider.c
+++ b/plugins/clang/ide-clang-completion-provider.c
@@ -632,7 +632,7 @@ ide_clang_completion_provider_activate_proposal (GtkSourceCompletionProvider *pr
g_assert (IDE_IS_SOURCE_SNIPPET (snippet));
g_assert (IDE_IS_SOURCE_VIEW (self->view));
- ide_source_view_push_snippet (self->view, snippet);
+ ide_source_view_push_snippet (self->view, snippet, NULL);
IDE_RETURN (TRUE);
}
diff --git a/plugins/jedi/jedi_plugin.py b/plugins/jedi/jedi_plugin.py
index 9357e68..de71608 100644
--- a/plugins/jedi/jedi_plugin.py
+++ b/plugins/jedi/jedi_plugin.py
@@ -314,7 +314,7 @@ class JediCompletionProvider(Ide.Object,
snippet.add_chunk(chunk)
view = proposal.context.props.completion.props.view
- view.push_snippet(snippet)
+ view.push_snippet(snippet, None)
return True, None
diff --git a/src/workbench/gb-workbench.c b/src/workbench/gb-workbench.c
index 1753bb9..1011b1d 100644
--- a/src/workbench/gb-workbench.c
+++ b/src/workbench/gb-workbench.c
@@ -1008,7 +1008,7 @@ gb_workbench_add_temporary_buffer (GbWorkbench *self)
context = gb_workbench_get_context (self);
buffer_manager = ide_context_get_buffer_manager (context);
- buffer = ide_buffer_manager_create_buffer (buffer_manager);
+ buffer = ide_buffer_manager_create_temporary_buffer (buffer_manager);
g_clear_object (&buffer);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]