summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>2009-09-03 17:49:52 +0300
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>2009-09-03 17:49:52 +0300
commit26168494dbe5b7c3455ab20d15043f4b77e187e7 (patch)
tree546898c4cdd9dad002a877806a6cf94315d3d776 /src/ui
parente3d4c12c3902e154e2c660d12e6761704a44da49 (diff)
downloadrygel-26168494dbe5b7c3455ab20d15043f4b77e187e7.tar.gz
core,ui,data: Replace 'ip' config with 'interface'
Replace 'host-ip' configuration key with 'interface'. Also provide an ease-to-use UI component to set this key in the user config.
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/Makefile.am2
-rw-r--r--src/ui/rygel-general-pref-section.vala60
2 files changed, 55 insertions, 7 deletions
diff --git a/src/ui/Makefile.am b/src/ui/Makefile.am
index 5bafd9aa..9d62e0ee 100644
--- a/src/ui/Makefile.am
+++ b/src/ui/Makefile.am
@@ -30,7 +30,7 @@ rygel_preferences_SOURCES = \
rygel.stamp: $(rygel_preferences_VALASOURCES)
rygel_preferences_VALAFLAGS = \
- --vapidir=$(rygeldir) \
+ --vapidir=$(rygeldir) --thread \
--pkg rygel-1.0 --pkg cstuff --pkg gupnp-1.0 --pkg gupnp-av-1.0 \
--pkg dbus-glib-1 --pkg gconf-2.0 --pkg gstreamer-0.10 \
--pkg gio-2.0 --pkg gee-1.0 --pkg gtk+-2.0
diff --git a/src/ui/rygel-general-pref-section.vala b/src/ui/rygel-general-pref-section.vala
index 862e19e3..bccb21ae 100644
--- a/src/ui/rygel-general-pref-section.vala
+++ b/src/ui/rygel-general-pref-section.vala
@@ -21,17 +21,18 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
using Gtk;
+using GUPnP;
public class Rygel.GeneralPrefSection : PreferencesSection {
const string UPNP_CHECKBUTTON = "upnp-checkbutton";
- const string IP_ENTRY = "ip-entry";
+ const string IFACE_ENTRY = "iface-entry";
const string PORT_SPINBUTTON = "port-spinbutton";
const string TRANS_CHECKBUTTON = "transcoding-checkbutton";
const string MP3_CHECKBUTTON = "mp3-checkbutton";
const string MP2TS_CHECKBUTTON = "mp2ts-checkbutton";
const string LPCM_CHECKBUTTON = "lpcm-checkbutton";
- private Entry ip_entry;
+ private ComboBoxEntry iface_entry;
private SpinButton port_spin;
// Transcoding options
@@ -41,14 +42,16 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
private CheckButton mp2ts_check;
private CheckButton lpcm_check;
+ private ContextManager context_manager;
+
public GeneralPrefSection (Builder builder,
UserConfig config) throws Error {
base (config, "general");
this.upnp_check = (CheckButton) builder.get_object (UPNP_CHECKBUTTON);
assert (this.upnp_check != null);
- this.ip_entry = (Entry) builder.get_object (IP_ENTRY);
- assert (this.ip_entry != null);
+ this.iface_entry = (ComboBoxEntry) builder.get_object (IFACE_ENTRY);
+ assert (this.iface_entry != null);
this.port_spin = (SpinButton) builder.get_object (PORT_SPINBUTTON);
assert (this.port_spin != null);
this.trans_check = (CheckButton) builder.get_object (TRANS_CHECKBUTTON);
@@ -60,8 +63,13 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
this.lpcm_check = (CheckButton) builder.get_object (LPCM_CHECKBUTTON);
assert (this.lpcm_check != null);
+ this.context_manager = new ContextManager (null, 0);
+
+ // Apparently glade/GtkBuilder is unable to do this for us
+ this.iface_entry.set_text_column (0);
try {
- this.ip_entry.set_text (config.get_host_ip ());
+ this.iface_entry.append_text (config.get_interface ());
+ this.iface_entry.set_active (0);
} catch (GLib.Error err) {
// No problem if we fail to read the config, the default values
// will do just fine. Same goes for rest of the keys.
@@ -86,10 +94,15 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
} catch (GLib.Error err) {}
this.trans_check.toggled += this.on_trans_check_toggled;
+
+ this.context_manager.context_available.connect (
+ this.on_context_available);
+ this.context_manager.context_unavailable.connect (
+ this.on_context_unavailable);
}
public override void save () {
- this.config.set_host_ip (this.ip_entry.get_text ());
+ this.config.set_interface (this.iface_entry.get_active_text ());
this.config.set_port ((int) this.port_spin.get_value ());
this.config.set_upnp_enabled (this.upnp_check.active);
@@ -104,4 +117,39 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
this.mp2ts_check.sensitive =
this.lpcm_check.sensitive = trans_check.active;
}
+
+ private void on_context_available (GUPnP.ContextManager manager,
+ GUPnP.Context context) {
+ TreeIter iter;
+
+ if (!this.find_interface (context.interface, out iter)) {
+ this.iface_entry.append_text (context.interface);
+ }
+ }
+
+ private void on_context_unavailable (GUPnP.ContextManager manager,
+ GUPnP.Context context) {
+ TreeIter iter;
+
+ if (this.find_interface (context.interface, out iter)) {
+ var list_store = this.iface_entry.model as ListStore;
+ list_store.remove (iter);
+ }
+ }
+
+ private bool find_interface (string iface, out TreeIter iter) {
+ var model = this.iface_entry.model;
+ var more = model.get_iter_first (out iter);
+ while (more) {
+ model.get (iter, 0, &name, -1);
+
+ if (name == iface) {
+ break;
+ }
+
+ more = model.iter_next (ref iter);
+ }
+
+ return more;
+ }
}