r1548 - trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src

zhiyong_sun at sita.openmoko.org zhiyong_sun at sita.openmoko.org
Thu Mar 29 11:22:28 CEST 2007


Author: zhiyong_sun
Date: 2007-03-29 11:22:23 +0200 (Thu, 29 Mar 2007)
New Revision: 1548

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:
some small modifies, and reorgnize the icon names, add gprs icons, needs to find out gprs signal(connection) update function

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-29 08:11:39 UTC (rev 1547)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.c	2007-03-29 09:22:23 UTC (rev 1548)
@@ -17,7 +17,8 @@
 
 static struct lgsm_handle *lgsmh = NULL;
 static GPollFD GPfd;
-static int signal_value = GSM_SIGNAL_ERROR;
+static gint gsm_q = -99;
+static gint gprs_q = -99;
 
 static gboolean
 gsm_watcher_prepare (GSource * source, gint * timeout)
@@ -67,7 +68,7 @@
 sigq_handler(struct lgsm_handle *lh, int evt, struct gsmd_evt_auxdata *aux)
 {
 	printf("EVENT: Signal Quality: %u\n", aux->u.signal.sigq.rssi);
-	signal_value = aux->u.signal.sigq.rssi;
+	gsm_q = aux->u.signal.sigq.rssi;
 	//FIXME: Call panel applet image change function here, instead of use g timeout function to check singal value
 	return 0;
 }
@@ -124,12 +125,39 @@
   }
 }
 
-int
+GsmSignalQuality
 moko_panel_gsm_signal_quality()
 {
-  return signal_value;
+  switch (gsm_q)
+  {
+    case 4 :
+      return GSM_SIGNAL_LEVEL_1 ;
+    case 3 :
+      return GSM_SIGNAL_LEVEL_2 ;
+    case 2 :
+      return GSM_SIGNAL_LEVEL_3 ;
+    case 1 :
+      return GSM_SIGNAL_LEVEL_4 ;
+    case 0 :
+      return GSM_SIGNAL_LEVEL_5 ;
+    default :
+      return GSM_SIGNAL_ERROR;
+  }
 }
+/*for a rainning day*/
+GprsSignalQuality
+moko_panel_gprs_signal_quality()
+{
 
+if(0)
+{  switch (gprs_q)
+  {
+		  
+  }
+}
+  return GPRS_CLOSE;
+}
+
 void
 gsm_watcher_install (void)
 {

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-29 08:11:39 UTC (rev 1547)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/moko-gsm-conn.h	2007-03-29 09:22:23 UTC (rev 1548)
@@ -1,20 +1,38 @@
 #ifndef _MOKO_PANEL_GSM_CONN_
 #define _MOKO_PANEL_GSM_CONN_
 
+#include <glib-object.h>
+
 #define STDIN_BUF_SIZE	1024
 /*signal value: "0": best connection "5": connect error*/
-enum{
-  GSM_SIGNAL_LEVEL_5 = 0,
+G_BEGIN_DECLS
+
+typedef enum{
+  GSM_SIGNAL_LEVEL_1 = 0,
+  GSM_SIGNAL_LEVEL_2,
+  GSM_SIGNAL_LEVEL_3,
   GSM_SIGNAL_LEVEL_4,
-  GSM_SIGNAL_LEVEL_3,
-  GSM_SIGNAL_LEVEL_2,
-  GSM_SIGNAL_LEVEL_1,
-  GSM_SIGNAL_ERROR ,
-  TOTAL_SIGNALS
-};
+  GSM_SIGNAL_LEVEL_5,
+  GSM_SIGNAL_ERROR,
+  TOTAL_GSM_SIGNALS
+}GsmSignalQuality;
 
+typedef enum{
+  GPRS_SIGNAL_LEVEL_1 = 0,
+  GPRS_SIGNAL_LEVEL_2,
+  GPRS_SIGNAL_LEVEL_3,
+  GPRS_SIGNAL_LEVEL_4,
+  GPRS_SIGNAL_LEVEL_5,
+  TOTAL_GPRS_SIGNALS,
+  GPRS_CLOSE
+}GprsSignalQuality;
+
 void gsm_watcher_install (void);
 
-int moko_panel_gsm_signal_quality(void);
+GsmSignalQuality moko_panel_gsm_signal_quality(void);
 
+GprsSignalQuality moko_panel_gprs_signal_quality(void);
+
+G_END_DECLS
+
 #endif /*_MOKO_PANEL_GSM_CONN_*/

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-29 08:11:39 UTC (rev 1547)
+++ trunk/src/target/OM-2007/panel-plugins/openmoko-panel-gsm/src/openmoko-panel-gsm.c	2007-03-29 09:22:23 UTC (rev 1548)
@@ -22,11 +22,29 @@
 #include "moko-gsm-conn.h"
 
 typedef struct {
-	int gsm_quality;
-	GtkImage *image;
-	guint timeout_id;
+  GsmSignalQuality gsm_quality;
+  GprsSignalQuality gprs_quality;
+  GtkImage *image;
+  guint timeout_id;
 } GsmApplet;
 
+static gchar *gsm_q_name[TOTAL_GSM_SIGNALS]={
+  "SignalStrength_01.png",
+  "SignalStrength_02.png",
+  "SignalStrength_03.png",
+  "SignalStrength_04.png",
+  "SignalStrength_05.png",
+  "SignalStrength_00.png",
+};
+
+static gchar *gprs_q_name[TOTAL_GPRS_SIGNALS]={
+  "SignalStrength25g_01.png",
+  "SignalStrength25g_02.png",
+  "SignalStrength25g_03.png",
+  "SignalStrength25g_04.png",
+  "SignalStrength25g_05.png",
+};
+
 static void
 gsm_applet_free (GsmApplet *applet)
 {
@@ -38,7 +56,8 @@
 static gboolean
 timeout_cb (GsmApplet *applet)
 {
-  int new_gsm_q = moko_panel_gsm_signal_quality ();
+  GsmSignalQuality new_gsm_q = moko_panel_gsm_signal_quality ();
+  //GprsSignalQuality new_gprs_q = moko_panel_gprs_signal_quality (); 
   
   if (applet->gsm_quality == new_gsm_q)
 	/*Keep going, image need not change*/
@@ -46,53 +65,29 @@
   else
     applet->gsm_quality = new_gsm_q;
 
-  g_debug ("gsm signal = %d", applet->gsm_quality);
+  /*load new signal status image, FIXME:load these images in memery when initial the applet*/
+  char path[512];
+  snprintf (path, 512, "%s/%s", PKGDATADIR, gsm_q_name[applet->gsm_quality]);
+  gtk_image_set_from_file (applet->image, path);
 
-	switch (applet->gsm_quality)
-	{
-		case GSM_SIGNAL_ERROR :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_00.png");
-		    break;
-
-		case GSM_SIGNAL_LEVEL_1 :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_01.png");
-			break;
-
-		case GSM_SIGNAL_LEVEL_2 :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_02.png");
-			break;
-
-		case GSM_SIGNAL_LEVEL_3 :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_03.png");
-			break;
-
-		case GSM_SIGNAL_LEVEL_4 :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_04.png");
-			break;
-
-		case GSM_SIGNAL_LEVEL_5 :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_05.png");
-			break;
-
-		default :
-			gtk_image_set_from_file (applet->image, PKGDATADIR"/SignalStrength_00.png");
-			break;
-	}
-    /* Keep going */
-    return TRUE;
+  /* Keep going */
+  return TRUE;
 }
 
 G_MODULE_EXPORT GtkWidget* 
 mb_panel_applet_create(const char* id, GtkOrientation orientation)
 {
     MokoPanelApplet* mokoapplet = moko_panel_applet_new();
+    char path[512];
 
     GsmApplet *applet;
     applet = g_slice_new (GsmApplet);
 
     applet->gsm_quality = GSM_SIGNAL_ERROR;
+    applet->gsm_quality = GPRS_CLOSE;
 
-    applet->image = GTK_IMAGE(gtk_image_new_from_file (PKGDATADIR"/SignalStrength_00.png"));
+    snprintf (path, 512, "%s/%s", PKGDATADIR, gsm_q_name[applet->gsm_quality]);
+	applet->image = GTK_IMAGE(gtk_image_new_from_file (path));
     gtk_widget_set_name( applet->image, "OpenMoko gsm applet" );
     g_object_weak_ref( G_OBJECT(applet->image), (GWeakNotify) gsm_applet_free, applet );
 





More information about the commitlog mailing list