[gtksourceview/wip/chergert/gsv-gtk4: 116/118] use g_object_notify_by_pspec() and EXPLICIT_NOTIFY
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview/wip/chergert/gsv-gtk4: 116/118] use g_object_notify_by_pspec() and EXPLICIT_NOTIFY
- Date: Wed, 29 Jan 2020 19:07:17 +0000 (UTC)
commit 4823649dd27683c6215f1e80ed48a40edc2007ae
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 27 09:29:18 2020 -0800
use g_object_notify_by_pspec() and EXPLICIT_NOTIFY
Modernize usage of GObject properties by using G_PARAM_EXPLICITY_NOTIFY
to avoid extraneous notifications along with g_object_notify_by_pspec()
which is faster than looking up property specs by name.
gtksourceview/gtksourcecompletioncontext.c | 114 +++++-----
gtksourceview/gtksourcecompletionitem.c | 133 ++++++------
gtksourceview/gtksourcefile.c | 146 ++++++-------
gtksourceview/gtksourcefilesaver.c | 144 ++++++-------
gtksourceview/gtksourcelanguagemanager.c | 48 +++--
gtksourceview/gtksourcemarkattributes.c | 162 ++++++++-------
gtksourceview/gtksourceprintcompositor.c | 236 +++++++++++----------
gtksourceview/gtksourcesearchcontext.c | 139 +++++++------
gtksourceview/gtksourcestyleschememanager.c | 97 +++++----
gtksourceview/gtksourcetag.c | 64 +++---
gtksourceview/gtksourceview.c | 312 +++++++++++++++-------------
11 files changed, 826 insertions(+), 769 deletions(-)
---
diff --git a/gtksourceview/gtksourcecompletioncontext.c b/gtksourceview/gtksourcecompletioncontext.c
index 5bd636ea..1d715345 100644
--- a/gtksourceview/gtksourcecompletioncontext.c
+++ b/gtksourceview/gtksourcecompletioncontext.c
@@ -81,7 +81,8 @@ enum
PROP_0,
PROP_COMPLETION,
PROP_ITER,
- PROP_ACTIVATION
+ PROP_ACTIVATION,
+ N_PROPS
};
enum
@@ -91,6 +92,7 @@ enum
};
static guint context_signals[N_SIGNALS];
+static GParamSpec *properties[N_PROPS];
G_DEFINE_TYPE (GtkSourceCompletionContext, gtk_source_completion_context, G_TYPE_INITIALLY_UNOWNED)
@@ -147,7 +149,7 @@ set_iter (GtkSourceCompletionContext *context,
gtk_text_buffer_move_mark (buffer, context->mark, iter);
}
- g_object_notify (G_OBJECT (context), "iter");
+ g_object_notify_by_pspec (G_OBJECT (context), properties[PROP_ITER]);
}
static void
@@ -160,20 +162,20 @@ gtk_source_completion_context_set_property (GObject *object,
switch (prop_id)
{
- case PROP_COMPLETION:
- context->completion = g_value_dup_object (value);
- break;
+ case PROP_COMPLETION:
+ context->completion = g_value_dup_object (value);
+ break;
- case PROP_ITER:
- set_iter (context, g_value_get_boxed (value));
- break;
+ case PROP_ITER:
+ set_iter (context, g_value_get_boxed (value));
+ break;
- case PROP_ACTIVATION:
- context->activation = g_value_get_flags (value);
- break;
+ case PROP_ACTIVATION:
+ context->activation = g_value_get_flags (value);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -187,27 +189,27 @@ gtk_source_completion_context_get_property (GObject *object,
switch (prop_id)
{
- case PROP_COMPLETION:
- g_value_set_object (value, context->completion);
- break;
+ case PROP_COMPLETION:
+ g_value_set_object (value, context->completion);
+ break;
- case PROP_ITER:
- {
- GtkTextIter iter;
+ case PROP_ITER:
+ {
+ GtkTextIter iter;
- if (gtk_source_completion_context_get_iter (context, &iter))
- {
- g_value_set_boxed (value, &iter);
- }
+ if (gtk_source_completion_context_get_iter (context, &iter))
+ {
+ g_value_set_boxed (value, &iter);
}
- break;
+ }
+ break;
- case PROP_ACTIVATION:
- g_value_set_flags (value, context->activation);
- break;
+ case PROP_ACTIVATION:
+ g_value_set_flags (value, context->activation);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
@@ -238,45 +240,45 @@ gtk_source_completion_context_class_init (GtkSourceCompletionContextClass *klass
*
* The #GtkSourceCompletion associated with the context.
**/
- g_object_class_install_property (object_class,
- PROP_COMPLETION,
- g_param_spec_object ("completion",
- "Completion",
- "The completion object to which the context
belongs",
- GTK_SOURCE_TYPE_COMPLETION,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_COMPLETION] =
+ g_param_spec_object ("completion",
+ "Completion",
+ "The completion object to which the context belongs",
+ GTK_SOURCE_TYPE_COMPLETION,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionContext:iter:
*
* The #GtkTextIter at which the completion is invoked.
**/
- g_object_class_install_property (object_class,
- PROP_ITER,
- g_param_spec_boxed ("iter",
- "Iterator",
- "The GtkTextIter at which the completion was
invoked",
- GTK_TYPE_TEXT_ITER,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ITER] =
+ g_param_spec_boxed ("iter",
+ "Iterator",
+ "The GtkTextIter at which the completion was invoked",
+ GTK_TYPE_TEXT_ITER,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionContext:activation:
*
* The completion activation
**/
- g_object_class_install_property (object_class,
- PROP_ACTIVATION,
- g_param_spec_flags ("activation",
- "Activation",
- "The type of activation",
- GTK_SOURCE_TYPE_COMPLETION_ACTIVATION,
- GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ACTIVATION] =
+ g_param_spec_flags ("activation",
+ "Activation",
+ "The type of activation",
+ GTK_SOURCE_TYPE_COMPLETION_ACTIVATION,
+ GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
diff --git a/gtksourceview/gtksourcecompletionitem.c b/gtksourceview/gtksourcecompletionitem.c
index 2200246a..0a060375 100644
--- a/gtksourceview/gtksourcecompletionitem.c
+++ b/gtksourceview/gtksourcecompletionitem.c
@@ -52,7 +52,8 @@ enum
PROP_ICON,
PROP_ICON_NAME,
PROP_GICON,
- PROP_INFO
+ PROP_INFO,
+ N_PROPS
};
static void gtk_source_completion_proposal_iface_init (gpointer g_iface, gpointer iface_data);
@@ -64,6 +65,8 @@ G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionItem,
G_IMPLEMENT_INTERFACE (GTK_SOURCE_TYPE_COMPLETION_PROPOSAL,
gtk_source_completion_proposal_iface_init))
+static GParamSpec *properties [N_PROPS];
+
static gchar *
gtk_source_completion_proposal_get_label_impl (GtkSourceCompletionProposal *proposal)
{
@@ -280,56 +283,56 @@ gtk_source_completion_item_class_init (GtkSourceCompletionItemClass *klass)
*
* Label to be shown for this proposal.
*/
- g_object_class_install_property (object_class,
- PROP_LABEL,
- g_param_spec_string ("label",
- "Label",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_LABEL] =
+ g_param_spec_string ("label",
+ "Label",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:markup:
*
* Label with markup to be shown for this proposal.
*/
- g_object_class_install_property (object_class,
- PROP_MARKUP,
- g_param_spec_string ("markup",
- "Markup",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_MARKUP] =
+ g_param_spec_string ("markup",
+ "Markup",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:text:
*
* Proposal text.
*/
- g_object_class_install_property (object_class,
- PROP_TEXT,
- g_param_spec_string ("text",
- "Text",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_TEXT] =
+ g_param_spec_string ("text",
+ "Text",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:icon:
*
* The #GdkTexture for the icon to be shown for this proposal.
*/
- g_object_class_install_property (object_class,
- PROP_ICON,
- g_param_spec_object ("icon",
- "Icon",
- "",
- GDK_TYPE_TEXTURE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ICON] =
+ g_param_spec_object ("icon",
+ "Icon",
+ "",
+ GDK_TYPE_TEXTURE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:icon-name:
@@ -338,14 +341,14 @@ gtk_source_completion_item_class_init (GtkSourceCompletionItemClass *klass)
*
* Since: 3.18
*/
- g_object_class_install_property (object_class,
- PROP_ICON_NAME,
- g_param_spec_string ("icon-name",
- "Icon Name",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ICON_NAME] =
+ g_param_spec_string ("icon-name",
+ "Icon Name",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:gicon:
@@ -354,28 +357,30 @@ gtk_source_completion_item_class_init (GtkSourceCompletionItemClass *klass)
*
* Since: 3.18
*/
- g_object_class_install_property (object_class,
- PROP_GICON,
- g_param_spec_object ("gicon",
- "GIcon",
- "",
- G_TYPE_ICON,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_GICON] =
+ g_param_spec_object ("gicon",
+ "GIcon",
+ "",
+ G_TYPE_ICON,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceCompletionItem:info:
*
* Optional extra information to be shown for this proposal.
*/
- g_object_class_install_property (object_class,
- PROP_INFO,
- g_param_spec_string ("info",
- "Info",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_INFO] =
+ g_param_spec_string ("info",
+ "Info",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -419,7 +424,7 @@ gtk_source_completion_item_set_label (GtkSourceCompletionItem *item,
priv->label = g_strdup (label);
emit_changed (item);
- g_object_notify (G_OBJECT (item), "label");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_LABEL]);
}
}
@@ -444,7 +449,7 @@ gtk_source_completion_item_set_markup (GtkSourceCompletionItem *item,
priv->markup = g_strdup (markup);
emit_changed (item);
- g_object_notify (G_OBJECT (item), "markup");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_MARKUP]);
}
}
@@ -469,7 +474,7 @@ gtk_source_completion_item_set_text (GtkSourceCompletionItem *item,
priv->text = g_strdup (text);
emit_changed (item);
- g_object_notify (G_OBJECT (item), "text");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_TEXT]);
}
}
@@ -492,7 +497,7 @@ gtk_source_completion_item_set_icon (GtkSourceCompletionItem *item,
if (g_set_object (&priv->icon, icon))
{
emit_changed (item);
- g_object_notify (G_OBJECT (item), "icon");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_ICON]);
}
}
@@ -517,7 +522,7 @@ gtk_source_completion_item_set_icon_name (GtkSourceCompletionItem *item,
priv->icon_name = g_strdup (icon_name);
emit_changed (item);
- g_object_notify (G_OBJECT (item), "icon-name");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_ICON_NAME]);
}
}
@@ -540,7 +545,7 @@ gtk_source_completion_item_set_gicon (GtkSourceCompletionItem *item,
if (g_set_object (&priv->gicon, gicon))
{
emit_changed (item);
- g_object_notify (G_OBJECT (item), "gicon");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_GICON]);
}
}
@@ -565,6 +570,6 @@ gtk_source_completion_item_set_info (GtkSourceCompletionItem *item,
priv->info = g_strdup (info);
emit_changed (item);
- g_object_notify (G_OBJECT (item), "info");
+ g_object_notify_by_pspec (G_OBJECT (item), properties [PROP_INFO]);
}
}
diff --git a/gtksourceview/gtksourcefile.c b/gtksourceview/gtksourcefile.c
index 303bcc2a..33343509 100644
--- a/gtksourceview/gtksourcefile.c
+++ b/gtksourceview/gtksourcefile.c
@@ -51,7 +51,8 @@ enum
PROP_ENCODING,
PROP_NEWLINE_TYPE,
PROP_COMPRESSION_TYPE,
- PROP_READ_ONLY
+ PROP_READ_ONLY,
+ N_PROPS
};
typedef struct
@@ -79,6 +80,8 @@ typedef struct
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceFile, gtk_source_file, G_TYPE_OBJECT)
+static GParamSpec *properties[N_PROPS];
+
static void
gtk_source_file_get_property (GObject *object,
guint prop_id,
@@ -90,29 +93,29 @@ gtk_source_file_get_property (GObject *object,
switch (prop_id)
{
- case PROP_LOCATION:
- g_value_set_object (value, priv->location);
- break;
+ case PROP_LOCATION:
+ g_value_set_object (value, priv->location);
+ break;
- case PROP_ENCODING:
- g_value_set_boxed (value, priv->encoding);
- break;
+ case PROP_ENCODING:
+ g_value_set_boxed (value, priv->encoding);
+ break;
- case PROP_NEWLINE_TYPE:
- g_value_set_enum (value, priv->newline_type);
- break;
+ case PROP_NEWLINE_TYPE:
+ g_value_set_enum (value, priv->newline_type);
+ break;
- case PROP_COMPRESSION_TYPE:
- g_value_set_enum (value, priv->compression_type);
- break;
+ case PROP_COMPRESSION_TYPE:
+ g_value_set_enum (value, priv->compression_type);
+ break;
- case PROP_READ_ONLY:
- g_value_set_boolean (value, priv->readonly);
- break;
+ case PROP_READ_ONLY:
+ g_value_set_boolean (value, priv->readonly);
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -126,13 +129,13 @@ gtk_source_file_set_property (GObject *object,
switch (prop_id)
{
- case PROP_LOCATION:
- gtk_source_file_set_location (file, g_value_get_object (value));
- break;
+ case PROP_LOCATION:
+ gtk_source_file_set_location (file, g_value_get_object (value));
+ break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -169,15 +172,14 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_LOCATION,
- g_param_spec_object ("location",
- "Location",
- "",
- G_TYPE_FILE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_LOCATION] =
+ g_param_spec_object ("location",
+ "Location",
+ "",
+ G_TYPE_FILE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFile:encoding:
@@ -187,14 +189,13 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_ENCODING,
- g_param_spec_boxed ("encoding",
- "Encoding",
- "",
- GTK_SOURCE_TYPE_ENCODING,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_ENCODING] =
+ g_param_spec_boxed ("encoding",
+ "Encoding",
+ "",
+ GTK_SOURCE_TYPE_ENCODING,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFile:newline-type:
@@ -203,15 +204,14 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_NEWLINE_TYPE,
- g_param_spec_enum ("newline-type",
- "Newline type",
- "",
- GTK_SOURCE_TYPE_NEWLINE_TYPE,
- GTK_SOURCE_NEWLINE_TYPE_LF,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_NEWLINE_TYPE] =
+ g_param_spec_enum ("newline-type",
+ "Newline type",
+ "",
+ GTK_SOURCE_TYPE_NEWLINE_TYPE,
+ GTK_SOURCE_NEWLINE_TYPE_LF,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFile:compression-type:
@@ -220,15 +220,14 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_COMPRESSION_TYPE,
- g_param_spec_enum ("compression-type",
- "Compression type",
- "",
- GTK_SOURCE_TYPE_COMPRESSION_TYPE,
- GTK_SOURCE_COMPRESSION_TYPE_NONE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_COMPRESSION_TYPE] =
+ g_param_spec_enum ("compression-type",
+ "Compression type",
+ "",
+ GTK_SOURCE_TYPE_COMPRESSION_TYPE,
+ GTK_SOURCE_COMPRESSION_TYPE_NONE,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFile:read-only:
@@ -238,14 +237,15 @@ gtk_source_file_class_init (GtkSourceFileClass *klass)
*
* Since: 3.18
*/
- g_object_class_install_property (object_class,
- PROP_READ_ONLY,
- g_param_spec_boolean ("read-only",
- "Read Only",
- "",
- FALSE,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_READ_ONLY] =
+ g_param_spec_boolean ("read-only",
+ "Read Only",
+ "",
+ FALSE,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -290,7 +290,7 @@ gtk_source_file_set_location (GtkSourceFile *file,
if (g_set_object (&priv->location, location))
{
- g_object_notify (G_OBJECT (file), "location");
+ g_object_notify_by_pspec (G_OBJECT (file), properties[PROP_LOCATION]);
/* The modification_time is for the old location. */
priv->modification_time_set = FALSE;
@@ -328,7 +328,7 @@ _gtk_source_file_set_encoding (GtkSourceFile *file,
if (priv->encoding != encoding)
{
priv->encoding = encoding;
- g_object_notify (G_OBJECT (file), "encoding");
+ g_object_notify_by_pspec (G_OBJECT (file), properties[PROP_ENCODING]);
}
}
@@ -363,7 +363,7 @@ _gtk_source_file_set_newline_type (GtkSourceFile *file,
if (priv->newline_type != newline_type)
{
priv->newline_type = newline_type;
- g_object_notify (G_OBJECT (file), "newline-type");
+ g_object_notify_by_pspec (G_OBJECT (file), properties[PROP_NEWLINE_TYPE]);
}
}
@@ -395,7 +395,7 @@ _gtk_source_file_set_compression_type (GtkSourceFile *file,
if (priv->compression_type != compression_type)
{
priv->compression_type = compression_type;
- g_object_notify (G_OBJECT (file), "compression-type");
+ g_object_notify_by_pspec (G_OBJECT (file), properties[PROP_COMPRESSION_TYPE]);
}
}
@@ -680,7 +680,7 @@ _gtk_source_file_set_readonly (GtkSourceFile *file,
if (priv->readonly != readonly)
{
priv->readonly = readonly;
- g_object_notify (G_OBJECT (file), "read-only");
+ g_object_notify_by_pspec (G_OBJECT (file), properties[PROP_READ_ONLY]);
}
}
diff --git a/gtksourceview/gtksourcefilesaver.c b/gtksourceview/gtksourcefilesaver.c
index cb7bd484..8ee0e1a3 100644
--- a/gtksourceview/gtksourcefilesaver.c
+++ b/gtksourceview/gtksourcefilesaver.c
@@ -77,7 +77,8 @@ enum
PROP_ENCODING,
PROP_NEWLINE_TYPE,
PROP_COMPRESSION_TYPE,
- PROP_FLAGS
+ PROP_FLAGS,
+ N_PROPS
};
struct _GtkSourceFileSaver
@@ -140,6 +141,8 @@ typedef struct
G_DEFINE_TYPE (GtkSourceFileSaver, gtk_source_file_saver, G_TYPE_OBJECT)
+static GParamSpec *properties [N_PROPS];
+
static void read_file_chunk (GTask *task);
static void write_file_chunk (GTask *task);
static void recover_not_mounted (GTask *task);
@@ -352,15 +355,14 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_BUFFER,
- g_param_spec_object ("buffer",
- "GtkSourceBuffer",
- "",
- GTK_SOURCE_TYPE_BUFFER,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_BUFFER] =
+ g_param_spec_object ("buffer",
+ "GtkSourceBuffer",
+ "",
+ GTK_SOURCE_TYPE_BUFFER,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:file:
@@ -370,15 +372,14 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_FILE,
- g_param_spec_object ("file",
- "GtkSourceFile",
- "",
- GTK_SOURCE_TYPE_FILE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_FILE] =
+ g_param_spec_object ("file",
+ "GtkSourceFile",
+ "",
+ GTK_SOURCE_TYPE_FILE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:location:
@@ -388,15 +389,14 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_LOCATION,
- g_param_spec_object ("location",
- "Location",
- "",
- G_TYPE_FILE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_LOCATION] =
+ g_param_spec_object ("location",
+ "Location",
+ "",
+ G_TYPE_FILE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:encoding:
@@ -405,15 +405,14 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_ENCODING,
- g_param_spec_boxed ("encoding",
- "Encoding",
- "",
- GTK_SOURCE_TYPE_ENCODING,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ENCODING] =
+ g_param_spec_boxed ("encoding",
+ "Encoding",
+ "",
+ GTK_SOURCE_TYPE_ENCODING,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:newline-type:
@@ -422,16 +421,15 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_NEWLINE_TYPE,
- g_param_spec_enum ("newline-type",
- "Newline type",
- "",
- GTK_SOURCE_TYPE_NEWLINE_TYPE,
- GTK_SOURCE_NEWLINE_TYPE_LF,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_NEWLINE_TYPE] =
+ g_param_spec_enum ("newline-type",
+ "Newline type",
+ "",
+ GTK_SOURCE_TYPE_NEWLINE_TYPE,
+ GTK_SOURCE_NEWLINE_TYPE_LF,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:compression-type:
@@ -440,16 +438,15 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_COMPRESSION_TYPE,
- g_param_spec_enum ("compression-type",
- "Compression type",
- "",
- GTK_SOURCE_TYPE_COMPRESSION_TYPE,
- GTK_SOURCE_COMPRESSION_TYPE_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_COMPRESSION_TYPE] =
+ g_param_spec_enum ("compression-type",
+ "Compression type",
+ "",
+ GTK_SOURCE_TYPE_COMPRESSION_TYPE,
+ GTK_SOURCE_COMPRESSION_TYPE_NONE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceFileSaver:flags:
@@ -458,16 +455,17 @@ gtk_source_file_saver_class_init (GtkSourceFileSaverClass *klass)
*
* Since: 3.14
*/
- g_object_class_install_property (object_class,
- PROP_FLAGS,
- g_param_spec_flags ("flags",
- "Flags",
- "",
- GTK_SOURCE_TYPE_FILE_SAVER_FLAGS,
- GTK_SOURCE_FILE_SAVER_FLAGS_NONE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_FLAGS] =
+ g_param_spec_flags ("flags",
+ "Flags",
+ "",
+ GTK_SOURCE_TYPE_FILE_SAVER_FLAGS,
+ GTK_SOURCE_FILE_SAVER_FLAGS_NONE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
/* Due to potential deadlocks when registering types, we need to
* ensure the dependent private class GtkSourceBufferInputStream
@@ -1230,7 +1228,8 @@ gtk_source_file_saver_set_encoding (GtkSourceFileSaver *saver,
if (saver->encoding != encoding)
{
saver->encoding = encoding;
- g_object_notify (G_OBJECT (saver), "encoding");
+ g_object_notify_by_pspec (G_OBJECT (saver),
+ properties [PROP_ENCODING]);
}
}
@@ -1269,7 +1268,8 @@ gtk_source_file_saver_set_newline_type (GtkSourceFileSaver *saver,
if (saver->newline_type != newline_type)
{
saver->newline_type = newline_type;
- g_object_notify (G_OBJECT (saver), "newline-type");
+ g_object_notify_by_pspec (G_OBJECT (saver),
+ properties [PROP_NEWLINE_TYPE]);
}
}
@@ -1308,7 +1308,8 @@ gtk_source_file_saver_set_compression_type (GtkSourceFileSaver *saver,
if (saver->compression_type != compression_type)
{
saver->compression_type = compression_type;
- g_object_notify (G_OBJECT (saver), "compression-type");
+ g_object_notify_by_pspec (G_OBJECT (saver),
+ properties [PROP_COMPRESSION_TYPE]);
}
}
@@ -1344,7 +1345,8 @@ gtk_source_file_saver_set_flags (GtkSourceFileSaver *saver,
if (saver->flags != flags)
{
saver->flags = flags;
- g_object_notify (G_OBJECT (saver), "flags");
+ g_object_notify_by_pspec (G_OBJECT (saver),
+ properties [PROP_FLAGS]);
}
}
diff --git a/gtksourceview/gtksourcelanguagemanager.c b/gtksourceview/gtksourcelanguagemanager.c
index 28b91a78..2405b047 100644
--- a/gtksourceview/gtksourcelanguagemanager.c
+++ b/gtksourceview/gtksourcelanguagemanager.c
@@ -49,7 +49,8 @@
enum {
PROP_0,
PROP_SEARCH_PATH,
- PROP_LANGUAGE_IDS
+ PROP_LANGUAGE_IDS,
+ N_PROPS
};
struct _GtkSourceLanguageManager
@@ -65,6 +66,7 @@ struct _GtkSourceLanguageManager
};
static GtkSourceLanguageManager *default_instance;
+static GParamSpec *properties[N_PROPS];
G_DEFINE_TYPE (GtkSourceLanguageManager, gtk_source_language_manager, G_TYPE_OBJECT)
@@ -142,25 +144,27 @@ gtk_source_language_manager_class_init (GtkSourceLanguageManagerClass *klass)
object_class->set_property = gtk_source_language_manager_set_property;
object_class->get_property = gtk_source_language_manager_get_property;
- g_object_class_install_property (object_class,
- PROP_SEARCH_PATH,
- g_param_spec_boxed ("search-path",
- "Language specification directories",
- "List of directories where the "
- "language specification files (.lang) "
- "are located",
- G_TYPE_STRV,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_LANGUAGE_IDS,
- g_param_spec_boxed ("language-ids",
- "Language ids",
- "List of the ids of the available languages",
- G_TYPE_STRV,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_SEARCH_PATH] =
+ g_param_spec_boxed ("search-path",
+ "Language specification directories",
+ "List of directories where the "
+ "language specification files (.lang) "
+ "are located",
+ G_TYPE_STRV,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties[PROP_LANGUAGE_IDS] =
+ g_param_spec_boxed ("language-ids",
+ "Language ids",
+ "List of the ids of the available languages",
+ G_TYPE_STRV,
+ (G_PARAM_READABLE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -218,8 +222,8 @@ _gtk_source_language_manager_peek_default (void)
static void
notify_search_path (GtkSourceLanguageManager *mgr)
{
- g_object_notify (G_OBJECT (mgr), "search-path");
- g_object_notify (G_OBJECT (mgr), "language-ids");
+ g_object_notify_by_pspec (G_OBJECT (mgr), properties[PROP_SEARCH_PATH]);
+ g_object_notify_by_pspec (G_OBJECT (mgr), properties[PROP_LANGUAGE_IDS]);
}
/**
diff --git a/gtksourceview/gtksourcemarkattributes.c b/gtksourceview/gtksourcemarkattributes.c
index 2390bc00..915ce247 100644
--- a/gtksourceview/gtksourcemarkattributes.c
+++ b/gtksourceview/gtksourcemarkattributes.c
@@ -93,7 +93,8 @@ enum
PROP_BACKGROUND,
PROP_PIXBUF,
PROP_ICON_NAME,
- PROP_GICON
+ PROP_GICON,
+ N_PROPS
};
enum
@@ -104,6 +105,7 @@ enum
};
static guint signals[N_SIGNALS];
+static GParamSpec *properties[N_PROPS];
static void
gtk_source_mark_attributes_finalize (GObject *object)
@@ -126,7 +128,8 @@ set_background (GtkSourceMarkAttributes *attributes,
attributes->background_set = color != NULL;
- g_object_notify (G_OBJECT (attributes), "background");
+ g_object_notify_by_pspec (G_OBJECT (attributes),
+ properties [PROP_BACKGROUND]);
}
static void
@@ -142,7 +145,8 @@ set_icon_name (GtkSourceMarkAttributes *attributes,
gtk_source_pixbuf_helper_set_icon_name (attributes->helper,
icon_name);
- g_object_notify (G_OBJECT (attributes), "icon-name");
+ g_object_notify_by_pspec (G_OBJECT (attributes),
+ properties [PROP_ICON_NAME]);
}
static void
@@ -157,7 +161,8 @@ set_pixbuf (GtkSourceMarkAttributes *attributes,
gtk_source_pixbuf_helper_set_pixbuf (attributes->helper,
pixbuf);
- g_object_notify (G_OBJECT (attributes), "pixbuf");
+ g_object_notify_by_pspec (G_OBJECT (attributes),
+ properties [PROP_PIXBUF]);
}
static void
@@ -172,7 +177,8 @@ set_gicon (GtkSourceMarkAttributes *attributes,
gtk_source_pixbuf_helper_set_gicon (attributes->helper,
gicon);
- g_object_notify (G_OBJECT (attributes), "gicon");
+ g_object_notify_by_pspec (G_OBJECT (attributes),
+ properties [PROP_GICON]);
}
static void
@@ -185,21 +191,21 @@ gtk_source_mark_attributes_set_property (GObject *object,
switch (prop_id)
{
- case PROP_BACKGROUND:
- set_background (self, g_value_get_boxed (value));
- break;
- case PROP_PIXBUF:
- set_pixbuf (self, g_value_get_object (value));
- break;
- case PROP_ICON_NAME:
- set_icon_name (self, g_value_get_string (value));
- break;
- case PROP_GICON:
- set_gicon (self, g_value_get_object (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_BACKGROUND:
+ set_background (self, g_value_get_boxed (value));
+ break;
+ case PROP_PIXBUF:
+ set_pixbuf (self, g_value_get_object (value));
+ break;
+ case PROP_ICON_NAME:
+ set_icon_name (self, g_value_get_string (value));
+ break;
+ case PROP_GICON:
+ set_gicon (self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -213,31 +219,31 @@ gtk_source_mark_attributes_get_property (GObject *object,
switch (prop_id)
{
- case PROP_BACKGROUND:
- if (self->background_set)
- {
- g_value_set_boxed (value, &self->background);
- }
- else
- {
- g_value_set_boxed (value, NULL);
- }
- break;
- case PROP_PIXBUF:
- g_value_set_object (value,
- gtk_source_pixbuf_helper_get_pixbuf (self->helper));
- break;
- case PROP_ICON_NAME:
- g_value_set_string (value,
- gtk_source_pixbuf_helper_get_icon_name (self->helper));
- break;
- case PROP_GICON:
- g_value_set_object (value,
- gtk_source_pixbuf_helper_get_gicon (self->helper));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_BACKGROUND:
+ if (self->background_set)
+ {
+ g_value_set_boxed (value, &self->background);
+ }
+ else
+ {
+ g_value_set_boxed (value, NULL);
+ }
+ break;
+ case PROP_PIXBUF:
+ g_value_set_object (value,
+ gtk_source_pixbuf_helper_get_pixbuf (self->helper));
+ break;
+ case PROP_ICON_NAME:
+ g_value_set_string (value,
+ gtk_source_pixbuf_helper_get_icon_name (self->helper));
+ break;
+ case PROP_GICON:
+ g_value_set_object (value,
+ gtk_source_pixbuf_helper_get_gicon (self->helper));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -256,56 +262,58 @@ gtk_source_mark_attributes_class_init (GtkSourceMarkAttributesClass *klass)
*
* A color used for background of a line.
*/
- g_object_class_install_property (object_class,
- PROP_BACKGROUND,
- g_param_spec_boxed ("background",
- "Background",
- "The background",
- GDK_TYPE_RGBA,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_BACKGROUND] =
+ g_param_spec_boxed ("background",
+ "Background",
+ "The background",
+ GDK_TYPE_RGBA,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceMarkAttributes:pixbuf:
*
* A #GdkPixbuf that may be a base of a rendered icon.
*/
- g_object_class_install_property (object_class,
- PROP_PIXBUF,
- g_param_spec_object ("pixbuf",
- "Pixbuf",
- "The pixbuf",
- GDK_TYPE_PIXBUF,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_PIXBUF] =
+ g_param_spec_object ("pixbuf",
+ "Pixbuf",
+ "The pixbuf",
+ GDK_TYPE_PIXBUF,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceMarkAttributes:icon-name:
*
* An icon name that may be a base of a rendered icon.
*/
- g_object_class_install_property (object_class,
- PROP_ICON_NAME,
- g_param_spec_string ("icon-name",
- "Icon Name",
- "The icon name",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_ICON_NAME] =
+ g_param_spec_string ("icon-name",
+ "Icon Name",
+ "The icon name",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceMarkAttributes:gicon:
*
* A #GIcon that may be a base of a rendered icon.
*/
- g_object_class_install_property (object_class,
- PROP_GICON,
- g_param_spec_object ("gicon",
- "GIcon",
- "The GIcon",
- G_TYPE_ICON,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_GICON] =
+ g_param_spec_object ("gicon",
+ "GIcon",
+ "The GIcon",
+ G_TYPE_ICON,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
/**
* GtkSourceMarkAttributes::query-tooltip-text:
diff --git a/gtksourceview/gtksourceprintcompositor.c b/gtksourceview/gtksourceprintcompositor.c
index 4d9ecfcf..a07438ce 100644
--- a/gtksourceview/gtksourceprintcompositor.c
+++ b/gtksourceview/gtksourceprintcompositor.c
@@ -189,11 +189,14 @@ enum
PROP_LINE_NUMBERS_FONT_NAME,
PROP_HEADER_FONT_NAME,
PROP_FOOTER_FONT_NAME,
- PROP_N_PAGES
+ PROP_N_PAGES,
+ N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourcePrintCompositor, gtk_source_print_compositor, G_TYPE_OBJECT)
+static GParamSpec *properties[N_PROPS];
+
#define MM_PER_INCH 25.4
#define POINTS_PER_INCH 72
@@ -436,15 +439,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_BUFFER,
- g_param_spec_object ("buffer",
- "Source Buffer",
- "The GtkSourceBuffer object to print",
- GTK_SOURCE_TYPE_BUFFER,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties[PROP_BUFFER] =
+ g_param_spec_object ("buffer",
+ "Source Buffer",
+ "The GtkSourceBuffer object to print",
+ GTK_SOURCE_TYPE_BUFFER,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:tab-width:
@@ -456,16 +458,16 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_TAB_WIDTH,
- g_param_spec_uint ("tab-width",
- "Tab Width",
- "Width of a tab character expressed in spaces",
- 1,
- MAX_TAB_WIDTH,
- DEFAULT_TAB_WIDTH,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_TAB_WIDTH] =
+ g_param_spec_uint ("tab-width",
+ "Tab Width",
+ "Width of a tab character expressed in spaces",
+ 1,
+ MAX_TAB_WIDTH,
+ DEFAULT_TAB_WIDTH,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
@@ -478,15 +480,15 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_WRAP_MODE,
- g_param_spec_enum ("wrap-mode",
- "Wrap Mode",
- "",
- GTK_TYPE_WRAP_MODE,
- GTK_WRAP_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_WRAP_MODE] =
+ g_param_spec_enum ("wrap-mode",
+ "Wrap Mode",
+ "",
+ GTK_TYPE_WRAP_MODE,
+ GTK_WRAP_NONE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:highlight-syntax:
@@ -498,14 +500,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_HIGHLIGHT_SYNTAX,
- g_param_spec_boolean ("highlight-syntax",
- "Highlight Syntax",
- "",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_HIGHLIGHT_SYNTAX] =
+ g_param_spec_boolean ("highlight-syntax",
+ "Highlight Syntax",
+ "",
+ TRUE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:print-line-numbers:
@@ -519,14 +521,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_PRINT_LINE_NUMBERS,
- g_param_spec_uint ("print-line-numbers",
- "Print Line Numbers",
- "",
- 0, 100, 1,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_PRINT_LINE_NUMBERS] =
+ g_param_spec_uint ("print-line-numbers",
+ "Print Line Numbers",
+ "",
+ 0, 100, 1,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:print-header:
@@ -542,14 +544,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_PRINT_HEADER,
- g_param_spec_boolean ("print-header",
- "Print Header",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_PRINT_HEADER] =
+ g_param_spec_boolean ("print-header",
+ "Print Header",
+ "",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:print-footer:
@@ -565,14 +567,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_PRINT_FOOTER,
- g_param_spec_boolean ("print-footer",
- "Print Footer",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_PRINT_FOOTER] =
+ g_param_spec_boolean ("print-footer",
+ "Print Footer",
+ "",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:body-font-name:
@@ -588,14 +590,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_BODY_FONT_NAME,
- g_param_spec_string ("body-font-name",
- "Body Font Name",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_BODY_FONT_NAME] =
+ g_param_spec_string ("body-font-name",
+ "Body Font Name",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:line-numbers-font-name:
@@ -612,14 +614,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_LINE_NUMBERS_FONT_NAME,
- g_param_spec_string ("line-numbers-font-name",
- "Line Numbers Font Name",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_LINE_NUMBERS_FONT_NAME] =
+ g_param_spec_string ("line-numbers-font-name",
+ "Line Numbers Font Name",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:header-font-name:
@@ -636,14 +638,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_HEADER_FONT_NAME,
- g_param_spec_string ("header-font-name",
- "Header Font Name",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_HEADER_FONT_NAME] =
+ g_param_spec_string ("header-font-name",
+ "Header Font Name",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:footer-font-name:
@@ -660,14 +662,14 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_FOOTER_FONT_NAME,
- g_param_spec_string ("footer-font-name",
- "Footer Font Name",
- "",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_FOOTER_FONT_NAME] =
+ g_param_spec_string ("footer-font-name",
+ "Footer Font Name",
+ "",
+ NULL,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourcePrintCompositor:n-pages:
@@ -677,14 +679,15 @@ gtk_source_print_compositor_class_init (GtkSourcePrintCompositorClass *klass)
*
* Since: 2.2
*/
- g_object_class_install_property (object_class,
- PROP_N_PAGES,
- g_param_spec_int ("n-pages",
- "Number of pages",
- "",
- -1, G_MAXINT, -1,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_N_PAGES] =
+ g_param_spec_int ("n-pages",
+ "Number of pages",
+ "",
+ -1, G_MAXINT, -1,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -811,7 +814,6 @@ gtk_source_print_compositor_new_from_view (GtkSourceView *view)
font_desc = pango_context_get_font_description (pango_context);
priv->body_font = pango_font_description_copy (font_desc);
- g_object_notify (G_OBJECT (compositor), "body-font-name"); /* FIXME: is this needed? */
return compositor;
}
@@ -865,7 +867,8 @@ gtk_source_print_compositor_set_tab_width (GtkSourcePrintCompositor *compositor,
priv->tab_width = width;
- g_object_notify (G_OBJECT (compositor), "tab-width");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_TAB_WIDTH]);
}
/**
@@ -914,7 +917,8 @@ gtk_source_print_compositor_set_wrap_mode (GtkSourcePrintCompositor *compositor,
priv->wrap_mode = wrap_mode;
- g_object_notify (G_OBJECT (compositor), "wrap-mode");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_WRAP_MODE]);
}
/**
@@ -966,7 +970,8 @@ gtk_source_print_compositor_set_highlight_syntax (GtkSourcePrintCompositor *comp
priv->highlight_syntax = highlight;
- g_object_notify (G_OBJECT (compositor), "highlight-syntax");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_HIGHLIGHT_SYNTAX]);
}
/**
@@ -1022,7 +1027,8 @@ gtk_source_print_compositor_set_print_line_numbers (GtkSourcePrintCompositor *co
priv->print_line_numbers = interval;
- g_object_notify (G_OBJECT (compositor), "print-line-numbers");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_PRINT_LINE_NUMBERS]);
}
/**
@@ -1059,7 +1065,8 @@ gtk_source_print_compositor_set_print_header (GtkSourcePrintCompositor *composit
priv->print_header = print;
- g_object_notify (G_OBJECT (compositor), "print-header");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_PRINT_HEADER]);
}
/**
@@ -1119,7 +1126,8 @@ gtk_source_print_compositor_set_print_footer (GtkSourcePrintCompositor *composit
priv->print_footer = print;
- g_object_notify (G_OBJECT (compositor), "print-footer");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_PRINT_FOOTER]);
}
/**
@@ -1323,7 +1331,8 @@ gtk_source_print_compositor_set_body_font_name (GtkSourcePrintCompositor *compos
&priv->body_font,
font_name))
{
- g_object_notify (G_OBJECT (compositor), "body-font-name");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_BODY_FONT_NAME]);
}
}
@@ -1382,7 +1391,8 @@ gtk_source_print_compositor_set_line_numbers_font_name (GtkSourcePrintCompositor
&priv->line_numbers_font,
font_name))
{
- g_object_notify (G_OBJECT (compositor), "line-numbers-font-name");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_LINE_NUMBERS_FONT_NAME]);
}
}
@@ -1448,7 +1458,8 @@ gtk_source_print_compositor_set_header_font_name (GtkSourcePrintCompositor *comp
font_name))
{
- g_object_notify (G_OBJECT (compositor), "header-font-name");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_HEADER_FONT_NAME]);
}
}
@@ -1514,7 +1525,8 @@ gtk_source_print_compositor_set_footer_font_name (GtkSourcePrintCompositor *comp
font_name))
{
- g_object_notify (G_OBJECT (compositor), "footer-font-name");
+ g_object_notify_by_pspec (G_OBJECT (compositor),
+ properties [PROP_FOOTER_FONT_NAME]);
}
}
diff --git a/gtksourceview/gtksourcesearchcontext.c b/gtksourceview/gtksourcesearchcontext.c
index d2ea3059..a746d084 100644
--- a/gtksourceview/gtksourcesearchcontext.c
+++ b/gtksourceview/gtksourcesearchcontext.c
@@ -298,7 +298,8 @@ enum
PROP_HIGHLIGHT,
PROP_MATCH_STYLE,
PROP_OCCURRENCES_COUNT,
- PROP_REGEX_ERROR
+ PROP_REGEX_ERROR,
+ N_PROPS
};
struct _GtkSourceSearchContext
@@ -368,6 +369,8 @@ typedef struct
G_DEFINE_TYPE (GtkSourceSearchContext, gtk_source_search_context, G_TYPE_OBJECT)
+static GParamSpec *properties[N_PROPS];
+
static void install_idle_scan (GtkSourceSearchContext *search);
#ifdef ENABLE_DEBUG
@@ -541,7 +544,7 @@ clear_search (GtkSourceSearchContext *search)
if (search->regex_error != NULL)
{
g_clear_error (&search->regex_error);
- g_object_notify (G_OBJECT (search), "regex-error");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_REGEX_ERROR]);
}
clear_task (search);
@@ -766,7 +769,7 @@ basic_forward_regex_search (GtkSourceSearchContext *search,
if (search->regex_error != NULL)
{
- g_object_notify (G_OBJECT (search), "regex-error");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_REGEX_ERROR]);
found = FALSE;
}
@@ -1756,7 +1759,8 @@ idle_scan_normal_search (GtkSourceSearchContext *search)
{
search->idle_scan_id = 0;
- g_object_notify (G_OBJECT (search), "occurrences-count");
+ g_object_notify_by_pspec (G_OBJECT (search),
+ properties [PROP_OCCURRENCES_COUNT]);
g_clear_object (&search->scan_region);
return G_SOURCE_REMOVE;
@@ -1926,7 +1930,7 @@ regex_search_scan_segment (GtkSourceSearchContext *search,
if (search->regex_error != NULL)
{
- g_object_notify (G_OBJECT (search), "regex-error");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_REGEX_ERROR]);
}
if (g_match_info_is_partial_match (match_info))
@@ -2055,7 +2059,8 @@ idle_scan_regex_search (GtkSourceSearchContext *search)
{
search->idle_scan_id = 0;
- g_object_notify (G_OBJECT (search), "occurrences-count");
+ g_object_notify_by_pspec (G_OBJECT (search),
+ properties [PROP_OCCURRENCES_COUNT]);
g_clear_object (&search->scan_region);
return G_SOURCE_REMOVE;
@@ -2364,7 +2369,7 @@ update_regex (GtkSourceSearchContext *search)
if (regex_error_changed)
{
- g_object_notify (G_OBJECT (search), "regex-error");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_REGEX_ERROR]);
}
}
@@ -2637,7 +2642,8 @@ set_settings (GtkSourceSearchContext *search,
search_text_updated (search);
update (search);
- g_object_notify (G_OBJECT (search), "settings");
+ g_object_notify_by_pspec (G_OBJECT (search),
+ properties [PROP_SETTINGS]);
}
static void
@@ -2720,7 +2726,7 @@ gtk_source_search_context_get_property (GObject *object,
break;
case PROP_REGEX_ERROR:
- g_value_set_pointer (value, gtk_source_search_context_get_regex_error (search));
+ g_value_take_boxed (value, gtk_source_search_context_get_regex_error (search));
break;
default:
@@ -2782,15 +2788,14 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.10
*/
- g_object_class_install_property (object_class,
- PROP_BUFFER,
- g_param_spec_object ("buffer",
- "Buffer",
- "The associated GtkSourceBuffer",
- GTK_SOURCE_TYPE_BUFFER,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_BUFFER] =
+ g_param_spec_object ("buffer",
+ "Buffer",
+ "The associated GtkSourceBuffer",
+ GTK_SOURCE_TYPE_BUFFER,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceSearchContext:settings:
@@ -2801,15 +2806,14 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.10
*/
- g_object_class_install_property (object_class,
- PROP_SETTINGS,
- g_param_spec_object ("settings",
- "Settings",
- "The associated GtkSourceSearchSettings",
- GTK_SOURCE_TYPE_SEARCH_SETTINGS,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SETTINGS] =
+ g_param_spec_object ("settings",
+ "Settings",
+ "The associated GtkSourceSearchSettings",
+ GTK_SOURCE_TYPE_SEARCH_SETTINGS,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceSearchContext:highlight:
@@ -2818,15 +2822,14 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.10
*/
- g_object_class_install_property (object_class,
- PROP_HIGHLIGHT,
- g_param_spec_boolean ("highlight",
- "Highlight",
- "Highlight search occurrences",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_HIGHLIGHT] =
+ g_param_spec_boolean ("highlight",
+ "Highlight",
+ "Highlight search occurrences",
+ TRUE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceSearchContext:match-style:
@@ -2835,15 +2838,14 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.16
*/
- g_object_class_install_property (object_class,
- PROP_MATCH_STYLE,
- g_param_spec_object ("match-style",
- "Match style",
- "The text style for matches",
- GTK_SOURCE_TYPE_STYLE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_MATCH_STYLE] =
+ g_param_spec_object ("match-style",
+ "Match style",
+ "The text style for matches",
+ GTK_SOURCE_TYPE_STYLE,
+ (G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceSearchContext:occurrences-count:
@@ -2854,16 +2856,15 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.10
*/
- g_object_class_install_property (object_class,
- PROP_OCCURRENCES_COUNT,
- g_param_spec_int ("occurrences-count",
- "Occurrences count",
- "Total number of search occurrences",
- -1,
- G_MAXINT,
- 0,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_OCCURRENCES_COUNT] =
+ g_param_spec_int ("occurrences-count",
+ "Occurrences count",
+ "Total number of search occurrences",
+ -1,
+ G_MAXINT,
+ 0,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceSearchContext:regex-error:
@@ -2876,13 +2877,15 @@ gtk_source_search_context_class_init (GtkSourceSearchContextClass *klass)
*
* Since: 3.10
*/
- g_object_class_install_property (object_class,
- PROP_REGEX_ERROR,
- g_param_spec_pointer ("regex-error",
- "Regex error",
- "Regular expression error",
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_REGEX_ERROR] =
+ g_param_spec_boxed ("regex-error",
+ "Regex error",
+ "Regular expression error",
+ G_TYPE_ERROR,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -2984,7 +2987,7 @@ gtk_source_search_context_set_highlight (GtkSourceSearchContext *search,
search->highlight = highlight;
sync_found_tag (search);
- g_object_notify (G_OBJECT (search), "highlight");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_HIGHLIGHT]);
}
}
@@ -3040,7 +3043,7 @@ gtk_source_search_context_set_match_style (GtkSourceSearchContext *search,
g_object_ref (match_style);
}
- g_object_notify (G_OBJECT (search), "match-style");
+ g_object_notify_by_pspec (G_OBJECT (search), properties [PROP_MATCH_STYLE]);
}
/**
@@ -3048,12 +3051,14 @@ gtk_source_search_context_set_match_style (GtkSourceSearchContext *search,
* @search: a #GtkSourceSearchContext.
*
* Regular expression patterns must follow certain rules. If
- * #GtkSourceSearchSettings:search-text breaks a rule, the error can be retrieved
- * with this function. The error domain is #G_REGEX_ERROR.
+ * #GtkSourceSearchSettings:search-text breaks a rule, the error can be
+ * retrieved with this function. The error domain is #G_REGEX_ERROR.
*
* Free the return value with g_error_free().
*
- * Returns: (nullable): the #GError, or %NULL if the pattern is valid.
+ * Returns: (transfer full) (nullable): the #GError, or %NULL if the
+ * pattern is valid.
+ *
* Since: 3.10
*/
GError *
diff --git a/gtksourceview/gtksourcestyleschememanager.c b/gtksourceview/gtksourcestyleschememanager.c
index 83f7443a..8d6c937b 100644
--- a/gtksourceview/gtksourcestyleschememanager.c
+++ b/gtksourceview/gtksourcestyleschememanager.c
@@ -52,10 +52,12 @@ struct _GtkSourceStyleSchemeManager
enum {
PROP_0,
PROP_SEARCH_PATH,
- PROP_SCHEME_IDS
+ PROP_SCHEME_IDS,
+ N_PROPS
};
static GtkSourceStyleSchemeManager *default_instance;
+static GParamSpec *properties[N_PROPS];
G_DEFINE_TYPE (GtkSourceStyleSchemeManager, gtk_source_style_scheme_manager, G_TYPE_OBJECT)
@@ -65,22 +67,18 @@ gtk_source_style_scheme_manager_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GtkSourceStyleSchemeManager *sm;
-
- sm = GTK_SOURCE_STYLE_SCHEME_MANAGER (object);
+ GtkSourceStyleSchemeManager *sm = GTK_SOURCE_STYLE_SCHEME_MANAGER (object);
switch (prop_id)
{
- case PROP_SEARCH_PATH:
- gtk_source_style_scheme_manager_set_search_path
- (sm, g_value_get_boxed (value));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
- prop_id,
- pspec);
- break;
+ case PROP_SEARCH_PATH:
+ gtk_source_style_scheme_manager_set_search_path (sm,
+ g_value_get_boxed (value));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -90,27 +88,23 @@ gtk_source_style_scheme_manager_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GtkSourceStyleSchemeManager *sm;
-
- sm = GTK_SOURCE_STYLE_SCHEME_MANAGER (object);
+ GtkSourceStyleSchemeManager *sm = GTK_SOURCE_STYLE_SCHEME_MANAGER (object);
switch (prop_id)
{
- case PROP_SEARCH_PATH:
- g_value_set_boxed (value,
- gtk_source_style_scheme_manager_get_search_path (sm));
- break;
-
- case PROP_SCHEME_IDS:
- g_value_set_boxed (value,
- gtk_source_style_scheme_manager_get_scheme_ids (sm));
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
- prop_id,
- pspec);
- break;
+ case PROP_SEARCH_PATH:
+ g_value_set_boxed (value,
+ gtk_source_style_scheme_manager_get_search_path (sm));
+ break;
+
+ case PROP_SCHEME_IDS:
+ g_value_set_boxed (value,
+ gtk_source_style_scheme_manager_get_scheme_ids (sm));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -150,21 +144,24 @@ gtk_source_style_scheme_manager_class_init (GtkSourceStyleSchemeManagerClass *kl
object_class->set_property = gtk_source_style_scheme_manager_set_property;
object_class->get_property = gtk_source_style_scheme_manager_get_property;
- g_object_class_install_property (object_class,
- PROP_SEARCH_PATH,
- g_param_spec_boxed ("search-path",
- "Style scheme search path",
- "List of directories and files where the style
schemes are located",
- G_TYPE_STRV,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class,
- PROP_SCHEME_IDS,
- g_param_spec_boxed ("scheme-ids",
- "Scheme ids",
- "List of the ids of the available style schemes",
- G_TYPE_STRV,
- G_PARAM_READABLE));
+ properties [PROP_SEARCH_PATH] =
+ g_param_spec_boxed ("search-path",
+ "Style scheme search path",
+ "List of directories and files where the style schemes are located",
+ G_TYPE_STRV,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_SCHEME_IDS] =
+ g_param_spec_boxed ("scheme-ids",
+ "Scheme ids",
+ "List of the ids of the available style schemes",
+ G_TYPE_STRV,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@@ -400,8 +397,8 @@ notify_search_path (GtkSourceStyleSchemeManager *mgr)
{
mgr->need_reload = TRUE;
- g_object_notify (G_OBJECT (mgr), "search-path");
- g_object_notify (G_OBJECT (mgr), "scheme-ids");
+ g_object_notify_by_pspec (G_OBJECT (mgr), properties [PROP_SEARCH_PATH]);
+ g_object_notify_by_pspec (G_OBJECT (mgr), properties [PROP_SCHEME_IDS]);
}
/**
@@ -542,7 +539,7 @@ gtk_source_style_scheme_manager_force_rescan (GtkSourceStyleSchemeManager *manag
manager->need_reload = TRUE;
- g_object_notify (G_OBJECT (manager), "scheme-ids");
+ g_object_notify_by_pspec (G_OBJECT (manager), properties[PROP_SCHEME_IDS]);
}
/**
diff --git a/gtksourceview/gtksourcetag.c b/gtksourceview/gtksourcetag.c
index 279525ee..5eced477 100644
--- a/gtksourceview/gtksourcetag.c
+++ b/gtksourceview/gtksourcetag.c
@@ -47,10 +47,13 @@ enum
PROP_0,
PROP_DRAW_SPACES,
PROP_DRAW_SPACES_SET,
+ N_PROPS
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkSourceTag, gtk_source_tag, GTK_TYPE_TEXT_TAG)
+static GParamSpec *properties[N_PROPS];
+
static void
gtk_source_tag_get_property (GObject *object,
guint prop_id,
@@ -92,19 +95,20 @@ gtk_source_tag_set_property (GObject *object,
switch (prop_id)
{
- case PROP_DRAW_SPACES:
- priv->draw_spaces = g_value_get_boolean (value);
- priv->draw_spaces_set = TRUE;
- g_object_notify (object, "draw-spaces-set");
- break;
-
- case PROP_DRAW_SPACES_SET:
- priv->draw_spaces_set = g_value_get_boolean (value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_DRAW_SPACES:
+ priv->draw_spaces = g_value_get_boolean (value);
+ priv->draw_spaces_set = TRUE;
+ g_object_notify_by_pspec (object,
+ properties[PROP_DRAW_SPACES_SET]);
+ break;
+
+ case PROP_DRAW_SPACES_SET:
+ priv->draw_spaces_set = g_value_get_boolean (value);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
gtk_text_tag_changed (GTK_TEXT_TAG (tag), size_changed);
@@ -130,14 +134,14 @@ gtk_source_tag_class_init (GtkSourceTagClass *klass)
*
* Since: 3.20
*/
- g_object_class_install_property (object_class,
- PROP_DRAW_SPACES,
- g_param_spec_boolean ("draw-spaces",
- "Draw Spaces",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_DRAW_SPACES] =
+ g_param_spec_boolean ("draw-spaces",
+ "Draw Spaces",
+ "",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceTag:draw-spaces-set:
@@ -147,14 +151,16 @@ gtk_source_tag_class_init (GtkSourceTagClass *klass)
*
* Since: 3.20
*/
- g_object_class_install_property (object_class,
- PROP_DRAW_SPACES_SET,
- g_param_spec_boolean ("draw-spaces-set",
- "Draw Spaces Set",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_DRAW_SPACES_SET] =
+ g_param_spec_boolean ("draw-spaces-set",
+ "Draw Spaces Set",
+ "",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 5a165bdc..4ddf8260 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -178,9 +178,12 @@ enum
PROP_INDENT_ON_TAB,
PROP_BACKGROUND_PATTERN,
PROP_SMART_BACKSPACE,
- PROP_SPACE_DRAWER
+ PROP_SPACE_DRAWER,
+ N_PROPS
};
+static GParamSpec *properties[N_PROPS];
+
typedef struct
{
GtkSourceStyleScheme *style_scheme;
@@ -512,122 +515,121 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
*
* The completion object associated with the view
*/
- g_object_class_install_property (object_class,
- PROP_COMPLETION,
- g_param_spec_object ("completion",
- "Completion",
- "The completion object associated with the
view",
- GTK_SOURCE_TYPE_COMPLETION,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_COMPLETION] =
+ g_param_spec_object ("completion",
+ "Completion",
+ "The completion object associated with the view",
+ GTK_SOURCE_TYPE_COMPLETION,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:show-line-numbers:
*
* Whether to display line numbers
*/
- g_object_class_install_property (object_class,
- PROP_SHOW_LINE_NUMBERS,
- g_param_spec_boolean ("show-line-numbers",
- "Show Line Numbers",
- "Whether to display line numbers",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SHOW_LINE_NUMBERS] =
+ g_param_spec_boolean ("show-line-numbers",
+ "Show Line Numbers",
+ "Whether to display line numbers",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:show-line-marks:
*
* Whether to display line mark pixbufs
*/
- g_object_class_install_property (object_class,
- PROP_SHOW_LINE_MARKS,
- g_param_spec_boolean ("show-line-marks",
- "Show Line Marks",
- "Whether to display line mark pixbufs",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SHOW_LINE_MARKS] =
+ g_param_spec_boolean ("show-line-marks",
+ "Show Line Marks",
+ "Whether to display line mark pixbufs",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:tab-width:
*
* Width of a tab character expressed in number of spaces.
*/
- g_object_class_install_property (object_class,
- PROP_TAB_WIDTH,
- g_param_spec_uint ("tab-width",
- "Tab Width",
- "Width of a tab character expressed in spaces",
- 1,
- MAX_TAB_WIDTH,
- DEFAULT_TAB_WIDTH,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_TAB_WIDTH] =
+ g_param_spec_uint ("tab-width",
+ "Tab Width",
+ "Width of a tab character expressed in spaces",
+ 1,
+ MAX_TAB_WIDTH,
+ DEFAULT_TAB_WIDTH,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:indent-width:
*
* Width of an indentation step expressed in number of spaces.
*/
- g_object_class_install_property (object_class,
- PROP_INDENT_WIDTH,
- g_param_spec_int ("indent-width",
- "Indent Width",
- "Number of spaces to use for each step of indent",
- -1,
- MAX_INDENT_WIDTH,
- -1,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_AUTO_INDENT,
- g_param_spec_boolean ("auto-indent",
- "Auto Indentation",
- "Whether to enable auto indentation",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_INSERT_SPACES,
- g_param_spec_boolean ("insert-spaces-instead-of-tabs",
- "Insert Spaces Instead of Tabs",
- "Whether to insert spaces instead of tabs",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_INDENT_WIDTH] =
+ g_param_spec_int ("indent-width",
+ "Indent Width",
+ "Number of spaces to use for each step of indent",
+ -1,
+ MAX_INDENT_WIDTH,
+ -1,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_AUTO_INDENT] =
+ g_param_spec_boolean ("auto-indent",
+ "Auto Indentation",
+ "Whether to enable auto indentation",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_INSERT_SPACES] =
+ g_param_spec_boolean ("insert-spaces-instead-of-tabs",
+ "Insert Spaces Instead of Tabs",
+ "Whether to insert spaces instead of tabs",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:show-right-margin:
*
* Whether to display the right margin.
*/
- g_object_class_install_property (object_class,
- PROP_SHOW_RIGHT_MARGIN,
- g_param_spec_boolean ("show-right-margin",
- "Show Right Margin",
- "Whether to display the right margin",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SHOW_RIGHT_MARGIN] =
+ g_param_spec_boolean ("show-right-margin",
+ "Show Right Margin",
+ "Whether to display the right margin",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:right-margin-position:
*
* Position of the right margin.
*/
- g_object_class_install_property (object_class,
- PROP_RIGHT_MARGIN_POSITION,
- g_param_spec_uint ("right-margin-position",
- "Right Margin Position",
- "Position of the right margin",
- 1,
- MAX_RIGHT_MARGIN_POSITION,
- DEFAULT_RIGHT_MARGIN_POSITION,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_RIGHT_MARGIN_POSITION] =
+ g_param_spec_uint ("right-margin-position",
+ "Right Margin Position",
+ "Position of the right margin",
+ 1,
+ MAX_RIGHT_MARGIN_POSITION,
+ DEFAULT_RIGHT_MARGIN_POSITION,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:smart-home-end:
@@ -636,35 +638,35 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
*
* Since: 2.0
*/
- g_object_class_install_property (object_class,
- PROP_SMART_HOME_END,
- g_param_spec_enum ("smart-home-end",
- "Smart Home/End",
- "HOME and END keys move to first/last "
- "non whitespace characters on line before going "
- "to the start/end of the line",
- GTK_SOURCE_TYPE_SMART_HOME_END_TYPE,
- GTK_SOURCE_SMART_HOME_END_DISABLED,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_HIGHLIGHT_CURRENT_LINE,
- g_param_spec_boolean ("highlight-current-line",
- "Highlight current line",
- "Whether to highlight the current line",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_INDENT_ON_TAB,
- g_param_spec_boolean ("indent-on-tab",
- "Indent on tab",
- "Whether to indent the selected text when the
tab key is pressed",
- TRUE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SMART_HOME_END] =
+ g_param_spec_enum ("smart-home-end",
+ "Smart Home/End",
+ "HOME and END keys move to first/last "
+ "non whitespace characters on line before going "
+ "to the start/end of the line",
+ GTK_SOURCE_TYPE_SMART_HOME_END_TYPE,
+ GTK_SOURCE_SMART_HOME_END_DISABLED,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_HIGHLIGHT_CURRENT_LINE] =
+ g_param_spec_boolean ("highlight-current-line",
+ "Highlight current line",
+ "Whether to highlight the current line",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
+
+ properties [PROP_INDENT_ON_TAB] =
+ g_param_spec_boolean ("indent-on-tab",
+ "Indent on tab",
+ "Whether to indent the selected text when the tab key is pressed",
+ TRUE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:background-pattern:
@@ -673,15 +675,15 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
*
* Since: 3.16
*/
- g_object_class_install_property (object_class,
- PROP_BACKGROUND_PATTERN,
- g_param_spec_enum ("background-pattern",
- "Background pattern",
- "Draw a specific background pattern on the view",
- GTK_SOURCE_TYPE_BACKGROUND_PATTERN_TYPE,
- GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_BACKGROUND_PATTERN] =
+ g_param_spec_enum ("background-pattern",
+ "Background pattern",
+ "Draw a specific background pattern on the view",
+ GTK_SOURCE_TYPE_BACKGROUND_PATTERN_TYPE,
+ GTK_SOURCE_BACKGROUND_PATTERN_TYPE_NONE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:smart-backspace:
@@ -690,14 +692,14 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
*
* Since: 3.18
*/
- g_object_class_install_property (object_class,
- PROP_SMART_BACKSPACE,
- g_param_spec_boolean ("smart-backspace",
- "Smart Backspace",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SMART_BACKSPACE] =
+ g_param_spec_boolean ("smart-backspace",
+ "Smart Backspace",
+ "",
+ FALSE,
+ (G_PARAM_READWRITE |
+ G_PARAM_EXPLICIT_NOTIFY |
+ G_PARAM_STATIC_STRINGS));
/**
* GtkSourceView:space-drawer:
@@ -706,14 +708,15 @@ gtk_source_view_class_init (GtkSourceViewClass *klass)
*
* Since: 3.24
*/
- g_object_class_install_property (object_class,
- PROP_SPACE_DRAWER,
- g_param_spec_object ("space-drawer",
- "Space Drawer",
- "",
- GTK_SOURCE_TYPE_SPACE_DRAWER,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ properties [PROP_SPACE_DRAWER] =
+ g_param_spec_object ("space-drawer",
+ "Space Drawer",
+ "",
+ GTK_SOURCE_TYPE_SPACE_DRAWER,
+ (G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_properties (object_class, N_PROPS, properties);
/**
* GtkSourceView::show-completion:
@@ -2742,7 +2745,8 @@ gtk_source_view_set_show_line_numbers (GtkSourceView *view,
gtk_widget_set_visible (GTK_WIDGET (priv->line_renderer), show);
priv->show_line_numbers = show;
- g_object_notify (G_OBJECT (view), "show_line_numbers");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_SHOW_LINE_NUMBERS]);
}
/**
@@ -2823,7 +2827,8 @@ gtk_source_view_set_show_line_marks (GtkSourceView *view,
gtk_widget_set_visible (GTK_WIDGET (priv->marks_renderer), show);
priv->show_line_marks = show;
- g_object_notify (G_OBJECT (view), "show_line_marks");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_SHOW_LINE_MARKS]);
}
static gboolean
@@ -2880,7 +2885,8 @@ gtk_source_view_set_tab_width (GtkSourceView *view,
priv->tab_width = width;
if (set_tab_stops_internal (view))
{
- g_object_notify (G_OBJECT (view), "tab-width");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_TAB_WIDTH]);
}
else
{
@@ -2945,7 +2951,8 @@ gtk_source_view_set_indent_width (GtkSourceView *view,
if (priv->indent_width != width)
{
priv->indent_width = width;
- g_object_notify (G_OBJECT (view), "indent-width");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_INDENT_WIDTH]);
}
}
@@ -4010,7 +4017,8 @@ gtk_source_view_set_auto_indent (GtkSourceView *view,
if (priv->auto_indent != enable)
{
priv->auto_indent = enable;
- g_object_notify (G_OBJECT (view), "auto_indent");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_AUTO_INDENT]);
}
}
@@ -4055,7 +4063,8 @@ gtk_source_view_set_insert_spaces_instead_of_tabs (GtkSourceView *view,
if (priv->insert_spaces != enable)
{
priv->insert_spaces = enable;
- g_object_notify (G_OBJECT (view), "insert_spaces_instead_of_tabs");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_INSERT_SPACES]);
}
}
@@ -4106,7 +4115,8 @@ gtk_source_view_set_indent_on_tab (GtkSourceView *view,
if (priv->indent_on_tab != enable)
{
priv->indent_on_tab = enable;
- g_object_notify (G_OBJECT (view), "indent_on_tab");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_INDENT_ON_TAB]);
}
}
@@ -4258,7 +4268,8 @@ gtk_source_view_set_highlight_current_line (GtkSourceView *view,
gtk_source_view_queue_draw (view);
- g_object_notify (G_OBJECT (view), "highlight_current_line");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_HIGHLIGHT_CURRENT_LINE]);
}
}
@@ -4303,7 +4314,8 @@ gtk_source_view_set_show_right_margin (GtkSourceView *view,
gtk_source_view_queue_draw (view);
- g_object_notify (G_OBJECT (view), "show-right-margin");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_SHOW_RIGHT_MARGIN]);
}
}
@@ -4348,7 +4360,8 @@ gtk_source_view_set_right_margin_position (GtkSourceView *view,
gtk_source_view_queue_draw (view);
- g_object_notify (G_OBJECT (view), "right-margin-position");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_RIGHT_MARGIN_POSITION]);
}
}
@@ -4375,7 +4388,8 @@ gtk_source_view_set_smart_backspace (GtkSourceView *view,
if (smart_backspace != priv->smart_backspace)
{
priv->smart_backspace = smart_backspace;
- g_object_notify (G_OBJECT (view), "smart-backspace");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_SMART_BACKSPACE]);
}
}
@@ -4419,7 +4433,8 @@ gtk_source_view_set_smart_home_end (GtkSourceView *view,
if (priv->smart_home_end != smart_home_end)
{
priv->smart_home_end = smart_home_end;
- g_object_notify (G_OBJECT (view), "smart_home_end");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_SMART_HOME_END]);
}
}
@@ -4872,7 +4887,8 @@ gtk_source_view_set_background_pattern (GtkSourceView *view,
gtk_source_view_queue_draw (view);
- g_object_notify (G_OBJECT (view), "background-pattern");
+ g_object_notify_by_pspec (G_OBJECT (view),
+ properties [PROP_BACKGROUND_PATTERN]);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]