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 695534 - region: Translate restart notification into the target language
region: Translate restart notification into the target language
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Region & Language
unspecified
Other All
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-03-10 03:12 UTC by Rui Matos
Modified: 2013-03-14 15:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
region: Translate restart notification into the target language (2.08 KB, patch)
2013-03-10 03:12 UTC, Rui Matos
committed Details | Review
region: Show restart notification only if strictly needed (3.50 KB, patch)
2013-03-11 14:06 UTC, Rui Matos
needs-work Details | Review
region: Use a GDBusProxy to access org.gnome.SessionManager (3.64 KB, patch)
2013-03-13 21:10 UTC, Rui Matos
needs-work Details | Review
region: Show restart notification only if strictly needed (5.96 KB, patch)
2013-03-13 21:12 UTC, Rui Matos
needs-work Details | Review
region: Cancel any async operations with callbacks on finalize (2.97 KB, patch)
2013-03-14 10:29 UTC, Rui Matos
committed Details | Review
region: Use a GDBusProxy to access org.gnome.SessionManager (3.73 KB, patch)
2013-03-14 10:31 UTC, Rui Matos
committed Details | Review
region: Show restart notification only if strictly needed (6.08 KB, patch)
2013-03-14 10:32 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2013-03-10 03:12:57 UTC
See patch.
Comment 1 Rui Matos 2013-03-10 03:12:59 UTC
Created attachment 238493 [details] [review]
region: Translate restart notification into the target language

We used to do this before the panel re-design.
Comment 2 Matthias Clasen 2013-03-11 03:20:38 UTC
Review of attachment 238493 [details] [review]:

Looks good to me
Comment 3 Bastien Nocera 2013-03-11 09:31:45 UTC
Review of attachment 238493 [details] [review]:

Seems that this code would still show a restart notification if the language was already the language of the session. Looks fine otherwise.
Comment 4 Rui Matos 2013-03-11 14:06:31 UTC
Created attachment 238577 [details] [review]
region: Show restart notification only if strictly needed

If the user is changing the setting back to the current locale we
shouldn't show the restart notification.
--

(In reply to comment #3)
> Seems that this code would still show a restart notification if the language
> was already the language of the session. Looks fine otherwise.

Good point. This should address that and while at it also your comment
https://bugzilla.gnome.org/show_bug.cgi?id=695535#c6 .
Comment 5 Bastien Nocera 2013-03-12 17:36:00 UTC
Review of attachment 238577 [details] [review]:

::: panels/region/cc-region-panel.c
@@ +275,3 @@
+        current_locale = setlocale (category, NULL);
+
+        if (!gnome_parse_locale (current_locale, &current_lang_code, &current_country_code, NULL, NULL))

The current locale is the one you would get calling GetLocale() on org.gnome.SessionManager, not the one you would get running SetLocale.
Comment 6 Rui Matos 2013-03-13 21:10:39 UTC
Created attachment 238820 [details] [review]
region: Use a GDBusProxy to access org.gnome.SessionManager

We'll use this interface beyond just calling Logout() so lets keep a
proxy around.
Comment 7 Rui Matos 2013-03-13 21:12:03 UTC
Created attachment 238821 [details] [review]
region: Show restart notification only if strictly needed

--

(In reply to comment #5)
> The current locale is the one you would get calling GetLocale() on
> org.gnome.SessionManager, not the one you would get running SetLocale.

Ok. This one does that
Comment 8 Bastien Nocera 2013-03-14 09:40:19 UTC
Review of attachment 238820 [details] [review]:

::: panels/region/cc-region-panel.c
@@ +1595,3 @@
+        GError *error = NULL;
+
+        priv->session = g_dbus_proxy_new_for_bus_finish (res, &error);

Needs to check for G_IO_ERROR_CANCELLED here

@@ +1626,3 @@
         priv->user_manager = act_user_manager_get_default ();
 
+        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,

Missing a cancellable.
Comment 9 Bastien Nocera 2013-03-14 09:45:51 UTC
Review of attachment 238821 [details] [review]:

Looks fine otherwise.

::: panels/region/cc-region-panel.c
@@ +331,3 @@
+{
+        CcRegionPanelPrivate *priv = self->priv;
+        MaybeNotifyData *mnd = g_new0 (MaybeNotifyData, 1);

split this.

@@ +337,3 @@
+        mnd->target_locale = g_strdup (target_locale);
+
+        g_dbus_proxy_call (priv->session,

Needs a GCancellable.
Comment 10 Rui Matos 2013-03-14 10:29:45 UTC
Created attachment 238856 [details] [review]
region: Cancel any async operations with callbacks on finalize

Otherwise we may end up using a finalized "object" in the callbacks.
Comment 11 Rui Matos 2013-03-14 10:31:52 UTC
Created attachment 238857 [details] [review]
region: Use a GDBusProxy to access org.gnome.SessionManager

--

There was a previous place where we weren't using a cancellable
so I attached a patch to fix that too.

(In reply to comment #8)
> ::: panels/region/cc-region-panel.c
> @@ +1595,3 @@
> +        GError *error = NULL;
> +
> +        priv->session = g_dbus_proxy_new_for_bus_finish (res, &error);
>
> Needs to check for G_IO_ERROR_CANCELLED here

Good point fixed.

> @@ +1626,3 @@
>          priv->user_manager = act_user_manager_get_default ();
>
> +        g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
>
> Missing a cancellable.

Fixed.
Comment 12 Rui Matos 2013-03-14 10:32:24 UTC
Created attachment 238858 [details] [review]
region: Show restart notification only if strictly needed

--

(In reply to comment #9)
> ::: panels/region/cc-region-panel.c
> @@ +331,3 @@
> +{
> +        CcRegionPanelPrivate *priv = self->priv;
> +        MaybeNotifyData *mnd = g_new0 (MaybeNotifyData, 1);
>
> split this.

Done.

> @@ +337,3 @@
> +        mnd->target_locale = g_strdup (target_locale);
> +
> +        g_dbus_proxy_call (priv->session,
>
> Needs a GCancellable.

Fixed.
Comment 13 Bastien Nocera 2013-03-14 14:45:29 UTC
Review of attachment 238856 [details] [review]:

Looks good.
Comment 14 Bastien Nocera 2013-03-14 14:46:44 UTC
Review of attachment 238857 [details] [review]:

Looks good.
Comment 15 Bastien Nocera 2013-03-14 14:49:19 UTC
Review of attachment 238858 [details] [review]:

Looks good otherwise.

::: panels/region/cc-region-panel.c
@@ +292,3 @@
+        const gchar *current_locale = NULL;
+
+        retval = g_dbus_proxy_call_finish (self->priv->session, res, &error);

NO!
s/self->priv->session/G_DBUS_PROXY(source)/
Comment 16 Rui Matos 2013-03-14 15:55:11 UTC
(In reply to comment #15)
> ::: panels/region/cc-region-panel.c
> @@ +292,3 @@
> +        const gchar *current_locale = NULL;
> +
> +        retval = g_dbus_proxy_call_finish (self->priv->session, res, &error);
>
> NO!
> s/self->priv->session/G_DBUS_PROXY(source)/

GAH! Thanks for spotting, pushed with the fix.

Attachment 238493 [details] pushed as e2163ea - region: Translate restart notification into the target language
Attachment 238856 [details] pushed as 3efb71b - region: Cancel any async operations with callbacks on finalize
Attachment 238857 [details] pushed as 50ea2c1 - region: Use a GDBusProxy to access org.gnome.SessionManager
Attachment 238858 [details] pushed as 9c64f31 - region: Show restart notification only if strictly needed