[gnome-initial-setup/wip/port-to-gtk4: 8/23] network: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/wip/port-to-gtk4: 8/23] network: Port to GTK4
- Date: Mon, 25 Jul 2022 15:52:55 +0000 (UTC)
commit 66fd914ca08457a96ba3c9263ef10ab38ab4cde9
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Jul 5 18:00:17 2022 -0300
network: Port to GTK4
gnome-initial-setup/gnome-initial-setup.c | 6 +-
gnome-initial-setup/meson.build | 4 +-
gnome-initial-setup/pages/meson.build | 2 +-
.../pages/network/gis-network-page.c | 69 +++-----
.../pages/network/gis-network-page.ui | 179 +++++++++------------
.../pages/network/network-dialogs.c | 4 +-
6 files changed, 110 insertions(+), 154 deletions(-)
---
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index 186cc1b0..5614c692 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -32,7 +32,7 @@
#include "pages/welcome/gis-welcome-page.h"
#include "pages/language/gis-language-page.h"
#include "pages/keyboard/gis-keyboard-page.h"
-//#include "pages/network/gis-network-page.h"
+#include "pages/network/gis-network-page.h"
//#include "pages/timezone/gis-timezone-page.h"
//#include "pages/privacy/gis-privacy-page.h"
//#include "pages/software/gis-software-page.h"
@@ -65,7 +65,7 @@ static PageData page_table[] = {
PAGE (welcome, FALSE),
PAGE (language, FALSE),
PAGE (keyboard, FALSE),
- //PAGE (network, FALSE),
+ PAGE (network, FALSE),
//PAGE (privacy, FALSE),
//PAGE (timezone, TRUE),
//PAGE (software, TRUE),
@@ -94,6 +94,8 @@ should_skip_page (const gchar *page_id,
if (strcmp (page_id, "welcome") == 0)
return !should_skip_page ("language", skip_pages);
+ return FALSE;
+
/* check through our skip pages list for pages we don't want */
if (skip_pages) {
while (skip_pages[i]) {
diff --git a/gnome-initial-setup/meson.build b/gnome-initial-setup/meson.build
index e1b78752..6197b9ef 100644
--- a/gnome-initial-setup/meson.build
+++ b/gnome-initial-setup/meson.build
@@ -46,8 +46,8 @@ geocode_glib_2_dep = dependency(
)
dependencies = [
- #dependency ('libnm', version: '>= 1.2'),
- #dependency ('libnma', version: '>= 1.0'),
+ dependency ('libnm', version: '>= 1.2'),
+ dependency ('libnma-gtk4', version: '>= 1.0'),
dependency ('polkit-gobject-1', version: '>= 0.103'),
dependency ('accountsservice'),
#geocode_glib_2_dep,
diff --git a/gnome-initial-setup/pages/meson.build b/gnome-initial-setup/pages/meson.build
index 10c7b448..e6150074 100644
--- a/gnome-initial-setup/pages/meson.build
+++ b/gnome-initial-setup/pages/meson.build
@@ -2,7 +2,7 @@ pages = [
#'account',
'language',
'keyboard',
- #'network',
+ 'network',
#'timezone',
#'privacy',
#'goa',
diff --git a/gnome-initial-setup/pages/network/gis-network-page.c
b/gnome-initial-setup/pages/network/gis-network-page.c
index 331cd370..859288f8 100644
--- a/gnome-initial-setup/pages/network/gis-network-page.c
+++ b/gnome-initial-setup/pages/network/gis-network-page.c
@@ -44,7 +44,6 @@ typedef enum {
struct _GisNetworkPagePrivate {
GtkWidget *network_list;
- GtkWidget *scrolled_window;
GtkWidget *no_network_label;
GtkWidget *no_network_spinner;
GtkWidget *turn_on_label;
@@ -158,8 +157,8 @@ ap_sort (GtkListBoxRow *a,
GtkWidget *wa, *wb;
guint sa, sb;
- wa = gtk_bin_get_child (GTK_BIN (a));
- wb = gtk_bin_get_child (GTK_BIN (b));
+ wa = gtk_list_box_row_get_child (a);
+ wb = gtk_list_box_row_get_child (b);
sa = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (wa), "strength"));
sb = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (wb), "strength"));
@@ -169,21 +168,6 @@ ap_sort (GtkListBoxRow *a,
return 0;
}
-static void
-update_header_func (GtkListBoxRow *child,
- GtkListBoxRow *before,
- gpointer user_data)
-{
- GtkWidget *header;
-
- if (before == NULL)
- return;
-
- header = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_list_box_row_set_header (child, header);
- gtk_widget_show (header);
-}
-
static void
add_access_point (GisNetworkPage *page, NMAccessPoint *ap, NMAccessPoint *active)
{
@@ -245,20 +229,20 @@ add_access_point (GisNetworkPage *page, NMAccessPoint *ap, NMAccessPoint *active
widget = gtk_label_new (ssid_text);
gtk_widget_set_margin_top (widget, 12);
gtk_widget_set_margin_bottom (widget, 12);
- gtk_box_pack_start (GTK_BOX (row), widget, FALSE, FALSE, 0);
+ gtk_box_append (GTK_BOX (row), widget);
if (activated) {
- state_widget = gtk_image_new_from_icon_name ("object-select-symbolic", GTK_ICON_SIZE_MENU);
+ state_widget = gtk_image_new_from_icon_name ("object-select-symbolic");
} else if (activating) {
state_widget = gtk_spinner_new ();
- gtk_widget_show (state_widget);
gtk_spinner_start (GTK_SPINNER (state_widget));
}
if (state_widget) {
- gtk_widget_set_halign (state_widget, GTK_ALIGN_CENTER);
+ gtk_widget_set_halign (state_widget, GTK_ALIGN_START);
gtk_widget_set_valign (state_widget, GTK_ALIGN_CENTER);
- gtk_box_pack_start (GTK_BOX (row), state_widget, FALSE, FALSE, 0);
+ gtk_widget_set_hexpand (state_widget, TRUE);
+ gtk_box_append (GTK_BOX (row), state_widget);
}
grid = gtk_grid_new ();
@@ -266,11 +250,11 @@ add_access_point (GisNetworkPage *page, NMAccessPoint *ap, NMAccessPoint *active
gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE);
gtk_widget_set_valign (grid, GTK_ALIGN_CENTER);
gtk_size_group_add_widget (priv->icons, grid);
- gtk_box_pack_end (GTK_BOX (row), grid, FALSE, FALSE, 0);
+ gtk_box_append (GTK_BOX (row), grid);
if (security != NM_AP_SEC_UNKNOWN &&
security != NM_AP_SEC_NONE) {
- widget = gtk_image_new_from_icon_name ("network-wireless-encrypted-symbolic", GTK_ICON_SIZE_MENU);
+ widget = gtk_image_new_from_icon_name ("network-wireless-encrypted-symbolic");
gtk_grid_attach (GTK_GRID (grid), widget, 0, 0, 1, 1);
}
@@ -284,12 +268,10 @@ add_access_point (GisNetworkPage *page, NMAccessPoint *ap, NMAccessPoint *active
icon_name = "network-wireless-signal-good-symbolic";
else
icon_name = "network-wireless-signal-excellent-symbolic";
- widget = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_MENU);
+ widget = gtk_image_new_from_icon_name (icon_name);
gtk_widget_set_halign (widget, GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (grid), widget, 1, 0, 1, 1);
- gtk_widget_show_all (row);
-
/* if this connection is the active one or is being activated, then make sure
* it's sorted before all others */
if (activating || activated)
@@ -299,10 +281,7 @@ add_access_point (GisNetworkPage *page, NMAccessPoint *ap, NMAccessPoint *active
g_object_set_data (G_OBJECT (row), "ssid", (gpointer) ssid);
g_object_set_data (G_OBJECT (row), "strength", GUINT_TO_POINTER (strength));
- widget = gtk_list_box_row_new ();
- gtk_container_add (GTK_CONTAINER (widget), row);
- gtk_widget_show (widget);
- gtk_container_add (GTK_CONTAINER (priv->network_list), widget);
+ gtk_list_box_append (GTK_LIST_BOX (priv->network_list), row);
}
static void
@@ -318,13 +297,12 @@ add_access_point_other (GisNetworkPage *page)
widget = gtk_label_new (C_("Wireless access point", "Other…"));
gtk_widget_set_margin_top (widget, 12);
gtk_widget_set_margin_bottom (widget, 12);
- gtk_box_pack_start (GTK_BOX (row), widget, FALSE, FALSE, 0);
- gtk_widget_show_all (row);
+ gtk_box_append (GTK_BOX (row), widget);
g_object_set_data (G_OBJECT (row), "object-path", "ap-other...");
g_object_set_data (G_OBJECT (row), "strength", GUINT_TO_POINTER (0));
- gtk_container_add (GTK_CONTAINER (priv->network_list), row);
+ gtk_list_box_append (GTK_LIST_BOX (priv->network_list), row);
}
static gboolean refresh_wireless_list (GisNetworkPage *page);
@@ -372,8 +350,8 @@ refresh_wireless_list (GisNetworkPage *page)
NMAccessPoint *ap;
const GPtrArray *aps;
GPtrArray *unique_aps;
+ GtkWidget *child;
guint i;
- GList *children, *l;
gboolean enabled;
g_debug ("Refreshing Wi-Fi networks list");
@@ -386,10 +364,8 @@ refresh_wireless_list (GisNetworkPage *page)
active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (priv->nm_device));
- children = gtk_container_get_children (GTK_CONTAINER (priv->network_list));
- for (l = children; l; l = l->next)
- gtk_container_remove (GTK_CONTAINER (priv->network_list), l->data);
- g_list_free (children);
+ while ((child = gtk_widget_get_first_child (priv->network_list)) != NULL)
+ gtk_list_box_remove (GTK_LIST_BOX (priv->network_list), child);
aps = nm_device_wifi_get_access_points (NM_DEVICE_WIFI (priv->nm_device));
enabled = nm_client_wireless_get_enabled (priv->nm_client);
@@ -414,7 +390,7 @@ refresh_wireless_list (GisNetworkPage *page)
gtk_widget_hide (priv->turn_on_switch);
}
- gtk_widget_hide (priv->scrolled_window);
+ gtk_widget_hide (priv->network_list);
goto out;
} else {
@@ -422,7 +398,7 @@ refresh_wireless_list (GisNetworkPage *page)
gtk_widget_hide (priv->no_network_label);
gtk_widget_hide (priv->turn_on_label);
gtk_widget_hide (priv->turn_on_switch);
- gtk_widget_show (priv->scrolled_window);
+ gtk_widget_show (priv->network_list);
}
unique_aps = get_strongest_unique_aps (aps);
@@ -501,8 +477,9 @@ static void
connect_to_hidden_network (GisNetworkPage *page)
{
GisNetworkPagePrivate *priv = gis_network_page_get_instance_private (page);
- cc_network_panel_connect_to_hidden_network (gtk_widget_get_toplevel (GTK_WIDGET (page)),
- priv->nm_client);
+ GtkRoot *root = gtk_widget_get_root (GTK_WIDGET (page));
+
+ cc_network_panel_connect_to_hidden_network (GTK_WIDGET (root), priv->nm_client);
}
static void
@@ -525,7 +502,7 @@ row_activated (GtkListBox *box,
if (priv->refreshing)
return;
- child = gtk_bin_get_child (GTK_BIN (row));
+ child = gtk_list_box_row_get_child (row);
object_path = g_object_get_data (G_OBJECT (child), "object-path");
ssid_target = g_object_get_data (G_OBJECT (child), "ssid");
@@ -765,7 +742,6 @@ gis_network_page_constructed (GObject *object)
priv->icons = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_list_box_set_selection_mode (GTK_LIST_BOX (priv->network_list), GTK_SELECTION_NONE);
- gtk_list_box_set_header_func (GTK_LIST_BOX (priv->network_list), update_header_func, NULL, NULL);
gtk_list_box_set_sort_func (GTK_LIST_BOX (priv->network_list), ap_sort, NULL, NULL);
g_signal_connect (priv->network_list, "row-activated",
G_CALLBACK (row_activated), page);
@@ -822,7 +798,6 @@ gis_network_page_class_init (GisNetworkPageClass *klass)
gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
"/org/gnome/initial-setup/gis-network-page.ui");
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisNetworkPage, network_list);
- gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisNetworkPage, scrolled_window);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisNetworkPage, no_network_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisNetworkPage,
no_network_spinner);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass), GisNetworkPage, turn_on_label);
diff --git a/gnome-initial-setup/pages/network/gis-network-page.ui
b/gnome-initial-setup/pages/network/gis-network-page.ui
index cdad9a60..2bda59ca 100644
--- a/gnome-initial-setup/pages/network/gis-network-page.ui
+++ b/gnome-initial-setup/pages/network/gis-network-page.ui
@@ -1,117 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.0 on Wed Oct 16 17:37:48 2013 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
<template class="GisNetworkPage" parent="GisPage">
<child>
- <object class="GtkBox" id="box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">fill</property>
- <property name="margin_bottom">32</property>
+ <object class="AdwPreferencesPage">
<child>
- <object class="GisPageHeader" id="header">
- <property name="visible">True</property>
- <property name="margin_top">24</property>
- <property name="title" translatable="yes">Wi-Fi</property>
- <property name="subtitle" translatable="yes">Connecting to the internet helps you get new apps,
information, and other upgrades. It also helps set the time and your location automatically.</property>
- <property name="icon_name">network-wireless-symbolic</property>
- <property name="show_icon" bind-source="GisNetworkPage" bind-property="small-screen"
bind-flags="invert-boolean|sync-create"/>
- </object>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolled_window">
- <property name="margin_top">18</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
+ <object class="AdwPreferencesGroup">
<child>
- <object class="GtkViewport" id="viewport1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <object class="GtkBox" id="box">
+ <property name="orientation">vertical</property>
+ <property name="margin_bottom">32</property>
+ <child>
+ <object class="GisPageHeader" id="header">
+ <property name="margin_top">24</property>
+ <property name="title" translatable="yes">Wi-Fi</property>
+ <property name="subtitle" translatable="yes">Connecting to the internet helps you get
new apps, information, and other upgrades. It also helps set the time and your location
automatically.</property>
+ <property name="icon_name">network-wireless-symbolic</property>
+ <property name="show_icon" bind-source="GisNetworkPage" bind-property="small-screen"
bind-flags="invert-boolean|sync-create"/>
+ </object>
+ </child>
<child>
<object class="GtkListBox" id="network_list">
- <property name="visible">True</property>
+ <property name="valign">start</property>
<property name="vexpand">True</property>
+ <property name="margin-top">18</property>
+ <style>
+ <class name="boxed-list" />
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkGrid" id="no_network_grid">
+ <property name="margin_top">18</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="row-spacing">10</property>
+ <child>
+ <object class="GtkSpinner" id="no_network_spinner">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin_start">6</property>
+ <property name="margin_end">6</property>
+ <property name="spinning">True</property>
+ <layout>
+ <property name="column">0</property>
+ <property name="row">0</property>
+ <property name="column-span">1</property>
+ <property name="row-span">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="no_network_label">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">No wireless available</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">0</property>
+ <property name="column-span">2</property>
+ <property name="row-span">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="turn_on_label">
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="label" translatable="yes">Turn On</property>
+ <layout>
+ <property name="column">1</property>
+ <property name="row">1</property>
+ <property name="column-span">1</property>
+ <property name="row-span">1</property>
+ </layout>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="turn_on_switch">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <layout>
+ <property name="column">2</property>
+ <property name="row">1</property>
+ <property name="column-span">1</property>
+ <property name="row-span">1</property>
+ </layout>
+ </object>
+ </child>
</object>
</child>
</object>
</child>
</object>
</child>
- <child>
- <object class="GtkGrid" id="no_network_grid">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">18</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
- <property name="row-spacing">10</property>
- <child>
- <object class="GtkSpinner" id="no_network_spinner">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="margin_start">6</property>
- <property name="margin_end">6</property>
- <property name="active">True</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="no_network_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="label" translatable="yes">No wireless available</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">2</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="turn_on_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">start</property>
- <property name="valign">center</property>
- <property name="label" translatable="yes">Turn On</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkSwitch" id="turn_on_switch">
- <property name="visible">True</property>
- <property name="halign">end</property>
- <property name="valign">center</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- </object>
- </child>
</object>
</child>
</template>
diff --git a/gnome-initial-setup/pages/network/network-dialogs.c
b/gnome-initial-setup/pages/network/network-dialogs.c
index 09490e65..9018eac6 100644
--- a/gnome-initial-setup/pages/network/network-dialogs.c
+++ b/gnome-initial-setup/pages/network/network-dialogs.c
@@ -181,8 +181,7 @@ wireless_dialog_response_cb (GtkDialog *foo,
g_object_unref (connection);
done:
- gtk_widget_hide (GTK_WIDGET (dialog));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gtk_window_destroy (GTK_WINDOW (dialog));
}
static void
@@ -194,7 +193,6 @@ show_wireless_dialog (GtkWidget *toplevel,
g_debug ("About to parent and show a network dialog");
- g_assert (gtk_widget_is_toplevel (toplevel));
g_object_set (G_OBJECT (dialog),
"modal", TRUE,
"transient-for", toplevel,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]