Commits

Daniel Poelzleithner committed 250c90c Merge

merge

Comments (0)

Files changed (8)

moo/mooapp/mooapp.c

         return FALSE;
     }
 
-    *stamp = moo_markup_get_int_prop (root, "stamp", 0);
+    *stamp = moo_markup_uint_prop (root, "stamp", 0);
 
     for (node = root->children; node != NULL; node = node->next)
     {
         if (encoding && encoding[0])
             file.encoding = g_strdup (encoding);
 
-        file.line = moo_markup_get_int_prop (node, "line", 0);
-        if (moo_markup_get_bool_prop (node, "new-window", FALSE))
+        file.line = moo_markup_int_prop (node, "line", 0);
+        if (moo_markup_bool_prop (node, "new-window", FALSE))
             file.options |= MOO_EDIT_OPEN_NEW_WINDOW;
-        if (moo_markup_get_bool_prop (node, "new-tab", FALSE))
+        if (moo_markup_bool_prop (node, "new-tab", FALSE))
             file.options |= MOO_EDIT_OPEN_NEW_TAB;
-        if (moo_markup_get_bool_prop (node, "reload", FALSE))
+        if (moo_markup_bool_prop (node, "reload", FALSE))
             file.options |= MOO_EDIT_OPEN_RELOAD;
 
         if (!files)

moo/mooedit/mooeditor.c

 
             doc = load_doc_session (editor, window, node, file_is_uri);
 
-            if (doc && moo_markup_get_bool_prop (node, "active", FALSE))
+            if (doc && moo_markup_bool_prop (node, "active", FALSE))
                 active_doc = doc;
         }
     }
 
             window = load_window_session (editor, node, !old_format);
 
-            if (window && moo_markup_get_bool_prop (node, "active", FALSE))
+            if (window && moo_markup_bool_prop (node, "active", FALSE))
                 active_window = window;
         }
 

moo/mooedit/moofold.c

 #define WANT_CHECKS 0
 #endif
 
+static void     moo_fold_get_property       (GObject    *object,
+                                             guint       prop_id,
+                                             GValue     *value,
+                                             GParamSpec *pspec);
 static void     moo_fold_finalize           (GObject    *object);
 static void     moo_fold_free_recursively   (MooFold    *fold);
 
 static int      _moo_fold_get_end           (MooFold    *fold);
 
-
 enum {
     PROP_0,
     PROP_PARENT,
     PROP_COLLAPSED
 };
 
-
 /* MOO_TYPE_FOLD */
 G_DEFINE_TYPE (MooFold, moo_fold, G_TYPE_OBJECT)
 
-static void     moo_fold_set_property   (GObject        *object,
-                                         guint           prop_id,
-                                         const GValue   *value,
-                                         GParamSpec     *pspec);
-static void     moo_fold_get_property  (GObject        *object,
-                                        guint           prop_id,
-                                        GValue         *value,
-                                        GParamSpec     *pspec);
-
 static void
 moo_fold_class_init (MooFoldClass *klass)
 {
 
     gobject_class->finalize = moo_fold_finalize;
 
-    gobject_class->set_property = moo_fold_set_property;
     gobject_class->get_property = moo_fold_get_property;
 
     g_object_class_install_property (gobject_class,
                                              "Children Number",
                                              "Number of children",
                                              0, G_MAXINT, 0,
-                                             G_PARAM_READWRITE));
+                                             G_PARAM_READABLE));
 
 
     g_object_class_install_property (gobject_class,
             break;
 
         case PROP_COLLAPSED:
-            g_value_set_object (value, fold->collapsed);
+            g_value_set_boolean (value, fold->collapsed);
             break;
 
         default:
     }
 }
 
-static void
-moo_fold_set_property (GObject        *object,
-                            guint           prop_id,
-                            const GValue   *value,
-                            GParamSpec     *pspec)
-{
-    //MooFold *fold = MOO_FOLD (object);
-
-    switch (prop_id)
-    {
-        default:
-            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
-            break;
-    }
-}
-
-
 
 static void
 moo_fold_init (MooFold *fold)

moo/mooutils/moomarkup.c

 
 
 int
-moo_markup_get_int_prop (MooMarkupNode      *node,
-                         const char         *prop_name,
-                         int                 default_val)
+moo_markup_int_prop (MooMarkupNode *node,
+                     const char    *prop_name,
+                     int            default_val)
 {
     g_return_val_if_fail (MOO_MARKUP_IS_ELEMENT (node), default_val);
     g_return_val_if_fail (prop_name != NULL, default_val);
                                        default_val);
 }
 
-
-void
-moo_markup_set_int_prop (MooMarkupNode      *node,
-                         const char         *prop_name,
-                         int                 val)
+guint
+moo_markup_uint_prop (MooMarkupNode *node,
+                      const char    *prop_name,
+                      guint          default_val)
 {
-    moo_markup_set_prop (node, prop_name,
-                         _moo_convert_int_to_string (val));
+    g_return_val_if_fail (MOO_MARKUP_IS_ELEMENT (node), default_val);
+    g_return_val_if_fail (prop_name != NULL, default_val);
+    return _moo_convert_string_to_uint (moo_markup_get_prop (node, prop_name),
+                                        default_val);
 }
 
-
 gboolean
-moo_markup_get_bool_prop (MooMarkupNode      *node,
-                          const char         *prop_name,
-                          gboolean            default_val)
+moo_markup_bool_prop (MooMarkupNode *node,
+                      const char    *prop_name,
+                      gboolean       default_val)
 {
     g_return_val_if_fail (MOO_MARKUP_IS_ELEMENT (node), default_val);
     g_return_val_if_fail (prop_name != NULL, default_val);
 
 
 void
-moo_markup_set_bool_prop (MooMarkupNode      *node,
-                          const char         *prop_name,
-                          gboolean            val)
+moo_markup_set_bool_prop (MooMarkupNode *node,
+                          const char    *prop_name,
+                          gboolean       val)
 {
     moo_markup_set_prop (node, prop_name,
                          _moo_convert_bool_to_string (val));

moo/mooutils/moomarkup.h

                                                      const char         *prop_name,
                                                      const char         *val);
 
-int                 moo_markup_get_int_prop         (MooMarkupNode      *node,
+int                 moo_markup_int_prop             (MooMarkupNode      *node,
                                                      const char         *prop_name,
                                                      int                 default_val);
-void                moo_markup_set_int_prop         (MooMarkupNode      *node,
+guint               moo_markup_uint_prop            (MooMarkupNode      *node,
                                                      const char         *prop_name,
-                                                     int                 val);
-gboolean            moo_markup_get_bool_prop        (MooMarkupNode      *node,
+                                                     guint               default_val);
+gboolean            moo_markup_bool_prop            (MooMarkupNode      *node,
                                                      const char         *prop_name,
                                                      gboolean            default_val);
 void                moo_markup_set_bool_prop        (MooMarkupNode      *node,

moo/mooutils/moopane.c

                       G_CALLBACK (pane_window_configure), pane);
 }
 
-/* XXX gtk_widget_reparent() doesn't work here for some reasons */
-/* shouldn't it work now, as I fixed GTK_NO_WINDOW flag? */
+/* FIXME use gtk_widget_reparent(), it does work now */
 static void
 reparent (GtkWidget *widget,
           GtkWidget *old_container,

moo/mooutils/mooutils-gobject.c

     return FALSE;
 }
 
+static gboolean
+_moo_value_convert_to_uint (const GValue *val,
+                            guint        *dest)
+{
+    GValue result = {0};
+
+    g_value_init (&result, G_TYPE_UINT);
+
+    if (_moo_value_convert (val, &result))
+    {
+        *dest = g_value_get_uint (&result);
+        return TRUE;
+    }
+
+    return FALSE;
+}
 
 double
 _moo_value_convert_to_double (const GValue *val)
     return int_val;
 }
 
+guint
+_moo_convert_string_to_uint (const char *string,
+                             guint       default_val)
+{
+    guint int_val = default_val;
+
+    if (string && string[0])
+    {
+        GValue str_val = {0};
+
+        g_value_init (&str_val, G_TYPE_STRING);
+        g_value_set_static_string (&str_val, string);
+
+        if (!_moo_value_convert_to_uint (&str_val, &int_val))
+            g_warning ("%s: could not convert string '%s' to uint",
+                       G_STRFUNC, string);
+
+        g_value_unset (&str_val);
+    }
+
+    return int_val;
+}
 
 gboolean
 _moo_convert_string_to_bool (const char *string,
 }
 
 
-const char*
+const char *
 _moo_convert_int_to_string (int value)
 {
     GValue int_val = {0};

moo/mooutils/mooutils-gobject.h

                                              gboolean        default_val);
 int             _moo_convert_string_to_int  (const char     *string,
                                              int             default_val);
+guint           _moo_convert_string_to_uint (const char     *string,
+                                             guint           default_val);
 const char     *_moo_convert_bool_to_string (gboolean        value);
 const char     *_moo_convert_int_to_string  (int             value);