After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 752141 - sorting: Allow adding sorting clauses to an existing GomSorting
sorting: Allow adding sorting clauses to an existing GomSorting
Status: RESOLVED FIXED
Product: gom
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Gom Maintainers
Gom Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-08 21:10 UTC by Mathieu Bridon
Modified: 2015-07-10 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sorting: Create the queue in init (1.12 KB, patch)
2015-07-08 21:10 UTC, Mathieu Bridon
committed Details | Review
sorting: Allow adding sorting clauses to an existing GomSorting (7.51 KB, patch)
2015-07-08 21:11 UTC, Mathieu Bridon
needs-work Details | Review
doc: Add GomSorting to the documentation (769 bytes, patch)
2015-07-09 15:22 UTC, Mathieu Bridon
committed Details | Review
sorting: Improve the gom_sorting_new documentation (1.76 KB, patch)
2015-07-09 15:22 UTC, Mathieu Bridon
accepted-commit_now Details | Review
sorting: Allow adding sorting clauses to an existing GomSorting (8.14 KB, patch)
2015-07-09 15:22 UTC, Mathieu Bridon
accepted-commit_now Details | Review
sorting: Improve the gom_sorting_new documentation (1.74 KB, patch)
2015-07-10 07:48 UTC, Mathieu Bridon
committed Details | Review
sorting: Properly free the GomOrderByTerm (1.04 KB, patch)
2015-07-10 07:48 UTC, Mathieu Bridon
committed Details | Review
sorting: Allow adding sorting clauses to an existing GomSorting (7.58 KB, patch)
2015-07-10 07:48 UTC, Mathieu Bridon
committed Details | Review

Description Mathieu Bridon 2015-07-08 21:10:51 UTC
.
Comment 1 Mathieu Bridon 2015-07-08 21:10:56 UTC
Created attachment 307106 [details] [review]
sorting: Create the queue in init

This is where it should have been from the start, otherwise using
g_object_new() won't have the queue created.
Comment 2 Mathieu Bridon 2015-07-08 21:11:01 UTC
Created attachment 307107 [details] [review]
sorting: Allow adding sorting clauses to an existing GomSorting

This allows another way to use GomSorting objects.

In addition, it makes it possible to use GomSorting from GI-based
bindings.

As it turns out, GObject Introspection does not support variadic
functions, so gom_sorting_new just isn't usable from GI-based bindings.

But with this commit, GI-based bindings can now simply create a new,
empty GomSorting object, then add their sorting clauses to it.
Comment 3 Bastien Nocera 2015-07-08 22:27:37 UTC
Review of attachment 307106 [details] [review]:

++
Comment 4 Bastien Nocera 2015-07-08 22:32:55 UTC
Review of attachment 307107 [details] [review]:

::: gom/gom-sorting.c
@@ +186,3 @@
+ * Add a new ORDER BY clause to the sorting object.
+ *
+ * This allows chaining ORDER BY clases, adding them one at a time, rather

classes.

@@ +190,3 @@
+ *
+ * Example:
+ *

Missing some markup to make this show up as C. See the gdbus or gvariant docs to see how.

@@ +199,3 @@
+ * The above example maps to the following SQL statement:
+ *
+ *     ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'

Ditto.

@@ +200,3 @@
+ *
+ *     ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'
+ */

You should mention in the _new() that it won't work for bindings, and link to this function's docs.

@@ +214,3 @@
+
+   o->resource_type = resource_type;
+   o->property_name = strdup(property_name);

Nope. g_strdup(). So you can free with g_free().

Please check other uses of strdup() in your original patch.
Comment 5 Mathieu Bridon 2015-07-09 15:21:43 UTC
(In reply to Bastien Nocera from comment #4)
> Review of attachment 307107 [details] [review] [review]:
> 
> ::: gom/gom-sorting.c
> @@ +186,3 @@
> + * Add a new ORDER BY clause to the sorting object.
> + *
> + * This allows chaining ORDER BY clases, adding them one at a time, rather
> 
> classes.

I actually meant "clauses" here.

> @@ +190,3 @@
> + *
> + * Example:
> + *
> 
> Missing some markup to make this show up as C. See the gdbus or gvariant
> docs to see how.
> 
> @@ +199,3 @@
> + * The above example maps to the following SQL statement:
> + *
> + *     ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'
> 
> Ditto.

Both fixed in the next patch version.

Note that the GomSorting docs actually weren't built at all, so I'm adding a patch to do that.

> @@ +200,3 @@
> + *
> + *     ORDER BY 'episodes'.'season-number' DESC, 'episodes'.'episode-number'
> + */
> 
> You should mention in the _new() that it won't work for bindings, and link
> to this function's docs.

Fixed in the next version of the patch.

> @@ +214,3 @@
> +
> +   o->resource_type = resource_type;
> +   o->property_name = strdup(property_name);
> 
> Nope. g_strdup(). So you can free with g_free().

Good thing you mentioned g_free, that made me realize I wasn't free-ing that string at all :x

> Please check other uses of strdup() in your original patch.

That's the only one, fixed in the next version of the patch.
Comment 6 Mathieu Bridon 2015-07-09 15:22:04 UTC
Created attachment 307152 [details] [review]
doc: Add GomSorting to the documentation
Comment 7 Mathieu Bridon 2015-07-09 15:22:12 UTC
Created attachment 307153 [details] [review]
sorting: Improve the gom_sorting_new documentation

This adds language markup, and the proper # signs in front of types.
Comment 8 Mathieu Bridon 2015-07-09 15:22:20 UTC
Created attachment 307154 [details] [review]
sorting: Allow adding sorting clauses to an existing GomSorting

This allows another way to use GomSorting objects.

In addition, it makes it possible to use GomSorting from GI-based
bindings.

As it turns out, GObject Introspection does not support variadic
functions, so gom_sorting_new just isn't usable from GI-based bindings.

But with this commit, GI-based bindings can now simply create a new,
empty GomSorting object, then add their sorting clauses to it.
Comment 9 Bastien Nocera 2015-07-09 15:54:10 UTC
Review of attachment 307152 [details] [review]:

gom-sections.txt needs to be updated as well.
Comment 10 Bastien Nocera 2015-07-09 15:55:39 UTC
Review of attachment 307153 [details] [review]:

Looks good otherwise.

::: gom/gom-sorting.c
@@ +113,3 @@
  * gom_sorting_new: (constructor)
  * @first_resource_type: A subclass of #GomResource.
+ * @first_property_name: A pointer to a const #gchar.

"A string" is good enough. If you need to link to the char docs, I think the reader might need something more basic ;)
Comment 11 Bastien Nocera 2015-07-09 15:57:00 UTC
Review of attachment 307154 [details] [review]:

Looks good otherwise.

::: gom/gom-sorting.c
@@ +41,3 @@
+gom_order_by_term_free (GomOrderByTerm *term)
+{
+   g_free (term->property_name);

We don't use spaces before parenthesis in gom.

::: gom/gom-sorting.h
@@ +63,3 @@
                                        GomSortingMode  first_sorting_mode,
                                        ...);
+void gom_sorting_add                  (GomSorting *sorting,

Alignment of the "*sorting" variable name.
Comment 12 Mathieu Bridon 2015-07-09 18:34:37 UTC
(In reply to Bastien Nocera from comment #9)
> Review of attachment 307152 [details] [review] [review]:
> 
> gom-sections.txt needs to be updated as well.

That file is automatically generated.

And I just checked, it does contain the GomSorting stuff.
Comment 13 Bastien Nocera 2015-07-09 19:30:57 UTC
Review of attachment 307152 [details] [review]:

Looks good then.
Comment 14 Mathieu Bridon 2015-07-10 07:43:57 UTC
Attachment 307152 [details] pushed as 9d2bca5 - doc: Add GomSorting to the documentation
Comment 15 Mathieu Bridon 2015-07-10 07:48:08 UTC
Created attachment 307198 [details] [review]
sorting: Improve the gom_sorting_new documentation

This adds language markup, and the proper # signs in front of types.
Comment 16 Mathieu Bridon 2015-07-10 07:48:12 UTC
Created attachment 307199 [details] [review]
sorting: Properly free the GomOrderByTerm

We were leaking the property_name string.
Comment 17 Mathieu Bridon 2015-07-10 07:48:18 UTC
Created attachment 307200 [details] [review]
sorting: Allow adding sorting clauses to an existing GomSorting

This allows another way to use GomSorting objects.

In addition, it makes it possible to use GomSorting from GI-based
bindings.

As it turns out, GObject Introspection does not support variadic
functions, so gom_sorting_new just isn't usable from GI-based bindings.

But with this commit, GI-based bindings can now simply create a new,
empty GomSorting object, then add their sorting clauses to it.
Comment 18 Bastien Nocera 2015-07-10 10:16:33 UTC
Review of attachment 307198 [details] [review]:

Yep.
Comment 19 Bastien Nocera 2015-07-10 10:16:58 UTC
Review of attachment 307199 [details] [review]:

Looks good.
Comment 20 Bastien Nocera 2015-07-10 10:17:41 UTC
Review of attachment 307200 [details] [review]:

Looks good.
Comment 21 Mathieu Bridon 2015-07-10 16:44:46 UTC
Attachment 307198 [details] pushed as ab60def - sorting: Improve the gom_sorting_new documentation
Attachment 307199 [details] pushed as 38ec658 - sorting: Properly free the GomOrderByTerm
Attachment 307200 [details] pushed as e7a8801 - sorting: Allow adding sorting clauses to an existing GomSorting