[gnome-control-center] network: Move setting the device header pairs to common panel code
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: Move setting the device header pairs to common panel code
- Date: Tue, 17 Jul 2012 15:58:42 +0000 (UTC)
commit f4c13e835b72c8f3f274000663390932c0f74462
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 17 16:00:40 2012 +0100
network: Move setting the device header pairs to common panel code
This is yet another step to splitting out the other devices types.
panels/network/net-vpn.c | 84 ++++++++++------------------------------
panels/network/network-vpn.ui | 52 +++++++++++++-------------
panels/network/panel-common.c | 34 ++++++++++++++++
panels/network/panel-common.h | 4 ++
4 files changed, 85 insertions(+), 89 deletions(-)
---
diff --git a/panels/network/net-vpn.c b/panels/network/net-vpn.c
index 7422443..ee2ebd1 100644
--- a/panels/network/net-vpn.c
+++ b/panels/network/net-vpn.c
@@ -237,7 +237,7 @@ vpn_proxy_add_to_notebook (NetObject *object,
/* add widgets to size group */
widget = GTK_WIDGET (gtk_builder_get_object (vpn->priv->builder,
- "heading_vpn_group_password"));
+ "heading_group_password"));
gtk_size_group_add_widget (heading_size_group, widget);
/* reparent */
@@ -253,41 +253,6 @@ vpn_proxy_add_to_notebook (NetObject *object,
}
static void
-panel_set_widget_data (NetVpn *vpn,
- const gchar *widget_suffix,
- const gchar *value)
-{
- gchar *heading_id;
- gchar *label_id = NULL;
- GtkWidget *heading;
- GtkWidget *widget;
- const gchar *sub_pane = "vpn";
- NetVpnPrivate *priv = vpn->priv;
-
- /* hide the row if there is no value */
- heading_id = g_strdup_printf ("heading_%s_%s", sub_pane, widget_suffix);
- label_id = g_strdup_printf ("label_%s_%s", sub_pane, widget_suffix);
- heading = GTK_WIDGET (gtk_builder_get_object (priv->builder, heading_id));
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, label_id));
- if (heading == NULL || widget == NULL) {
- g_critical ("no widgets %s, %s found", heading_id, label_id);
- return;
- }
- g_free (heading_id);
- g_free (label_id);
-
- if (value == NULL) {
- gtk_widget_hide (heading);
- gtk_widget_hide (widget);
- } else {
- /* there exists a value */
- gtk_widget_show (heading);
- gtk_widget_show (widget);
- gtk_label_set_label (GTK_LABEL (widget), value);
- }
-}
-
-static void
nm_device_refresh_vpn_ui (NetVpn *vpn)
{
GtkWidget *widget;
@@ -304,19 +269,12 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
NMClient *client;
sw = GTK_WIDGET (gtk_builder_get_object (priv->builder,
- "device_vpn_off_switch"));
+ "device_off_switch"));
gtk_widget_set_visible (sw, TRUE);
- /* set VPN icon */
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
- "image_vpn_device"));
- gtk_image_set_from_icon_name (GTK_IMAGE (widget),
- "network-vpn",
- GTK_ICON_SIZE_DIALOG);
-
/* update title */
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
- "label_vpn_device"));
+ "label_device"));
title = g_strdup_printf (_("%s VPN"), nm_connection_get_id (vpn->priv->connection));
net_object_set_title (NET_OBJECT (vpn), title);
gtk_label_set_label (GTK_LABEL (widget), title);
@@ -340,7 +298,7 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
}
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
- "label_vpn_status"));
+ "label_status"));
status = panel_vpn_state_to_localized_string (state);
gtk_label_set_label (GTK_LABEL (widget), status);
priv->updating_device = TRUE;
@@ -350,29 +308,29 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
priv->updating_device = FALSE;
/* service type */
- panel_set_widget_data (vpn,
- "service_type",
- vpn->priv->service_type);
+ panel_set_device_widget_details (vpn->priv->builder,
+ "service_type",
+ vpn->priv->service_type);
/* gateway */
- panel_set_widget_data (vpn,
- "gateway",
- net_vpn_get_gateway (vpn));
+ panel_set_device_widget_details (vpn->priv->builder,
+ "gateway",
+ net_vpn_get_gateway (vpn));
/* groupname */
- panel_set_widget_data (vpn,
- "group_name",
- net_vpn_get_id (vpn));
+ panel_set_device_widget_details (vpn->priv->builder,
+ "group_name",
+ net_vpn_get_id (vpn));
/* username */
- panel_set_widget_data (vpn,
- "username",
- net_vpn_get_username (vpn));
+ panel_set_device_widget_details (vpn->priv->builder,
+ "username",
+ net_vpn_get_username (vpn));
/* password */
- panel_set_widget_data (vpn,
- "group_password",
- net_vpn_get_password (vpn));
+ panel_set_device_widget_details (vpn->priv->builder,
+ "group_password",
+ net_vpn_get_password (vpn));
}
static void
@@ -541,12 +499,12 @@ net_vpn_init (NetVpn *vpn)
}
widget = GTK_WIDGET (gtk_builder_get_object (vpn->priv->builder,
- "device_vpn_off_switch"));
+ "device_off_switch"));
g_signal_connect (widget, "notify::active",
G_CALLBACK (device_off_toggled), vpn);
widget = GTK_WIDGET (gtk_builder_get_object (vpn->priv->builder,
- "button_vpn_options"));
+ "button_options"));
g_signal_connect (widget, "clicked",
G_CALLBACK (edit_connection), vpn);
}
diff --git a/panels/network/network-vpn.ui b/panels/network/network-vpn.ui
index de1e4a0..224dbef 100644
--- a/panels/network/network-vpn.ui
+++ b/panels/network/network-vpn.ui
@@ -31,7 +31,7 @@
<property name="row_spacing">10</property>
<property name="column_spacing">6</property>
<child>
- <object class="GtkImage" id="image_vpn_device">
+ <object class="GtkImage" id="image_device">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
@@ -56,7 +56,7 @@
<property name="hexpand">True</property>
<property name="spacing">3</property>
<child>
- <object class="GtkLabel" id="label_vpn_device">
+ <object class="GtkLabel" id="label_device">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -74,7 +74,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_status">
+ <object class="GtkLabel" id="label_status">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -95,12 +95,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="heading_vpn_service_type">
+ <object class="GtkLabel" id="heading_service_type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">VPN Type</property>
- <property name="mnemonic_widget">label_vpn_service_type</property>
+ <property name="mnemonic_widget">label_service_type</property>
<style>
<class name="dim-label"/>
</style>
@@ -113,12 +113,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="heading_vpn_gateway">
+ <object class="GtkLabel" id="heading_gateway">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Gateway</property>
- <property name="mnemonic_widget">label_vpn_gateway</property>
+ <property name="mnemonic_widget">label_gateway</property>
<style>
<class name="dim-label"/>
</style>
@@ -131,12 +131,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="heading_vpn_group_name">
+ <object class="GtkLabel" id="heading_group_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Group Name</property>
- <property name="mnemonic_widget">label_vpn_group_name</property>
+ <property name="mnemonic_widget">label_group_name</property>
<style>
<class name="dim-label"/>
</style>
@@ -149,12 +149,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="heading_vpn_group_password">
+ <object class="GtkLabel" id="heading_group_password">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Group Password</property>
- <property name="mnemonic_widget">label_vpn_group_password</property>
+ <property name="mnemonic_widget">label_group_password</property>
<style>
<class name="dim-label"/>
</style>
@@ -167,12 +167,12 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="heading_vpn_username">
+ <object class="GtkLabel" id="heading_username">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Username</property>
- <property name="mnemonic_widget">label_vpn_username</property>
+ <property name="mnemonic_widget">label_username</property>
<style>
<class name="dim-label"/>
</style>
@@ -185,7 +185,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_service_type">
+ <object class="GtkLabel" id="label_service_type">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -200,7 +200,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_gateway">
+ <object class="GtkLabel" id="label_gateway">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -215,7 +215,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_group_name">
+ <object class="GtkLabel" id="label_group_name">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -230,7 +230,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_group_password">
+ <object class="GtkLabel" id="label_group_password">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -245,7 +245,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label_vpn_username">
+ <object class="GtkLabel" id="label_username">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
@@ -260,13 +260,13 @@
</packing>
</child>
<child>
- <object class="GtkAlignment" id="alignment_vpn_switch">
+ <object class="GtkAlignment" id="alignment_switch">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="valign">start</property>
<child>
- <object class="GtkSwitch" id="device_vpn_off_switch">
+ <object class="GtkSwitch" id="device_off_switch">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -294,7 +294,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkButton" id="button_vpn_options">
+ <object class="GtkButton" id="button_options">
<property name="label" translatable="yes">_Configure...</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
@@ -326,11 +326,11 @@
</object>
<object class="GtkSizeGroup" id="sizegroup1">
<widgets>
- <widget name="heading_vpn_service_type"/>
- <widget name="heading_vpn_gateway"/>
- <widget name="heading_vpn_group_name"/>
- <widget name="heading_vpn_group_password"/>
- <widget name="heading_vpn_username"/>
+ <widget name="heading_service_type"/>
+ <widget name="heading_gateway"/>
+ <widget name="heading_group_name"/>
+ <widget name="heading_group_password"/>
+ <widget name="heading_username"/>
</widgets>
</object>
</interface>
diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c
index aa2a020..1321ae3 100644
--- a/panels/network/panel-common.c
+++ b/panels/network/panel-common.c
@@ -473,3 +473,37 @@ panel_device_state_reason_to_localized_string (NMDevice *device)
}
return value;
}
+
+gboolean
+panel_set_device_widget_details (GtkBuilder *builder,
+ const gchar *widget_suffix,
+ const gchar *value)
+{
+ gchar *heading_id;
+ gchar *label_id;
+ GtkWidget *heading;
+ GtkWidget *widget;
+
+ /* hide the row if there is no value */
+ heading_id = g_strdup_printf ("heading_%s", widget_suffix);
+ label_id = g_strdup_printf ("label_%s", widget_suffix);
+ heading = GTK_WIDGET (gtk_builder_get_object (builder, heading_id));
+ widget = GTK_WIDGET (gtk_builder_get_object (builder, label_id));
+ if (heading == NULL || widget == NULL) {
+ g_critical ("no widgets %s, %s found", heading_id, label_id);
+ return FALSE;
+ }
+ g_free (heading_id);
+ g_free (label_id);
+
+ if (value == NULL) {
+ gtk_widget_hide (heading);
+ gtk_widget_hide (widget);
+ } else {
+ /* there exists a value */
+ gtk_widget_show (heading);
+ gtk_widget_show (widget);
+ gtk_label_set_label (GTK_LABEL (widget), value);
+ }
+ return TRUE;
+}
diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h
index f2c305d..3ad53e3 100644
--- a/panels/network/panel-common.h
+++ b/panels/network/panel-common.h
@@ -26,6 +26,7 @@
#include <NetworkManager.h>
#include <NetworkManagerVPN.h>
#include <nm-device.h>
+#include <gtk/gtk.h>
G_BEGIN_DECLS
@@ -36,6 +37,9 @@ const gchar *panel_ap_mode_to_localized_string (NM80211Mode mode
const gchar *panel_device_state_to_localized_string (NMDevice *device);
const gchar *panel_vpn_state_to_localized_string (NMVPNConnectionState type);
const gchar *panel_device_state_reason_to_localized_string (NMDevice *device);
+gboolean panel_set_device_widget_details (GtkBuilder *builder,
+ const gchar *widget_suffix,
+ const gchar *value);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]