[gtksourceview/wip/chergert/gsv-gtk4: 24/192] completion: modernize GtkSourceCompletionInfo
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 24/192] completion: modernize GtkSourceCompletionInfo
- Date: Fri, 7 Aug 2020 18:31:04 +0000 (UTC)
commit 4a32f6deab9d565518ac9053a730ad112221e774
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 8 17:02:05 2020 -0800
completion: modernize GtkSourceCompletionInfo
Make final and switch to G_DECLARE_FINAL_TYPE()
gtksourceview/gtksourceautocleanups.h | 1 -
gtksourceview/gtksourcecompletioninfo.c | 50 +++++++++++++++++----------------
gtksourceview/gtksourcecompletioninfo.h | 42 ++++++---------------------
3 files changed, 34 insertions(+), 59 deletions(-)
---
diff --git a/gtksourceview/gtksourceautocleanups.h b/gtksourceview/gtksourceautocleanups.h
index 3a2460c60..aa8070c3c 100644
--- a/gtksourceview/gtksourceautocleanups.h
+++ b/gtksourceview/gtksourceautocleanups.h
@@ -28,7 +28,6 @@ G_BEGIN_DECLS
#ifndef __GI_SCANNER__
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceCompletionInfo, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceCompletionItem, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceFile, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSourceFileLoader, g_object_unref)
diff --git a/gtksourceview/gtksourcecompletioninfo.c b/gtksourceview/gtksourcecompletioninfo.c
index 77f6582ff..427008cc6 100644
--- a/gtksourceview/gtksourcecompletioninfo.c
+++ b/gtksourceview/gtksourcecompletioninfo.c
@@ -60,8 +60,10 @@
#include "gtksourcecompletioninfo.h"
#include <glib/gi18n-lib.h>
-struct _GtkSourceCompletionInfoPrivate
+struct _GtkSourceCompletionInfo
{
+ GtkWindow parent_instance;
+
guint idle_resize;
GtkWidget *attached_to;
@@ -72,7 +74,7 @@ struct _GtkSourceCompletionInfoPrivate
guint transient_set : 1;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceCompletionInfo, gtk_source_completion_info, GTK_TYPE_WINDOW);
+G_DEFINE_TYPE (GtkSourceCompletionInfo, gtk_source_completion_info, GTK_TYPE_WINDOW);
/* Resize the window */
@@ -87,7 +89,7 @@ idle_resize (GtkSourceCompletionInfo *info)
gint cur_window_width;
gint cur_window_height;
- info->priv->idle_resize = 0;
+ info->idle_resize = 0;
if (child == NULL)
{
@@ -117,9 +119,9 @@ idle_resize (GtkSourceCompletionInfo *info)
static void
queue_resize (GtkSourceCompletionInfo *info)
{
- if (info->priv->idle_resize == 0)
+ if (info->idle_resize == 0)
{
- info->priv->idle_resize = g_idle_add ((GSourceFunc)idle_resize, info);
+ info->idle_resize = g_idle_add ((GSourceFunc)idle_resize, info);
}
}
@@ -205,21 +207,21 @@ static void
set_attached_to (GtkSourceCompletionInfo *info,
GtkWidget *attached_to)
{
- if (info->priv->attached_to != NULL)
+ if (info->attached_to != NULL)
{
- g_object_remove_weak_pointer (G_OBJECT (info->priv->attached_to),
- (gpointer *) &info->priv->attached_to);
+ g_object_remove_weak_pointer (G_OBJECT (info->attached_to),
+ (gpointer *) &info->attached_to);
- if (info->priv->focus_out_event_handler != 0)
+ if (info->focus_out_event_handler != 0)
{
- g_signal_handler_disconnect (info->priv->attached_to,
- info->priv->focus_out_event_handler);
+ g_signal_handler_disconnect (info->attached_to,
+ info->focus_out_event_handler);
- info->priv->focus_out_event_handler = 0;
+ info->focus_out_event_handler = 0;
}
}
- info->priv->attached_to = attached_to;
+ info->attached_to = attached_to;
if (attached_to == NULL)
{
@@ -227,15 +229,15 @@ set_attached_to (GtkSourceCompletionInfo *info,
}
g_object_add_weak_pointer (G_OBJECT (attached_to),
- (gpointer *) &info->priv->attached_to);
+ (gpointer *) &info->attached_to);
- info->priv->focus_out_event_handler =
+ info->focus_out_event_handler =
g_signal_connect_swapped (attached_to,
"focus-out-event",
G_CALLBACK (focus_out_event_cb),
info);
- info->priv->transient_set = FALSE;
+ info->transient_set = FALSE;
}
static void
@@ -247,7 +249,7 @@ update_attached_to (GtkSourceCompletionInfo *info)
static void
gtk_source_completion_info_init (GtkSourceCompletionInfo *info)
{
- info->priv = gtk_source_completion_info_get_instance_private (info);
+ info = gtk_source_completion_info_get_instance_private (info);
g_signal_connect (info,
"notify::attached-to",
@@ -271,10 +273,10 @@ gtk_source_completion_info_dispose (GObject *object)
{
GtkSourceCompletionInfo *info = GTK_SOURCE_COMPLETION_INFO (object);
- if (info->priv->idle_resize != 0)
+ if (info->idle_resize != 0)
{
- g_source_remove (info->priv->idle_resize);
- info->priv->idle_resize = 0;
+ g_source_remove (info->idle_resize);
+ info->idle_resize = 0;
}
set_attached_to (info, NULL);
@@ -287,16 +289,16 @@ gtk_source_completion_info_show (GtkWidget *widget)
{
GtkSourceCompletionInfo *info = GTK_SOURCE_COMPLETION_INFO (widget);
- if (info->priv->attached_to != NULL && !info->priv->transient_set)
+ if (info->attached_to != NULL && !info->transient_set)
{
GtkWidget *toplevel;
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (info->priv->attached_to));
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (info->attached_to));
if (gtk_widget_is_toplevel (toplevel))
{
gtk_window_set_transient_for (GTK_WINDOW (info),
GTK_WINDOW (toplevel));
- info->priv->transient_set = TRUE;
+ info->transient_set = TRUE;
}
}
@@ -342,7 +344,7 @@ _gtk_source_completion_info_set_xoffset (GtkSourceCompletionInfo *window,
{
g_return_if_fail (GTK_SOURCE_IS_COMPLETION_INFO (window));
- window->priv->xoffset = xoffset;
+ window->xoffset = xoffset;
}
/* Move to iter */
diff --git a/gtksourceview/gtksourcecompletioninfo.h b/gtksourceview/gtksourcecompletioninfo.h
index 8c169f204..423dce7e0 100644
--- a/gtksourceview/gtksourcecompletioninfo.h
+++ b/gtksourceview/gtksourcecompletioninfo.h
@@ -30,45 +30,19 @@
G_BEGIN_DECLS
-#define GTK_SOURCE_TYPE_COMPLETION_INFO (gtk_source_completion_info_get_type ())
-#define GTK_SOURCE_COMPLETION_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GTK_SOURCE_TYPE_COMPLETION_INFO, GtkSourceCompletionInfo))
-#define GTK_SOURCE_COMPLETION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GTK_SOURCE_TYPE_COMPLETION_INFO, GtkSourceCompletionInfoClass)
-#define GTK_SOURCE_IS_COMPLETION_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GTK_SOURCE_TYPE_COMPLETION_INFO))
-#define GTK_SOURCE_IS_COMPLETION_INFO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GTK_SOURCE_TYPE_COMPLETION_INFO))
-#define GTK_SOURCE_COMPLETION_INFO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GTK_SOURCE_TYPE_COMPLETION_INFO, GtkSourceCompletionInfoClass))
-
-typedef struct _GtkSourceCompletionInfoPrivate GtkSourceCompletionInfoPrivate;
-
-struct _GtkSourceCompletionInfo
-{
- GtkWindow parent;
-
- GtkSourceCompletionInfoPrivate *priv;
-};
-
-typedef struct _GtkSourceCompletionInfoClass GtkSourceCompletionInfoClass;
-
-struct _GtkSourceCompletionInfoClass
-{
- GtkWindowClass parent_class;
-
- gpointer padding[10];
-};
+#define GTK_SOURCE_TYPE_COMPLETION_INFO (gtk_source_completion_info_get_type())
GTK_SOURCE_AVAILABLE_IN_ALL
-GType gtk_source_completion_info_get_type (void) G_GNUC_CONST;
+G_DECLARE_FINAL_TYPE (GtkSourceCompletionInfo, gtk_source_completion_info, GTK_SOURCE, COMPLETION_INFO,
GtkWindow)
GTK_SOURCE_AVAILABLE_IN_ALL
-GtkSourceCompletionInfo *
- gtk_source_completion_info_new (void);
-
+GtkSourceCompletionInfo *gtk_source_completion_info_new (void);
GTK_SOURCE_AVAILABLE_IN_ALL
-void gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *info,
- GtkTextView *view,
- GtkTextIter *iter);
-
+void gtk_source_completion_info_move_to_iter (GtkSourceCompletionInfo *info,
+ GtkTextView *view,
+ GtkTextIter *iter);
G_GNUC_INTERNAL
-void _gtk_source_completion_info_set_xoffset (GtkSourceCompletionInfo *info,
- gint xoffset);
+void _gtk_source_completion_info_set_xoffset (GtkSourceCompletionInfo *info,
+ gint xoffset);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]