[nautilus-ideviceinfo] Deal better with the absence of SIM card in phones
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-ideviceinfo] Deal better with the absence of SIM card in phones
- Date: Fri, 13 Aug 2010 11:18:49 +0000 (UTC)
commit 3c885e61fdc3aca80577edfa3a36473647da5c26
Author: Bastien Nocera <hadess hadess net>
Date: Fri Aug 13 12:18:47 2010 +0100
Deal better with the absence of SIM card in phones
Hide the ICCID label as well, and make sure we don't think iPads
could be phones.
src/ideviceinfo-property-page.c | 41 +++++++++++++++++++++++++++++++++++---
src/nautilus-ideviceinfo.ui | 21 ++++++++++++++++++-
2 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/src/ideviceinfo-property-page.c b/src/ideviceinfo-property-page.c
index 3bbddc1..6196486 100644
--- a/src/ideviceinfo-property-page.c
+++ b/src/ideviceinfo-property-page.c
@@ -224,6 +224,7 @@ update_ui (CompletedMessage *msg)
gboolean is_phone = FALSE;
gboolean is_ipod_touch = FALSE;
+ gboolean has_sim = FALSE;
GtkLabel *lbDeviceName = GTK_LABEL(gtk_builder_get_object (builder, "lbDeviceNameText"));
GtkLabel *lbDeviceModel = GTK_LABEL(gtk_builder_get_object (builder, "lbDeviceModelText"));
@@ -290,6 +291,8 @@ update_ui (CompletedMessage *msg)
}
if (g_str_has_prefix(devtype, "iPod"))
is_ipod_touch = TRUE;
+ else if (!g_str_has_prefix(devtype, "iPad"))
+ is_phone = TRUE;
node = plist_dict_get_item(dict, "ModelNumber");
if (node) {
plist_get_string_val(node, &val2);
@@ -343,6 +346,20 @@ update_ui (CompletedMessage *msg)
}
val = NULL;
}
+ node = plist_dict_get_item(dict, "SIMStatus");
+ if (node) {
+ plist_get_string_val(node, &val);
+ if (val) {
+ if (g_str_equal(val, "kCTSIMSupportSIMStatusNotInserted"))
+ has_sim = FALSE;
+ else
+ has_sim = TRUE;
+ free(val);
+ }
+ val = NULL;
+ } else {
+ has_sim = FALSE;
+ }
node = plist_dict_get_item(dict, "SerialNumber");
if (node) {
plist_get_string_val(node, &val);
@@ -361,13 +378,13 @@ update_ui (CompletedMessage *msg)
}
val = NULL;
}
- if (!is_ipod_touch) {
+ if (is_phone) {
node = plist_dict_get_item(dict, "PhoneNumber");
if (node) {
plist_get_string_val(node, &val);
if (val) {
unsigned int i;
- is_phone = TRUE;
+
/* replace spaces, otherwise the telephone
* number will be mixed up when displaying
* in RTL mode */
@@ -380,6 +397,15 @@ update_ui (CompletedMessage *msg)
free(val);
}
val = NULL;
+ } else if (!has_sim) {
+ gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "lbTelNo")));
+ gtk_widget_hide(GTK_WIDGET(lbTelNo));
+ gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "lbIMSI")));
+ gtk_widget_hide(GTK_WIDGET(lbIMSI));
+ gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "lbCarrier")));
+ gtk_widget_hide(GTK_WIDGET(lbCarrier));
+ gtk_widget_hide (GTK_WIDGET(gtk_builder_get_object (builder, "lbICCID")));
+ gtk_widget_hide(GTK_WIDGET(lbICCID));
} else {
gtk_widget_hide(GTK_WIDGET(lbTelNo));
}
@@ -387,17 +413,22 @@ update_ui (CompletedMessage *msg)
if (node) {
plist_get_string_val(node, &val);
if (val) {
- is_phone = TRUE;
+
gtk_label_set_text(lbIMEI, val);
free(val);
}
val = NULL;
}
+
+ /* If we don't have a SIM card, there's no point in doing all that */
+ if (!has_sim)
+ goto end_phone;
+
+
node = plist_dict_get_item(dict, "InternationalMobileSubscriberIdentity");
if (node) {
plist_get_string_val(node, &val);
if (val) {
- is_phone = TRUE;
#ifdef HAVE_MOBILE_PROVIDER_INFO
char *carrier;
carrier = get_carrier_from_imsi(val);
@@ -416,6 +447,7 @@ update_ui (CompletedMessage *msg)
/* hide SIM related infos */
gtk_widget_hide(GTK_WIDGET(lbIMSI));
gtk_widget_hide(GTK_WIDGET(lbCarrier));
+ gtk_widget_hide(GTK_WIDGET(lbICCID));
}
node = plist_dict_get_item(dict, "IntegratedCircuitCardIdentity");
if (node) {
@@ -431,6 +463,7 @@ update_ui (CompletedMessage *msg)
} else {
gtk_widget_hide(GTK_WIDGET(vbPhone));
}
+end_phone:
node = plist_dict_get_item(dict, "BluetoothAddress");
if (node) {
val = get_mac_address_val(node);
diff --git a/src/nautilus-ideviceinfo.ui b/src/nautilus-ideviceinfo.ui
index 46263b8..a73cf51 100644
--- a/src/nautilus-ideviceinfo.ui
+++ b/src/nautilus-ideviceinfo.ui
@@ -1,14 +1,16 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkVBox" id="ideviceinfo">
<property name="visible">True</property>
<property name="border_width">12</property>
+ <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="vbGeneral">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
@@ -193,6 +195,7 @@
<child>
<object class="GtkVBox" id="vbPhone">
<property name="no_show_all">True</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
@@ -227,16 +230,21 @@
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="xalign">0</property>
+ <property name="yalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">Phone Number:</property>
</object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
</child>
<child>
<object class="GtkLabel" id="lbCarrier">
<property name="width_request">110</property>
<property name="visible">True</property>
<property name="xalign">0</property>
+ <property name="yalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">Mobile Carrier:</property>
@@ -244,6 +252,7 @@
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -258,6 +267,7 @@
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -274,6 +284,7 @@
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -281,6 +292,7 @@
<property name="width_request">120</property>
<property name="visible">True</property>
<property name="xalign">0</property>
+ <property name="yalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
<property name="label" translatable="yes">Modem Firmware:</property>
@@ -288,6 +300,7 @@
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -304,6 +317,7 @@
<property name="right_attach">3</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
@@ -338,6 +352,7 @@
<object class="GtkLabel" id="lbModemFwText">
<property name="visible">True</property>
<property name="xalign">0</property>
+ <property name="yalign">0</property>
<property name="xpad">1</property>
<property name="ypad">1</property>
<property name="selectable">True</property>
@@ -406,6 +421,7 @@
<child>
<object class="GtkVBox" id="vbNetwork">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
@@ -506,6 +522,7 @@
<child>
<object class="GtkVBox" id="vbStorage">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="label4">
@@ -528,6 +545,7 @@
<child>
<object class="GtkVBox" id="vbox8">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkAlignment" id="disk_usage">
<property name="visible">True</property>
@@ -566,7 +584,6 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
- <property name="use_action_appearance">False</property>
</object>
<packing>
<property name="expand">False</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]