[gnome-control-center/gnome-41] info-overview: Allow changing "Device Name" by pressing "Enter"
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gnome-41] info-overview: Allow changing "Device Name" by pressing "Enter"
- Date: Mon, 7 Mar 2022 17:27:30 +0000 (UTC)
commit a66e7855fca1d9a920577da05363fb4c91f46024
Author: Felipe Borges <felipeborges gnome org>
Date: Mon Mar 7 17:01:02 2022 +0100
info-overview: Allow changing "Device Name" by pressing "Enter"
The hostname/device name dialog has only a GtkEntry. So a user
navigating with only a keyboard should be able to apply their
changes by pressing "Enter".
panels/info-overview/cc-info-overview-panel.c | 34 ++++++++++++++++++++++++++
panels/info-overview/cc-info-overview-panel.ui | 1 +
2 files changed, 35 insertions(+)
---
diff --git a/panels/info-overview/cc-info-overview-panel.c b/panels/info-overview/cc-info-overview-panel.c
index 6e832eb35..f95477af6 100644
--- a/panels/info-overview/cc-info-overview-panel.c
+++ b/panels/info-overview/cc-info-overview-panel.c
@@ -836,6 +836,38 @@ on_device_name_entry_changed (CcInfoOverviewPanel *self)
g_strcmp0 (current_hostname, new_hostname) != 0);
}
+static void
+update_device_name (CcInfoOverviewPanel *self)
+{
+ const gchar *hostname;
+
+ /* We simply change the CcHostnameEntry text. CcHostnameEntry
+ * listens to changes and updates hostname on change.
+ */
+ hostname = gtk_entry_get_text (self->device_name_entry);
+ gtk_entry_set_text (GTK_ENTRY (self->hostname_entry), hostname);
+}
+
+static void
+on_hostname_editor_dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ CcInfoOverviewPanel *self)
+{
+ if (response == GTK_RESPONSE_APPLY)
+ {
+ update_device_name (self);
+ }
+
+ gtk_window_close (GTK_WINDOW (dialog));
+}
+
+static void
+on_device_name_entry_activated_cb (CcInfoOverviewPanel *self)
+{
+ update_device_name (self);
+ gtk_window_close (GTK_WINDOW (self->hostname_editor));
+}
+
static void
open_hostname_edit_dialog (CcInfoOverviewPanel *self)
{
@@ -951,6 +983,8 @@ cc_info_overview_panel_class_init (CcInfoOverviewPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, cc_info_panel_row_activated_cb);
gtk_widget_class_bind_template_callback (widget_class, on_device_name_entry_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_device_name_entry_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_hostname_editor_dialog_response_cb);
g_type_ensure (CC_TYPE_LIST_ROW);
g_type_ensure (CC_TYPE_HOSTNAME_ENTRY);
diff --git a/panels/info-overview/cc-info-overview-panel.ui b/panels/info-overview/cc-info-overview-panel.ui
index 95afe867c..8e3cc6909 100644
--- a/panels/info-overview/cc-info-overview-panel.ui
+++ b/panels/info-overview/cc-info-overview-panel.ui
@@ -220,6 +220,7 @@
<object class="GtkEntry" id="device_name_entry">
<property name="visible">True</property>
<signal name="changed" handler="on_device_name_entry_changed" swapped="yes"/>
+ <signal name="activate" handler="on_device_name_entry_activated_cb" swapped="yes" />
</object>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]