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 679284 - Don't change hostname on every character entered
Don't change hostname on every character entered
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Control-Center Maintainers
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-07-02 22:47 UTC by William Jon McCann
Modified: 2012-11-06 11:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
info-panel: Set the hostname only after a small delay (2.76 KB, patch)
2012-11-01 16:37 UTC, Thomas Wood
needs-work Details | Review
info-panel: Set the hostname only after a small delay (3.51 KB, patch)
2012-11-02 11:43 UTC, Thomas Wood
needs-work Details | Review
info-panel: Set the hostname only after a small delay (3.67 KB, patch)
2012-11-05 11:28 UTC, Thomas Wood
committed Details | Review

Description William Jon McCann 2012-07-02 22:47:14 UTC
We are currently setting/changing the hostname everytime the user enters a character in the device name field. 

** Message: Cached variant is 0xe55d20
** Message: Got cached property: 'Jon's Laptop'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's '
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's C'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Co'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Com'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Comp'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Compu'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Comput'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Compute'
** Message: Cached variant is (nil)
** Message: Got manual property: 'Jon's Computer'

This is what happens to a client listening to changes on the hostname interface (nautilus in this case).
Comment 1 Bastien Nocera 2012-07-03 09:12:05 UTC
I don't see how that's wrong with doing that.

There's no other entry in the dialogue that somebody would likely go to when done with this one, so we can't apply it on focus out. I also don't see think that get notified of 9 or 10 characters should be a major performance drain.
Comment 2 William Jon McCann 2012-07-03 12:47:19 UTC
Changing the hostname has implications. Performance isn't the biggest concern here. I don't think it makes any sense at all to change the hostname every character. Simply using a small timeout would be much preferable.
Comment 3 Thomas Wood 2012-11-01 16:37:35 UTC
Created attachment 227821 [details] [review]
info-panel: Set the hostname only after a small delay

Avoid setting the hostname from the entry on every single key press and
instead wait for a second after the last key press.
Comment 4 Bastien Nocera 2012-11-01 17:25:10 UTC
Review of attachment 227821 [details] [review]:

Use a separate function to set/unset the timeout. and use a define for the 1 second constant
Comment 5 Thomas Wood 2012-11-02 11:43:03 UTC
Created attachment 227883 [details] [review]
info-panel: Set the hostname only after a small delay

Avoid setting the hostname from the entry on every single key press and
instead wait for a second after the last key press.
Comment 6 Bastien Nocera 2012-11-02 17:21:12 UTC
Review of attachment 227883 [details] [review]:

::: panels/info/cc-info-panel.c
@@ +56,3 @@
 #define KEY_SESSION_NAME          "session-name"
 
+#define SET_HOSTNAME_TIMEOUT (1)

Not (1), 1.

@@ +114,3 @@
   GSettings           *session_settings;
 
+  guint set_hostname_timeout_source;

..._source_id
and line it up please.

@@ +122,3 @@
 static void refresh_update_button (CcInfoPanel *self);
+static gboolean set_hostname_timeout (gpointer user_data);
+static void remove_hostname_timeout (CcInfoPanel *panel);

Can you move the functions above so they don't need declarations?

@@ +513,3 @@
+    {
+      remove_hostname_timeout (CC_INFO_PANEL (object));
+

No need for a linefeed here.

@@ +1767,3 @@
 
+static gboolean
+set_hostname_timeout (gpointer user_data)

Use CcInfoPanel *self
directly in the function declaration.

@@ +1792,3 @@
+reset_hostname_timeout (CcInfoPanel *panel)
+{
+  CcInfoPanelPrivate *priv = panel->priv;

Remove the priv variable (a single use)
Comment 7 Thomas Wood 2012-11-05 11:06:14 UTC
(In reply to comment #6)
> Review of attachment 227883 [details] [review]:
> 
> ::: panels/info/cc-info-panel.c
> @@ +56,3 @@
>  #define KEY_SESSION_NAME          "session-name"
> 
> +#define SET_HOSTNAME_TIMEOUT (1)
> 
> Not (1), 1.
> 
> @@ +114,3 @@
>    GSettings           *session_settings;
> 
> +  guint set_hostname_timeout_source;
> 
> ..._source_id
> and line it up please.

Line up with what? The other variables are grouped and lined up by logical usage; the timeout source variables stands on it's own.
Comment 8 Thomas Wood 2012-11-05 11:10:40 UTC
(In reply to comment #6)
> Review of attachment 227883 [details] [review]:

> @@ +122,3 @@
>  static void refresh_update_button (CcInfoPanel *self);
> +static gboolean set_hostname_timeout (gpointer user_data);
> +static void remove_hostname_timeout (CcInfoPanel *panel);
> 
> Can you move the functions above so they don't need declarations?
> 

This would mean moving info_panel_set_hostname as well, or forward declaring it.
Comment 9 Thomas Wood 2012-11-05 11:28:27 UTC
Created attachment 228095 [details] [review]
info-panel: Set the hostname only after a small delay

Updated patch based on the discussion on IRC.
Comment 10 Bastien Nocera 2012-11-05 13:49:19 UTC
Review of attachment 228095 [details] [review]:

Looks good for master.
Comment 11 Thomas Wood 2012-11-06 11:56:04 UTC
Attachment 228095 [details] pushed as 53d06c7 - info-panel: Set the hostname only after a small delay