Populate listen dropdown with actual interface IP addresses. Remember choice between sessions

This commit is contained in:
Latif Khalifa
2013-12-18 19:18:00 +01:00
parent eda1b91dd2
commit b5d16ceda1
3 changed files with 26 additions and 8 deletions

View File

@@ -5,6 +5,7 @@ using OpenMetaverse.StructuredData;
using System.IO;
using System.IO.Compression;
using System.Text;
using System.Net;
public partial class MainWindow
@@ -23,10 +24,32 @@ public partial class MainWindow
Resize(Options.Instance["main_width"], Options.Instance["main_height"]);
Move(Options.Instance["main_x"], Options.Instance["main_y"]);
}
// populate the listen box with the known IP Addresses of this host
cbListen.AppendText("127.0.0.1");
int selected = 0;
try
{
int current = 0;
foreach (var address in Dns.GetHostAddresses(Dns.GetHostName()))
{
if (address.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork || address.ToString() == "127.0.0.1") continue;
current++;
if (Options.Instance["listed_address"] == address.ToString())
{
selected = current;
}
cbListen.AppendText(address.ToString());
}
}
catch { }
cbListen.Active = selected;
}
void SaveSettings()
{
Options.Instance["listed_address"] = cbListen.ActiveText;
Options.Instance["main_split_pos"] = mainSplit.Position;
int x, y;

View File

@@ -166,11 +166,8 @@ public partial class MainWindow
w5.Fill = false;
// Container child hboxMenu.Gtk.Box+BoxChild
this.cbListen = global::Gtk.ComboBoxEntry.NewText ();
this.cbListen.AppendText (global::Mono.Unix.Catalog.GetString ("127.0.0.1"));
this.cbListen.AppendText (global::Mono.Unix.Catalog.GetString ("0.0.0.0"));
this.cbListen.WidthRequest = 100;
this.cbListen.WidthRequest = 120;
this.cbListen.Name = "cbListen";
this.cbListen.Active = 0;
this.hboxMenu.Add (this.cbListen);
global::Gtk.Box.BoxChild w6 = ((global::Gtk.Box.BoxChild)(this.hboxMenu [this.cbListen]));
w6.Position = 3;

View File

@@ -124,11 +124,9 @@
<child>
<widget class="Gtk.ComboBoxEntry" id="cbListen">
<property name="MemberName" />
<property name="WidthRequest">100</property>
<property name="WidthRequest">120</property>
<property name="IsTextCombo">True</property>
<property name="Items" translatable="yes">127.0.0.1
0.0.0.0</property>
<property name="Active">0</property>
<property name="Items" translatable="yes" />
</widget>
<packing>
<property name="Position">3</property>