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 685458 - keyboard: Convert old libgnomekbd and IBus settings
keyboard: Convert old libgnomekbd and IBus settings
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: keyboard
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on: 685457
Blocks:
 
 
Reported: 2012-10-04 02:22 UTC by Rui Matos
Modified: 2012-10-05 17:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
keyboard: Convert old libgnomekbd and IBus settings (7.29 KB, patch)
2012-10-04 02:22 UTC, Rui Matos
needs-work Details | Review
keyboard: Convert old libgnomekbd and IBus settings (8.84 KB, patch)
2012-10-04 21:40 UTC, Rui Matos
accepted-commit_now Details | Review
keyboard: Convert old libgnomekbd and IBus settings (8.54 KB, patch)
2012-10-05 16:25 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2012-10-04 02:22:56 UTC
Patch attached. This depends on bug 685457.
Comment 1 Rui Matos 2012-10-04 02:22:58 UTC
Created attachment 225736 [details] [review]
keyboard: Convert old libgnomekbd and IBus settings
Comment 2 Matthias Clasen 2012-10-04 03:43:38 UTC
Review of attachment 225736 [details] [review]:

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +1436,3 @@
+        g_strfreev (options);
+        g_object_unref (libgnomekbd_settings);
+        g_strfreev ((gchar **) g_ptr_array_free (opt_array, FALSE));

This looks slightly odd - why not use g_ptr_array_new_full and have g_ptr_array_free free the elements.
Comment 3 Bastien Nocera 2012-10-04 11:19:55 UTC
Review of attachment 225736 [details] [review]:

Can I have tests for the conversion functions as well?

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +558,3 @@
+        gchar **engines, **e;
+
+        if (!schema_is_installed ("org.freedesktop.ibus.general"))

Given that both IBus (for org.freedesktop.ibus.general) and libgnomekbd (for org.gnome.libgnomekbd.keyboard) are requirements of the keyboard plugins (right now), is it necessary to check for them being installed?

I guess at least for libgnomekbd, that makes sense for 3.8.

@@ +1394,3 @@
+        GSettingsSchema *schema;
+
+        schema_source = g_settings_schema_source_get_default ();

I would use g_settings_list_schemas() instead. Could you cache whether those schemas are available as well?
Comment 4 Rui Matos 2012-10-04 21:40:53 UTC
Created attachment 225850 [details] [review]
keyboard: Convert old libgnomekbd and IBus settings

--
(In reply to comment #2)
> Review of attachment 225736 [details] [review]:
> +        g_strfreev ((gchar **) g_ptr_array_free (opt_array, FALSE));
>
> This looks slightly odd - why not use g_ptr_array_new_full and have
> g_ptr_array_free free the elements.

Fixed.

(In reply to comment #3)
> Review of attachment 225736 [details] [review]:
> +        if (!schema_is_installed ("org.freedesktop.ibus.general"))
>
> Given that both IBus (for org.freedesktop.ibus.general) and libgnomekbd (for
> org.gnome.libgnomekbd.keyboard) are requirements of the keyboard plugins (right
> now), is it necessary to check for them being installed?
>
> I guess at least for libgnomekbd, that makes sense for 3.8.

I'd prefer to keep checking since we have been telling people which
want to use other IM frameworks to remove the ibus-daemon package from
their systems and, at least in Fedora, that's where the schema lives.

> @@ +1394,3 @@
> +        GSettingsSchema *schema;
> +
> +        schema_source = g_settings_schema_source_get_default ();
>
> I would use g_settings_list_schemas() instead. Could you cache whether those
> schemas are available as well?

Yes, done.
Comment 5 Bastien Nocera 2012-10-05 15:25:58 UTC
Review of attachment 225850 [details] [review]:

Looks good after that change.

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +155,3 @@
+        const gchar * const *schemas;
+        const gchar * const *s;
+        static GHashTable *cache = NULL;

That would leak. I meant:
self->priv->has_ibus_schema = schema_is_installed(...);
etc. in start()
Comment 6 Rui Matos 2012-10-05 16:25:03 UTC
Created attachment 225895 [details] [review]
keyboard: Convert old libgnomekbd and IBus settings

--

Honestly, a bunch of string comparisons on a code path that normally
is only going to be hit once (on 1st login after upgrade or
installation) doesn't really warrant a cache or even a boolean IMO, so
I just removed it.
Comment 7 Bastien Nocera 2012-10-05 16:50:09 UTC
Review of attachment 225895 [details] [review]:

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +1488,3 @@
+        gchar *stamp_file_path = NULL;
+
+        stamp_dir_path = g_build_filename (g_get_user_data_dir (), PACKAGE_NAME, NULL);

config_dir() maybe?

@@ +1512,3 @@
+        g_strfreev (options);
+
+        fd = creat (stamp_file_path, 0644);

something like g_file_set_contents(stamp_file_path, "", 0, NULL); ?

(don't forget to remove the fcntl include)
Comment 8 Rui Matos 2012-10-05 17:19:58 UTC
(In reply to comment #7)
> +        stamp_dir_path = g_build_filename (g_get_user_data_dir (),
> PACKAGE_NAME, NULL);
>
> config_dir() maybe?

As noted on IRC, data_dir() is also what gsettings-data-convert uses
for its stamp file.

> @@ +1512,3 @@
> +        g_strfreev (options);
> +
> +        fd = creat (stamp_file_path, 0644);
>
> something like g_file_set_contents(stamp_file_path, "", 0, NULL); ?
>
> (don't forget to remove the fcntl include)

Yup, done. Thanks for the review!

Attachment 225895 [details] pushed as a131ce9 - keyboard: Convert old libgnomekbd and IBus settings