[gnome-builder] libide: modernize GObjects.Use G_DECLARE_FINAL_TYPE() and G_DECLARE_DERIVABLE_TYPE()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: modernize GObjects.Use G_DECLARE_FINAL_TYPE() and G_DECLARE_DERIVABLE_TYPE()
- Date: Fri, 8 May 2015 22:24:14 +0000 (UTC)
commit b1a0288aeb279fa4c5ee95a8f283e9eebc766410
Author: Dimitris Zenios <dimitris zenios gmail com>
Date: Sat May 9 01:19:13 2015 +0300
libide: modernize GObjects.Use G_DECLARE_FINAL_TYPE() and G_DECLARE_DERIVABLE_TYPE()
IdeBuffer,IdeSourceView,IdeLineChangeGutterRenderer,IdeLineDiagnosticsGutterRenderer
and IdeGitRemoteCallbacks were not converted since we are waiting for GtkSourceView and
GgitRemoteCallbacks to be updated to the new g_autoptr functionality
https://bugzilla.gnome.org/show_bug.cgi?id=749139
libide/clang/ide-clang-completion-item.c | 4 -
libide/clang/ide-clang-completion-item.h | 17 +--
libide/clang/ide-clang-completion-provider.c | 4 -
libide/clang/ide-clang-completion-provider.h | 14 +--
libide/html/ide-html-completion-provider.c | 16 ++-
libide/html/ide-html-completion-provider.h | 29 +---
libide/ide-source-map.c | 5 -
libide/ide-source-map.h | 13 +--
libide/ide-source-snippet-completion-item.c | 29 ++--
libide/ide-source-snippet-completion-item.h | 31 +---
libide/ide-source-snippet-completion-provider.c | 73 ++++-----
libide/ide-source-snippet-completion-provider.h | 31 +---
libide/ide-source-snippet-parser.c | 191 +++++++++++------------
libide/ide-source-snippet-parser.h | 39 +----
libide/ide-source-snippets.c | 46 ++----
libide/ide-source-snippets.h | 27 +---
libide/ide-source-view-mode.c | 75 ++++-----
libide/ide-source-view-mode.h | 27 +---
libide/theatrics/ide-animation.c | 171 ++++++++------------
libide/theatrics/ide-animation.h | 30 +---
libide/theatrics/ide-box-theatric.c | 95 ++++++------
libide/theatrics/ide-box-theatric.h | 28 +---
22 files changed, 355 insertions(+), 640 deletions(-)
---
diff --git a/libide/clang/ide-clang-completion-item.c b/libide/clang/ide-clang-completion-item.c
index e2c37a9..56dc19e 100644
--- a/libide/clang/ide-clang-completion-item.c
+++ b/libide/clang/ide-clang-completion-item.c
@@ -27,10 +27,6 @@
#include "ide-source-snippet.h"
#include "ide-source-snippet-chunk.h"
-struct _IdeClangCompletionItemClass
-{
- GObjectClass parent_class;
-};
struct _IdeClangCompletionItem
{
diff --git a/libide/clang/ide-clang-completion-item.h b/libide/clang/ide-clang-completion-item.h
index d58e4ae..067f82a 100644
--- a/libide/clang/ide-clang-completion-item.h
+++ b/libide/clang/ide-clang-completion-item.h
@@ -25,18 +25,11 @@
G_BEGIN_DECLS
-#define IDE_TYPE_CLANG_COMPLETION_ITEM (ide_clang_completion_item_get_type())
-#define IDE_CLANG_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_CLANG_COMPLETION_ITEM, IdeClangCompletionItem))
-#define IDE_CLANG_COMPLETION_ITEM_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_CLANG_COMPLETION_ITEM, IdeClangCompletionItem const))
-#define IDE_CLANG_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_CLANG_COMPLETION_ITEM, IdeClangCompletionItemClass))
-#define IDE_IS_CLANG_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_CLANG_COMPLETION_ITEM))
-#define IDE_IS_CLANG_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_CLANG_COMPLETION_ITEM))
-#define IDE_CLANG_COMPLETION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_CLANG_COMPLETION_ITEM, IdeClangCompletionItemClass))
-
-typedef struct _IdeClangCompletionItem IdeClangCompletionItem;
-typedef struct _IdeClangCompletionItemClass IdeClangCompletionItemClass;
-
-GType ide_clang_completion_item_get_type (void);
+#define IDE_TYPE_CLANG_COMPLETION_ITEM (ide_clang_completion_item_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeClangCompletionItem, ide_clang_completion_item,
+ IDE, CLANG_COMPLETION_ITEM, GObject)
+
IdeSourceSnippet *ide_clang_completion_item_get_snippet (IdeClangCompletionItem *self);
const gchar *ide_clang_completion_item_get_typed_text (IdeClangCompletionItem *self);
guint ide_clang_completion_item_get_priority (IdeClangCompletionItem *self);
diff --git a/libide/clang/ide-clang-completion-provider.c b/libide/clang/ide-clang-completion-provider.c
index b417ddb..036b872 100644
--- a/libide/clang/ide-clang-completion-provider.c
+++ b/libide/clang/ide-clang-completion-provider.c
@@ -35,10 +35,6 @@
#define MAX_COMPLETION_ITEMS 200
-struct _IdeClangCompletionProviderClass
-{
- GObjectClass parent_class;
-};
struct _IdeClangCompletionProvider
{
diff --git a/libide/clang/ide-clang-completion-provider.h b/libide/clang/ide-clang-completion-provider.h
index ff9c9df..c0c2331 100644
--- a/libide/clang/ide-clang-completion-provider.h
+++ b/libide/clang/ide-clang-completion-provider.h
@@ -23,18 +23,10 @@
G_BEGIN_DECLS
-#define IDE_TYPE_CLANG_COMPLETION_PROVIDER (ide_clang_completion_provider_get_type())
-#define IDE_CLANG_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_CLANG_COMPLETION_PROVIDER, IdeClangCompletionProvider))
-#define IDE_CLANG_COMPLETION_PROVIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_CLANG_COMPLETION_PROVIDER, IdeClangCompletionProvider const))
-#define IDE_CLANG_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_CLANG_COMPLETION_PROVIDER, IdeClangCompletionProviderClass))
-#define IDE_IS_CLANG_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_CLANG_COMPLETION_PROVIDER))
-#define IDE_IS_CLANG_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_CLANG_COMPLETION_PROVIDER))
-#define IDE_CLANG_COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_CLANG_COMPLETION_PROVIDER, IdeClangCompletionProviderClass))
+#define IDE_TYPE_CLANG_COMPLETION_PROVIDER (ide_clang_completion_provider_get_type())
-typedef struct _IdeClangCompletionProvider IdeClangCompletionProvider;
-typedef struct _IdeClangCompletionProviderClass IdeClangCompletionProviderClass;
-
-GType ide_clang_completion_provider_get_type (void);
+G_DECLARE_FINAL_TYPE (IdeClangCompletionProvider, ide_clang_completion_provider,
+ IDE, CLANG_COMPLETION_PROVIDER, GObject)
G_END_DECLS
diff --git a/libide/html/ide-html-completion-provider.c b/libide/html/ide-html-completion-provider.c
index 294ea26..c93ad6d 100644
--- a/libide/html/ide-html-completion-provider.c
+++ b/libide/html/ide-html-completion-provider.c
@@ -40,14 +40,18 @@ typedef struct
gint mode;
} SearchState;
+struct _IdeHtmlCompletionProvider
+{
+ GObject parent_instance;
+};
+
static void completion_provider_init (GtkSourceCompletionProviderIface *);
-G_DEFINE_TYPE_EXTENDED (IdeHtmlCompletionProvider,
- ide_html_completion_provider,
- G_TYPE_OBJECT,
- 0,
- G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
- completion_provider_init))
+G_DEFINE_TYPE_WITH_CODE (IdeHtmlCompletionProvider,
+ ide_html_completion_provider,
+ G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
+ completion_provider_init))
static gchar *
get_word (GtkSourceCompletionContext *context)
diff --git a/libide/html/ide-html-completion-provider.h b/libide/html/ide-html-completion-provider.h
index cee3030..8c95ca5 100644
--- a/libide/html/ide-html-completion-provider.h
+++ b/libide/html/ide-html-completion-provider.h
@@ -23,33 +23,10 @@
G_BEGIN_DECLS
-#define IDE_TYPE_HTML_COMPLETION_PROVIDER (ide_html_completion_provider_get_type())
-#define IDE_HTML_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProvider))
-#define IDE_HTML_COMPLETION_PROVIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProvider const))
-#define IDE_HTML_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProviderClass))
-#define IDE_IS_HTML_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER))
-#define IDE_IS_HTML_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_HTML_COMPLETION_PROVIDER))
-#define IDE_HTML_COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_HTML_COMPLETION_PROVIDER, IdeHtmlCompletionProviderClass))
-
-typedef struct _IdeHtmlCompletionProvider IdeHtmlCompletionProvider;
-typedef struct _IdeHtmlCompletionProviderClass IdeHtmlCompletionProviderClass;
-typedef struct _IdeHtmlCompletionProviderPrivate IdeHtmlCompletionProviderPrivate;
-
-struct _IdeHtmlCompletionProvider
-{
- GObject parent;
-
- /*< private >*/
- IdeHtmlCompletionProviderPrivate *priv;
-};
-
-struct _IdeHtmlCompletionProviderClass
-{
- GObjectClass parent;
-};
-
-GType ide_html_completion_provider_get_type (void);
+#define IDE_TYPE_HTML_COMPLETION_PROVIDER (ide_html_completion_provider_get_type())
+G_DECLARE_FINAL_TYPE (IdeHtmlCompletionProvider, ide_html_completion_provider,
+ IDE, HTML_COMPLETION_PROVIDER, GObject)
G_END_DECLS
#endif /* IDE_HTML_COMPLETION_PROVIDER_H */
diff --git a/libide/ide-source-map.c b/libide/ide-source-map.c
index e5e44e6..6885a25 100644
--- a/libide/ide-source-map.c
+++ b/libide/ide-source-map.c
@@ -50,11 +50,6 @@ struct _IdeSourceMap
guint show_map : 1;
};
-struct _IdeSourceMapClass
-{
- GtkOverlayClass parent_class;
-};
-
G_DEFINE_TYPE (IdeSourceMap, ide_source_map, GTK_TYPE_OVERLAY)
enum {
diff --git a/libide/ide-source-map.h b/libide/ide-source-map.h
index 6454452..4699f7d 100644
--- a/libide/ide-source-map.h
+++ b/libide/ide-source-map.h
@@ -24,19 +24,10 @@
G_BEGIN_DECLS
#define IDE_TYPE_SOURCE_MAP (ide_source_map_get_type())
-#define IDE_SOURCE_MAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_MAP,
IdeSourceMap))
-#define IDE_SOURCE_MAP_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_MAP, IdeSourceMap
const))
-#define IDE_SOURCE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_SOURCE_MAP,
IdeSourceMapClass))
-#define IDE_IS_SOURCE_MAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_SOURCE_MAP))
-#define IDE_IS_SOURCE_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_SOURCE_MAP))
-#define IDE_SOURCE_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_SOURCE_MAP,
IdeSourceMapClass))
-typedef struct _IdeSourceMap IdeSourceMap;
-typedef struct _IdeSourceMapClass IdeSourceMapClass;
+G_DECLARE_FINAL_TYPE (IdeSourceMap, ide_source_map,
+ IDE, SOURCE_MAP, GtkOverlay)
-G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeSourceMap, g_object_unref)
-
-GType ide_source_map_get_type (void);
GtkSourceView *ide_source_map_get_view (IdeSourceMap *self);
void ide_source_map_set_view (IdeSourceMap *self,
GtkSourceView *view);
diff --git a/libide/ide-source-snippet-completion-item.c b/libide/ide-source-snippet-completion-item.c
index 072f65a..80eb53a 100644
--- a/libide/ide-source-snippet-completion-item.c
+++ b/libide/ide-source-snippet-completion-item.c
@@ -21,8 +21,10 @@
#include "ide-source-snippet-completion-item.h"
-struct _IdeSourceSnippetCompletionItemPrivate
+struct _IdeSourceSnippetCompletionItem
{
+ GObject parent_instance;
+
IdeSourceSnippet *snippet;
};
@@ -36,13 +38,11 @@ static GParamSpec *gParamSpecs [LAST_PROP];
static void init_proposal_iface (GtkSourceCompletionProposalIface *iface);
-G_DEFINE_TYPE_EXTENDED (IdeSourceSnippetCompletionItem,
+G_DEFINE_TYPE_WITH_CODE (IdeSourceSnippetCompletionItem,
ide_source_snippet_completion_item,
G_TYPE_OBJECT,
- 0,
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROPOSAL,
- init_proposal_iface)
- G_ADD_PRIVATE (IdeSourceSnippetCompletionItem))
+ init_proposal_iface))
GtkSourceCompletionProposal *
ide_source_snippet_completion_item_new (IdeSourceSnippet *snippet)
@@ -58,7 +58,7 @@ IdeSourceSnippet *
ide_source_snippet_completion_item_get_snippet (IdeSourceSnippetCompletionItem *item)
{
g_return_val_if_fail (IDE_IS_SOURCE_SNIPPET_COMPLETION_ITEM (item), NULL);
- return item->priv->snippet;
+ return item->snippet;
}
void
@@ -66,18 +66,16 @@ ide_source_snippet_completion_item_set_snippet (IdeSourceSnippetCompletionItem *
IdeSourceSnippet *snippet)
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET_COMPLETION_ITEM (item));
- g_clear_object (&item->priv->snippet);
- item->priv->snippet = g_object_ref (snippet);
+ g_clear_object (&item->snippet);
+ item->snippet = g_object_ref (snippet);
}
static void
ide_source_snippet_completion_item_finalize (GObject *object)
{
- IdeSourceSnippetCompletionItemPrivate *priv;
-
- priv = IDE_SOURCE_SNIPPET_COMPLETION_ITEM (object)->priv;
+ IdeSourceSnippetCompletionItem *self = IDE_SOURCE_SNIPPET_COMPLETION_ITEM (object);
- g_clear_object (&priv->snippet);
+ g_clear_object (&self->snippet);
G_OBJECT_CLASS (ide_source_snippet_completion_item_parent_class)->finalize (object);
}
@@ -142,7 +140,6 @@ ide_source_snippet_completion_item_class_init (IdeSourceSnippetCompletionItemCla
static void
ide_source_snippet_completion_item_init (IdeSourceSnippetCompletionItem *item)
{
- item->priv = ide_source_snippet_completion_item_get_instance_private (item);
}
static gchar *
@@ -152,10 +149,10 @@ get_label (GtkSourceCompletionProposal *p)
const gchar *trigger = NULL;
const gchar *description = NULL;
- if (item->priv->snippet)
+ if (item->snippet)
{
- trigger = ide_source_snippet_get_trigger (item->priv->snippet);
- description = ide_source_snippet_get_description (item->priv->snippet);
+ trigger = ide_source_snippet_get_trigger (item->snippet);
+ description = ide_source_snippet_get_description (item->snippet);
}
if (description)
diff --git a/libide/ide-source-snippet-completion-item.h b/libide/ide-source-snippet-completion-item.h
index b71be81..d678c46 100644
--- a/libide/ide-source-snippet-completion-item.h
+++ b/libide/ide-source-snippet-completion-item.h
@@ -25,32 +25,11 @@
G_BEGIN_DECLS
-#define IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM (ide_source_snippet_completion_item_get_type())
-#define IDE_SOURCE_SNIPPET_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM, IdeSourceSnippetCompletionItem))
-#define IDE_SOURCE_SNIPPET_COMPLETION_ITEM_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM, IdeSourceSnippetCompletionItem const))
-#define IDE_SOURCE_SNIPPET_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM, IdeSourceSnippetCompletionItemClass))
-#define IDE_IS_SOURCE_SNIPPET_COMPLETION_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM))
-#define IDE_IS_SOURCE_SNIPPET_COMPLETION_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM))
-#define IDE_SOURCE_SNIPPET_COMPLETION_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM, IdeSourceSnippetCompletionItemClass))
-
-typedef struct _IdeSourceSnippetCompletionItem IdeSourceSnippetCompletionItem;
-typedef struct _IdeSourceSnippetCompletionItemClass IdeSourceSnippetCompletionItemClass;
-typedef struct _IdeSourceSnippetCompletionItemPrivate IdeSourceSnippetCompletionItemPrivate;
-
-struct _IdeSourceSnippetCompletionItem
-{
- GObject parent;
-
- /*< private >*/
- IdeSourceSnippetCompletionItemPrivate *priv;
-};
-
-struct _IdeSourceSnippetCompletionItemClass
-{
- GObjectClass parent_class;
-};
-
-GType ide_source_snippet_completion_item_get_type (void);
+#define IDE_TYPE_SOURCE_SNIPPET_COMPLETION_ITEM (ide_source_snippet_completion_item_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeSourceSnippetCompletionItem, ide_source_snippet_completion_item,
+ IDE, SOURCE_SNIPPET_COMPLETION_ITEM, GObject)
+
GtkSourceCompletionProposal *ide_source_snippet_completion_item_new (IdeSourceSnippet *snippet);
IdeSourceSnippet *ide_source_snippet_completion_item_get_snippet (IdeSourceSnippetCompletionItem
*item);
void ide_source_snippet_completion_item_set_snippet (IdeSourceSnippetCompletionItem
*item,
diff --git a/libide/ide-source-snippet-completion-provider.c b/libide/ide-source-snippet-completion-provider.c
index 265e575..719e608 100644
--- a/libide/ide-source-snippet-completion-provider.c
+++ b/libide/ide-source-snippet-completion-provider.c
@@ -22,21 +22,23 @@
#include "ide-source-snippet-completion-item.h"
#include "ide-source-snippet-completion-provider.h"
+struct _IdeSourceSnippetCompletionProvider
+{
+ GObject parent_instance;
+
+ IdeSourceView *source_view;
+ IdeSourceSnippets *snippets;
+};
+
+
static void init_provider (GtkSourceCompletionProviderIface *iface);
-G_DEFINE_TYPE_EXTENDED (IdeSourceSnippetCompletionProvider,
+G_DEFINE_TYPE_WITH_CODE (IdeSourceSnippetCompletionProvider,
ide_source_snippet_completion_provider,
G_TYPE_OBJECT,
- 0,
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROVIDER,
init_provider))
-struct _IdeSourceSnippetCompletionProviderPrivate
-{
- IdeSourceView *source_view;
- IdeSourceSnippets *snippets;
-};
-
typedef struct
{
GtkSourceCompletionProvider *provider;
@@ -68,7 +70,7 @@ ide_source_snippet_completion_provider_get_snippets (IdeSourceSnippetCompletionP
{
g_return_val_if_fail (IDE_IS_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider), NULL);
- return provider->priv->snippets;
+ return provider->snippets;
}
void
@@ -77,23 +79,21 @@ ide_source_snippet_completion_provider_set_snippets (IdeSourceSnippetCompletionP
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider));
- g_clear_object (&provider->priv->snippets);
- provider->priv->snippets = snippets ? g_object_ref (snippets) : NULL;
+ g_clear_object (&provider->snippets);
+ provider->snippets = snippets ? g_object_ref (snippets) : NULL;
g_object_notify_by_pspec (G_OBJECT (provider), gParamSpecs[PROP_SNIPPETS]);
}
static void
ide_source_snippet_completion_provider_finalize (GObject *object)
{
- IdeSourceSnippetCompletionProviderPrivate *priv;
+ IdeSourceSnippetCompletionProvider *self = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (object);
- priv = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (object)->priv;
+ g_clear_object (&self->snippets);
- g_clear_object (&priv->snippets);
-
- if (priv->source_view)
- g_object_remove_weak_pointer (G_OBJECT (priv->source_view),
- (gpointer *) &priv->source_view);
+ if (self->source_view)
+ g_object_remove_weak_pointer (G_OBJECT (self->source_view),
+ (gpointer *) &self->source_view);
G_OBJECT_CLASS (ide_source_snippet_completion_provider_parent_class)->finalize (object);
}
@@ -109,7 +109,7 @@ ide_source_snippet_completion_provider_get_property (GObject *object,
switch (prop_id)
{
case PROP_SOURCE_VIEW:
- g_value_set_object (value, provider->priv->source_view);
+ g_value_set_object (value, provider->source_view);
break;
case PROP_SNIPPETS:
@@ -132,15 +132,15 @@ ide_source_snippet_completion_provider_set_property (GObject *object,
switch (prop_id)
{
case PROP_SOURCE_VIEW:
- if (provider->priv->source_view)
+ if (provider->source_view)
{
- g_object_remove_weak_pointer (G_OBJECT (provider->priv->source_view),
- (gpointer *) &provider->priv->source_view);
- provider->priv->source_view = NULL;
+ g_object_remove_weak_pointer (G_OBJECT (provider->source_view),
+ (gpointer *) &provider->source_view);
+ provider->source_view = NULL;
}
- if ((provider->priv->source_view = g_value_get_object (value)))
- g_object_add_weak_pointer (G_OBJECT (provider->priv->source_view),
- (gpointer *) &provider->priv->source_view);
+ if ((provider->source_view = g_value_get_object (value)))
+ g_object_add_weak_pointer (G_OBJECT (provider->source_view),
+ (gpointer *) &provider->source_view);
break;
case PROP_SNIPPETS:
@@ -161,7 +161,6 @@ ide_source_snippet_completion_provider_class_init (IdeSourceSnippetCompletionPro
object_class->finalize = ide_source_snippet_completion_provider_finalize;
object_class->get_property = ide_source_snippet_completion_provider_get_property;
object_class->set_property = ide_source_snippet_completion_provider_set_property;
- g_type_class_add_private (object_class, sizeof (IdeSourceSnippetCompletionProviderPrivate));
gParamSpecs[PROP_SOURCE_VIEW] =
g_param_spec_object ("source-view",
@@ -183,10 +182,6 @@ ide_source_snippet_completion_provider_class_init (IdeSourceSnippetCompletionPro
static void
ide_source_snippet_completion_provider_init (IdeSourceSnippetCompletionProvider *provider)
{
- provider->priv =
- G_TYPE_INSTANCE_GET_PRIVATE (provider,
- IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER,
- IdeSourceSnippetCompletionProviderPrivate);
}
static gboolean
@@ -281,13 +276,11 @@ static void
provider_populate (GtkSourceCompletionProvider *provider,
GtkSourceCompletionContext *context)
{
- IdeSourceSnippetCompletionProviderPrivate *priv;
SearchState state = { 0 };
GtkTextIter iter;
+ IdeSourceSnippetCompletionProvider *self = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider);
- priv = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider)->priv;
-
- if (!priv->snippets)
+ if (!self->snippets)
{
gtk_source_completion_context_add_proposals (context, provider, NULL, TRUE);
return;
@@ -300,7 +293,7 @@ provider_populate (GtkSourceCompletionProvider *provider,
state.word = get_word (provider, &iter);
if (state.word && *state.word)
- ide_source_snippets_foreach (priv->snippets, state.word, foreach_snippet,
+ ide_source_snippets_foreach (self->snippets, state.word, foreach_snippet,
&state);
/*
@@ -319,16 +312,14 @@ provider_activate_proposal (GtkSourceCompletionProvider *provider,
GtkSourceCompletionProposal *proposal,
GtkTextIter *iter)
{
- IdeSourceSnippetCompletionProviderPrivate *priv;
IdeSourceSnippetCompletionItem *item;
IdeSourceSnippet *snippet;
GtkTextBuffer *buffer;
GtkTextIter end;
gchar *word;
+ IdeSourceSnippetCompletionProvider *self = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider);
- priv = IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER (provider)->priv;
-
- if (priv->source_view)
+ if (self->source_view)
{
item = IDE_SOURCE_SNIPPET_COMPLETION_ITEM (proposal);
snippet = ide_source_snippet_completion_item_get_snippet (item);
@@ -352,7 +343,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 (priv->source_view),
+ ide_source_view_push_snippet (IDE_SOURCE_VIEW (self->source_view),
snippet);
g_object_unref (snippet);
diff --git a/libide/ide-source-snippet-completion-provider.h b/libide/ide-source-snippet-completion-provider.h
index 73d5476..df696f8 100644
--- a/libide/ide-source-snippet-completion-provider.h
+++ b/libide/ide-source-snippet-completion-provider.h
@@ -26,32 +26,11 @@
G_BEGIN_DECLS
-#define IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER
(ide_source_snippet_completion_provider_get_type())
-#define IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER, IdeSourceSnippetCompletionProvider))
-#define IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER, IdeSourceSnippetCompletionProvider const))
-#define IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER, IdeSourceSnippetCompletionProviderClass))
-#define IDE_IS_SOURCE_SNIPPET_COMPLETION_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER))
-#define IDE_IS_SOURCE_SNIPPET_COMPLETION_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER))
-#define IDE_SOURCE_SNIPPET_COMPLETION_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER, IdeSourceSnippetCompletionProviderClass))
-
-typedef struct _IdeSourceSnippetCompletionProvider IdeSourceSnippetCompletionProvider;
-typedef struct _IdeSourceSnippetCompletionProviderClass IdeSourceSnippetCompletionProviderClass;
-typedef struct _IdeSourceSnippetCompletionProviderPrivate IdeSourceSnippetCompletionProviderPrivate;
-
-struct _IdeSourceSnippetCompletionProvider
-{
- GObject parent;
-
- /*< private >*/
- IdeSourceSnippetCompletionProviderPrivate *priv;
-};
-
-struct _IdeSourceSnippetCompletionProviderClass
-{
- GObjectClass parent_class;
-};
-
-GType ide_source_snippet_completion_provider_get_type (void);
+#define IDE_TYPE_SOURCE_SNIPPET_COMPLETION_PROVIDER (ide_source_snippet_completion_provider_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeSourceSnippetCompletionProvider, ide_source_snippet_completion_provider,
+ IDE, SOURCE_SNIPPET_COMPLETION_PROVIDER, GObject)
+
GtkSourceCompletionProvider *ide_source_snippet_completion_provider_new (IdeSourceView *source_view,
IdeSourceSnippets *snippets);
diff --git a/libide/ide-source-snippet-parser.c b/libide/ide-source-snippet-parser.c
index fde15b7..74e146f 100644
--- a/libide/ide-source-snippet-parser.c
+++ b/libide/ide-source-snippet-parser.c
@@ -25,10 +25,10 @@
#include "ide-source-snippet-parser.h"
#include "ide-source-snippet-private.h"
-G_DEFINE_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser, G_TYPE_OBJECT)
-
-struct _IdeSourceSnippetParserPrivate
+struct _IdeSourceSnippetParser
{
+ GObject parent_instance;
+
GList *snippets;
gint lineno;
@@ -39,6 +39,10 @@ struct _IdeSourceSnippetParserPrivate
GString *cur_text;
};
+
+G_DEFINE_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser, G_TYPE_OBJECT)
+
+
IdeSourceSnippetParser *
ide_source_snippet_parser_new (void)
{
@@ -48,37 +52,35 @@ ide_source_snippet_parser_new (void)
static void
ide_source_snippet_parser_flush_chunk (IdeSourceSnippetParser *parser)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
IdeSourceSnippetChunk *chunk;
- if (priv->cur_text->len)
+ if (parser->cur_text->len)
{
chunk = ide_source_snippet_chunk_new ();
- ide_source_snippet_chunk_set_spec (chunk, priv->cur_text->str);
- priv->chunks = g_list_append (priv->chunks, chunk);
- g_string_truncate (priv->cur_text, 0);
+ ide_source_snippet_chunk_set_spec (chunk, parser->cur_text->str);
+ parser->chunks = g_list_append (parser->chunks, chunk);
+ g_string_truncate (parser->cur_text, 0);
}
}
static void
ide_source_snippet_parser_store (IdeSourceSnippetParser *parser)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
IdeSourceSnippet *snippet;
GList *scope_iter;
GList *chunck_iter;
ide_source_snippet_parser_flush_chunk (parser);
- for (scope_iter = priv->scope; scope_iter; scope_iter = scope_iter->next)
+ for (scope_iter = parser->scope; scope_iter; scope_iter = scope_iter->next)
{
- snippet = ide_source_snippet_new (priv->cur_name, g_strdup(scope_iter->data));
- ide_source_snippet_set_description(snippet, priv->cur_desc);
+ snippet = ide_source_snippet_new (parser->cur_name, g_strdup(scope_iter->data));
+ ide_source_snippet_set_description(snippet, parser->cur_desc);
- for (chunck_iter = priv->chunks; chunck_iter; chunck_iter = chunck_iter->next)
+ for (chunck_iter = parser->chunks; chunck_iter; chunck_iter = chunck_iter->next)
{
#if 0
g_printerr ("%s: Tab: %02d Link: %02d Text: %s\n",
- parser->priv->cur_name,
+ parser->cur_name,
ide_source_snippet_chunk_get_tab_stop (chunck_iter->data),
ide_source_snippet_chunk_get_linked_chunk (chunck_iter->data),
ide_source_snippet_chunk_get_text (chunck_iter->data));
@@ -86,48 +88,45 @@ ide_source_snippet_parser_store (IdeSourceSnippetParser *parser)
ide_source_snippet_add_chunk (snippet, chunck_iter->data);
}
- priv->snippets = g_list_append (priv->snippets, snippet);
+ parser->snippets = g_list_append (parser->snippets, snippet);
}
}
static void
ide_source_snippet_parser_finish (IdeSourceSnippetParser *parser)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
-
- if (priv->cur_name)
+ if (parser->cur_name)
{
ide_source_snippet_parser_store(parser);
}
- g_clear_pointer (&priv->cur_name, g_free);
+ g_clear_pointer (&parser->cur_name, g_free);
- g_string_truncate (priv->cur_text, 0);
+ g_string_truncate (parser->cur_text, 0);
- g_list_foreach (priv->chunks, (GFunc) g_object_unref, NULL);
- g_list_free (priv->chunks);
- priv->chunks = NULL;
+ g_list_foreach (parser->chunks, (GFunc) g_object_unref, NULL);
+ g_list_free (parser->chunks);
+ parser->chunks = NULL;
- g_list_free_full(priv->scope, g_free);
- priv->scope = NULL;
+ g_list_free_full(parser->scope, g_free);
+ parser->scope = NULL;
- g_free(priv->cur_desc);
- priv->cur_desc = NULL;
+ g_free(parser->cur_desc);
+ parser->cur_desc = NULL;
}
static void
ide_source_snippet_parser_do_part_simple (IdeSourceSnippetParser *parser,
- const gchar *line)
+ const gchar *line)
{
- g_string_append (parser->priv->cur_text, line);
+ g_string_append (parser->cur_text, line);
}
static void
ide_source_snippet_parser_do_part_n (IdeSourceSnippetParser *parser,
- gint n,
- const gchar *inner)
+ gint n,
+ const gchar *inner)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
IdeSourceSnippetChunk *chunk;
g_return_if_fail (IDE_IS_SOURCE_SNIPPET_PARSER (parser));
@@ -137,14 +136,13 @@ ide_source_snippet_parser_do_part_n (IdeSourceSnippetParser *parser,
chunk = ide_source_snippet_chunk_new ();
ide_source_snippet_chunk_set_spec (chunk, n ? inner : "");
ide_source_snippet_chunk_set_tab_stop (chunk, n);
- priv->chunks = g_list_append (priv->chunks, chunk);
+ parser->chunks = g_list_append (parser->chunks, chunk);
}
static void
ide_source_snippet_parser_do_part_linked (IdeSourceSnippetParser *parser,
- gint n)
+ gint n)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
IdeSourceSnippetChunk *chunk;
gchar text[12];
@@ -160,14 +158,13 @@ ide_source_snippet_parser_do_part_linked (IdeSourceSnippetParser *parser,
ide_source_snippet_chunk_set_spec (chunk, "");
ide_source_snippet_chunk_set_tab_stop (chunk, 0);
}
- priv->chunks = g_list_append (priv->chunks, chunk);
+ parser->chunks = g_list_append (parser->chunks, chunk);
}
static void
ide_source_snippet_parser_do_part_named (IdeSourceSnippetParser *parser,
- const gchar *name)
+ const gchar *name)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
IdeSourceSnippetChunk *chunk;
gchar *spec;
@@ -175,7 +172,7 @@ ide_source_snippet_parser_do_part_named (IdeSourceSnippetParser *parser,
spec = g_strdup_printf ("$%s", name);
ide_source_snippet_chunk_set_spec (chunk, spec);
ide_source_snippet_chunk_set_tab_stop (chunk, -1);
- priv->chunks = g_list_append (priv->chunks, chunk);
+ parser->chunks = g_list_append (parser->chunks, chunk);
g_free (spec);
}
@@ -281,7 +278,7 @@ parse_variable (const gchar *line,
static void
ide_source_snippet_parser_do_part (IdeSourceSnippetParser *parser,
- const gchar *line)
+ const gchar *line)
{
const gchar *dollar;
gchar *str;
@@ -364,16 +361,15 @@ parse_dollar:
static void
ide_source_snippet_parser_do_snippet (IdeSourceSnippetParser *parser,
- const gchar *line)
+ const gchar *line)
{
- parser->priv->cur_name = g_strstrip (g_strdup (&line[8]));
+ parser->cur_name = g_strstrip (g_strdup (&line[8]));
}
static void
ide_source_snippet_parser_do_snippet_scope (IdeSourceSnippetParser *parser,
- const gchar *line)
+ const gchar *line)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
gchar **scope_list;
GList *iter;
gint i;
@@ -384,7 +380,7 @@ ide_source_snippet_parser_do_snippet_scope (IdeSourceSnippetParser *parser,
for (i = 0; scope_list[i]; i++)
{
add_scope = TRUE;
- for (iter = priv->scope; iter; iter = iter->next)
+ for (iter = parser->scope; iter; iter = iter->next)
{
if (g_strcmp0(iter->data, scope_list[i]) == 0)
add_scope = FALSE;
@@ -392,7 +388,7 @@ ide_source_snippet_parser_do_snippet_scope (IdeSourceSnippetParser *parser,
}
if (add_scope)
- priv->scope = g_list_append(priv->scope,
+ parser->scope = g_list_append(parser->scope,
g_strstrip (g_strdup (scope_list[i])));
}
@@ -401,48 +397,44 @@ ide_source_snippet_parser_do_snippet_scope (IdeSourceSnippetParser *parser,
static void
ide_source_snippet_parser_do_snippet_description (IdeSourceSnippetParser *parser,
- const gchar *line)
+ const gchar *line)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
-
- if (priv->cur_desc)
+ if (parser->cur_desc)
{
- g_free(priv->cur_desc);
- priv->cur_desc = NULL;
+ g_free(parser->cur_desc);
+ parser->cur_desc = NULL;
}
- priv->cur_desc = g_strstrip (g_strdup (&line[7]));
+ parser->cur_desc = g_strstrip (g_strdup (&line[7]));
}
static void
ide_source_snippet_parser_feed_line (IdeSourceSnippetParser *parser,
- gchar *basename,
- const gchar *line)
+ gchar *basename,
+ const gchar *line)
{
- IdeSourceSnippetParserPrivate *priv = parser->priv;
-
g_assert (parser);
g_assert (basename);
g_assert (line);
- priv->lineno++;
+ parser->lineno++;
switch (*line)
{
case '\0':
- if (priv->cur_name)
- g_string_append_c (priv->cur_text, '\n');
+ if (parser->cur_name)
+ g_string_append_c (parser->cur_text, '\n');
break;
case '#':
break;
case '\t':
- if (priv->cur_name)
+ if (parser->cur_name)
{
GList *iter;
gboolean add_default_scope = TRUE;
- for (iter = priv->scope; iter; iter = iter->next)
+ for (iter = parser->scope; iter; iter = iter->next)
{
if (g_strcmp0(iter->data, basename) == 0)
{
@@ -452,11 +444,11 @@ ide_source_snippet_parser_feed_line (IdeSourceSnippetParser *parser,
}
if (add_default_scope)
- priv->scope = g_list_append(priv->scope,
+ parser->scope = g_list_append(parser->scope,
g_strstrip (g_strdup (basename)));
- if (priv->cur_text->len || priv->chunks)
- g_string_append_c (priv->cur_text, '\n');
+ if (parser->cur_text->len || parser->chunks)
+ g_string_append_c (parser->cur_text, '\n');
ide_source_snippet_parser_do_part (parser, line);
}
break;
@@ -470,18 +462,18 @@ ide_source_snippet_parser_feed_line (IdeSourceSnippetParser *parser,
}
case '-':
- if (priv->cur_text->len || priv->chunks)
+ if (parser->cur_text->len || parser->chunks)
{
ide_source_snippet_parser_store(parser);
- g_string_truncate (priv->cur_text, 0);
+ g_string_truncate (parser->cur_text, 0);
- g_list_foreach (priv->chunks, (GFunc) g_object_unref, NULL);
- g_list_free (priv->chunks);
- priv->chunks = NULL;
+ g_list_foreach (parser->chunks, (GFunc) g_object_unref, NULL);
+ g_list_free (parser->chunks);
+ parser->chunks = NULL;
- g_list_free_full(priv->scope, g_free);
- priv->scope = NULL;
+ g_list_free_full(parser->scope, g_free);
+ parser->scope = NULL;
}
if (g_str_has_prefix(line, "- scope"))
@@ -498,15 +490,15 @@ ide_source_snippet_parser_feed_line (IdeSourceSnippetParser *parser,
/* Fall through */
default:
- g_warning (_("Invalid snippet at line %d: %s"), priv->lineno, line);
+ g_warning (_("Invalid snippet at line %d: %s"), parser->lineno, line);
break;
}
}
gboolean
ide_source_snippet_parser_load_from_file (IdeSourceSnippetParser *parser,
- GFile *file,
- GError **error)
+ GFile *file,
+ GError **error)
{
GFileInputStream *file_stream;
GDataInputStream *data_stream;
@@ -556,37 +548,35 @@ GList *
ide_source_snippet_parser_get_snippets (IdeSourceSnippetParser *parser)
{
g_return_val_if_fail (IDE_IS_SOURCE_SNIPPET_PARSER (parser), NULL);
- return parser->priv->snippets;
+ return parser->snippets;
}
static void
ide_source_snippet_parser_finalize (GObject *object)
{
- IdeSourceSnippetParserPrivate *priv;
-
- priv = IDE_SOURCE_SNIPPET_PARSER (object)->priv;
+ IdeSourceSnippetParser *self = IDE_SOURCE_SNIPPET_PARSER (object);
- g_list_foreach (priv->snippets, (GFunc) g_object_unref, NULL);
- g_list_free (priv->snippets);
- priv->snippets = NULL;
+ g_list_foreach (self->snippets, (GFunc) g_object_unref, NULL);
+ g_list_free (self->snippets);
+ self->snippets = NULL;
- g_list_foreach (priv->chunks, (GFunc) g_object_unref, NULL);
- g_list_free (priv->chunks);
- priv->chunks = NULL;
+ g_list_foreach (self->chunks, (GFunc) g_object_unref, NULL);
+ g_list_free (self->chunks);
+ self->chunks = NULL;
- g_list_free_full(priv->scope, g_free);
- priv->scope = NULL;
+ g_list_free_full(self->scope, g_free);
+ self->scope = NULL;
- if (priv->cur_text)
- g_string_free (priv->cur_text, TRUE);
+ if (self->cur_text)
+ g_string_free (self->cur_text, TRUE);
- g_free (priv->cur_name);
- priv->cur_name = NULL;
+ g_free (self->cur_name);
+ self->cur_name = NULL;
- if (priv->cur_desc)
+ if (self->cur_desc)
{
- g_free (priv->cur_desc);
- priv->cur_desc = NULL;
+ g_free (self->cur_desc);
+ self->cur_desc = NULL;
}
G_OBJECT_CLASS (ide_source_snippet_parser_parent_class)->finalize (object);
@@ -599,18 +589,13 @@ ide_source_snippet_parser_class_init (IdeSourceSnippetParserClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ide_source_snippet_parser_finalize;
- g_type_class_add_private (object_class,
- sizeof (IdeSourceSnippetParserPrivate));
}
static void
ide_source_snippet_parser_init (IdeSourceSnippetParser *parser)
{
- parser->priv = G_TYPE_INSTANCE_GET_PRIVATE (parser,
- IDE_TYPE_SOURCE_SNIPPET_PARSER,
- IdeSourceSnippetParserPrivate);
- parser->priv->lineno = -1;
- parser->priv->cur_text = g_string_new (NULL);
- parser->priv->scope = NULL;
- parser->priv->cur_desc = NULL;
+ parser->lineno = -1;
+ parser->cur_text = g_string_new (NULL);
+ parser->scope = NULL;
+ parser->cur_desc = NULL;
}
diff --git a/libide/ide-source-snippet-parser.h b/libide/ide-source-snippet-parser.h
index 2e51287..4eb91e7 100644
--- a/libide/ide-source-snippet-parser.h
+++ b/libide/ide-source-snippet-parser.h
@@ -23,37 +23,16 @@
G_BEGIN_DECLS
-#define IDE_TYPE_SOURCE_SNIPPET_PARSER (ide_source_snippet_parser_get_type())
-#define IDE_SOURCE_SNIPPET_PARSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_PARSER, IdeSourceSnippetParser))
-#define IDE_SOURCE_SNIPPET_PARSER_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
IDE_TYPE_SOURCE_SNIPPET_PARSER, IdeSourceSnippetParser const))
-#define IDE_SOURCE_SNIPPET_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
IDE_TYPE_SOURCE_SNIPPET_PARSER, IdeSourceSnippetParserClass))
-#define IDE_IS_SOURCE_SNIPPET_PARSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
IDE_TYPE_SOURCE_SNIPPET_PARSER))
-#define IDE_IS_SOURCE_SNIPPET_PARSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
IDE_TYPE_SOURCE_SNIPPET_PARSER))
-#define IDE_SOURCE_SNIPPET_PARSER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
IDE_TYPE_SOURCE_SNIPPET_PARSER, IdeSourceSnippetParserClass))
-
-typedef struct _IdeSourceSnippetParser IdeSourceSnippetParser;
-typedef struct _IdeSourceSnippetParserClass IdeSourceSnippetParserClass;
-typedef struct _IdeSourceSnippetParserPrivate IdeSourceSnippetParserPrivate;
-
-struct _IdeSourceSnippetParser
-{
- GObject parent;
-
- /*< private >*/
- IdeSourceSnippetParserPrivate *priv;
-};
-
-struct _IdeSourceSnippetParserClass
-{
- GObjectClass parent_class;
-};
-
-GType ide_source_snippet_parser_get_type (void);
+#define IDE_TYPE_SOURCE_SNIPPET_PARSER (ide_source_snippet_parser_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeSourceSnippetParser, ide_source_snippet_parser,
+ IDE, SOURCE_SNIPPET_PARSER, GObject)
+
IdeSourceSnippetParser *ide_source_snippet_parser_new (void);
-gboolean ide_source_snippet_parser_load_from_file (IdeSourceSnippetParser *parser,
- GFile *file,
- GError **error);
-GList *ide_source_snippet_parser_get_snippets (IdeSourceSnippetParser *parser);
+gboolean ide_source_snippet_parser_load_from_file (IdeSourceSnippetParser *parser,
+ GFile *file,
+ GError **error);
+GList *ide_source_snippet_parser_get_snippets (IdeSourceSnippetParser *parser);
G_END_DECLS
diff --git a/libide/ide-source-snippets.c b/libide/ide-source-snippets.c
index 881b7f2..dd4ffc4 100644
--- a/libide/ide-source-snippets.c
+++ b/libide/ide-source-snippets.c
@@ -26,13 +26,17 @@
#include "trie.h"
-G_DEFINE_TYPE (IdeSourceSnippets, ide_source_snippets, G_TYPE_OBJECT)
-
-struct _IdeSourceSnippetsPrivate
+struct _IdeSourceSnippets
{
- Trie *snippets;
+ GObject parent_instance;
+
+ Trie *snippets;
};
+
+G_DEFINE_TYPE (IdeSourceSnippets, ide_source_snippets, G_TYPE_OBJECT)
+
+
IdeSourceSnippets *
ide_source_snippets_new (void)
{
@@ -43,14 +47,10 @@ ide_source_snippets_new (void)
void
ide_source_snippets_clear (IdeSourceSnippets *snippets)
{
- IdeSourceSnippetsPrivate *priv;
-
g_return_if_fail (IDE_IS_SOURCE_SNIPPETS (snippets));
- priv = snippets->priv;
-
- trie_destroy (priv->snippets);
- priv->snippets = trie_new (g_object_unref);
+ trie_destroy (snippets->snippets);
+ snippets->snippets = trie_new (g_object_unref);
}
static gboolean
@@ -72,18 +72,18 @@ copy_into (Trie *trie,
void
ide_source_snippets_merge (IdeSourceSnippets *snippets,
- IdeSourceSnippets *other)
+ IdeSourceSnippets *other)
{
g_return_if_fail (IDE_IS_SOURCE_SNIPPETS (snippets));
g_return_if_fail (IDE_IS_SOURCE_SNIPPETS (other));
- trie_traverse (other->priv->snippets,
+ trie_traverse (other->snippets,
"",
G_PRE_ORDER,
G_TRAVERSE_LEAVES,
-1,
copy_into,
- snippets->priv->snippets);
+ snippets->snippets);
}
void
@@ -96,7 +96,7 @@ ide_source_snippets_add (IdeSourceSnippets *snippets,
g_return_if_fail (IDE_IS_SOURCE_SNIPPET (snippet));
trigger = ide_source_snippet_get_trigger (snippet);
- trie_insert (snippets->priv->snippets, trigger, g_object_ref (snippet));
+ trie_insert (snippets->snippets, trigger, g_object_ref (snippet));
}
gboolean
@@ -123,18 +123,15 @@ ide_source_snippets_foreach (IdeSourceSnippets *snippets,
GFunc foreach_func,
gpointer user_data)
{
- IdeSourceSnippetsPrivate *priv;
gpointer closure[2] = { foreach_func, user_data };
g_return_if_fail (IDE_IS_SOURCE_SNIPPETS (snippets));
g_return_if_fail (foreach_func);
- priv = snippets->priv;
-
if (!prefix)
prefix = "";
- trie_traverse (priv->snippets,
+ trie_traverse (snippets->snippets,
prefix,
G_PRE_ORDER,
G_TRAVERSE_LEAVES,
@@ -146,11 +143,9 @@ ide_source_snippets_foreach (IdeSourceSnippets *snippets,
static void
ide_source_snippets_finalize (GObject *object)
{
- IdeSourceSnippetsPrivate *priv;
-
- priv = IDE_SOURCE_SNIPPETS (object)->priv;
+ IdeSourceSnippets *self = IDE_SOURCE_SNIPPETS (object);
- g_clear_pointer (&priv->snippets, (GDestroyNotify) trie_destroy);
+ g_clear_pointer (&self->snippets, (GDestroyNotify) trie_destroy);
G_OBJECT_CLASS (ide_source_snippets_parent_class)->finalize (object);
}
@@ -162,15 +157,10 @@ ide_source_snippets_class_init (IdeSourceSnippetsClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ide_source_snippets_finalize;
- g_type_class_add_private (object_class, sizeof (IdeSourceSnippetsPrivate));
}
static void
ide_source_snippets_init (IdeSourceSnippets *snippets)
{
- snippets->priv = G_TYPE_INSTANCE_GET_PRIVATE (snippets,
- IDE_TYPE_SOURCE_SNIPPETS,
- IdeSourceSnippetsPrivate);
-
- snippets->priv->snippets = trie_new (g_object_unref);
+ snippets->snippets = trie_new (g_object_unref);
}
diff --git a/libide/ide-source-snippets.h b/libide/ide-source-snippets.h
index 16f074d..008b4f7 100644
--- a/libide/ide-source-snippets.h
+++ b/libide/ide-source-snippets.h
@@ -25,30 +25,10 @@
G_BEGIN_DECLS
-#define IDE_TYPE_SOURCE_SNIPPETS (ide_source_snippets_get_type())
-#define IDE_SOURCE_SNIPPETS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_SNIPPETS,
IdeSourceSnippets))
-#define IDE_SOURCE_SNIPPETS_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_SNIPPETS,
IdeSourceSnippets const))
-#define IDE_SOURCE_SNIPPETS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_SOURCE_SNIPPETS,
IdeSourceSnippetsClass))
-#define IDE_IS_SOURCE_SNIPPETS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_SOURCE_SNIPPETS))
-#define IDE_IS_SOURCE_SNIPPETS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_SOURCE_SNIPPETS))
-#define IDE_SOURCE_SNIPPETS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_SOURCE_SNIPPETS,
IdeSourceSnippetsClass))
+#define IDE_TYPE_SOURCE_SNIPPETS (ide_source_snippets_get_type())
-typedef struct _IdeSourceSnippets IdeSourceSnippets;
-typedef struct _IdeSourceSnippetsClass IdeSourceSnippetsClass;
-typedef struct _IdeSourceSnippetsPrivate IdeSourceSnippetsPrivate;
-
-struct _IdeSourceSnippets
-{
- GObject parent;
-
- /*< private >*/
- IdeSourceSnippetsPrivate *priv;
-};
-
-struct _IdeSourceSnippetsClass
-{
- GObjectClass parent_class;
-};
+G_DECLARE_FINAL_TYPE (IdeSourceSnippets, ide_source_snippets,
+ IDE, SOURCE_SNIPPETS, GObject)
void ide_source_snippets_add (IdeSourceSnippets *snippets,
IdeSourceSnippet *snippet);
@@ -56,7 +36,6 @@ void ide_source_snippets_clear (IdeSourceSnippets *snippet
void ide_source_snippets_merge (IdeSourceSnippets *snippets,
IdeSourceSnippets *other);
IdeSourceSnippets *ide_source_snippets_new (void);
-GType ide_source_snippets_get_type (void);
void ide_source_snippets_foreach (IdeSourceSnippets *snippets,
const gchar *prefix,
GFunc foreach_func,
diff --git a/libide/ide-source-view-mode.c b/libide/ide-source-view-mode.c
index 5217619..2804f1d 100644
--- a/libide/ide-source-view-mode.c
+++ b/libide/ide-source-view-mode.c
@@ -25,16 +25,18 @@
#include "ide-source-view.h"
#include "ide-source-view-mode.h"
-typedef struct
+struct _IdeSourceViewMode
{
+ GtkWidget parent_instance;
+
GtkWidget *view;
char *name;
char *display_name;
gchar *default_mode;
IdeSourceViewModeType type;
-} IdeSourceViewModePrivate;
+};
-G_DEFINE_TYPE_WITH_PRIVATE (IdeSourceViewMode, ide_source_view_mode, GTK_TYPE_WIDGET)
+G_DEFINE_TYPE (IdeSourceViewMode, ide_source_view_mode, GTK_TYPE_WIDGET)
enum {
PROP_0,
@@ -92,21 +94,17 @@ get_string_param (IdeSourceViewMode *self,
const gchar *
ide_source_view_mode_get_default_mode (IdeSourceViewMode *self)
{
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (self);
-
/*
* instead of switching back to "default" mode, use this mode instead
* if no other mode is specified.
*/
- return priv->default_mode;
+ return self->default_mode;
}
const gchar *
ide_source_view_mode_get_display_name (IdeSourceViewMode *self)
{
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (self);
-
- return priv->display_name;
+ return self->display_name;
}
gboolean
@@ -149,14 +147,13 @@ ide_source_view_mode_get_keep_mark_on_char (IdeSourceViewMode *self)
static void
ide_source_view_mode_finalize (GObject *object)
{
- IdeSourceViewMode *self = (IdeSourceViewMode *)object;
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (self);
+ IdeSourceViewMode *self = IDE_SOURCE_VIEW_MODE (object);
- g_clear_object (&priv->view);
- g_clear_pointer (&priv->name, g_free);
- g_clear_pointer (&priv->default_mode, g_free);
- g_clear_pointer (&priv->display_name, g_free);
- priv->type = 0;
+ g_clear_object (&self->view);
+ g_clear_pointer (&self->name, g_free);
+ g_clear_pointer (&self->default_mode, g_free);
+ g_clear_pointer (&self->display_name, g_free);
+ self->type = 0;
G_OBJECT_CLASS (ide_source_view_mode_parent_class)->finalize (object);
}
@@ -169,16 +166,12 @@ proxy_closure_marshal (GClosure *closure,
gpointer invocation_hint,
gpointer marshal_data)
{
- IdeSourceViewMode *mode;
- IdeSourceViewModePrivate *priv;
GValue *param_copy;
-
- mode = IDE_SOURCE_VIEW_MODE (g_value_get_object (¶m_values[0]));
- priv = ide_source_view_mode_get_instance_private (mode);
+ IdeSourceViewMode *mode = IDE_SOURCE_VIEW_MODE (g_value_get_object (¶m_values[0]));
param_copy = g_memdup (param_values, sizeof (GValue) * n_param_values);
- param_copy[0].data[0].v_pointer = priv->view;
+ param_copy[0].data[0].v_pointer = mode->view;
g_signal_emitv (param_copy,
GPOINTER_TO_INT (closure->data),
0,
@@ -218,11 +211,9 @@ proxy_all_action_signals (GType type)
const gchar *
ide_source_view_mode_get_name (IdeSourceViewMode *mode)
{
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (mode);
-
g_return_val_if_fail (IDE_IS_SOURCE_VIEW_MODE (mode), NULL);
- return priv->name;
+ return mode->name;
}
static void
@@ -408,7 +399,6 @@ _ide_source_view_mode_do_event (IdeSourceViewMode *mode,
GdkEventKey *event,
gboolean *remove)
{
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (mode);
GtkStyleContext *context;
gboolean suppress_unbound;
gboolean handled;
@@ -423,13 +413,13 @@ _ide_source_view_mode_do_event (IdeSourceViewMode *mode,
g_object_ref (context);
gtk_style_context_save (context);
- gtk_style_context_add_class (context, priv->name);
+ gtk_style_context_add_class (context, mode->name);
handled = gtk_bindings_activate_event (G_OBJECT (mode), event);
gtk_style_context_restore (context);
g_object_unref (context);
*remove = FALSE;
- switch (priv->type)
+ switch (mode->type)
{
case IDE_SOURCE_VIEW_MODE_TYPE_TRANSIENT:
if (handled)
@@ -441,7 +431,7 @@ _ide_source_view_mode_do_event (IdeSourceViewMode *mode,
if (!is_modifier_key (event))
{
if (!toplevel_is_offscreen (event->window))
- gtk_widget_error_bell (priv->view);
+ gtk_widget_error_bell (mode->view);
handled = TRUE;
*remove = TRUE;
}
@@ -457,7 +447,7 @@ _ide_source_view_mode_do_event (IdeSourceViewMode *mode,
gdk_window_beep (event->window);
/* cancel any inflight macros */
- g_signal_emit_by_name (priv->view, "end-macro");
+ g_signal_emit_by_name (mode->view, "end-macro");
handled = TRUE;
}
@@ -480,32 +470,30 @@ _ide_source_view_mode_new (GtkWidget *view,
const char *name,
IdeSourceViewModeType type)
{
- IdeSourceViewModePrivate *priv;
IdeSourceViewMode *mode;
mode = g_object_new (IDE_TYPE_SOURCE_VIEW_MODE, NULL);
- priv = ide_source_view_mode_get_instance_private (mode);
- priv->view = g_object_ref (view);
- priv->name = g_strdup (name);
- priv->type = type;
+ mode->view = g_object_ref (view);
+ mode->name = g_strdup (name);
+ mode->type = type;
- if (priv->name != NULL)
+ if (mode->name != NULL)
{
GtkStyleContext *context;
context = gtk_widget_get_style_context (GTK_WIDGET (mode));
- gtk_style_context_add_class (context, priv->name);
+ gtk_style_context_add_class (context, mode->name);
}
- priv->default_mode = get_string_param (mode, "default-mode");
- priv->display_name = get_string_param (mode, "display-name");
+ mode->default_mode = get_string_param (mode, "default-mode");
+ mode->display_name = get_string_param (mode, "display-name");
IDE_TRACE_MSG ("supress_unbound = %d", ide_source_view_mode_get_suppress_unbound (mode));
IDE_TRACE_MSG ("block_cursor = %d", ide_source_view_mode_get_block_cursor (mode));
- IDE_TRACE_MSG ("type = %d", (int)priv->type);
- IDE_TRACE_MSG ("default_mode = %s", priv->default_mode ?: "(null)");
- IDE_TRACE_MSG ("display_name = %s", priv->display_name ?: "(null)");
+ IDE_TRACE_MSG ("type = %d", (int)mode->type);
+ IDE_TRACE_MSG ("default_mode = %s", mode->default_mode ?: "(null)");
+ IDE_TRACE_MSG ("display_name = %s", mode->display_name ?: "(null)");
return g_object_ref_sink (mode);
}
@@ -513,7 +501,6 @@ _ide_source_view_mode_new (GtkWidget *view,
IdeSourceViewModeType
ide_source_view_mode_get_mode_type (IdeSourceViewMode *self)
{
- IdeSourceViewModePrivate *priv = ide_source_view_mode_get_instance_private (self);
g_return_val_if_fail (IDE_IS_SOURCE_VIEW_MODE (self), 0);
- return priv->type;
+ return self->type;
}
diff --git a/libide/ide-source-view-mode.h b/libide/ide-source-view-mode.h
index b5f6b51..9e3ceeb 100644
--- a/libide/ide-source-view-mode.h
+++ b/libide/ide-source-view-mode.h
@@ -26,28 +26,11 @@
G_BEGIN_DECLS
-#define IDE_TYPE_SOURCE_VIEW_MODE (ide_source_view_mode_get_type())
-#define IDE_SOURCE_VIEW_MODE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_VIEW_MODE,
IdeSourceViewMode))
-#define IDE_SOURCE_VIEW_MODE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_SOURCE_VIEW_MODE,
IdeSourceViewMode const))
-#define IDE_SOURCE_VIEW_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_SOURCE_VIEW_MODE,
IdeSourceViewModeClass))
-#define IDE_IS_SOURCE_VIEW_MODE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_SOURCE_VIEW_MODE))
-#define IDE_IS_SOURCE_VIEW_MODE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_SOURCE_VIEW_MODE))
-#define IDE_SOURCE_VIEW_MODE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_SOURCE_VIEW_MODE,
IdeSourceViewModeClass))
-
-typedef struct _IdeSourceViewMode IdeSourceViewMode;
-typedef struct _IdeSourceViewModeClass IdeSourceViewModeClass;
-
-struct _IdeSourceViewMode
-{
- GtkWidget parent;
-};
-
-struct _IdeSourceViewModeClass
-{
- GtkWidgetClass parent_class;
-};
-
-GType ide_source_view_mode_get_type (void);
+#define IDE_TYPE_SOURCE_VIEW_MODE (ide_source_view_mode_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeSourceViewMode, ide_source_view_mode,
+ IDE, SOURCE_VIEW_MODE, GtkWidget)
+
gboolean ide_source_view_mode_get_repeat_insert_with_count (IdeSourceViewMode *self);
gboolean ide_source_view_mode_get_block_cursor (IdeSourceViewMode *self);
gboolean ide_source_view_mode_get_suppress_unbound (IdeSourceViewMode *self);
diff --git a/libide/theatrics/ide-animation.c b/libide/theatrics/ide-animation.c
index d0ae0cb..fd76bad 100644
--- a/libide/theatrics/ide-animation.c
+++ b/libide/theatrics/ide-animation.c
@@ -26,8 +26,6 @@
#define FALLBACK_FRAME_RATE 60
-G_DEFINE_TYPE (IdeAnimation, ide_animation, G_TYPE_INITIALLY_UNOWNED)
-
typedef gdouble (*AlphaFunc) (gdouble offset);
typedef void (*TweenFunc) (const GValue *begin,
const GValue *end,
@@ -43,17 +41,20 @@ typedef struct
} Tween;
-struct _IdeAnimationPrivate
+struct _IdeAnimation
{
- gpointer target; /* Target object to animate */
- guint64 begin_msec; /* Time in which animation started */
- guint duration_msec; /* Duration of animation */
- guint mode; /* Tween mode */
- guint tween_handler; /* GSource performing tweens */
- GArray *tweens; /* Array of tweens to perform */
- GdkFrameClock *frame_clock; /* An optional frame-clock for sync. */
+ GInitiallyUnowned parent_instance;
+
+ gpointer target; /* Target object to animate */
+ guint64 begin_msec; /* Time in which animation started */
+ guint duration_msec; /* Duration of animation */
+ guint mode; /* Tween mode */
+ guint tween_handler; /* GSource performing tweens */
+ GArray *tweens; /* Array of tweens to perform */
+ GdkFrameClock *frame_clock; /* An optional frame-clock for sync. */
};
+G_DEFINE_TYPE (IdeAnimation, ide_animation, G_TYPE_INITIALLY_UNOWNED)
enum {
PROP_0,
@@ -222,30 +223,27 @@ ide_animation_alpha_ease_in_out_quad (gdouble offset)
static void
ide_animation_load_begin_values (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
GtkContainer *container;
Tween *tween;
gint i;
g_return_if_fail (IDE_IS_ANIMATION (animation));
- priv = animation->priv;
-
- for (i = 0; i < priv->tweens->len; i++)
+ for (i = 0; i < animation->tweens->len; i++)
{
- tween = &g_array_index (priv->tweens, Tween, i);
+ tween = &g_array_index (animation->tweens, Tween, i);
g_value_reset (&tween->begin);
if (tween->is_child)
{
- container = GTK_CONTAINER (gtk_widget_get_parent (priv->target));
+ container = GTK_CONTAINER (gtk_widget_get_parent (animation->target));
gtk_container_child_get_property (container,
- priv->target,
+ animation->target,
tween->pspec->name,
&tween->begin);
}
else
{
- g_object_get_property (priv->target,
+ g_object_get_property (animation->target,
tween->pspec->name,
&tween->begin);
}
@@ -266,17 +264,14 @@ ide_animation_load_begin_values (IdeAnimation *animation)
static void
ide_animation_unload_begin_values (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
Tween *tween;
gint i;
g_return_if_fail (IDE_IS_ANIMATION (animation));
- priv = animation->priv;
-
- for (i = 0; i < priv->tweens->len; i++)
+ for (i = 0; i < animation->tweens->len; i++)
{
- tween = &g_array_index (priv->tweens, Tween, i);
+ tween = &g_array_index (animation->tweens, Tween, i);
g_value_reset (&tween->begin);
}
}
@@ -296,23 +291,20 @@ ide_animation_unload_begin_values (IdeAnimation *animation)
static gdouble
ide_animation_get_offset (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
GdkFrameClock *frame_clock;
gdouble offset;
gint64 frame_msec;
g_return_val_if_fail (IDE_IS_ANIMATION (animation), 0.0);
- priv = animation->priv;
-
- if (GTK_IS_WIDGET (priv->target) &&
- (frame_clock = gtk_widget_get_frame_clock (priv->target)))
+ if (GTK_IS_WIDGET (animation->target) &&
+ (frame_clock = gtk_widget_get_frame_clock (animation->target)))
frame_msec = gdk_frame_clock_get_frame_time (frame_clock) / 1000UL;
else
frame_msec = g_get_monotonic_time () / 1000UL;
- offset = (gdouble) (frame_msec - priv->begin_msec) /
- (gdouble) priv->duration_msec;
+ offset = (gdouble) (frame_msec - animation->begin_msec) /
+ (gdouble) animation->duration_msec;
return CLAMP (offset, 0.0, 1.0);
}
@@ -424,12 +416,10 @@ static void
ide_animation_set_frame_clock (IdeAnimation *animation,
GdkFrameClock *frame_clock)
{
- IdeAnimationPrivate *priv = animation->priv;
-
- if (priv->frame_clock != frame_clock)
+ if (animation->frame_clock != frame_clock)
{
- g_clear_object (&priv->frame_clock);
- priv->frame_clock = frame_clock ? g_object_ref (frame_clock) : NULL;
+ g_clear_object (&animation->frame_clock);
+ animation->frame_clock = frame_clock ? g_object_ref (frame_clock) : NULL;
}
}
@@ -437,15 +427,13 @@ static void
ide_animation_set_target (IdeAnimation *animation,
gpointer target)
{
- IdeAnimationPrivate *priv = animation->priv;
+ g_assert (!animation->target);
- g_assert (!priv->target);
+ animation->target = g_object_ref (target);
- priv->target = g_object_ref (target);
-
- if (GTK_IS_WIDGET (priv->target))
+ if (GTK_IS_WIDGET (animation->target))
ide_animation_set_frame_clock (animation,
- gtk_widget_get_frame_clock (priv->target));
+ gtk_widget_get_frame_clock (animation->target));
}
@@ -461,7 +449,6 @@ ide_animation_set_target (IdeAnimation *animation,
static gboolean
ide_animation_tick (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
gdouble offset;
gdouble alpha;
GValue value = { 0 };
@@ -470,30 +457,28 @@ ide_animation_tick (IdeAnimation *animation)
g_return_val_if_fail (IDE_IS_ANIMATION (animation), FALSE);
- priv = animation->priv;
-
offset = ide_animation_get_offset (animation);
- alpha = gAlphaFuncs[priv->mode](offset);
+ alpha = gAlphaFuncs[animation->mode](offset);
/*
* Update property values.
*/
- for (i = 0; i < priv->tweens->len; i++)
+ for (i = 0; i < animation->tweens->len; i++)
{
- tween = &g_array_index (priv->tweens, Tween, i);
+ tween = &g_array_index (animation->tweens, Tween, i);
g_value_init (&value, tween->pspec->value_type);
ide_animation_get_value_at_offset (animation, alpha, tween, &value);
if (!tween->is_child)
{
ide_animation_update_property (animation,
- priv->target,
+ animation->target,
tween,
&value);
}
else
{
ide_animation_update_child_property (animation,
- priv->target,
+ animation->target,
tween,
&value);
}
@@ -509,11 +494,11 @@ ide_animation_tick (IdeAnimation *animation)
* Flush any outstanding events to the graphics server (in the case of X).
*/
#if !GTK_CHECK_VERSION (3, 13, 0)
- if (GTK_IS_WIDGET (priv->target))
+ if (GTK_IS_WIDGET (animation->target))
{
GdkWindow *window;
- if ((window = gtk_widget_get_window (GTK_WIDGET (priv->target))))
+ if ((window = gtk_widget_get_window (GTK_WIDGET (animation->target))))
gdk_window_flush (window);
}
#endif
@@ -553,7 +538,7 @@ ide_animation_widget_tick_cb (GdkFrameClock *frame_clock,
g_assert (GDK_IS_FRAME_CLOCK (frame_clock));
g_assert (IDE_IS_ANIMATION (animation));
- if (animation->priv->tween_handler)
+ if (animation->tween_handler)
if (!(ret = ide_animation_tick (animation)))
ide_animation_stop (animation);
@@ -574,30 +559,26 @@ ide_animation_widget_tick_cb (GdkFrameClock *frame_clock,
void
ide_animation_start (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
-
g_return_if_fail (IDE_IS_ANIMATION (animation));
- g_return_if_fail (!animation->priv->tween_handler);
-
- priv = animation->priv;
+ g_return_if_fail (!animation->tween_handler);
g_object_ref_sink (animation);
ide_animation_load_begin_values (animation);
- if (priv->frame_clock)
+ if (animation->frame_clock)
{
- priv->begin_msec = gdk_frame_clock_get_frame_time (priv->frame_clock) / 1000UL;
- priv->tween_handler =
- g_signal_connect (priv->frame_clock,
+ animation->begin_msec = gdk_frame_clock_get_frame_time (animation->frame_clock) / 1000UL;
+ animation->tween_handler =
+ g_signal_connect (animation->frame_clock,
"update",
G_CALLBACK (ide_animation_widget_tick_cb),
animation);
- gdk_frame_clock_begin_updating (priv->frame_clock);
+ gdk_frame_clock_begin_updating (animation->frame_clock);
}
else
{
- priv->begin_msec = g_get_monotonic_time () / 1000UL;
- priv->tween_handler = ide_frame_source_add (FALLBACK_FRAME_RATE,
+ animation->begin_msec = g_get_monotonic_time () / 1000UL;
+ animation->tween_handler = ide_frame_source_add (FALLBACK_FRAME_RATE,
ide_animation_timeout_cb,
animation);
}
@@ -617,24 +598,20 @@ ide_animation_start (IdeAnimation *animation)
void
ide_animation_stop (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
-
g_return_if_fail (IDE_IS_ANIMATION (animation));
- priv = animation->priv;
-
- if (priv->tween_handler)
+ if (animation->tween_handler)
{
- if (priv->frame_clock)
+ if (animation->frame_clock)
{
- gdk_frame_clock_end_updating (priv->frame_clock);
- g_signal_handler_disconnect (priv->frame_clock, priv->tween_handler);
- priv->tween_handler = 0;
+ gdk_frame_clock_end_updating (animation->frame_clock);
+ g_signal_handler_disconnect (animation->frame_clock, animation->tween_handler);
+ animation->tween_handler = 0;
}
else
{
- g_source_remove (priv->tween_handler);
- priv->tween_handler = 0;
+ g_source_remove (animation->tween_handler);
+ animation->tween_handler = 0;
}
ide_animation_unload_begin_values (animation);
g_object_unref (animation);
@@ -659,7 +636,6 @@ ide_animation_add_property (IdeAnimation *animation,
GParamSpec *pspec,
const GValue *value)
{
- IdeAnimationPrivate *priv;
Tween tween = { 0 };
GType type;
@@ -667,16 +643,14 @@ ide_animation_add_property (IdeAnimation *animation,
g_return_if_fail (pspec != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (value->g_type);
- g_return_if_fail (animation->priv->target);
- g_return_if_fail (!animation->priv->tween_handler);
+ g_return_if_fail (animation->target);
+ g_return_if_fail (!animation->tween_handler);
- priv = animation->priv;
-
- type = G_TYPE_FROM_INSTANCE (priv->target);
+ type = G_TYPE_FROM_INSTANCE (animation->target);
tween.is_child = !g_type_is_a (type, pspec->owner_type);
if (tween.is_child)
{
- if (!GTK_IS_WIDGET (priv->target))
+ if (!GTK_IS_WIDGET (animation->target))
{
g_critical (_("Cannot locate property %s in class %s"),
pspec->name, g_type_name (type));
@@ -688,7 +662,7 @@ ide_animation_add_property (IdeAnimation *animation,
g_value_init (&tween.begin, pspec->value_type);
g_value_init (&tween.end, pspec->value_type);
g_value_copy (value, &tween.end);
- g_array_append_val (priv->tweens, tween);
+ g_array_append_val (animation->tweens, tween);
}
@@ -704,10 +678,10 @@ ide_animation_add_property (IdeAnimation *animation,
static void
ide_animation_dispose (GObject *object)
{
- IdeAnimationPrivate *priv = IDE_ANIMATION (object)->priv;
+ IdeAnimation *self = IDE_ANIMATION (object);
- g_clear_object (&priv->target);
- g_clear_object (&priv->frame_clock);
+ g_clear_object (&self->target);
+ g_clear_object (&self->frame_clock);
G_OBJECT_CLASS (ide_animation_parent_class)->dispose (object);
}
@@ -725,19 +699,19 @@ ide_animation_dispose (GObject *object)
static void
ide_animation_finalize (GObject *object)
{
- IdeAnimationPrivate *priv = IDE_ANIMATION (object)->priv;
+ IdeAnimation *self = IDE_ANIMATION (object);
Tween *tween;
gint i;
- for (i = 0; i < priv->tweens->len; i++)
+ for (i = 0; i < self->tweens->len; i++)
{
- tween = &g_array_index (priv->tweens, Tween, i);
+ tween = &g_array_index (self->tweens, Tween, i);
g_value_unset (&tween->begin);
g_value_unset (&tween->end);
g_param_spec_unref (tween->pspec);
}
- g_array_unref (priv->tweens);
+ g_array_unref (self->tweens);
G_OBJECT_CLASS (ide_animation_parent_class)->finalize (object);
}
@@ -763,7 +737,7 @@ ide_animation_set_property (GObject *object,
switch (prop_id)
{
case PROP_DURATION:
- animation->priv->duration_msec = g_value_get_uint (value);
+ animation->duration_msec = g_value_get_uint (value);
break;
case PROP_FRAME_CLOCK:
@@ -771,7 +745,7 @@ ide_animation_set_property (GObject *object,
break;
case PROP_MODE:
- animation->priv->mode = g_value_get_enum (value);
+ animation->mode = g_value_get_enum (value);
break;
case PROP_TARGET:
@@ -804,7 +778,6 @@ ide_animation_class_init (IdeAnimationClass *klass)
object_class->dispose = ide_animation_dispose;
object_class->finalize = ide_animation_finalize;
object_class->set_property = ide_animation_set_property;
- g_type_class_add_private (object_class, sizeof (IdeAnimationPrivate));
/**
* IdeAnimation:duration:
@@ -916,15 +889,9 @@ ide_animation_class_init (IdeAnimationClass *klass)
static void
ide_animation_init (IdeAnimation *animation)
{
- IdeAnimationPrivate *priv;
-
- priv = G_TYPE_INSTANCE_GET_PRIVATE (animation, IDE_TYPE_ANIMATION, IdeAnimationPrivate);
-
- animation->priv = priv;
-
- priv->duration_msec = 250;
- priv->mode = IDE_ANIMATION_EASE_IN_OUT_QUAD;
- priv->tweens = g_array_new (FALSE, FALSE, sizeof (Tween));
+ animation->duration_msec = 250;
+ animation->mode = IDE_ANIMATION_EASE_IN_OUT_QUAD;
+ animation->tweens = g_array_new (FALSE, FALSE, sizeof (Tween));
}
diff --git a/libide/theatrics/ide-animation.h b/libide/theatrics/ide-animation.h
index 0f3fabe..b2352ee 100644
--- a/libide/theatrics/ide-animation.h
+++ b/libide/theatrics/ide-animation.h
@@ -23,18 +23,12 @@
G_BEGIN_DECLS
-#define IDE_TYPE_ANIMATION (ide_animation_get_type())
-#define IDE_TYPE_ANIMATION_MODE (ide_animation_mode_get_type())
-#define IDE_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_ANIMATION, IdeAnimation))
-#define IDE_ANIMATION_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_ANIMATION, IdeAnimation
const))
-#define IDE_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_ANIMATION,
IdeAnimationClass))
-#define IDE_IS_ANIMATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_ANIMATION))
-#define IDE_IS_ANIMATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_ANIMATION))
-#define IDE_ANIMATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_ANIMATION,
IdeAnimationClass))
+#define IDE_TYPE_ANIMATION (ide_animation_get_type())
+#define IDE_TYPE_ANIMATION_MODE (ide_animation_mode_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeAnimation, ide_animation,
+ IDE, ANIMATION, GInitiallyUnowned)
-typedef struct _IdeAnimation IdeAnimation;
-typedef struct _IdeAnimationClass IdeAnimationClass;
-typedef struct _IdeAnimationPrivate IdeAnimationPrivate;
typedef enum _IdeAnimationMode IdeAnimationMode;
enum _IdeAnimationMode
@@ -49,20 +43,6 @@ enum _IdeAnimationMode
IDE_ANIMATION_LAST
};
-struct _IdeAnimation
-{
- GInitiallyUnowned parent;
-
- /*< private >*/
- IdeAnimationPrivate *priv;
-};
-
-struct _IdeAnimationClass
-{
- GInitiallyUnownedClass parent_class;
-};
-
-GType ide_animation_get_type (void);
GType ide_animation_mode_get_type (void);
void ide_animation_start (IdeAnimation *animation);
void ide_animation_stop (IdeAnimation *animation);
diff --git a/libide/theatrics/ide-box-theatric.c b/libide/theatrics/ide-box-theatric.c
index 368a7b4..b673d9a 100644
--- a/libide/theatrics/ide-box-theatric.c
+++ b/libide/theatrics/ide-box-theatric.c
@@ -24,8 +24,10 @@
#include "ide-box-theatric.h"
#include "ide-cairo.h"
-struct _IdeBoxTheatricPrivate
+struct _IdeBoxTheatric
{
+ GObject parent_instance;
+
GtkWidget *target;
GtkWidget *toplevel;
GdkRectangle area;
@@ -47,7 +49,7 @@ enum {
LAST_PROP
};
-G_DEFINE_TYPE_WITH_PRIVATE (IdeBoxTheatric, ide_box_theatric, G_TYPE_OBJECT)
+G_DEFINE_TYPE (IdeBoxTheatric, ide_box_theatric, G_TYPE_OBJECT)
static GParamSpec *gParamSpecs[LAST_PROP];
@@ -55,14 +57,12 @@ static void
get_toplevel_rect (IdeBoxTheatric *theatric,
GdkRectangle *area)
{
- IdeBoxTheatricPrivate *priv = theatric->priv;
-
- gtk_widget_translate_coordinates (priv->target, priv->toplevel,
- priv->area.x, priv->area.y,
+ gtk_widget_translate_coordinates (theatric->target, theatric->toplevel,
+ theatric->area.x, theatric->area.y,
&area->x, &area->y);
- area->width = priv->area.width;
- area->height = priv->area.height;
+ area->width = theatric->area.width;
+ area->height = theatric->area.height;
}
static gboolean
@@ -70,7 +70,6 @@ on_toplevel_draw (GtkWidget *widget,
cairo_t *cr,
IdeBoxTheatric *theatric)
{
- IdeBoxTheatricPrivate *priv = theatric->priv;
GdkRectangle area;
get_toplevel_rect (theatric, &area);
@@ -82,10 +81,10 @@ on_toplevel_draw (GtkWidget *widget,
#endif
ide_cairo_rounded_rectangle (cr, &area, 3, 3);
- gdk_cairo_set_source_rgba (cr, &priv->background_rgba);
+ gdk_cairo_set_source_rgba (cr, &theatric->background_rgba);
cairo_fill (cr);
- priv->last_area = area;
+ theatric->last_area = area;
return FALSE;
}
@@ -94,12 +93,12 @@ static void
ide_box_theatric_notify (GObject *object,
GParamSpec *pspec)
{
- IdeBoxTheatricPrivate *priv = IDE_BOX_THEATRIC (object)->priv;
+ IdeBoxTheatric *self = IDE_BOX_THEATRIC (object);
if (G_OBJECT_CLASS (ide_box_theatric_parent_class)->notify)
G_OBJECT_CLASS (ide_box_theatric_parent_class)->notify (object, pspec);
- if (priv->target && priv->toplevel)
+ if (self->target && self->toplevel)
{
GdkWindow *window;
GdkRectangle area;
@@ -111,9 +110,9 @@ ide_box_theatric_notify (GObject *object,
area.x, area.y, area.width, area.height);
#endif
- window = gtk_widget_get_window (priv->toplevel);
+ window = gtk_widget_get_window (self->toplevel);
- gdk_window_invalidate_rect (window, &priv->last_area, TRUE);
+ gdk_window_invalidate_rect (window, &self->last_area, TRUE);
gdk_window_invalidate_rect (window, &area, TRUE);
}
}
@@ -121,18 +120,18 @@ ide_box_theatric_notify (GObject *object,
static void
ide_box_theatric_dispose (GObject *object)
{
- IdeBoxTheatricPrivate *priv = IDE_BOX_THEATRIC (object)->priv;
+ IdeBoxTheatric *self = IDE_BOX_THEATRIC (object);
- if (priv->target)
+ if (self->target)
{
- if (priv->draw_handler && priv->toplevel)
+ if (self->draw_handler && self->toplevel)
{
- g_signal_handler_disconnect (priv->toplevel, priv->draw_handler);
- priv->draw_handler = 0;
+ g_signal_handler_disconnect (self->toplevel, self->draw_handler);
+ self->draw_handler = 0;
}
- g_object_remove_weak_pointer (G_OBJECT (priv->target),
- (gpointer *) &priv->target);
- priv->target = NULL;
+ g_object_remove_weak_pointer (G_OBJECT (self->target),
+ (gpointer *) &self->target);
+ self->target = NULL;
}
G_OBJECT_CLASS (ide_box_theatric_parent_class)->dispose (object);
@@ -140,41 +139,41 @@ ide_box_theatric_dispose (GObject *object)
static void
ide_box_theatric_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
IdeBoxTheatric *theatric = IDE_BOX_THEATRIC (object);
switch (prop_id)
{
case PROP_ALPHA:
- g_value_set_double (value, theatric->priv->background_rgba.alpha);
+ g_value_set_double (value, theatric->background_rgba.alpha);
break;
case PROP_BACKGROUND:
g_value_take_string (value,
- gdk_rgba_to_string (&theatric->priv->background_rgba));
+ gdk_rgba_to_string (&theatric->background_rgba));
break;
case PROP_HEIGHT:
- g_value_set_int (value, theatric->priv->area.height);
+ g_value_set_int (value, theatric->area.height);
break;
case PROP_TARGET:
- g_value_set_object (value, theatric->priv->target);
+ g_value_set_object (value, theatric->target);
break;
case PROP_WIDTH:
- g_value_set_int (value, theatric->priv->area.width);
+ g_value_set_int (value, theatric->area.width);
break;
case PROP_X:
- g_value_set_int (value, theatric->priv->area.x);
+ g_value_set_int (value, theatric->area.x);
break;
case PROP_Y:
- g_value_set_int (value, theatric->priv->area.y);
+ g_value_set_int (value, theatric->area.y);
break;
default:
@@ -193,46 +192,45 @@ ide_box_theatric_set_property (GObject *object,
switch (prop_id)
{
case PROP_ALPHA:
- theatric->priv->background_rgba.alpha = g_value_get_double (value);
+ theatric->background_rgba.alpha = g_value_get_double (value);
break;
case PROP_BACKGROUND:
{
- gdouble old_alpha = theatric->priv->background_rgba.alpha;
+ gdouble old_alpha = theatric->background_rgba.alpha;
- gdk_rgba_parse (&theatric->priv->background_rgba,
+ gdk_rgba_parse (&theatric->background_rgba,
g_value_get_string (value));
- theatric->priv->background_rgba.alpha = old_alpha;
+ theatric->background_rgba.alpha = old_alpha;
}
break;
case PROP_HEIGHT:
- theatric->priv->area.height = g_value_get_int (value);
+ theatric->area.height = g_value_get_int (value);
break;
case PROP_TARGET:
- theatric->priv->target = g_value_get_object (value);
- theatric->priv->toplevel =
- gtk_widget_get_toplevel (theatric->priv->target);
- g_object_add_weak_pointer (G_OBJECT (theatric->priv->target),
- (gpointer *) &theatric->priv->target);
- theatric->priv->draw_handler =
- g_signal_connect_after (theatric->priv->toplevel,
+ theatric->target = g_value_get_object (value);
+ theatric->toplevel = gtk_widget_get_toplevel (theatric->target);
+ g_object_add_weak_pointer (G_OBJECT (theatric->target),
+ (gpointer *) &theatric->target);
+ theatric->draw_handler =
+ g_signal_connect_after (theatric->toplevel,
"draw",
G_CALLBACK (on_toplevel_draw),
theatric);
break;
case PROP_WIDTH:
- theatric->priv->area.width = g_value_get_int (value);
+ theatric->area.width = g_value_get_int (value);
break;
case PROP_X:
- theatric->priv->area.x = g_value_get_int (value);
+ theatric->area.x = g_value_get_int (value);
break;
case PROP_Y:
- theatric->priv->area.y = g_value_get_int (value);
+ theatric->area.y = g_value_get_int (value);
break;
default:
@@ -320,5 +318,4 @@ ide_box_theatric_class_init (IdeBoxTheatricClass *klass)
static void
ide_box_theatric_init (IdeBoxTheatric *theatric)
{
- theatric->priv = ide_box_theatric_get_instance_private (theatric);
}
diff --git a/libide/theatrics/ide-box-theatric.h b/libide/theatrics/ide-box-theatric.h
index 94a4276..d2545f0 100644
--- a/libide/theatrics/ide-box-theatric.h
+++ b/libide/theatrics/ide-box-theatric.h
@@ -23,32 +23,10 @@
G_BEGIN_DECLS
-#define IDE_TYPE_BOX_THEATRIC (ide_box_theatric_get_type())
-#define IDE_BOX_THEATRIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_BOX_THEATRIC,
IdeBoxTheatric))
-#define IDE_BOX_THEATRIC_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_BOX_THEATRIC,
IdeBoxTheatric const))
-#define IDE_BOX_THEATRIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), IDE_TYPE_BOX_THEATRIC,
IdeBoxTheatricClass))
-#define IDE_IS_BOX_THEATRIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_BOX_THEATRIC))
-#define IDE_IS_BOX_THEATRIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), IDE_TYPE_BOX_THEATRIC))
-#define IDE_BOX_THEATRIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), IDE_TYPE_BOX_THEATRIC,
IdeBoxTheatricClass))
+#define IDE_TYPE_BOX_THEATRIC (ide_box_theatric_get_type())
-typedef struct _IdeBoxTheatric IdeBoxTheatric;
-typedef struct _IdeBoxTheatricClass IdeBoxTheatricClass;
-typedef struct _IdeBoxTheatricPrivate IdeBoxTheatricPrivate;
-
-struct _IdeBoxTheatric
-{
- GObject parent;
-
- /*< private >*/
- IdeBoxTheatricPrivate *priv;
-};
-
-struct _IdeBoxTheatricClass
-{
- GObjectClass parent_class;
-};
-
-GType ide_box_theatric_get_type (void);
+G_DECLARE_FINAL_TYPE (IdeBoxTheatric, ide_box_theatric,
+ IDE, BOX_THEATRIC, GObject)
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]