summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriampkumar02 <iampkumar02@gmail.com>2023-03-28 12:38:34 +0530
committerFelipe Borges <felipeborges@gnome.org>2023-04-11 13:49:09 +0200
commit27d5e7dd2634cf78b7caa4e436d27de905a523a2 (patch)
treec2eb1438fab908d9adb9f385d0d71f331e5d9f7b
parent4b450409c5ffc24bacfbed45a966111b241be98e (diff)
downloadgnome-control-center-27d5e7dd2634cf78b7caa4e436d27de905a523a2.tar.gz
wifi: Center panel title when subtitle isn't visible
We used to have a custom title widget containing a label for the title and another for the subtitle (status). When the subtitle label wasn't visible, the title label wouldn't get centered vertically in the headerbar. By porting the custom title widget to AdwWindowTitle we get the title centered for free. Fixes #1891
-rw-r--r--panels/network/net-device-wifi.c15
-rw-r--r--panels/network/network-wifi.ui21
2 files changed, 7 insertions, 29 deletions
diff --git a/panels/network/net-device-wifi.c b/panels/network/net-device-wifi.c
index a72141119..74004e5db 100644
--- a/panels/network/net-device-wifi.c
+++ b/panels/network/net-device-wifi.c
@@ -53,7 +53,7 @@ struct _NetDeviceWifi
{
AdwBin parent;
- GtkBox *center_box;
+ AdwWindowTitle *wifi_headerbar_title;
GtkListBoxRow *connect_hidden_row;
GtkSwitch *device_off_switch;
GtkBox *header_box;
@@ -65,8 +65,6 @@ struct _NetDeviceWifi
GtkBox *listbox_box;
GtkStack *stack;
GtkListBoxRow *start_hotspot_row;
- GtkLabel *status_label;
- GtkLabel *title_label;
CcPanel *panel;
NMClient *client;
@@ -363,8 +361,7 @@ nm_device_wifi_refresh_ui (NetDeviceWifi *self)
wireless_enabled_toggled (self);
status = panel_device_status_to_localized_string (self->device, NULL);
- gtk_label_set_label (self->status_label, status);
-
+ adw_window_title_set_subtitle (self->wifi_headerbar_title, status);
/* update list of APs */
show_wifi_list (self);
}
@@ -1198,7 +1195,7 @@ net_device_wifi_class_init (NetDeviceWifiClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/network/network-wifi.ui");
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, center_box);
+ gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, wifi_headerbar_title);
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, connect_hidden_row);
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, device_off_switch);
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, header_box);
@@ -1210,8 +1207,6 @@ net_device_wifi_class_init (NetDeviceWifiClass *klass)
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, listbox_box);
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, stack);
gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, start_hotspot_row);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, status_label);
- gtk_widget_class_bind_template_child (widget_class, NetDeviceWifi, title_label);
gtk_widget_class_bind_template_callback (widget_class, device_off_switch_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, on_popover_row_activated_cb);
@@ -1301,7 +1296,7 @@ void
net_device_wifi_set_title (NetDeviceWifi *self, const gchar *title)
{
g_return_if_fail (NET_IS_DEVICE_WIFI (self));
- gtk_label_set_label (self->title_label, title);
+ adw_window_title_set_title (self->wifi_headerbar_title, title);
}
GtkWidget *
@@ -1315,7 +1310,7 @@ GtkWidget *
net_device_wifi_get_title_widget (NetDeviceWifi *self)
{
g_return_val_if_fail (NET_IS_DEVICE_WIFI (self), NULL);
- return GTK_WIDGET (self->center_box);
+ return GTK_WIDGET (self->wifi_headerbar_title);
}
void
diff --git a/panels/network/network-wifi.ui b/panels/network/network-wifi.ui
index aba532c56..48e120881 100644
--- a/panels/network/network-wifi.ui
+++ b/panels/network/network-wifi.ui
@@ -57,25 +57,8 @@
</template>
<!-- Center widget -->
- <object class="GtkBox" id="center_box">
- <property name="orientation">vertical</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkLabel" id="title_label">
- <property name="label" translatable="yes">Wi-Fi</property>
- <style>
- <class name="title" />
- </style>
- </object>
- </child>
- <child>
- <object class="GtkLabel" id="status_label">
- <style>
- <class name="subtitle" />
- </style>
- </object>
- </child>
+ <object class="AdwWindowTitle" id="wifi_headerbar_title">
+ <property name="title" translatable="yes">Wi-Fi</property>
</object>
<!-- Box with the On/Off switch + menu button -->