[Goodies-commits] r2334 - in xfce4-wavelan-plugin/trunk: . panel-plugin

James Westby jamesw at xfce.org
Wed Jan 10 21:26:20 CET 2007


Author: jamesw
Date: 2007-01-10 20:26:19 +0000 (Wed, 10 Jan 2007)
New Revision: 2334

Modified:
   xfce4-wavelan-plugin/trunk/ChangeLog
   xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c
Log:
	* Fix a bug where the interface that is top of the list isn't used unless
		something else is selected first. It now defaults to the first interface
		found if there is no rc file or interface stored in it. This does remove
		the ability to have an instance without an associated interface, but who
		wants that anyway? Thanks to Maximilian Schleiss for the report.


Modified: xfce4-wavelan-plugin/trunk/ChangeLog
===================================================================
--- xfce4-wavelan-plugin/trunk/ChangeLog	2007-01-10 19:24:47 UTC (rev 2333)
+++ xfce4-wavelan-plugin/trunk/ChangeLog	2007-01-10 20:26:19 UTC (rev 2334)
@@ -1,3 +1,11 @@
+2007-01-10 20:23  james
+
+	* Fix a bug where the interface that is top of the list isn't used unless
+		something else is selected first. It now defaults to the first interface
+		found if there is no rc file or interface stored in it. This does remove
+		the ability to have an instance without an associated interface, but who
+		wants that anyway? Thanks to Maximilian Schleiss for the report.
+
 2007-01-10 19:07  james
 
 	* Add the headers added in the last change to the checks in configure.

Modified: xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c
===================================================================
--- xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c	2007-01-10 19:24:47 UTC (rev 2333)
+++ xfce4-wavelan-plugin/trunk/panel-plugin/wavelan.c	2007-01-10 20:26:19 UTC (rev 2334)
@@ -265,6 +265,37 @@
   }
 }
 
+/* query installed devices */
+static GList*
+wavelan_query_interfaces (void)
+{
+  GList *interfaces = NULL;
+  gchar  line[1024];
+  FILE  *fp;
+  gint   n;
+
+  TRACE ("Entered wavelan_query_interface");
+  
+  fp = popen ("/sbin/ifconfig -a", "r");
+  if (fp != NULL)
+    {
+      while (fgets (line, 1024, fp) != NULL)
+        {
+          if (!isalpha (*line))
+            continue;
+
+          for (n = 0; isalnum (line[n]); ++n);
+          line[n] = '\0';
+
+          interfaces = g_list_append (interfaces, g_strdup (line));
+        }
+
+      pclose (fp);
+    }
+
+  return interfaces;
+}
+
 static void
 wavelan_read_config(XfcePanelPlugin *plugin, t_wavelan *wavelan)
 {
@@ -284,13 +315,19 @@
       if ((s = xfce_rc_read_entry (rc, "Interface", NULL)) != NULL) 
       {
         wavelan->interface = g_strdup (s);
-      }
+      } 
       
       wavelan->autohide = xfce_rc_read_bool_entry (rc, "Autohide", FALSE);
       wavelan->autohide_missing = xfce_rc_read_bool_entry(rc, "AutohideMissing", FALSE);
       wavelan->square_icon = xfce_rc_read_bool_entry(rc, "SquareIcon", FALSE);
     }
   }
+
+  if (wavelan->interface == NULL) {
+    GList *interfaces = wavelan_query_interfaces();
+    wavelan->interface = g_list_first(interfaces)->data;
+    g_list_free(interfaces);
+  }
   
   wavelan_reset(wavelan);
 }
@@ -474,37 +511,6 @@
   wavelan_set_square_icon(wavelan, gtk_toggle_button_get_active(button));
 }
 
-/* query installed devices */
-static GList*
-wavelan_query_interfaces (void)
-{
-  GList *interfaces = NULL;
-  gchar  line[1024];
-  FILE  *fp;
-  gint   n;
-
-  TRACE ("Entered wavelan_query_interface");
-  
-  fp = popen ("/sbin/ifconfig -a", "r");
-  if (fp != NULL)
-    {
-      while (fgets (line, 1024, fp) != NULL)
-        {
-          if (!isalpha (*line))
-            continue;
-
-          for (n = 0; isalnum (line[n]); ++n);
-          line[n] = '\0';
-
-          interfaces = g_list_append (interfaces, g_strdup (line));
-        }
-
-      pclose (fp);
-    }
-
-  return interfaces;
-}
-
 static void
 wavelan_dialog_response (GtkWidget *dlg, int response, t_wavelan *wavelan)
 {




More information about the Goodies-commits mailing list