summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2010-12-15 19:22:15 +0000
committerRichard Hughes <richard@hughsie.com>2010-12-15 19:22:15 +0000
commita248ecc4d4d274dca2265016f60ca03d379659dc (patch)
tree58d1a2b0da2d2d8e9d611ded7c55c029a4da0a16
parent6b49a205877515b0f64315cfaac2a5ed483b8def (diff)
network: split out common non-object functionality into its own source file
-rw-r--r--panels/network/Makefile.am2
-rw-r--r--panels/network/cc-network-panel.c143
-rw-r--r--panels/network/panel-common.c174
-rw-r--r--panels/network/panel-common.h66
-rw-r--r--po/POTFILES.in1
5 files changed, 245 insertions, 141 deletions
diff --git a/panels/network/Makefile.am b/panels/network/Makefile.am
index f0d7deb9a..78daca1ca 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 251232e7d..e5da7dddb 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 000000000..3a19bd78e
--- /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 000000000..c92fd942b
--- /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 c4ee4c133..e5eda1e56 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