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 682004 - gnome-xkb-info: Parse XKB options
gnome-xkb-info: Parse XKB options
Status: RESOLVED FIXED
Product: gnome-desktop
Classification: Core
Component: libgnome-desktop
unspecified
Other All
: Normal normal
: ---
Assigned To: Desktop Maintainers
Desktop Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-16 13:51 UTC by Rui Matos
Modified: 2012-08-18 15:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gnome-xkb-info: Parse XKB options (12.22 KB, patch)
2012-08-16 13:51 UTC, Rui Matos
reviewed Details | Review
gnome-xkb-info: Parse XKB options (12.76 KB, patch)
2012-08-17 00:26 UTC, Rui Matos
needs-work Details | Review
gnome-xkb-info: Use glib's slice allocator for small structures (2.56 KB, patch)
2012-08-17 00:29 UTC, Rui Matos
committed Details | Review
gnome-xkb-info: Parse XKB options (13.99 KB, patch)
2012-08-18 15:07 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2012-08-16 13:51:03 UTC
See patch.
Comment 1 Rui Matos 2012-08-16 13:51:05 UTC
Created attachment 221370 [details] [review]
gnome-xkb-info: Parse XKB options

And offer public API to get at them.
Comment 2 Bastien Nocera 2012-08-16 14:34:18 UTC
Review of attachment 221370 [details] [review]:

::: libgnome-desktop/gnome-xkb-info.c
@@ +58,3 @@
 };
 
+typedef struct _Option Option;

Please namespace those.

@@ +65,3 @@
+};
+
+typedef struct _OptionGroup OptionGroup;

Namespace really required (OptionGroup, GOptionGroup?)

@@ +111,3 @@
+  Option *option = data;
+
+  g_return_if_fail (option != NULL);

Either return silently, or assert if it's NULL, depending on whether it might happen or not.

@@ +309,3 @@
+        }
+
+      priv->current_parser_group = g_new0 (OptionGroup, 1);

I'd use g_slice_* functions instead, as you're creating loads of small items.

::: libgnome-desktop/gnome-xkb-info.h
@@ +77,3 @@
+GList          *gnome_xkb_info_get_all_option_groups            (GnomeXkbInfo *self);
+GList          *gnome_xkb_info_get_options_for_group            (GnomeXkbInfo *self,
+                                                                 const gchar  *id);

Why is it "*id" here, and "*group_id" below? Is it the same variable?
Comment 3 Rui Matos 2012-08-17 00:26:14 UTC
Created attachment 221535 [details] [review]
gnome-xkb-info: Parse XKB options

--
(In reply to comment #2)
> Namespace really required (OptionGroup, GOptionGroup?)

Ack.

> @@ +111,3 @@
> +  g_return_if_fail (option != NULL);
>
> Either return silently, or assert if it's NULL, depending on whether it might
> happen or not.

Well, I was just being consistent with what was already there. You
suggested it in bug 676583 comment 6.

I am sure these can never be NULL but...

> ::: libgnome-desktop/gnome-xkb-info.h
> @@ +77,3 @@
> +GList          *gnome_xkb_info_get_all_option_groups            (GnomeXkbInfo
> *self);
> +GList          *gnome_xkb_info_get_options_for_group            (GnomeXkbInfo
> *self,
> +                                                                 const gchar
> *id);
>
> Why is it "*id" here, and "*group_id" below? Is it the same variable?

Renamed it to be clearer.
Comment 4 Rui Matos 2012-08-17 00:29:50 UTC
Created attachment 221536 [details] [review]
gnome-xkb-info: Use glib's slice allocator for small structures

--
(In reply to comment #2)
> I'd use g_slice_* functions instead, as you're creating loads of small items.

Ok, here it is.

FWIW, I've heard people saying that glibc's malloc these days is
better and glib's slice allocator should be deprecated. Anyway, I've
never investigated it.
Comment 5 Bastien Nocera 2012-08-17 14:10:26 UTC
Review of attachment 221535 [details] [review]:

Did you check that descriptions would get translated? I don't see any calls to bindtextdomain() for example.

Would be good to have a small utility that dumps all the known options in the current locale, just to check that it's working.

Rest of the code looks good.
Comment 6 Rui Matos 2012-08-18 15:07:06 UTC
Created attachment 221697 [details] [review]
gnome-xkb-info: Parse XKB options

--
(In reply to comment #5)
> Did you check that descriptions would get translated? I don't see any calls to
> bindtextdomain() for example.

It uses the g_dgettext() based macro defined at the top of the file.

> Would be good to have a small utility that dumps all the known options in the
> current locale, just to check that it's working.

Sure, here's the same patch plus a change to test-xkb-info exercising
the new API.
Comment 7 Bastien Nocera 2012-08-18 15:18:23 UTC
Attachment 221536 [details] pushed as 21b7df0 - gnome-xkb-info: Use glib's slice allocator for small structures
Attachment 221697 [details] pushed as 8716011 - gnome-xkb-info: Parse XKB options