[gnome-control-center] network: Convert connection editor to GtkListBox
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Convert connection editor to GtkListBox
- Date: Tue, 2 Jul 2013 15:29:34 +0000 (UTC)
commit 62f18a2e32fab1b2129ae5f8cb58be840a63fcb6
Author: Kalev Lember <kalevlember gmail com>
Date: Fri Jun 21 20:03:53 2013 +0200
network: Convert connection editor to GtkListBox
https://bugzilla.gnome.org/show_bug.cgi?id=702164
panels/network/connection-editor/ce-page-ip4.c | 142 +++++++++++---------
panels/network/connection-editor/ce-page-ip6.c | 140 +++++++++++---------
.../connection-editor/net-connection-editor.c | 84 +++++++-----
3 files changed, 204 insertions(+), 162 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-ip4.c b/panels/network/connection-editor/ce-page-ip4.c
index a7f1124..1bf98a8 100644
--- a/panels/network/connection-editor/ce-page-ip4.c
+++ b/panels/network/connection-editor/ce-page-ip4.c
@@ -29,8 +29,6 @@
#include "ce-page-ip4.h"
#include <nm-utils.h>
-#include "egg-list-box/egg-list-box.h"
-
G_DEFINE_TYPE (CEPageIP4, ce_page_ip4, CE_TYPE_PAGE)
enum {
@@ -93,19 +91,21 @@ switch_toggled (GObject *object,
}
static void
-update_separator (GtkWidget **separator,
- GtkWidget *child,
- GtkWidget *before,
- gpointer user_data)
+update_header (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
{
+ GtkWidget *current;
+
if (before == NULL)
return;
- if (*separator == NULL)
+ current = gtk_list_box_row_get_header (row);
+ if (current == NULL)
{
- *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (*separator);
- g_object_ref_sink (*separator);
+ current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_show (current);
+ gtk_list_box_row_set_header (row, current);
}
}
@@ -138,10 +138,12 @@ update_row_sensitivity (CEPageIP4 *page, GtkWidget *list)
static void
remove_row (GtkButton *button, CEPageIP4 *page)
{
- GtkWidget *row;
GtkWidget *list;
+ GtkWidget *row;
+ GtkWidget *row_box;
- row = gtk_widget_get_parent (GTK_WIDGET (button));
+ row_box = gtk_widget_get_parent (GTK_WIDGET (button));
+ row = gtk_widget_get_parent (row_box);
list = gtk_widget_get_parent (row);
gtk_container_remove (GTK_CONTAINER (list), row);
@@ -180,15 +182,18 @@ add_address_row (CEPageIP4 *page,
const gchar *gateway)
{
GtkWidget *row;
+ GtkWidget *row_grid;
GtkWidget *widget;
GtkWidget *label;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_grid_new ();
+ row = gtk_list_box_row_new ();
+
+ row_grid = gtk_grid_new ();
label = gtk_label_new (_("Address"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -197,11 +202,11 @@ add_address_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);
label = gtk_label_new (_("Netmask"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -210,12 +215,12 @@ add_address_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);
label = gtk_label_new (_("Gateway"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -224,7 +229,7 @@ add_address_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -232,15 +237,17 @@ add_address_row (CEPageIP4 *page,
image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Address"));
gtk_button_set_image (GTK_BUTTON (delete_button), image);
- gtk_grid_attach (GTK_GRID (row), delete_button, 3, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 2, 1, 1);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_grid_set_row_spacing (GTK_GRID (row), 10);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
+ gtk_widget_set_margin_left (row_grid, 10);
+ gtk_widget_set_margin_right (row_grid, 10);
+ gtk_widget_set_margin_top (row_grid, 10);
+ gtk_widget_set_margin_bottom (row_grid, 10);
+ gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);
+
+ gtk_container_add (GTK_CONTAINER (row), row_grid);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->address_list), row);
@@ -300,10 +307,10 @@ add_address_section (CEPageIP4 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->address_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->address_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
add_section_toolbar (page, widget, G_CALLBACK (add_empty_address_row));
@@ -341,15 +348,18 @@ add_dns_row (CEPageIP4 *page,
const gchar *address)
{
GtkWidget *row;
+ GtkWidget *row_box;
GtkWidget *label;
GtkWidget *widget;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ row = gtk_list_box_row_new ();
+
+ row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new (_("Server"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_box_pack_start (GTK_BOX (row), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), label, FALSE, FALSE, 0);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -358,7 +368,7 @@ add_dns_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_box_pack_start (GTK_BOX (row), widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), widget, TRUE, TRUE, 0);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -366,14 +376,16 @@ add_dns_row (CEPageIP4 *page,
image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete DNS Server"));
gtk_button_set_image (GTK_BUTTON (delete_button), image);
- gtk_box_pack_start (GTK_BOX (row), delete_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), delete_button, FALSE, FALSE, 0);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_widget_set_margin_left (row_box, 10);
+ gtk_widget_set_margin_right (row_box, 10);
+ gtk_widget_set_margin_top (row_box, 10);
+ gtk_widget_set_margin_bottom (row_box, 10);
+ gtk_widget_set_halign (row_box, GTK_ALIGN_FILL);
+
+ gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->dns_list), row);
@@ -398,10 +410,10 @@ add_dns_section (CEPageIP4 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->dns_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->dns_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_dns = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "auto_dns_switch"));
gtk_switch_set_active (page->auto_dns, !nm_setting_ip4_config_get_ignore_auto_dns (page->setting));
@@ -432,15 +444,18 @@ add_route_row (CEPageIP4 *page,
gint metric)
{
GtkWidget *row;
+ GtkWidget *row_grid;
GtkWidget *label;
GtkWidget *widget;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_grid_new ();
+ row = gtk_list_box_row_new ();
+
+ row_grid = gtk_grid_new ();
label = gtk_label_new (_("Address"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -449,11 +464,11 @@ add_route_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);
label = gtk_label_new (_("Netmask"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -462,11 +477,11 @@ add_route_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);
label = gtk_label_new (_("Gateway"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -475,12 +490,12 @@ add_route_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);
/* Translators: Please see https://en.wikipedia.org/wiki/Metrics_(networking) */
label = gtk_label_new (C_("network parameters", "Metric"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 4, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -493,7 +508,7 @@ add_route_row (CEPageIP4 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 4, 1, 1);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -503,16 +518,17 @@ add_route_row (CEPageIP4 *page,
gtk_button_set_image (GTK_BUTTON (delete_button), image);
gtk_widget_set_halign (delete_button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (delete_button, GTK_ALIGN_CENTER);
- gtk_grid_attach (GTK_GRID (row), delete_button, 3, 1, 1, 4);
+ gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 1, 1, 4);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_grid_set_row_spacing (GTK_GRID (row), 10);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
+ gtk_widget_set_margin_left (row_grid, 10);
+ gtk_widget_set_margin_right (row_grid, 10);
+ gtk_widget_set_margin_top (row_grid, 10);
+ gtk_widget_set_margin_bottom (row_grid, 10);
+ gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);
+ gtk_container_add (GTK_CONTAINER (row), row_grid);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->routes_list), row);
@@ -537,10 +553,10 @@ add_routes_section (CEPageIP4 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->routes_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->routes_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_routes = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder,
"auto_routes_switch"));
gtk_switch_set_active (page->auto_routes, !nm_setting_ip4_config_get_ignore_auto_routes
(page->setting));
diff --git a/panels/network/connection-editor/ce-page-ip6.c b/panels/network/connection-editor/ce-page-ip6.c
index aee7037..c30a4b6 100644
--- a/panels/network/connection-editor/ce-page-ip6.c
+++ b/panels/network/connection-editor/ce-page-ip6.c
@@ -29,8 +29,6 @@
#include "ce-page-ip6.h"
#include <nm-utils.h>
-#include "egg-list-box/egg-list-box.h"
-
G_DEFINE_TYPE (CEPageIP6, ce_page_ip6, CE_TYPE_PAGE)
enum {
@@ -95,19 +93,21 @@ switch_toggled (GObject *object,
}
static void
-update_separator (GtkWidget **separator,
- GtkWidget *child,
- GtkWidget *before,
- gpointer user_data)
+update_header (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
{
+ GtkWidget *current;
+
if (before == NULL)
return;
- if (*separator == NULL)
+ current = gtk_list_box_row_get_header (row);
+ if (current == NULL)
{
- *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (*separator);
- g_object_ref_sink (*separator);
+ current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_show (current);
+ gtk_list_box_row_set_header (row, current);
}
}
@@ -141,9 +141,11 @@ static void
remove_row (GtkButton *button, CEPageIP6 *page)
{
GtkWidget *row;
+ GtkWidget *row_box;
GtkWidget *list;
- row = gtk_widget_get_parent (GTK_WIDGET (button));
+ row_box = gtk_widget_get_parent (GTK_WIDGET (button));
+ row = gtk_widget_get_parent (row_box);
list = gtk_widget_get_parent (row);
gtk_container_remove (GTK_CONTAINER (list), row);
@@ -182,15 +184,18 @@ add_address_row (CEPageIP6 *page,
const gchar *gateway)
{
GtkWidget *row;
+ GtkWidget *row_grid;
GtkWidget *label;
GtkWidget *widget;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_grid_new ();
+ row = gtk_list_box_row_new ();
+
+ row_grid = gtk_grid_new ();
label = gtk_label_new (_("Address"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -199,11 +204,11 @@ add_address_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);
label = gtk_label_new (_("Prefix"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -212,11 +217,11 @@ add_address_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);
label = gtk_label_new (_("Gateway"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -225,7 +230,7 @@ add_address_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -233,15 +238,17 @@ add_address_row (CEPageIP6 *page,
image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete Address"));
gtk_button_set_image (GTK_BUTTON (delete_button), image);
- gtk_grid_attach (GTK_GRID (row), delete_button, 3, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 2, 1, 1);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_grid_set_row_spacing (GTK_GRID (row), 10);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
+ gtk_widget_set_margin_left (row_grid, 10);
+ gtk_widget_set_margin_right (row_grid, 10);
+ gtk_widget_set_margin_top (row_grid, 10);
+ gtk_widget_set_margin_bottom (row_grid, 10);
+ gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);
+
+ gtk_container_add (GTK_CONTAINER (row), row_grid);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->address_list), row);
@@ -301,10 +308,10 @@ add_address_section (CEPageIP6 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->address_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->address_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
add_section_toolbar (page, widget, G_CALLBACK (add_empty_address_row));
@@ -344,16 +351,19 @@ add_dns_row (CEPageIP6 *page,
const gchar *address)
{
GtkWidget *row;
+ GtkWidget *row_box;
GtkWidget *label;
GtkWidget *widget;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ row = gtk_list_box_row_new ();
gtk_widget_set_can_focus (row, FALSE);
+
+ row_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
label = gtk_label_new (_("Server"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_box_pack_start (GTK_BOX (row), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), label, FALSE, FALSE, 0);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -362,7 +372,7 @@ add_dns_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_box_pack_start (GTK_BOX (row), widget, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), widget, TRUE, TRUE, 0);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -370,14 +380,16 @@ add_dns_row (CEPageIP6 *page,
image = gtk_image_new_from_icon_name ("user-trash-symbolic", GTK_ICON_SIZE_MENU);
atk_object_set_name (gtk_widget_get_accessible (delete_button), _("Delete DNS Server"));
gtk_button_set_image (GTK_BUTTON (delete_button), image);
- gtk_box_pack_start (GTK_BOX (row), delete_button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), delete_button, FALSE, FALSE, 0);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_widget_set_margin_left (row_box, 10);
+ gtk_widget_set_margin_right (row_box, 10);
+ gtk_widget_set_margin_top (row_box, 10);
+ gtk_widget_set_margin_bottom (row_box, 10);
+ gtk_widget_set_halign (row_box, GTK_ALIGN_FILL);
+
+ gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->dns_list), row);
@@ -402,10 +414,10 @@ add_dns_section (CEPageIP6 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->dns_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->dns_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_dns = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder, "auto_dns_switch"));
gtk_switch_set_active (page->auto_dns, !nm_setting_ip6_config_get_ignore_auto_dns (page->setting));
@@ -436,15 +448,18 @@ add_route_row (CEPageIP6 *page,
gint metric)
{
GtkWidget *row;
+ GtkWidget *row_grid;
GtkWidget *label;
GtkWidget *widget;
GtkWidget *delete_button;
GtkWidget *image;
- row = gtk_grid_new ();
+ row = gtk_list_box_row_new ();
+
+ row_grid = gtk_grid_new ();
label = gtk_label_new (_("Address"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 1, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -453,11 +468,11 @@ add_route_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 1, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 1, 1, 1);
label = gtk_label_new (_("Prefix"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 2, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -470,11 +485,11 @@ add_route_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 2, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 2, 1, 1);
label = gtk_label_new (_("Gateway"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -483,12 +498,12 @@ add_route_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 3, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);
/* Translators: Please see https://en.wikipedia.org/wiki/Metrics_(networking) */
label = gtk_label_new (C_("network parameters", "Metric"));
gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
- gtk_grid_attach (GTK_GRID (row), label, 1, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), label, 1, 4, 1, 1);
widget = gtk_entry_new ();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
@@ -501,7 +516,7 @@ add_route_row (CEPageIP6 *page,
gtk_widget_set_margin_left (widget, 10);
gtk_widget_set_margin_right (widget, 10);
gtk_widget_set_hexpand (widget, TRUE);
- gtk_grid_attach (GTK_GRID (row), widget, 2, 4, 1, 1);
+ gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 4, 1, 1);
delete_button = gtk_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
@@ -511,16 +526,17 @@ add_route_row (CEPageIP6 *page,
gtk_button_set_image (GTK_BUTTON (delete_button), image);
gtk_widget_set_halign (delete_button, GTK_ALIGN_CENTER);
gtk_widget_set_valign (delete_button, GTK_ALIGN_CENTER);
- gtk_grid_attach (GTK_GRID (row), delete_button, 3, 1, 1, 4);
+ gtk_grid_attach (GTK_GRID (row_grid), delete_button, 3, 1, 1, 4);
g_object_set_data (G_OBJECT (row), "delete-button", delete_button);
- gtk_grid_set_row_spacing (GTK_GRID (row), 10);
- gtk_widget_set_margin_left (row, 10);
- gtk_widget_set_margin_right (row, 10);
- gtk_widget_set_margin_top (row, 10);
- gtk_widget_set_margin_bottom (row, 10);
- gtk_widget_set_halign (row, GTK_ALIGN_FILL);
+ gtk_grid_set_row_spacing (GTK_GRID (row_grid), 10);
+ gtk_widget_set_margin_left (row_grid, 10);
+ gtk_widget_set_margin_right (row_grid, 10);
+ gtk_widget_set_margin_top (row_grid, 10);
+ gtk_widget_set_margin_bottom (row_grid, 10);
+ gtk_widget_set_halign (row_grid, GTK_ALIGN_FILL);
+ gtk_container_add (GTK_CONTAINER (row), row_grid);
gtk_widget_show_all (row);
gtk_container_add (GTK_CONTAINER (page->routes_list), row);
@@ -545,10 +561,10 @@ add_routes_section (CEPageIP6 *page)
frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (widget), frame);
- page->routes_list = list = GTK_WIDGET (egg_list_box_new ());
- egg_list_box_set_selection_mode (EGG_LIST_BOX (list), GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (EGG_LIST_BOX (list), update_separator, NULL, NULL);
- egg_list_box_set_sort_func (EGG_LIST_BOX (list), sort_first_last, NULL, NULL);
+ page->routes_list = list = gtk_list_box_new ();
+ gtk_list_box_set_selection_mode (GTK_LIST_BOX (list), GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (GTK_LIST_BOX (list), update_header, NULL, NULL);
+ gtk_list_box_set_sort_func (GTK_LIST_BOX (list), (GtkListBoxSortFunc)sort_first_last, NULL, NULL);
gtk_container_add (GTK_CONTAINER (frame), list);
page->auto_routes = GTK_SWITCH (gtk_builder_get_object (CE_PAGE (page)->builder,
"auto_routes_switch"));
gtk_switch_set_active (page->auto_routes, !nm_setting_ip6_config_get_ignore_auto_routes
(page->setting));
diff --git a/panels/network/connection-editor/net-connection-editor.c
b/panels/network/connection-editor/net-connection-editor.c
index 5f53a87..a645c57 100644
--- a/panels/network/connection-editor/net-connection-editor.c
+++ b/panels/network/connection-editor/net-connection-editor.c
@@ -40,8 +40,6 @@
#include "ce-page-vpn.h"
#include "vpn-helpers.h"
-#include "egg-list-box/egg-list-box.h"
-
enum {
DONE,
LAST_SIGNAL
@@ -568,19 +566,21 @@ net_connection_editor_set_connection (NetConnectionEditor *editor,
}
static void
-update_separator (GtkWidget **separator,
- GtkWidget *child,
- GtkWidget *before,
- gpointer user_data)
+update_header (GtkListBoxRow *row,
+ GtkListBoxRow *before,
+ gpointer user_data)
{
+ GtkWidget *current;
+
if (before == NULL)
return;
- if (*separator == NULL)
+ current = gtk_list_box_row_get_header (row);
+ if (current == NULL)
{
- *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_widget_show (*separator);
- g_object_ref_sink (*separator);
+ current = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_widget_show (current);
+ gtk_list_box_row_set_header (row, current);
}
}
@@ -705,7 +705,7 @@ vpn_import_complete (NMConnection *connection, gpointer user_data)
}
static void
-vpn_type_activated (EggListBox *list, GtkWidget *row, NetConnectionEditor *editor)
+vpn_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *editor)
{
const char *service_name = g_object_get_data (G_OBJECT (row), "service_name");
NMConnection *connection;
@@ -730,13 +730,14 @@ vpn_type_activated (EggListBox *list, GtkWidget *row, NetConnectionEditor *edito
}
static void
-select_vpn_type (NetConnectionEditor *editor, EggListBox *list)
+select_vpn_type (NetConnectionEditor *editor, GtkListBox *list)
{
GHashTable *vpn_plugins;
GHashTableIter vpn_iter;
gpointer service_name, vpn_plugin;
GList *children, *plugin_list, *iter;
- GtkWidget *row, *name_label, *desc_label;
+ GtkWidget *row, *row_box;
+ GtkWidget *name_label, *desc_label;
GError *error = NULL;
/* Get the available VPN types */
@@ -773,15 +774,17 @@ select_vpn_type (NetConnectionEditor *editor, EggListBox *list)
NULL);
desc_markup = g_markup_printf_escaped ("<span size='smaller'>%s</span>", desc);
- row = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_set_margin_left (row, 12);
- gtk_widget_set_margin_right (row, 12);
- gtk_widget_set_margin_top (row, 12);
- gtk_widget_set_margin_bottom (row, 12);
+ row = gtk_list_box_row_new ();
+
+ row_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_widget_set_margin_left (row_box, 12);
+ gtk_widget_set_margin_right (row_box, 12);
+ gtk_widget_set_margin_top (row_box, 12);
+ gtk_widget_set_margin_bottom (row_box, 12);
name_label = gtk_label_new (name);
gtk_misc_set_alignment (GTK_MISC (name_label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (row), name_label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), name_label, FALSE, TRUE, 0);
desc_label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (desc_label), desc_markup);
@@ -789,38 +792,42 @@ select_vpn_type (NetConnectionEditor *editor, EggListBox *list)
gtk_misc_set_alignment (GTK_MISC (desc_label), 0.0, 0.5);
context = gtk_widget_get_style_context (desc_label);
gtk_style_context_add_class (context, "dim-label");
- gtk_box_pack_start (GTK_BOX (row), desc_label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), desc_label, FALSE, TRUE, 0);
g_free (name);
g_free (desc);
g_free (desc_markup);
+ gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_widget_show_all (row);
g_object_set_data_full (G_OBJECT (row), "service_name", service_name, g_free);
gtk_container_add (GTK_CONTAINER (list), row);
}
/* Import */
- row = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_widget_set_margin_left (row, 12);
- gtk_widget_set_margin_right (row, 12);
- gtk_widget_set_margin_top (row, 12);
- gtk_widget_set_margin_bottom (row, 12);
+ row = gtk_list_box_row_new ();
+
+ row_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ gtk_widget_set_margin_left (row_box, 12);
+ gtk_widget_set_margin_right (row_box, 12);
+ gtk_widget_set_margin_top (row_box, 12);
+ gtk_widget_set_margin_bottom (row_box, 12);
name_label = gtk_label_new (_("Import from fileā¦"));
gtk_misc_set_alignment (GTK_MISC (name_label), 0.0, 0.5);
- gtk_box_pack_start (GTK_BOX (row), name_label, FALSE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (row_box), name_label, FALSE, TRUE, 0);
+ gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_widget_show_all (row);
g_object_set_data (G_OBJECT (row), "service_name", "import");
gtk_container_add (GTK_CONTAINER (list), row);
- g_signal_connect (list, "child-activated",
+ g_signal_connect (list, "row-activated",
G_CALLBACK (vpn_type_activated), editor);
}
static void
-connection_type_activated (EggListBox *list, GtkWidget *row, NetConnectionEditor *editor)
+connection_type_activated (GtkListBox *list, GtkWidget *row, NetConnectionEditor *editor)
{
const NetConnectionType *connection_type = g_object_get_data (G_OBJECT (row), "connection_type");
NMConnection *connection;
@@ -841,31 +848,34 @@ net_connection_editor_add_connection (NetConnectionEditor *editor)
{
GtkNotebook *notebook;
GtkContainer *frame;
- EggListBox *list;
+ GtkListBox *list;
int i;
notebook = GTK_NOTEBOOK (gtk_builder_get_object (editor->builder, "details_toplevel_notebook"));
frame = GTK_CONTAINER (gtk_builder_get_object (editor->builder, "details_add_connection_frame"));
- list = egg_list_box_new ();
- egg_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
- egg_list_box_set_separator_funcs (list, update_separator, NULL, NULL);
- g_signal_connect (list, "child-activated",
+ list = GTK_LIST_BOX (gtk_list_box_new ());
+ gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
+ gtk_list_box_set_header_func (list, update_header, NULL, NULL);
+ g_signal_connect (list, "row-activated",
G_CALLBACK (connection_type_activated), editor);
for (i = 0; i < G_N_ELEMENTS (connection_types); i++) {
- GtkWidget *row, *label;
+ GtkWidget *row, *row_box, *label;
- row = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ row = gtk_list_box_row_new ();
+
+ row_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
label = gtk_label_new (_(connection_types[i].name));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_widget_set_margin_left (label, 12);
gtk_widget_set_margin_right (label, 12);
gtk_widget_set_margin_top (label, 12);
gtk_widget_set_margin_bottom (label, 12);
- gtk_box_pack_start (GTK_BOX (row), label, FALSE, TRUE, 0);
- g_object_set_data (G_OBJECT (row), "connection_type", (gpointer) &connection_types[i]);
+ gtk_box_pack_start (GTK_BOX (row_box), label, FALSE, TRUE, 0);
+ g_object_set_data (G_OBJECT (row), "connection_type", (gpointer) &connection_types[i]);
+ gtk_container_add (GTK_CONTAINER (row), row_box);
gtk_container_add (GTK_CONTAINER (list), row);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]