summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-12-03 12:44:53 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-12-03 12:44:53 +0100
commita86d68ea11fa71c79205fd82726173e3c2c50068 (patch)
treeb3af1b7d76310479204c34592a8197193454f201
parentf865d8783171d30518047081304701c55fee3192 (diff)
downloadnetwork-manager-applet-aleksander/mobile-providers.tar.gz
libnm-gtk: new javascript example on how to use the mobile provider databasealeksander/mobile-providers
-rw-r--r--configure.ac1
-rw-r--r--src/libnm-gtk/Makefile.am2
-rw-r--r--src/libnm-gtk/examples/Makefile.am2
-rw-r--r--src/libnm-gtk/examples/mobile-providers.js23
4 files changed, 27 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index c202fe68..c0219ff2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -251,6 +251,7 @@ Makefile
src/Makefile
src/libnm-gtk/Makefile
src/libnm-gtk/tests/Makefile
+src/libnm-gtk/examples/Makefile
src/libnm-gtk/libnm-gtk.pc
src/marshallers/Makefile
src/utils/Makefile
diff --git a/src/libnm-gtk/Makefile.am b/src/libnm-gtk/Makefile.am
index 70039af2..dbc74774 100644
--- a/src/libnm-gtk/Makefile.am
+++ b/src/libnm-gtk/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = . tests
+SUBDIRS = . tests examples
uidir = $(datadir)/libnm-gtk
ui_DATA = wifi.ui
diff --git a/src/libnm-gtk/examples/Makefile.am b/src/libnm-gtk/examples/Makefile.am
new file mode 100644
index 00000000..d78ecd8d
--- /dev/null
+++ b/src/libnm-gtk/examples/Makefile.am
@@ -0,0 +1,2 @@
+
+EXTRA_DIST = mobile-providers.js
diff --git a/src/libnm-gtk/examples/mobile-providers.js b/src/libnm-gtk/examples/mobile-providers.js
new file mode 100644
index 00000000..0cf6fc8b
--- /dev/null
+++ b/src/libnm-gtk/examples/mobile-providers.js
@@ -0,0 +1,23 @@
+#!/usr/bin/gjs
+
+//
+// This example shows how to use the mobile providers database code from
+// within Javascript through gobject-introspection.
+//
+
+const NMGtk = imports.gi.NMGtk;
+
+var mpd = new NMGtk.MobileProvidersDatabase();
+try {
+ mpd.init(null);
+
+ let provider = mpd.lookup_3gpp_mcc_mnc('21403');
+ if (provider)
+ log ('Provider: ' + provider.get_name());
+ else
+ log ('Unknown provider');
+} catch (e) {
+ logError (e, 'Error while reading database');
+}
+
+