[gnome-control-center] network: split out common non-object functionality into its own source file
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] network: split out common non-object functionality into its own source file
- Date: Wed, 15 Dec 2010 19:25:48 +0000 (UTC)
commit a248ecc4d4d274dca2265016f60ca03d379659dc
Author: Richard Hughes <richard hughsie com>
Date: Wed Dec 15 19:22:15 2010 +0000
network: split out common non-object functionality into its own source file
panels/network/Makefile.am | 2 +
panels/network/cc-network-panel.c | 143 +------------------------------
panels/network/panel-common.c | 174 +++++++++++++++++++++++++++++++++++++
panels/network/panel-common.h | 66 ++++++++++++++
po/POTFILES.in | 1 +
5 files changed, 245 insertions(+), 141 deletions(-)
---
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index f0d7deb..78daca1 100644
--- a/panels/network/Makefile.am
+++ b/panels/network/Makefile.am
@@ -11,6 +11,8 @@ ccpanels_LTLIBRARIES = libnetwork.la
libnetwork_la_SOURCES = \
network-module.c \
+ panel-common.c \
+ panel-common.h \
panel-cell-renderer-mode.c \
panel-cell-renderer-mode.h \
panel-cell-renderer-signal.c \
diff --git a/panels/network/cc-network-panel.c b/panels/network/cc-network-panel.c
index 251232e..e5da7dd 100644
--- a/panels/network/cc-network-panel.c
+++ b/panels/network/cc-network-panel.c
@@ -22,6 +22,8 @@
#include "cc-network-panel.h"
+#include "panel-common.h"
+
G_DEFINE_DYNAMIC_TYPE (CcNetworkPanel, cc_network_panel, CC_TYPE_PANEL)
#define NETWORK_PANEL_PRIVATE(o) \
@@ -50,29 +52,6 @@ enum {
PANEL_WIRELESS_COLUMN_LAST
};
-typedef enum {
- NM_DEVICE_TYPE_UNKNOWN,
- NM_DEVICE_TYPE_ETHERNET,
- NM_DEVICE_TYPE_WIFI,
- NM_DEVICE_TYPE_GSM,
- NM_DEVICE_TYPE_CDMA,
- NM_DEVICE_TYPE_BLUETOOTH,
- NM_DEVICE_TYPE_MESH
-} NMDeviceType;
-
-typedef enum {
- NM_DEVICE_STATE_UNKNOWN,
- NM_DEVICE_STATE_UNMANAGED,
- NM_DEVICE_STATE_UNAVAILABLE,
- NM_DEVICE_STATE_DISCONNECTED,
- NM_DEVICE_STATE_PREPARE,
- NM_DEVICE_STATE_CONFIG,
- NM_DEVICE_STATE_NEED_AUTH,
- NM_DEVICE_STATE_IP_CONFIG,
- NM_DEVICE_STATE_ACTIVATED,
- NM_DEVICE_STATE_FAILED
-} NMDeviceState;
-
static void
cc_network_panel_get_property (GObject *object,
guint property_id,
@@ -275,124 +254,6 @@ panel_dbus_signal_cb (GDBusProxy *proxy,
}
}
-/**
- * panel_device_type_to_icon_name:
- **/
-static const gchar *
-panel_device_type_to_icon_name (guint type)
-{
- const gchar *value = NULL;
- switch (type) {
- case NM_DEVICE_TYPE_ETHERNET:
- value = "network-wired";
- break;
- case NM_DEVICE_TYPE_WIFI:
- case NM_DEVICE_TYPE_GSM:
- case NM_DEVICE_TYPE_CDMA:
- case NM_DEVICE_TYPE_BLUETOOTH:
- case NM_DEVICE_TYPE_MESH:
- value = "network-wireless";
- break;
- default:
- break;
- }
- return value;
-}
-
-/**
- * panel_device_type_to_localized_string:
- **/
-static const gchar *
-panel_device_type_to_localized_string (guint type)
-{
- const gchar *value = NULL;
- switch (type) {
- case NM_DEVICE_TYPE_UNKNOWN:
- /* TRANSLATORS: device type */
- value = _("Unknown");
- break;
- case NM_DEVICE_TYPE_ETHERNET:
- /* TRANSLATORS: device type */
- value = _("Wired");
- break;
- case NM_DEVICE_TYPE_WIFI:
- /* TRANSLATORS: device type */
- value = _("Wireless");
- break;
- case NM_DEVICE_TYPE_GSM:
- case NM_DEVICE_TYPE_CDMA:
- /* TRANSLATORS: device type */
- value = _("Mobile broadband");
- break;
- case NM_DEVICE_TYPE_BLUETOOTH:
- /* TRANSLATORS: device type */
- value = _("Bluetooth");
- break;
- case NM_DEVICE_TYPE_MESH:
- /* TRANSLATORS: device type */
- value = _("Mesh");
- break;
-
- default:
- break;
- }
- return value;
-}
-
-/**
- * panel_device_state_to_localized_string:
- **/
-static const gchar *
-panel_device_state_to_localized_string (guint type)
-{
- const gchar *value = NULL;
- switch (type) {
- case NM_DEVICE_STATE_UNKNOWN:
- /* TRANSLATORS: device status */
- value = _("Status unknown");
- break;
- case NM_DEVICE_STATE_UNMANAGED:
- /* TRANSLATORS: device status */
- value = _("Unmanaged");
- break;
- case NM_DEVICE_STATE_UNAVAILABLE:
- /* TRANSLATORS: device status */
- value = _("Unavailable");
- break;
- case NM_DEVICE_STATE_DISCONNECTED:
- /* TRANSLATORS: device status */
- value = _("Disconnected");
- break;
- case NM_DEVICE_STATE_PREPARE:
- /* TRANSLATORS: device status */
- value = _("Preparing connection");
- break;
- case NM_DEVICE_STATE_CONFIG:
- /* TRANSLATORS: device status */
- value = _("Configuring connection");
- break;
- case NM_DEVICE_STATE_NEED_AUTH:
- /* TRANSLATORS: device status */
- value = _("Authenticating");
- break;
- case NM_DEVICE_STATE_IP_CONFIG:
- /* TRANSLATORS: device status */
- value = _("Getting network address");
- break;
- case NM_DEVICE_STATE_ACTIVATED:
- /* TRANSLATORS: device status */
- value = _("Connected");
- break;
- case NM_DEVICE_STATE_FAILED:
- /* TRANSLATORS: device status */
- value = _("Failed to connect");
- break;
- default:
- break;
- }
- return value;
-}
-
typedef struct {
CcNetworkPanel *panel;
guint type;
diff --git a/panels/network/panel-common.c b/panels/network/panel-common.c
new file mode 100644
index 0000000..3a19bd7
--- /dev/null
+++ b/panels/network/panel-common.c
@@ -0,0 +1,174 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "panel-common.h"
+
+
+/**
+ * panel_device_type_to_icon_name:
+ **/
+const gchar *
+panel_device_type_to_icon_name (guint type)
+{
+ const gchar *value = NULL;
+ switch (type) {
+ case NM_DEVICE_TYPE_ETHERNET:
+ value = "network-wired";
+ break;
+ case NM_DEVICE_TYPE_WIFI:
+ case NM_DEVICE_TYPE_GSM:
+ case NM_DEVICE_TYPE_CDMA:
+ case NM_DEVICE_TYPE_BLUETOOTH:
+ case NM_DEVICE_TYPE_MESH:
+ value = "network-wireless";
+ break;
+ default:
+ break;
+ }
+ return value;
+}
+
+/**
+ * panel_device_type_to_localized_string:
+ **/
+const gchar *
+panel_device_type_to_localized_string (guint type)
+{
+ const gchar *value = NULL;
+ switch (type) {
+ case NM_DEVICE_TYPE_UNKNOWN:
+ /* TRANSLATORS: device type */
+ value = _("Unknown");
+ break;
+ case NM_DEVICE_TYPE_ETHERNET:
+ /* TRANSLATORS: device type */
+ value = _("Wired");
+ break;
+ case NM_DEVICE_TYPE_WIFI:
+ /* TRANSLATORS: device type */
+ value = _("Wireless");
+ break;
+ case NM_DEVICE_TYPE_GSM:
+ case NM_DEVICE_TYPE_CDMA:
+ /* TRANSLATORS: device type */
+ value = _("Mobile broadband");
+ break;
+ case NM_DEVICE_TYPE_BLUETOOTH:
+ /* TRANSLATORS: device type */
+ value = _("Bluetooth");
+ break;
+ case NM_DEVICE_TYPE_MESH:
+ /* TRANSLATORS: device type */
+ value = _("Mesh");
+ break;
+
+ default:
+ break;
+ }
+ return value;
+}
+
+/**
+ * panel_ap_mode_to_localized_string:
+ **/
+const gchar *
+panel_ap_mode_to_localized_string (guint mode)
+{
+ const gchar *value = NULL;
+ switch (mode) {
+ case NM_802_11_MODE_UNKNOWN:
+ /* TRANSLATORS: AP type */
+ value = _("Unknown");
+ break;
+ case NM_802_11_MODE_ADHOC:
+ /* TRANSLATORS: AP type */
+ value = _("Ad-hoc");
+ break;
+ case NM_802_11_MODE_INFRA:
+ /* TRANSLATORS: AP type */
+ value = _("Intrastructure");
+ break;
+ default:
+ break;
+ }
+ return value;
+}
+
+/**
+ * panel_device_state_to_localized_string:
+ **/
+const gchar *
+panel_device_state_to_localized_string (guint type)
+{
+ const gchar *value = NULL;
+ switch (type) {
+ case NM_DEVICE_STATE_UNKNOWN:
+ /* TRANSLATORS: device status */
+ value = _("Status unknown");
+ break;
+ case NM_DEVICE_STATE_UNMANAGED:
+ /* TRANSLATORS: device status */
+ value = _("Unmanaged");
+ break;
+ case NM_DEVICE_STATE_UNAVAILABLE:
+ /* TRANSLATORS: device status */
+ value = _("Unavailable");
+ break;
+ case NM_DEVICE_STATE_DISCONNECTED:
+ /* TRANSLATORS: device status */
+ value = _("Disconnected");
+ break;
+ case NM_DEVICE_STATE_PREPARE:
+ /* TRANSLATORS: device status */
+ value = _("Preparing connection");
+ break;
+ case NM_DEVICE_STATE_CONFIG:
+ /* TRANSLATORS: device status */
+ value = _("Configuring connection");
+ break;
+ case NM_DEVICE_STATE_NEED_AUTH:
+ /* TRANSLATORS: device status */
+ value = _("Authenticating");
+ break;
+ case NM_DEVICE_STATE_IP_CONFIG:
+ /* TRANSLATORS: device status */
+ value = _("Getting network address");
+ break;
+ case NM_DEVICE_STATE_ACTIVATED:
+ /* TRANSLATORS: device status */
+ value = _("Connected");
+ break;
+ case NM_DEVICE_STATE_FAILED:
+ /* TRANSLATORS: device status */
+ value = _("Failed to connect");
+ break;
+ default:
+ break;
+ }
+ return value;
+}
+
diff --git a/panels/network/panel-common.h b/panels/network/panel-common.h
new file mode 100644
index 0000000..c92fd94
--- /dev/null
+++ b/panels/network/panel-common.h
@@ -0,0 +1,66 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2010 Richard Hughes <richard hughsie com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef PANEL_COMMON_H
+#define PANEL_COMMON_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ NM_DEVICE_TYPE_UNKNOWN,
+ NM_DEVICE_TYPE_ETHERNET,
+ NM_DEVICE_TYPE_WIFI,
+ NM_DEVICE_TYPE_GSM,
+ NM_DEVICE_TYPE_CDMA,
+ NM_DEVICE_TYPE_BLUETOOTH,
+ NM_DEVICE_TYPE_MESH
+} NMDeviceType;
+
+typedef enum {
+ NM_DEVICE_STATE_UNKNOWN,
+ NM_DEVICE_STATE_UNMANAGED,
+ NM_DEVICE_STATE_UNAVAILABLE,
+ NM_DEVICE_STATE_DISCONNECTED,
+ NM_DEVICE_STATE_PREPARE,
+ NM_DEVICE_STATE_CONFIG,
+ NM_DEVICE_STATE_NEED_AUTH,
+ NM_DEVICE_STATE_IP_CONFIG,
+ NM_DEVICE_STATE_ACTIVATED,
+ NM_DEVICE_STATE_FAILED
+} NMDeviceState;
+
+typedef enum {
+ NM_802_11_MODE_UNKNOWN = 0,
+ NM_802_11_MODE_ADHOC,
+ NM_802_11_MODE_INFRA
+} NM80211Mode;
+
+const gchar *panel_device_type_to_icon_name (guint type);
+const gchar *panel_device_type_to_localized_string (guint type);
+const gchar *panel_ap_mode_to_localized_string (guint mode);
+const gchar *panel_device_state_to_localized_string (guint type);
+
+G_END_DECLS
+
+#endif /* PANEL_COMMON_H */
+
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c4ee4c1..e5eda1e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -49,6 +49,7 @@ panels/proxy/gnome-proxy-properties.c
panels/proxy/gnome-proxy-panel.desktop.in.in
[type: gettext/glade]panels/proxy/gnome-proxy-properties.ui
panels/network/cc-network-panel.c
+panels/network/panel-common.c
panels/network/gnome-network-panel.desktop.in.in
[type: gettext/glade]panels/network/network.ui
panels/power/gnome-power-panel.desktop.in.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]