[network-manager-netbook] Replace 'Flight mode' with 'Offline mode'.
- From: Tambet Ingo <tambeti src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [network-manager-netbook] Replace 'Flight mode' with 'Offline mode'.
- Date: Tue, 8 Sep 2009 07:16:39 +0000 (UTC)
commit 2a2a30f30d19f1b436e0a66246e8ed1afa1017aa
Author: Tambet Ingo <tambet gmail com>
Date: Tue Sep 8 10:12:56 2009 +0300
Replace 'Flight mode' with 'Offline mode'.
src/network-manager-netbook.ui | 4 +-
src/nmn-applet.c | 64 ++++++++++++++++++------------
src/nmn-networks.c | 79 ++++++++++++++++++++-----------------
src/nmn-nm-data.c | 84 ++++++++++++++++++++++++----------------
src/nmn-nm-data.h | 36 ++++++++--------
5 files changed, 152 insertions(+), 115 deletions(-)
---
diff --git a/src/network-manager-netbook.ui b/src/network-manager-netbook.ui
index 46627f1..5a3268c 100644
--- a/src/network-manager-netbook.ui
+++ b/src/network-manager-netbook.ui
@@ -239,7 +239,7 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes">This will disable all wireless connections</property>
+ <property name="label" translatable="yes">This will disable all network connections</property>
</object>
<packing>
<property name="right_attach">2</property>
@@ -293,7 +293,7 @@
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes"><b>Flight mode</b></property>
+ <property name="label" translatable="yes"><b>Offline mode</b></property>
<property name="use_markup">True</property>
</object>
<packing>
diff --git a/src/nmn-applet.c b/src/nmn-applet.c
index 2ad50fa..002ed81 100644
--- a/src/nmn-applet.c
+++ b/src/nmn-applet.c
@@ -42,7 +42,7 @@ typedef struct {
GtkWidget *enable_wifi;
GtkWidget *enable_ethernet;
GtkWidget *enable_3g;
- GtkWidget *enable_flightmode;
+ GtkWidget *enable_network;
GtkWidget *add_new_connection;
GtkWidget *new_dialog;
@@ -88,15 +88,28 @@ enable_wifi_toggled (NbtkGtkLightSwitch *w,
}
static void
+wifi_toggle_set_sensitive (NmnNMData *nm_data,
+ GtkWidget *widget,
+ gboolean suggested)
+{
+ if (suggested == FALSE || nmn_nm_data_wifi_can_change (nm_data) == FALSE)
+ gtk_widget_set_sensitive (widget, FALSE);
+ else
+ gtk_widget_set_sensitive (widget, TRUE);
+}
+
+static void
wifi_toggled (NmnNMData *nm_data,
- gboolean active,
- gpointer user_data)
+ gboolean active,
+ gpointer user_data)
{
NmnAppletPrivate *priv = GET_PRIVATE (user_data);
g_signal_handlers_block_by_func (priv->nm_data, enable_wifi_toggled, user_data);
nbtk_gtk_light_switch_set_active (NBTK_GTK_LIGHT_SWITCH (priv->enable_wifi), active);
g_signal_handlers_unblock_by_func (priv->nm_data, enable_wifi_toggled, user_data);
+
+ wifi_toggle_set_sensitive (priv->nm_data, priv->enable_wifi, TRUE);
}
static void
@@ -203,54 +216,55 @@ enable_3g_setup (NmnApplet *applet)
modems_toggled (priv->nm_data, nmn_nm_data_modems_get_active (priv->nm_data), applet);
}
-/* enable/disable Fligh mode button */
+/* enable/disable Offline mode button */
static void
-enable_flightmode_toggled (NbtkGtkLightSwitch *w,
- gboolean active,
- gpointer user_data)
+enable_network_toggled (NbtkGtkLightSwitch *w,
+ gboolean active,
+ gpointer user_data)
{
NmnAppletPrivate *priv = GET_PRIVATE (user_data);
- gtk_widget_set_sensitive (priv->enable_wifi, !active);
+ gtk_widget_set_sensitive (priv->enable_ethernet, !active);
gtk_widget_set_sensitive (priv->enable_3g, !active);
+ wifi_toggle_set_sensitive (priv->nm_data, priv->enable_wifi, !active);
- nmn_nm_data_flight_mode_toggled (priv->nm_data, active);
+ nmn_nm_data_offline_mode_toggled (priv->nm_data, active);
}
static void
-flightmode_toggled (NmnNMData *nm_data,
- gboolean active,
- gpointer user_data)
+offline_toggled (NmnNMData *nm_data,
+ gboolean active,
+ gpointer user_data)
{
NmnAppletPrivate *priv = GET_PRIVATE (user_data);
- g_signal_handlers_block_by_func (priv->nm_data, enable_flightmode_toggled, user_data);
- nbtk_gtk_light_switch_set_active (NBTK_GTK_LIGHT_SWITCH (priv->enable_flightmode), active);
- g_signal_handlers_unblock_by_func (priv->nm_data, enable_flightmode_toggled, user_data);
+ g_signal_handlers_block_by_func (priv->nm_data, enable_network_toggled, user_data);
+ nbtk_gtk_light_switch_set_active (NBTK_GTK_LIGHT_SWITCH (priv->enable_network), active);
+ g_signal_handlers_unblock_by_func (priv->nm_data, enable_network_toggled, user_data);
- gtk_widget_set_sensitive (priv->enable_flightmode, nmn_nm_data_flight_mode_can_change (priv->nm_data));
gtk_widget_set_sensitive (priv->enable_3g, !active);
- gtk_widget_set_sensitive (priv->enable_wifi, !active);
+ gtk_widget_set_sensitive (priv->enable_ethernet, !active);
+ wifi_toggle_set_sensitive (priv->nm_data, priv->enable_wifi, !active);
}
static void
-enable_flightmode_setup (NmnApplet *applet)
+enable_network_setup (NmnApplet *applet)
{
NmnAppletPrivate *priv = GET_PRIVATE (applet);
- priv->enable_flightmode = nbtk_gtk_light_switch_new ();
+ priv->enable_network = nbtk_gtk_light_switch_new ();
gtk_table_attach (priv->switch_table,
- priv->enable_flightmode,
+ priv->enable_network,
1, 2, 4, 5,
GTK_FILL, 0,
0, 0);
- g_signal_connect (priv->enable_flightmode, "switch-flipped", G_CALLBACK (enable_flightmode_toggled), applet);
- gtk_widget_show (priv->enable_flightmode);
+ g_signal_connect (priv->enable_network, "switch-flipped", G_CALLBACK (enable_network_toggled), applet);
+ gtk_widget_show (priv->enable_network);
- g_signal_connect (priv->nm_data, "flight-mode-toggled", G_CALLBACK (flightmode_toggled), applet);
- flightmode_toggled (priv->nm_data, nmn_nm_data_flight_mode_get_active (priv->nm_data), applet);
+ g_signal_connect (priv->nm_data, "offline-mode-toggled", G_CALLBACK (offline_toggled), applet);
+ offline_toggled (priv->nm_data, nmn_nm_data_offline_mode_get_active (priv->nm_data), applet);
}
/* add new connection button */
@@ -400,7 +414,7 @@ nmn_applet_init (NmnApplet *applet)
enable_wifi_setup (applet);
enable_ethernet_setup (applet);
enable_3g_setup (applet);
- enable_flightmode_setup (applet);
+ enable_network_setup (applet);
add_new_connection_setup (applet);
priv->plug = nmn_plug_new ();
diff --git a/src/nmn-networks.c b/src/nmn-networks.c
index 5acbc1a..0254a9a 100644
--- a/src/nmn-networks.c
+++ b/src/nmn-networks.c
@@ -82,42 +82,46 @@ static char *
build_no_networks_text (NmnNMData *data)
{
GString *string;
- gboolean wifi_enabled;
- gboolean ethernet_enabled;
- gboolean modem_enabled;
- guint disabled_count;
string = g_string_new (_("Sorry, we can't find any networks."));
- disabled_count = 0;
- wifi_enabled = nmn_nm_data_wifi_get_active (data);
- if (!wifi_enabled)
- disabled_count++;
-
- ethernet_enabled = nmn_nm_data_ethernet_get_active (data);
- if (!ethernet_enabled)
- disabled_count++;
-
- modem_enabled = nmn_nm_data_modems_get_active (data);
- if (!modem_enabled)
- disabled_count++;
-
- if (disabled_count > 0) {
- g_string_append (string, _(" You could try turning on "));
-
- if (!wifi_enabled) {
- g_string_append (string, _("WiFi"));
- g_string_append (string, get_punctuation (--disabled_count));
- }
-
- if (!ethernet_enabled) {
- g_string_append (string, _("Wired"));
- g_string_append (string, get_punctuation (--disabled_count));
- }
-
- if (!modem_enabled) {
- g_string_append (string, _("3G"));
- g_string_append (string, get_punctuation (--disabled_count));
+ if (nmn_nm_data_offline_mode_get_active (data)) {
+ g_string_append (string, _(" You could try disabling Offline mode."));
+ } else {
+ gboolean wifi_enabled;
+ gboolean ethernet_enabled;
+ gboolean modem_enabled;
+ guint disabled_count = 0;
+
+ wifi_enabled = nmn_nm_data_wifi_get_active (data);
+ if (!wifi_enabled)
+ disabled_count++;
+
+ ethernet_enabled = nmn_nm_data_ethernet_get_active (data);
+ if (!ethernet_enabled)
+ disabled_count++;
+
+ modem_enabled = nmn_nm_data_modems_get_active (data);
+ if (!modem_enabled)
+ disabled_count++;
+
+ if (disabled_count > 0) {
+ g_string_append (string, _(" You could try turning on "));
+
+ if (!wifi_enabled) {
+ g_string_append (string, _("WiFi"));
+ g_string_append (string, get_punctuation (--disabled_count));
+ }
+
+ if (!ethernet_enabled) {
+ g_string_append (string, _("Wired"));
+ g_string_append (string, get_punctuation (--disabled_count));
+ }
+
+ if (!modem_enabled) {
+ g_string_append (string, _("3G"));
+ g_string_append (string, get_punctuation (--disabled_count));
+ }
}
}
@@ -125,7 +129,7 @@ build_no_networks_text (NmnNMData *data)
}
static void
-foobar_changed (NmnNMData *data,
+switch_changed (NmnNMData *data,
gboolean active,
gpointer user_data)
{
@@ -383,9 +387,10 @@ constructor (GType type,
return NULL;
}
- g_signal_connect (priv->nm_data, "ethernet-toggled", G_CALLBACK (foobar_changed), object);
- g_signal_connect (priv->nm_data, "wifi-toggled", G_CALLBACK (foobar_changed), object);
- g_signal_connect (priv->nm_data, "modems-toggled", G_CALLBACK (foobar_changed), object);
+ g_signal_connect (priv->nm_data, "ethernet-toggled", G_CALLBACK (switch_changed), object);
+ g_signal_connect (priv->nm_data, "wifi-toggled", G_CALLBACK (switch_changed), object);
+ g_signal_connect (priv->nm_data, "modems-toggled", G_CALLBACK (switch_changed), object);
+ g_signal_connect (priv->nm_data, "offline-mode-toggled", G_CALLBACK (switch_changed), object);
add_no_networks_item (NMN_NETWORKS (object));
diff --git a/src/nmn-nm-data.c b/src/nmn-nm-data.c
index 391aad9..52bc983 100644
--- a/src/nmn-nm-data.c
+++ b/src/nmn-nm-data.c
@@ -27,7 +27,7 @@ enum {
ETHERNET_TOGGLED,
WIFI_TOGGLED,
MODEMS_TOGGLED,
- FLIGHT_MODE_TOGGLED,
+ OFFLINE_MODE_TOGGLED,
LAST_SIGNAL
};
@@ -43,7 +43,7 @@ typedef struct {
gboolean ethernet_active;
gboolean wifi_active;
gboolean modems_active;
- gboolean flight_mode_active;
+ gboolean offline_mode_active;
gboolean disposed;
} NmnNMDataPrivate;
@@ -98,6 +98,14 @@ nmn_nm_data_ethernet_toggled (NmnNMData *self,
}
gboolean
+nmn_nm_data_wifi_can_change (NmnNMData *self)
+{
+ g_return_val_if_fail (NMN_IS_NM_DATA (self), FALSE);
+
+ return nm_client_wireless_hardware_get_enabled (NM_CLIENT (self));
+}
+
+gboolean
nmn_nm_data_wifi_get_active (NmnNMData *self)
{
g_return_val_if_fail (NMN_IS_NM_DATA (self), FALSE);
@@ -105,15 +113,11 @@ nmn_nm_data_wifi_get_active (NmnNMData *self)
return GET_PRIVATE (self)->wifi_active;
}
-void
-nmn_nm_data_wifi_toggled (NmnNMData *self,
- gboolean active)
+static void
+wifi_toggled_internal (NmnNMData *self, gboolean active)
{
- NmnNMDataPrivate *priv;
-
- g_return_if_fail (NMN_IS_NM_DATA (self));
+ NmnNMDataPrivate *priv = GET_PRIVATE (self);
- priv = GET_PRIVATE (self);
if (priv->wifi_active != active) {
/* FIXME: Save in gconf? */
priv->wifi_active = active;
@@ -121,6 +125,16 @@ nmn_nm_data_wifi_toggled (NmnNMData *self,
}
}
+void
+nmn_nm_data_wifi_toggled (NmnNMData *self,
+ gboolean active)
+{
+ g_return_if_fail (NMN_IS_NM_DATA (self));
+
+ wifi_toggled_internal (self, active);
+ nm_client_wireless_set_enabled (NM_CLIENT (self), active);
+}
+
gboolean
nmn_nm_data_modems_get_active (NmnNMData *self)
{
@@ -146,41 +160,41 @@ nmn_nm_data_modems_toggled (NmnNMData *self,
}
gboolean
-nmn_nm_data_flight_mode_can_change (NmnNMData *self)
+nmn_nm_data_offline_mode_get_active (NmnNMData *self)
{
g_return_val_if_fail (NMN_IS_NM_DATA (self), FALSE);
- return nm_client_wireless_hardware_get_enabled (NM_CLIENT (self));
-}
-
-gboolean
-nmn_nm_data_flight_mode_get_active (NmnNMData *self)
-{
- g_return_val_if_fail (NMN_IS_NM_DATA (self), FALSE);
-
- return GET_PRIVATE (self)->flight_mode_active;
+ return GET_PRIVATE (self)->offline_mode_active;
}
static void
-flight_mode_toggled_internal (NmnNMData *self, gboolean active)
+offline_mode_toggled_internal (NmnNMData *self, gboolean active)
{
NmnNMDataPrivate *priv = GET_PRIVATE (self);
- if (priv->flight_mode_active != active) {
+ if (priv->offline_mode_active != active) {
/* FIXME: Save in gconf? */
- priv->flight_mode_active = active;
- g_signal_emit (self, signals[FLIGHT_MODE_TOGGLED], 0, active);
+ priv->offline_mode_active = active;
+ g_signal_emit (self, signals[OFFLINE_MODE_TOGGLED], 0, active);
}
}
void
-nmn_nm_data_flight_mode_toggled (NmnNMData *self,
- gboolean active)
+nmn_nm_data_offline_mode_toggled (NmnNMData *self,
+ gboolean active)
{
g_return_if_fail (NMN_IS_NM_DATA (self));
- flight_mode_toggled_internal (self, active);
- nm_client_wireless_set_enabled (NM_CLIENT (self), !active);
+ offline_mode_toggled_internal (self, active);
+ nm_client_sleep (NM_CLIENT (self), active);
+}
+
+static void
+nm_client_state_changed (NMClient *client,
+ GParamSpec *gobject,
+ gpointer user_data)
+{
+ offline_mode_toggled_internal (NMN_NM_DATA (client), nm_client_get_state (client) == NM_STATE_ASLEEP);
}
static void
@@ -188,8 +202,7 @@ nm_wireless_state_changed (NMClient *client,
GParamSpec *gobject,
gpointer user_data)
{
- flight_mode_toggled_internal (NMN_NM_DATA (client),
- !nm_client_wireless_get_enabled (client));
+ wifi_toggled_internal (NMN_NM_DATA (client), nm_client_wireless_get_enabled (client));
}
static void
@@ -201,7 +214,7 @@ nmn_nm_data_init (NmnNMData *self)
priv->ethernet_active = TRUE;
priv->wifi_active = TRUE;
priv->modems_active = TRUE;
- priv->flight_mode_active = FALSE;
+ priv->offline_mode_active = FALSE;
}
static GObject*
@@ -226,6 +239,11 @@ constructor (GType type,
priv->system_settings = NM_SETTINGS (nm_dbus_settings_system_new (bus));
g_signal_connect (object,
+ "notify::" NM_CLIENT_STATE,
+ G_CALLBACK (nm_client_state_changed),
+ NULL);
+
+ g_signal_connect (object,
"notify::" NM_CLIENT_WIRELESS_ENABLED,
G_CALLBACK (nm_wireless_state_changed),
NULL);
@@ -296,11 +314,11 @@ nmn_nm_data_class_init (NmnNMDataClass *class)
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
- signals[FLIGHT_MODE_TOGGLED] = g_signal_new
- ("flight-mode-toggled",
+ signals[OFFLINE_MODE_TOGGLED] = g_signal_new
+ ("offline-mode-toggled",
G_OBJECT_CLASS_TYPE (class),
G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (NmnNMDataClass, flight_mode_toggled),
+ G_STRUCT_OFFSET (NmnNMDataClass, offline_mode_toggled),
NULL, NULL,
g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
diff --git a/src/nmn-nm-data.h b/src/nmn-nm-data.h
index a747e8d..894da91 100644
--- a/src/nmn-nm-data.h
+++ b/src/nmn-nm-data.h
@@ -48,32 +48,32 @@ typedef struct {
void (*modems_toggled) (NmnNMData *self,
gboolean active);
- void (*flight_mode_toggled) (NmnNMData *self,
- gboolean active);
+ void (*offline_mode_toggled) (NmnNMData *self,
+ gboolean active);
} NmnNMDataClass;
GType nmn_nm_data_get_type (void);
-NmnNMData *nmn_nm_data_new (DBusGConnection *bus);
-NMSettings *nmn_nm_data_get_user_settings (NmnNMData *data);
-NMSettings *nmn_nm_data_get_system_settings (NmnNMData *data);
+NmnNMData *nmn_nm_data_new (DBusGConnection *bus);
+NMSettings *nmn_nm_data_get_user_settings (NmnNMData *data);
+NMSettings *nmn_nm_data_get_system_settings (NmnNMData *data);
-gboolean nmn_nm_data_ethernet_get_active (NmnNMData *self);
-void nmn_nm_data_ethernet_toggled (NmnNMData *self,
- gboolean active);
+gboolean nmn_nm_data_ethernet_get_active (NmnNMData *self);
+void nmn_nm_data_ethernet_toggled (NmnNMData *self,
+ gboolean active);
-gboolean nmn_nm_data_wifi_get_active (NmnNMData *self);
-void nmn_nm_data_wifi_toggled (NmnNMData *self,
- gboolean active);
+gboolean nmn_nm_data_wifi_can_change (NmnNMData *self);
+gboolean nmn_nm_data_wifi_get_active (NmnNMData *self);
+void nmn_nm_data_wifi_toggled (NmnNMData *self,
+ gboolean active);
-gboolean nmn_nm_data_modems_get_active (NmnNMData *self);
-void nmn_nm_data_modems_toggled (NmnNMData *self,
- gboolean active);
+gboolean nmn_nm_data_modems_get_active (NmnNMData *self);
+void nmn_nm_data_modems_toggled (NmnNMData *self,
+ gboolean active);
-gboolean nmn_nm_data_flight_mode_can_change (NmnNMData *self);
-gboolean nmn_nm_data_flight_mode_get_active (NmnNMData *self);
-void nmn_nm_data_flight_mode_toggled (NmnNMData *self,
- gboolean active);
+gboolean nmn_nm_data_offline_mode_get_active (NmnNMData *self);
+void nmn_nm_data_offline_mode_toggled (NmnNMData *self,
+ gboolean active);
#endif /* NMN_NM_DATA_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]