aboutsummaryrefslogtreecommitdiffstats
path: root/packages/gpe-conf/gpe-conf-0.1.22/fix-wificonfig.patch
blob: 9df234dc15cac53220e6bfbec7456a15bff8084d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
Index: cfgfile.h
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/cfgfile.h,v
retrieving revision 1.10
diff -u -r1.10 cfgfile.h
--- cfgfile.h	24 Nov 2004 15:43:10 -0000	1.10
+++ cfgfile.h	29 Nov 2004 16:21:47 -0000
@@ -58,15 +58,16 @@
 	t_wifimode mode;
 	gint iswireless;
 	
-	gint isstatic;
-	gint isinet;
-	gint isloop;
-	gint isdhcp;
-	gint isppp;
+	gboolean isstatic;
+	gboolean isinet;
+	gboolean isloop;
+	gboolean isdhcp;
+	gboolean isppp;
 	gint firstline;
 	gint lastline;
 	gint status;
 	gboolean ispresent;
+	gint uipos;	
 } NWInterface_t;
 
 gint set_file_open(gint openon);
Index: network.c
===================================================================
RCS file: /cvs/gpe/base/gpe-conf/network.c,v
retrieving revision 1.43
diff -u -r1.43 network.c
--- network.c	24 Nov 2004 15:43:10 -0000	1.43
+++ network.c	29 Nov 2004 16:21:48 -0000
@@ -65,7 +65,6 @@
 GtkWidget *create_nwdhcp_widgets (NWInterface_t iface);
 GtkWidget *create_nwppp_widgets (NWInterface_t iface);
 
-static guint not_added = 0;
 static gchar *cfgfile;
 static gboolean have_access = FALSE;
 static GtkTooltips *tooltips;
@@ -300,12 +299,15 @@
 		if (ctable)
 		{
 			label = gtk_label_new (iflist[i].name);
-			gtk_notebook_append_page (GTK_NOTEBOOK (table),
-						  GTK_WIDGET (ctable), label);
+			iflist[i].uipos = gtk_notebook_append_page (GTK_NOTEBOOK (table),
+			                                            GTK_WIDGET (ctable),
+			                                            label);
 			gtk_widget_show_all (table);
+			g_object_set_data(G_OBJECT(ctable), "ifnr", (gpointer)i);
 		}
 		else
-			not_added++;
+			iflist[i].uipos = -1;
+		
 		gtk_notebook_set_current_page (GTK_NOTEBOOK (table), -1);
 	}
 }
@@ -335,11 +337,13 @@
 void
 changed_nwtype (GtkToggleButton * togglebutton, gpointer user_data)
 {
-	GtkWidget *ctable, *label;
+	GtkWidget *ctable, *label, *page;
 	gchar wname[100];
-	gint row =
-		gtk_notebook_get_current_page (GTK_NOTEBOOK (table)) +
-		not_added - PAGE_OFFSET;
+	gint row;
+	
+	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (table), 
+	                                 gtk_notebook_get_current_page (GTK_NOTEBOOK (table)));
+	row = (gint)g_object_get_data(G_OBJECT(page), "ifnr");
 
 	if (!gtk_toggle_button_get_active (togglebutton))
 		return;		// just run once
@@ -385,10 +389,11 @@
 					  (GTK_NOTEBOOK (table)));
 		gtk_notebook_insert_page (GTK_NOTEBOOK (table),
 					  GTK_WIDGET (ctable), label,
-					  row - not_added + PAGE_OFFSET);
+					  iflist[row].uipos);
 		gtk_widget_show_all (table);
 		gtk_notebook_set_page (GTK_NOTEBOOK (table),
-				       row - not_added + PAGE_OFFSET);
+				      iflist[row].uipos);
+		g_object_set_data(G_OBJECT(ctable), "ifnr", (gpointer)row);
 	}
 }
 
@@ -922,12 +927,14 @@
 void
 changed_wifi (GtkToggleButton * togglebutton, gpointer user_data)
 {
-	GtkWidget *widget;
+	GtkWidget *widget, *page;
 	gchar wname[100];
-	gint ifnr = gtk_notebook_get_current_page (GTK_NOTEBOOK (table)) +
-		not_added - PAGE_OFFSET;
+	gint ifnr;
+	
+	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (table), 
+	                                 gtk_notebook_get_current_page (GTK_NOTEBOOK (table)));
+	ifnr = (gint)g_object_get_data(G_OBJECT(page), "ifnr");
 
-	// look who called us...
 	strcpy (wname, "wificonfig");
 	strcat (wname, iflist[ifnr].name);
 	
@@ -941,10 +948,12 @@
 void
 clicked_wificonfig (GtkButton *button, gpointer user_data)
 {
+	GtkWidget *page;
 	gint ifnr;
 	
-	ifnr = gtk_notebook_get_current_page (GTK_NOTEBOOK (table)) +
-		not_added - PAGE_OFFSET;
+	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK (table), 
+	                                 gtk_notebook_get_current_page (GTK_NOTEBOOK (table)));
+	ifnr = (gint)g_object_get_data(G_OBJECT(page), "ifnr");
 
 	show_wificonfig(gtk_widget_get_toplevel(GTK_WIDGET(button)), &iflist[ifnr]);
 }
@@ -1662,11 +1671,13 @@
 			if (!have_access)
 				gtk_widget_set_sensitive (ctable, FALSE);
 			label = gtk_label_new (iflist[row].name);
-			gtk_notebook_append_page (GTK_NOTEBOOK (table),
-						  GTK_WIDGET (ctable), label);
+			iflist[row].uipos = gtk_notebook_append_page (GTK_NOTEBOOK (table),
+			                                              GTK_WIDGET (ctable), 
+			                                              label);
+			g_object_set_data(G_OBJECT(ctable), "ifnr", (gpointer)row);
 		}
 		else
-			not_added++;	// we'll run into trouble if we have a loopback device between other in interfaces
+			iflist[row].uipos = -1;
 	}
 	return tablebox;
 }