[gtksourceview] CompletionWords: modernize a bit the code dealing with properties



commit 1ab030d9b5cfe97c08ecbbce74e15ddc2ed14f34
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Jun 13 13:52:38 2016 +0200

    CompletionWords: modernize a bit the code dealing with properties
    
    - Use g_object_class_install_properties().
    - Use G_PARAM_STATIC_STRINGS.
    
    Start with CompletionWords because it's the first in git grep.

 .../words/gtksourcecompletionwords.c               |  153 ++++++++++----------
 1 files changed, 74 insertions(+), 79 deletions(-)
---
diff --git a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c 
b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
index e6877c7..5b44587 100644
--- a/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
+++ b/gtksourceview/completion-providers/words/gtksourcecompletionwords.c
@@ -49,7 +49,6 @@
 enum
 {
        PROP_0,
-
        PROP_NAME,
        PROP_ICON,
        PROP_PROPOSALS_BATCH_SIZE,
@@ -57,7 +56,8 @@ enum
        PROP_MINIMUM_WORD_SIZE,
        PROP_INTERACTIVE_DELAY,
        PROP_PRIORITY,
-       PROP_ACTIVATION
+       PROP_ACTIVATION,
+       N_PROPERTIES
 };
 
 struct _GtkSourceCompletionWordsPrivate
@@ -92,6 +92,8 @@ typedef struct
        GtkSourceCompletionWordsBuffer *buffer;
 } BufferBinding;
 
+static GParamSpec *properties[N_PROPERTIES];
+
 static void gtk_source_completion_words_iface_init (GtkSourceCompletionProviderIface *iface);
 
 G_DEFINE_TYPE_WITH_CODE (GtkSourceCompletionWords,
@@ -423,76 +425,68 @@ gtk_source_completion_words_class_init (GtkSourceCompletionWordsClass *klass)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-       object_class->dispose = gtk_source_completion_words_dispose;
-
-       object_class->set_property = gtk_source_completion_words_set_property;
        object_class->get_property = gtk_source_completion_words_get_property;
+       object_class->set_property = gtk_source_completion_words_set_property;
+       object_class->dispose = gtk_source_completion_words_dispose;
 
-       g_object_class_install_property (object_class,
-                                        PROP_NAME,
-                                        g_param_spec_string ("name",
-                                                             "Name",
-                                                             "The provider name",
-                                                             NULL,
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_ICON,
-                                        g_param_spec_object ("icon",
-                                                             "Icon",
-                                                             "The provider icon",
-                                                             GDK_TYPE_PIXBUF,
-                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_PROPOSALS_BATCH_SIZE,
-                                        g_param_spec_uint ("proposals-batch-size",
-                                                           "Proposals Batch Size",
-                                                           "Number of proposals added in one batch",
-                                                           1,
-                                                           G_MAXUINT,
-                                                           300,
-                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_SCAN_BATCH_SIZE,
-                                        g_param_spec_uint ("scan-batch-size",
-                                                           "Scan Batch Size",
-                                                           "Number of lines scanned in one batch",
-                                                           1,
-                                                           G_MAXUINT,
-                                                           50,
-                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_MINIMUM_WORD_SIZE,
-                                        g_param_spec_uint ("minimum-word-size",
-                                                           "Minimum Word Size",
-                                                           "The minimum word size to complete",
-                                                           2,
-                                                           G_MAXUINT,
-                                                           2,
-                                                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_INTERACTIVE_DELAY,
-                                        g_param_spec_int ("interactive-delay",
-                                                          "Interactive Delay",
-                                                          "The delay before initiating interactive 
completion",
-                                                          -1,
-                                                          G_MAXINT,
-                                                          50,
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
-
-       g_object_class_install_property (object_class,
-                                        PROP_PRIORITY,
-                                        g_param_spec_int ("priority",
-                                                          "Priority",
-                                                          "Provider priority",
-                                                          G_MININT,
-                                                          G_MAXINT,
-                                                          0,
-                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+       properties[PROP_NAME] =
+               g_param_spec_string ("name",
+                                    "Name",
+                                    "The provider name",
+                                    NULL,
+                                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_ICON] =
+               g_param_spec_object ("icon",
+                                    "Icon",
+                                    "The provider icon",
+                                    GDK_TYPE_PIXBUF,
+                                    G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_PROPOSALS_BATCH_SIZE] =
+               g_param_spec_uint ("proposals-batch-size",
+                                  "Proposals Batch Size",
+                                  "Number of proposals added in one batch",
+                                  1,
+                                  G_MAXUINT,
+                                  300,
+                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_SCAN_BATCH_SIZE] =
+               g_param_spec_uint ("scan-batch-size",
+                                  "Scan Batch Size",
+                                  "Number of lines scanned in one batch",
+                                  1,
+                                  G_MAXUINT,
+                                  50,
+                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_MINIMUM_WORD_SIZE] =
+               g_param_spec_uint ("minimum-word-size",
+                                  "Minimum Word Size",
+                                  "The minimum word size to complete",
+                                  2,
+                                  G_MAXUINT,
+                                  2,
+                                  G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_INTERACTIVE_DELAY] =
+               g_param_spec_int ("interactive-delay",
+                                 "Interactive Delay",
+                                 "The delay before initiating interactive completion",
+                                 -1,
+                                 G_MAXINT,
+                                 50,
+                                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       properties[PROP_PRIORITY] =
+               g_param_spec_int ("priority",
+                                 "Priority",
+                                 "Provider priority",
+                                 G_MININT,
+                                 G_MAXINT,
+                                 0,
+                                 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
 
        /**
         * GtkSourceCompletionWords:activation:
@@ -501,15 +495,16 @@ gtk_source_completion_words_class_init (GtkSourceCompletionWordsClass *klass)
         *
         * Since: 3.10
         */
-       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_INTERACTIVE |
-                                                            GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED,
-                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+       properties[PROP_ACTIVATION] =
+               g_param_spec_flags ("activation",
+                                   "Activation",
+                                   "The type of activation",
+                                   GTK_SOURCE_TYPE_COMPLETION_ACTIVATION,
+                                   GTK_SOURCE_COMPLETION_ACTIVATION_INTERACTIVE |
+                                   GTK_SOURCE_COMPLETION_ACTIVATION_USER_REQUESTED,
+                                   G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
+
+       g_object_class_install_properties (object_class, N_PROPERTIES, properties);
 }
 
 static gboolean


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]