davemds pushed a commit to branch master.
commit 5e344beae4fd87fd4f7be983b155fbde33454e6e
Author: davemds <[email protected]>
Date: Sun Apr 14 17:39:13 2013 +0200
Update econnman to work with both old and new py bindings
I disabled the check for the presence of the old bindings
in configure.ac as the new bindings does not provide a pc file,
and because it now works with both versions,
but I highly raccomend to switch back from autotools to distutils.
---
configure.ac | 10 ++---
econnman-bin.in | 119 ++++++++++++++++++++++++++++++++++----------------------
2 files changed, 78 insertions(+), 51 deletions(-)
diff --git a/configure.ac b/configure.ac
index a73747d..05e52e2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,11 +10,11 @@ AM_PATH_PYTHON([2.6])
EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
# not strictly needed during compile, but let's force this check
-PKG_PROG_PKG_CONFIG
-PKG_CHECK_MODULES([PY_EFL], [
- python-elementary >= 1.7.0
- python-edbus >= 1.7.0
-])
+# PKG_PROG_PKG_CONFIG
+# PKG_CHECK_MODULES([PY_EFL], [
+ # python-elementary >= 1.7.0
+ # python-edbus >= 1.7.0
+# ])
AC_CONFIG_FILES([
Makefile
diff --git a/econnman-bin.in b/econnman-bin.in
index 6192e25..6ae0d95 100755
--- a/econnman-bin.in
+++ b/econnman-bin.in
@@ -7,18 +7,45 @@
# - Fix connman's PropertyChanged when changing off/manual -> dhcp,
# gateway is not updated.
-import elementary as elm
-import evas
-import e_dbus
-import ecore
-import edje
+
import dbus
import dbus.service
import logging
import argparse
import os.path
-dbus_ml = e_dbus.DBusEcoreMainLoop()
+try:
+ import efl.evas as evas
+ import efl.ecore as ecore
+ import efl.edje as edje
+ from efl.dbus_mainloop import DBusEcoreMainLoop
+ import efl.elementary as elm
+ from efl.elementary.window import Window
+ from efl.elementary.background import Background
+ from efl.elementary.box import Box
+ from efl.elementary.label import Label
+ from efl.elementary.naviframe import Naviframe
+ from efl.elementary.popup import Popup
+ from efl.elementary.button import Button
+ from efl.elementary.scroller import Scroller
+ from efl.elementary.check import Check
+ from efl.elementary.progressbar import Progressbar
+ from efl.elementary.genlist import Genlist, GenlistItemClass
+ from efl.elementary.segment_control import SegmentControl
+ from efl.elementary.frame import Frame
+ from efl.elementary.entry import Entry
+ from efl.elementary.icon import Icon
+ from efl.elementary.layout import Layout
+except:
+ import elementary as elm
+ import evas, e_dbus, ecore, edje
+ from e_dbus import DBusEcoreMainLoop
+ from elementary import Window, Background, Box, Label, Naviframe, Popup, \
+ Button, Scroller, Check, Progressbar, Genlist, GenlistItemClass, \
+ SegmentControl, Frame, Entry, Icon, Layout
+
+
+dbus_ml = DBusEcoreMainLoop()
bus = dbus.SystemBus(mainloop=dbus_ml)
log = logging.getLogger()
@@ -95,7 +122,7 @@ class ObjectView(object):
self.sig_ch = self.bus_obj.connect_to_signal("PropertyChanged",
self.on_property_changed)
- self.obj = elm.Scroller(parent)
+ self.obj = Scroller(parent)
self.obj.on_del_add(self._deleted)
self.obj.size_hint_weight = EXPAND_BOTH
self.obj.policy_set(elm.ELM_SCROLLER_POLICY_OFF,
@@ -103,7 +130,7 @@ class ObjectView(object):
self.obj.bounce_set(False, True)
self.obj.content_min_limit(True, False)
- self.box = elm.Box(self.obj)
+ self.box = Box(self.obj)
self.box.size_hint_weight = EXPAND_HORIZ
self.box.horizontal = False
@@ -128,7 +155,7 @@ class ObjectView(object):
log.critical("must be implemented!")
def add_check(self, box, label, callback=None):
- obj = elm.Check(box)
+ obj = Check(box)
obj.size_hint_weight = EXPAND_HORIZ
obj.size_hint_align = FILL_BOTH
obj.text = label
@@ -139,7 +166,7 @@ class ObjectView(object):
return obj
def add_button(self, box, label, callback):
- obj = elm.Button(box)
+ obj = Button(box)
obj.size_hint_weight = EXPAND_HORIZ
obj.size_hint_align = FILL_BOTH
obj.text = label
@@ -149,7 +176,7 @@ class ObjectView(object):
return obj
def add_label(self, box, label):
- lb = elm.Label(box)
+ lb = Label(box)
lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH
lb.text = label
@@ -158,7 +185,7 @@ class ObjectView(object):
return lb
def add_progress(self, box, label):
- pb = elm.Progressbar(box)
+ pb = Progressbar(box)
pb.size_hint_weight = EXPAND_HORIZ
pb.size_hint_align = FILL_BOTH
pb.text = label
@@ -167,7 +194,7 @@ class ObjectView(object):
return pb
def add_segment_control(self, box, options, callback):
- sc = elm.SegmentControl(box)
+ sc = SegmentControl(box)
sc.size_hint_weight = EXPAND_HORIZ
sc.size_hint_align = FILL_BOTH
items = {}
@@ -179,14 +206,14 @@ class ObjectView(object):
return sc, items
def add_frame_and_box(self, box, label):
- fr = elm.Frame(box)
+ fr = Frame(box)
fr.size_hint_weight = EXPAND_HORIZ
fr.size_hint_align = FILL_BOTH
fr.text = label
fr.show()
box.pack_end(fr)
- bx = elm.Box(fr)
+ bx = Box(fr)
bx.size_hint_weight = EXPAND_HORIZ
bx.size_hint_align = FILL_BOTH
bx.horizontal = False
@@ -197,7 +224,7 @@ class ObjectView(object):
def add_label_and_entry(self, box, label, callback=None):
lb = self.add_label(box, label)
- en = elm.Entry(box)
+ en = Entry(box)
en.size_hint_weight = EXPAND_HORIZ
en.size_hint_align = FILL_BOTH
en.single_line = True
@@ -218,7 +245,7 @@ class OfflineModeMonitor(object):
user to set the property remotely.
"""
def __init__(self, win):
- self.obj = elm.Check(win)
+ self.obj = Check(win)
self.obj.style = "toggle"
self.obj.part_text_set("on", "Offline")
self.obj.part_text_set("off", "Online")
@@ -275,7 +302,7 @@ class TechList(object):
def __init__(self, parent, on_selected=None):
self.techs = {}
self.items = {}
- self.obj = elm.Genlist(parent)
+ self.obj = Genlist(parent)
self.obj.on_del_add(self._deleted)
self.on_selected = on_selected
self.obj.callback_selected_add(self._tech_selected)
@@ -288,7 +315,7 @@ class TechList(object):
"net.connman.Technology",
"net.connman",
path_keyword='path')
- self.itc = elm.GenlistItemClass(item_style="default",
+ self.itc = GenlistItemClass(item_style="default",
text_get_func=self._item_text_get,
content_get_func=self._item_content_get)
@@ -367,7 +394,7 @@ class TechList(object):
def _item_content_get(self, obj, part, item_data):
if part == "elm.swallow.end":
- ic = elm.Icon(obj)
+ ic = Icon(obj)
ic.standard = "arrow_right"
return ic
@@ -377,7 +404,7 @@ class TechList(object):
if not t:
return None
- ic = elm.Icon(obj)
+ ic = Icon(obj)
if t.get("Connected", False):
ic.standard = "connman-tech-connected"
elif t.get("Powered", False):
@@ -509,7 +536,7 @@ class ServicesList(object):
def __init__(self, parent, on_selected=None, on_disclosure=None):
self.services = {}
self.items = {}
- self.obj = elm.Genlist(parent)
+ self.obj = Genlist(parent)
self.on_selected = on_selected
self.on_disclosure = on_disclosure
self.obj.callback_selected_add(self._item_selected)
@@ -523,7 +550,7 @@ class ServicesList(object):
path_keyword='path')
manager.GetServices(reply_handler=self._get_services_reply,
error_handler=self._get_services_error)
- self.itc = elm.GenlistItemClass(item_style="default",
+ self.itc = GenlistItemClass(item_style="default",
text_get_func=self._item_text_get,
content_get_func=self._item_content_get)
@@ -642,35 +669,35 @@ class ServicesList(object):
security.remove("none")
if part == "elm.swallow.end":
- bx = elm.Box(obj)
+ bx = Box(obj)
bx.horizontal = True
bx.homogeneous = True
bx.padding = (2, 0)
bx.align = (1.0, 0.5)
if connected:
- ic = elm.Icon(obj)
+ ic = Icon(obj)
ic.standard = "connman-connected"
ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show()
bx.pack_end(ic)
if security and favorite:
- ic = elm.Icon(obj)
+ ic = Icon(obj)
ic.standard = "connman-security-favorite"
ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show()
bx.pack_end(ic)
elif security:
- ic = elm.Icon(obj)
+ ic = Icon(obj)
ic.standard = "connman-security"
ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show()
bx.pack_end(ic)
- ic = elm.Icon(obj)
+ ic = Icon(obj)
ic.standard = "arrow_right"
- bt = elm.Button(obj)
+ bt = Button(obj)
bt.content = ic
bt.callback_clicked_add(self._item_disclosure, item_data)
bt.propagate_events = False
@@ -683,7 +710,7 @@ class ServicesList(object):
if part != "elm.swallow.icon":
return
- ly = elm.Layout(obj)
+ ly = Layout(obj)
ly.theme_set("icon", type, "default")
ly.size_hint_min_set(32, 32)
@@ -1332,25 +1359,25 @@ class Agent(dbus.service.Object):
on_done(response)
w.delete()
- self.dialog = w = elm.Window("econnman-agent",
elm.ELM_WIN_DIALOG_BASIC)
+ self.dialog = w = Window("econnman-agent", elm.ELM_WIN_DIALOG_BASIC)
w.title = "ConnMan Requested Input"
w.icon_name = "econnman"
w.autodel = True
w.on_del_add(on_deleted)
w.show()
- bg = elm.Background(w)
+ bg = Background(w)
bg.size_hint_weight = EXPAND_BOTH
bg.show()
w.resize_object_add(bg)
- bx = elm.Box(w)
+ bx = Box(w)
bx.size_hint_align = FILL_BOTH
bx.horizontal = False
bx.show()
w.resize_object_add(bx)
- lb = elm.Label(bx)
+ lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH
lb.text = "<b>ConnMan needs your input</b>"
@@ -1359,7 +1386,7 @@ class Agent(dbus.service.Object):
name = self.serv_lst.service_name_get(path)
if name:
- lb = elm.Label(bx)
+ lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH
lb.text = "Service: %s" % (name,)
@@ -1374,14 +1401,14 @@ class Agent(dbus.service.Object):
decos += " (type: %s)" % (t,)
if desc.get("Requirement") == "mandatory":
decos += " REQUIRED"
- lb = elm.Label(bx)
+ lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH
lb.text = "%s:%s" % (name, decos)
lb.show()
bx.pack_end(lb)
- en = elm.Entry(bx)
+ en = Entry(bx)
en.size_hint_weight = EXPAND_HORIZ
en.size_hint_align = FILL_BOTH
en.single_line = True
@@ -1392,7 +1419,7 @@ class Agent(dbus.service.Object):
bx.pack_end(en)
widgets[name] = en
- bt = elm.Button(bx)
+ bt = Button(bx)
bt.size_hint_weight = EXPAND_HORIZ
bt.size_hint_align = FILL_BOTH
bt.callback_clicked_add(on_clicked)
@@ -1410,12 +1437,12 @@ def popup_fatal(obj, title, message):
"""
win = obj.top_widget_get()
log.critical("%s: %s", title, message)
- pop = elm.Popup(win)
+ pop = Popup(win)
pop.size_hint_weight = EXPAND_BOTH
pop.part_text_set("title,text", title)
pop.text = message
- bt = elm.Button(win)
+ bt = Button(win)
bt.text = "Quit"
bt.callback_clicked_add(lambda bt: elm.exit())
pop.part_content_set("button1", bt)
@@ -1427,12 +1454,12 @@ def popup_error(obj, title, message):
"""Shows a popup with an error message and a Close button."""
win = obj.top_widget_get()
log.error("%s: %s", title, message)
- pop = elm.Popup(win)
+ pop = Popup(win)
pop.size_hint_weight = EXPAND_BOTH
pop.part_text_set("title,text", title)
pop.text = message
- bt = elm.Button(win)
+ bt = Button(win)
bt.text = "Close"
bt.callback_clicked_add(lambda bt: pop.delete())
pop.part_content_set("button1", bt)
@@ -1459,14 +1486,14 @@ if __name__ == "__main__":
if os.path.exists(td):
elm.theme_extension_add(td)
- win = elm.Window("econnman", elm.ELM_WIN_BASIC)
+ win = Window("econnman", elm.ELM_WIN_BASIC)
win.title = "EConnMan"
win.icon_name = "econnman"
win.autodel = True
win.size = (480, 700)
win.show()
- bg = elm.Background(win)
+ bg = Background(win)
bg.size_hint_weight = EXPAND_BOTH
bg.show()
win.resize_object_add(bg)
@@ -1481,14 +1508,14 @@ if __name__ == "__main__":
elm.shutdown()
raise
- nf = elm.Naviframe(win)
+ nf = Naviframe(win)
nf.size_hint_weight = EXPAND_BOTH
nf.show()
win.resize_object_add(nf)
offline_mon = OfflineModeMonitor(win)
- techs = elm.Button(win)
+ techs = Button(win)
techs.text = "Techs"
techs.callback_clicked_add(show_techs, nf)
--
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter