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.
This commit is contained in:
Davide Andreoli 2013-04-14 17:39:13 +02:00
parent b422f9470e
commit 5e344beae4
2 changed files with 78 additions and 51 deletions

View File

@ -10,11 +10,11 @@ AM_PATH_PYTHON([2.6])
EFL_WITH_BIN([edje], [edje-cc], [edje_cc]) EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
# not strictly needed during compile, but let's force this check # not strictly needed during compile, but let's force this check
PKG_PROG_PKG_CONFIG # PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([PY_EFL], [ # PKG_CHECK_MODULES([PY_EFL], [
python-elementary >= 1.7.0 # python-elementary >= 1.7.0
python-edbus >= 1.7.0 # python-edbus >= 1.7.0
]) # ])
AC_CONFIG_FILES([ AC_CONFIG_FILES([
Makefile Makefile

View File

@ -7,18 +7,45 @@
# - Fix connman's PropertyChanged when changing off/manual -> dhcp, # - Fix connman's PropertyChanged when changing off/manual -> dhcp,
# gateway is not updated. # gateway is not updated.
import elementary as elm
import evas
import e_dbus
import ecore
import edje
import dbus import dbus
import dbus.service import dbus.service
import logging import logging
import argparse import argparse
import os.path 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) bus = dbus.SystemBus(mainloop=dbus_ml)
log = logging.getLogger() log = logging.getLogger()
@ -95,7 +122,7 @@ class ObjectView(object):
self.sig_ch = self.bus_obj.connect_to_signal("PropertyChanged", self.sig_ch = self.bus_obj.connect_to_signal("PropertyChanged",
self.on_property_changed) self.on_property_changed)
self.obj = elm.Scroller(parent) self.obj = Scroller(parent)
self.obj.on_del_add(self._deleted) self.obj.on_del_add(self._deleted)
self.obj.size_hint_weight = EXPAND_BOTH self.obj.size_hint_weight = EXPAND_BOTH
self.obj.policy_set(elm.ELM_SCROLLER_POLICY_OFF, self.obj.policy_set(elm.ELM_SCROLLER_POLICY_OFF,
@ -103,7 +130,7 @@ class ObjectView(object):
self.obj.bounce_set(False, True) self.obj.bounce_set(False, True)
self.obj.content_min_limit(True, False) 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.size_hint_weight = EXPAND_HORIZ
self.box.horizontal = False self.box.horizontal = False
@ -128,7 +155,7 @@ class ObjectView(object):
log.critical("must be implemented!") log.critical("must be implemented!")
def add_check(self, box, label, callback=None): def add_check(self, box, label, callback=None):
obj = elm.Check(box) obj = Check(box)
obj.size_hint_weight = EXPAND_HORIZ obj.size_hint_weight = EXPAND_HORIZ
obj.size_hint_align = FILL_BOTH obj.size_hint_align = FILL_BOTH
obj.text = label obj.text = label
@ -139,7 +166,7 @@ class ObjectView(object):
return obj return obj
def add_button(self, box, label, callback): def add_button(self, box, label, callback):
obj = elm.Button(box) obj = Button(box)
obj.size_hint_weight = EXPAND_HORIZ obj.size_hint_weight = EXPAND_HORIZ
obj.size_hint_align = FILL_BOTH obj.size_hint_align = FILL_BOTH
obj.text = label obj.text = label
@ -149,7 +176,7 @@ class ObjectView(object):
return obj return obj
def add_label(self, box, label): def add_label(self, box, label):
lb = elm.Label(box) lb = Label(box)
lb.size_hint_weight = EXPAND_HORIZ lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH lb.size_hint_align = FILL_BOTH
lb.text = label lb.text = label
@ -158,7 +185,7 @@ class ObjectView(object):
return lb return lb
def add_progress(self, box, label): def add_progress(self, box, label):
pb = elm.Progressbar(box) pb = Progressbar(box)
pb.size_hint_weight = EXPAND_HORIZ pb.size_hint_weight = EXPAND_HORIZ
pb.size_hint_align = FILL_BOTH pb.size_hint_align = FILL_BOTH
pb.text = label pb.text = label
@ -167,7 +194,7 @@ class ObjectView(object):
return pb return pb
def add_segment_control(self, box, options, callback): def add_segment_control(self, box, options, callback):
sc = elm.SegmentControl(box) sc = SegmentControl(box)
sc.size_hint_weight = EXPAND_HORIZ sc.size_hint_weight = EXPAND_HORIZ
sc.size_hint_align = FILL_BOTH sc.size_hint_align = FILL_BOTH
items = {} items = {}
@ -179,14 +206,14 @@ class ObjectView(object):
return sc, items return sc, items
def add_frame_and_box(self, box, label): def add_frame_and_box(self, box, label):
fr = elm.Frame(box) fr = Frame(box)
fr.size_hint_weight = EXPAND_HORIZ fr.size_hint_weight = EXPAND_HORIZ
fr.size_hint_align = FILL_BOTH fr.size_hint_align = FILL_BOTH
fr.text = label fr.text = label
fr.show() fr.show()
box.pack_end(fr) box.pack_end(fr)
bx = elm.Box(fr) bx = Box(fr)
bx.size_hint_weight = EXPAND_HORIZ bx.size_hint_weight = EXPAND_HORIZ
bx.size_hint_align = FILL_BOTH bx.size_hint_align = FILL_BOTH
bx.horizontal = False bx.horizontal = False
@ -197,7 +224,7 @@ class ObjectView(object):
def add_label_and_entry(self, box, label, callback=None): def add_label_and_entry(self, box, label, callback=None):
lb = self.add_label(box, label) lb = self.add_label(box, label)
en = elm.Entry(box) en = Entry(box)
en.size_hint_weight = EXPAND_HORIZ en.size_hint_weight = EXPAND_HORIZ
en.size_hint_align = FILL_BOTH en.size_hint_align = FILL_BOTH
en.single_line = True en.single_line = True
@ -218,7 +245,7 @@ class OfflineModeMonitor(object):
user to set the property remotely. user to set the property remotely.
""" """
def __init__(self, win): def __init__(self, win):
self.obj = elm.Check(win) self.obj = Check(win)
self.obj.style = "toggle" self.obj.style = "toggle"
self.obj.part_text_set("on", "Offline") self.obj.part_text_set("on", "Offline")
self.obj.part_text_set("off", "Online") self.obj.part_text_set("off", "Online")
@ -275,7 +302,7 @@ class TechList(object):
def __init__(self, parent, on_selected=None): def __init__(self, parent, on_selected=None):
self.techs = {} self.techs = {}
self.items = {} self.items = {}
self.obj = elm.Genlist(parent) self.obj = Genlist(parent)
self.obj.on_del_add(self._deleted) self.obj.on_del_add(self._deleted)
self.on_selected = on_selected self.on_selected = on_selected
self.obj.callback_selected_add(self._tech_selected) self.obj.callback_selected_add(self._tech_selected)
@ -288,7 +315,7 @@ class TechList(object):
"net.connman.Technology", "net.connman.Technology",
"net.connman", "net.connman",
path_keyword='path') path_keyword='path')
self.itc = elm.GenlistItemClass(item_style="default", self.itc = GenlistItemClass(item_style="default",
text_get_func=self._item_text_get, text_get_func=self._item_text_get,
content_get_func=self._item_content_get) content_get_func=self._item_content_get)
@ -367,7 +394,7 @@ class TechList(object):
def _item_content_get(self, obj, part, item_data): def _item_content_get(self, obj, part, item_data):
if part == "elm.swallow.end": if part == "elm.swallow.end":
ic = elm.Icon(obj) ic = Icon(obj)
ic.standard = "arrow_right" ic.standard = "arrow_right"
return ic return ic
@ -377,7 +404,7 @@ class TechList(object):
if not t: if not t:
return None return None
ic = elm.Icon(obj) ic = Icon(obj)
if t.get("Connected", False): if t.get("Connected", False):
ic.standard = "connman-tech-connected" ic.standard = "connman-tech-connected"
elif t.get("Powered", False): elif t.get("Powered", False):
@ -509,7 +536,7 @@ class ServicesList(object):
def __init__(self, parent, on_selected=None, on_disclosure=None): def __init__(self, parent, on_selected=None, on_disclosure=None):
self.services = {} self.services = {}
self.items = {} self.items = {}
self.obj = elm.Genlist(parent) self.obj = Genlist(parent)
self.on_selected = on_selected self.on_selected = on_selected
self.on_disclosure = on_disclosure self.on_disclosure = on_disclosure
self.obj.callback_selected_add(self._item_selected) self.obj.callback_selected_add(self._item_selected)
@ -523,7 +550,7 @@ class ServicesList(object):
path_keyword='path') path_keyword='path')
manager.GetServices(reply_handler=self._get_services_reply, manager.GetServices(reply_handler=self._get_services_reply,
error_handler=self._get_services_error) 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, text_get_func=self._item_text_get,
content_get_func=self._item_content_get) content_get_func=self._item_content_get)
@ -642,35 +669,35 @@ class ServicesList(object):
security.remove("none") security.remove("none")
if part == "elm.swallow.end": if part == "elm.swallow.end":
bx = elm.Box(obj) bx = Box(obj)
bx.horizontal = True bx.horizontal = True
bx.homogeneous = True bx.homogeneous = True
bx.padding = (2, 0) bx.padding = (2, 0)
bx.align = (1.0, 0.5) bx.align = (1.0, 0.5)
if connected: if connected:
ic = elm.Icon(obj) ic = Icon(obj)
ic.standard = "connman-connected" ic.standard = "connman-connected"
ic.size_hint_min = ic.size_hint_max = (32, 32) ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show() ic.show()
bx.pack_end(ic) bx.pack_end(ic)
if security and favorite: if security and favorite:
ic = elm.Icon(obj) ic = Icon(obj)
ic.standard = "connman-security-favorite" ic.standard = "connman-security-favorite"
ic.size_hint_min = ic.size_hint_max = (32, 32) ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show() ic.show()
bx.pack_end(ic) bx.pack_end(ic)
elif security: elif security:
ic = elm.Icon(obj) ic = Icon(obj)
ic.standard = "connman-security" ic.standard = "connman-security"
ic.size_hint_min = ic.size_hint_max = (32, 32) ic.size_hint_min = ic.size_hint_max = (32, 32)
ic.show() ic.show()
bx.pack_end(ic) bx.pack_end(ic)
ic = elm.Icon(obj) ic = Icon(obj)
ic.standard = "arrow_right" ic.standard = "arrow_right"
bt = elm.Button(obj) bt = Button(obj)
bt.content = ic bt.content = ic
bt.callback_clicked_add(self._item_disclosure, item_data) bt.callback_clicked_add(self._item_disclosure, item_data)
bt.propagate_events = False bt.propagate_events = False
@ -683,7 +710,7 @@ class ServicesList(object):
if part != "elm.swallow.icon": if part != "elm.swallow.icon":
return return
ly = elm.Layout(obj) ly = Layout(obj)
ly.theme_set("icon", type, "default") ly.theme_set("icon", type, "default")
ly.size_hint_min_set(32, 32) ly.size_hint_min_set(32, 32)
@ -1332,25 +1359,25 @@ class Agent(dbus.service.Object):
on_done(response) on_done(response)
w.delete() 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.title = "ConnMan Requested Input"
w.icon_name = "econnman" w.icon_name = "econnman"
w.autodel = True w.autodel = True
w.on_del_add(on_deleted) w.on_del_add(on_deleted)
w.show() w.show()
bg = elm.Background(w) bg = Background(w)
bg.size_hint_weight = EXPAND_BOTH bg.size_hint_weight = EXPAND_BOTH
bg.show() bg.show()
w.resize_object_add(bg) w.resize_object_add(bg)
bx = elm.Box(w) bx = Box(w)
bx.size_hint_align = FILL_BOTH bx.size_hint_align = FILL_BOTH
bx.horizontal = False bx.horizontal = False
bx.show() bx.show()
w.resize_object_add(bx) w.resize_object_add(bx)
lb = elm.Label(bx) lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH lb.size_hint_align = FILL_BOTH
lb.text = "<b>ConnMan needs your input</b>" 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) name = self.serv_lst.service_name_get(path)
if name: if name:
lb = elm.Label(bx) lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH lb.size_hint_align = FILL_BOTH
lb.text = "Service: %s" % (name,) lb.text = "Service: %s" % (name,)
@ -1374,14 +1401,14 @@ class Agent(dbus.service.Object):
decos += " (type: %s)" % (t,) decos += " (type: %s)" % (t,)
if desc.get("Requirement") == "mandatory": if desc.get("Requirement") == "mandatory":
decos += " REQUIRED" decos += " REQUIRED"
lb = elm.Label(bx) lb = Label(bx)
lb.size_hint_weight = EXPAND_HORIZ lb.size_hint_weight = EXPAND_HORIZ
lb.size_hint_align = FILL_BOTH lb.size_hint_align = FILL_BOTH
lb.text = "%s:%s" % (name, decos) lb.text = "%s:%s" % (name, decos)
lb.show() lb.show()
bx.pack_end(lb) bx.pack_end(lb)
en = elm.Entry(bx) en = Entry(bx)
en.size_hint_weight = EXPAND_HORIZ en.size_hint_weight = EXPAND_HORIZ
en.size_hint_align = FILL_BOTH en.size_hint_align = FILL_BOTH
en.single_line = True en.single_line = True
@ -1392,7 +1419,7 @@ class Agent(dbus.service.Object):
bx.pack_end(en) bx.pack_end(en)
widgets[name] = en widgets[name] = en
bt = elm.Button(bx) bt = Button(bx)
bt.size_hint_weight = EXPAND_HORIZ bt.size_hint_weight = EXPAND_HORIZ
bt.size_hint_align = FILL_BOTH bt.size_hint_align = FILL_BOTH
bt.callback_clicked_add(on_clicked) bt.callback_clicked_add(on_clicked)
@ -1410,12 +1437,12 @@ def popup_fatal(obj, title, message):
""" """
win = obj.top_widget_get() win = obj.top_widget_get()
log.critical("%s: %s", title, message) log.critical("%s: %s", title, message)
pop = elm.Popup(win) pop = Popup(win)
pop.size_hint_weight = EXPAND_BOTH pop.size_hint_weight = EXPAND_BOTH
pop.part_text_set("title,text", title) pop.part_text_set("title,text", title)
pop.text = message pop.text = message
bt = elm.Button(win) bt = Button(win)
bt.text = "Quit" bt.text = "Quit"
bt.callback_clicked_add(lambda bt: elm.exit()) bt.callback_clicked_add(lambda bt: elm.exit())
pop.part_content_set("button1", bt) 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.""" """Shows a popup with an error message and a Close button."""
win = obj.top_widget_get() win = obj.top_widget_get()
log.error("%s: %s", title, message) log.error("%s: %s", title, message)
pop = elm.Popup(win) pop = Popup(win)
pop.size_hint_weight = EXPAND_BOTH pop.size_hint_weight = EXPAND_BOTH
pop.part_text_set("title,text", title) pop.part_text_set("title,text", title)
pop.text = message pop.text = message
bt = elm.Button(win) bt = Button(win)
bt.text = "Close" bt.text = "Close"
bt.callback_clicked_add(lambda bt: pop.delete()) bt.callback_clicked_add(lambda bt: pop.delete())
pop.part_content_set("button1", bt) pop.part_content_set("button1", bt)
@ -1459,14 +1486,14 @@ if __name__ == "__main__":
if os.path.exists(td): if os.path.exists(td):
elm.theme_extension_add(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.title = "EConnMan"
win.icon_name = "econnman" win.icon_name = "econnman"
win.autodel = True win.autodel = True
win.size = (480, 700) win.size = (480, 700)
win.show() win.show()
bg = elm.Background(win) bg = Background(win)
bg.size_hint_weight = EXPAND_BOTH bg.size_hint_weight = EXPAND_BOTH
bg.show() bg.show()
win.resize_object_add(bg) win.resize_object_add(bg)
@ -1481,14 +1508,14 @@ if __name__ == "__main__":
elm.shutdown() elm.shutdown()
raise raise
nf = elm.Naviframe(win) nf = Naviframe(win)
nf.size_hint_weight = EXPAND_BOTH nf.size_hint_weight = EXPAND_BOTH
nf.show() nf.show()
win.resize_object_add(nf) win.resize_object_add(nf)
offline_mon = OfflineModeMonitor(win) offline_mon = OfflineModeMonitor(win)
techs = elm.Button(win) techs = Button(win)
techs.text = "Techs" techs.text = "Techs"
techs.callback_clicked_add(show_techs, nf) techs.callback_clicked_add(show_techs, nf)