r1526 - trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src
zhiyong_sun at sita.openmoko.org
zhiyong_sun at sita.openmoko.org
Wed Mar 28 10:28:06 CEST 2007
Author: zhiyong_sun
Date: 2007-03-28 10:28:01 +0200 (Wed, 28 Mar 2007)
New Revision: 1526
Modified:
trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.c
trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.h
trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
Log:
just reset G call back function time, and redefine the GSM signal value ENUM, call load image function when the value sure changed.
Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.c
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.c 2007-03-28 07:19:16 UTC (rev 1525)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.c 2007-03-28 08:28:01 UTC (rev 1526)
@@ -17,7 +17,7 @@
static struct lgsm_handle *lgsmh = NULL;
static GPollFD GPfd;
-static int signal_value = -99;
+static int signal_value = GSM_SIGNAL_ERROR;
static gboolean
gsm_watcher_prepare (GSource * source, gint * timeout)
Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.h
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.h 2007-03-28 07:19:16 UTC (rev 1525)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.h 2007-03-28 08:28:01 UTC (rev 1526)
@@ -2,15 +2,15 @@
#define _MOKO_PANEL_GSM_CONN_
#define STDIN_BUF_SIZE 1024
-
+/*signal value: "0": best connection "5": connect error*/
enum{
- GSM_SIGNAL_ERROR = 0,
- GSM_SIGNAL_LEVEL_1,
- GSM_SIGNAL_LEVEL_2,
- GSM_SIGNAL_LEVEL_3,
- GSM_SIGNAL_LEVEL_4,
- GSM_SIGNAL_LEVEL_5,
- TOTAL_SIGNALS
+ GSM_SIGNAL_LEVEL_5 = 0,
+ GSM_SIGNAL_LEVEL_4,
+ GSM_SIGNAL_LEVEL_3,
+ GSM_SIGNAL_LEVEL_2,
+ GSM_SIGNAL_LEVEL_1,
+ GSM_SIGNAL_ERROR ,
+ TOTAL_SIGNALS
};
void gsm_watcher_install (void);
Modified: trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c
===================================================================
--- trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c 2007-03-28 07:19:16 UTC (rev 1525)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c 2007-03-28 08:28:01 UTC (rev 1526)
@@ -38,9 +38,16 @@
static gboolean
timeout_cb (GsmApplet *applet)
{
- int sig_q = moko_panel_gsm_signal_quality ();
- g_debug ("moko gsm quality = %d", sig_q);
-if (0){
+ int new_gsm_q = moko_panel_gsm_signal_quality ();
+
+ if (applet->gsm_quality == new_gsm_q)
+ /*Keep going, image need not change*/
+ return TRUE;
+ else
+ applet->gsm_quality = new_gsm_q;
+
+ g_debug ("gsm signal = %d", applet->gsm_quality);
+
switch (applet->gsm_quality)
{
case GSM_SIGNAL_ERROR :
@@ -71,7 +78,6 @@
gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_00.png");
break;
}
-}
/* Keep going */
return TRUE;
}
@@ -82,19 +88,15 @@
MokoPanelApplet* mokoapplet = moko_panel_applet_new();
GsmApplet *applet;
- time_t t;
- struct tm *local_time;
-
applet = g_slice_new (GsmApplet);
+ applet->gsm_quality = GSM_SIGNAL_ERROR;
+
applet->image = GTK_IMAGE(gtk_image_new_from_file (PKGDATADIR"/SignalStrength_00.png"));
gtk_widget_set_name( applet->image, "OpenMoko gsm applet" );
g_object_weak_ref( G_OBJECT(applet->image), (GWeakNotify) gsm_applet_free, applet );
- t = time( NULL );
- local_time = localtime(&t);
- //FIXME: Do not use g_timeout function, convert to use gsm signal handle callback.
- applet->timeout_id = g_timeout_add( 2000, (GSourceFunc) timeout_cb, applet);
+ applet->timeout_id = g_timeout_add(10000, (GSourceFunc) timeout_cb, applet);
moko_panel_applet_set_widget( GTK_CONTAINER(mokoapplet), applet->image );
gtk_widget_show_all( GTK_WIDGET(mokoapplet) );
More information about the commitlog
mailing list