Add a share button to the browser.
This commit is contained in:
parent
d0613d2a42
commit
f86977781e
@ -119,11 +119,10 @@ class NavigationToolbar(gtk.Toolbar):
|
|||||||
self.insert(separator, -1)
|
self.insert(separator, -1)
|
||||||
separator.show()
|
separator.show()
|
||||||
|
|
||||||
item = gtk.MenuToolButton(None, "Share")
|
share = gtk.ToolButton("Share")
|
||||||
item.set_menu(gtk.Menu())
|
share.connect("clicked", self.__share_cb)
|
||||||
item.connect("show-menu", self.__show_share_menu_cb)
|
self.insert(share, -1)
|
||||||
toolbar.insert(item, -1)
|
share.show()
|
||||||
item.show()
|
|
||||||
|
|
||||||
separator = gtk.SeparatorToolItem()
|
separator = gtk.SeparatorToolItem()
|
||||||
self.insert(separator, -1)
|
self.insert(separator, -1)
|
||||||
@ -150,25 +149,14 @@ class NavigationToolbar(gtk.Toolbar):
|
|||||||
def __reload_cb(self, button):
|
def __reload_cb(self, button):
|
||||||
self.embed.reload()
|
self.embed.reload()
|
||||||
|
|
||||||
|
def __share_cb(self, button):
|
||||||
|
|
||||||
def __location_changed(self, embed):
|
def __location_changed(self, embed):
|
||||||
self._update_sensitivity()
|
self._update_sensitivity()
|
||||||
|
|
||||||
def __open_address_cb(self, address):
|
def __open_address_cb(self, address):
|
||||||
self.embed.load_address(address)
|
self.embed.load_address(address)
|
||||||
|
|
||||||
def __show_share_menu_cb(self, button):
|
|
||||||
menu = gtk.Menu()
|
|
||||||
|
|
||||||
item = gtk.MenuItem("Group", False)
|
|
||||||
item.connect("activate", self.__share_group_activate_cb)
|
|
||||||
menu.append(item)
|
|
||||||
item.show()
|
|
||||||
|
|
||||||
button.set_menu(menu)
|
|
||||||
|
|
||||||
def __share_group_activate_cb(self, item, link):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class BrowserActivity(activity.Activity):
|
class BrowserActivity(activity.Activity):
|
||||||
def __init__(self, uri):
|
def __init__(self, uri):
|
||||||
activity.Activity.__init__(self)
|
activity.Activity.__init__(self)
|
||||||
|
33
chat/chat.py
33
chat/chat.py
@ -346,16 +346,37 @@ class GroupChat(Chat):
|
|||||||
chat.activity_connect_to_shell()
|
chat.activity_connect_to_shell()
|
||||||
chat.recv_message(sender, msg)
|
chat.recv_message(sender, msg)
|
||||||
|
|
||||||
def run(self):
|
class ChatShell(dbus.service.Object):
|
||||||
|
instance = None
|
||||||
|
|
||||||
|
def get_instance():
|
||||||
|
if not ChatShell.instance:
|
||||||
|
ChatShell.instance = ChatShell()
|
||||||
|
return ChatShell.instance
|
||||||
|
|
||||||
|
get_instance = staticmethod(get_instance)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
session_bus = dbus.SessionBus()
|
||||||
|
bus_name = dbus.service.BusName('com.redhat.Sugar.Chat', bus=session_bus)
|
||||||
|
object_path = '/com/redhat/Sugar/Chat'
|
||||||
|
|
||||||
|
dbus.service.Object.__init__(self, bus_name, object_path)
|
||||||
|
|
||||||
|
def open_group_chat(self):
|
||||||
|
group_chat = GroupChat()
|
||||||
|
group_chat.activity_connect_to_shell()
|
||||||
|
|
||||||
|
@dbus.service.method('com.redhat.Sugar.ChatShell')
|
||||||
|
def send_message(self, message):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
ChatShell.get_instance().open_group_chat()
|
||||||
try:
|
try:
|
||||||
gtk.main()
|
gtk.main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def main():
|
|
||||||
app = GroupChat()
|
|
||||||
app.activity_connect_to_shell()
|
|
||||||
app.run()
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -75,44 +75,6 @@ class GlibXMLRPCServer(GlibTCPServer, SimpleXMLRPCServer.SimpleXMLRPCDispatcher)
|
|||||||
SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
|
SimpleXMLRPCServer.SimpleXMLRPCDispatcher.__init__(self)
|
||||||
GlibTCPServer.__init__(self, addr, requestHandler)
|
GlibTCPServer.__init__(self, addr, requestHandler)
|
||||||
|
|
||||||
def _marshaled_dispatch(self, data, dispatch_method = None):
|
|
||||||
"""Dispatches an XML-RPC method from marshalled (XML) data.
|
|
||||||
|
|
||||||
XML-RPC methods are dispatched from the marshalled (XML) data
|
|
||||||
using the _dispatch method and the result is returned as
|
|
||||||
marshalled data. For backwards compatibility, a dispatch
|
|
||||||
function can be provided as an argument (see comment in
|
|
||||||
SimpleXMLRPCRequestHandler.do_POST) but overriding the
|
|
||||||
existing method through subclassing is the prefered means
|
|
||||||
of changing method dispatch behavior.
|
|
||||||
"""
|
|
||||||
|
|
||||||
params, method = xmlrpclib.loads(data)
|
|
||||||
|
|
||||||
# generate response
|
|
||||||
try:
|
|
||||||
if dispatch_method is not None:
|
|
||||||
response = dispatch_method(method, params)
|
|
||||||
else:
|
|
||||||
response = self._dispatch(method, params)
|
|
||||||
# wrap response in a singleton tuple
|
|
||||||
response = (response,)
|
|
||||||
response = xmlrpclib.dumps(response, methodresponse=1)
|
|
||||||
except Fault, fault:
|
|
||||||
response = xmlrpclib.dumps(fault)
|
|
||||||
except:
|
|
||||||
set = sys.exc_type
|
|
||||||
sev = sys.exc_value
|
|
||||||
ser = sys.exc_traceback
|
|
||||||
|
|
||||||
# report exception back to server
|
|
||||||
response = xmlrpclib.dumps(xmlrpclib.Fault(1, "%s:%s" % (set, sev)))
|
|
||||||
|
|
||||||
print "Exception while processing request:"
|
|
||||||
traceback.print_exception(set, sev, ser)
|
|
||||||
|
|
||||||
return response
|
|
||||||
|
|
||||||
|
|
||||||
class GroupChatController(object):
|
class GroupChatController(object):
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ import os
|
|||||||
import pwd
|
import pwd
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import socket
|
import socket
|
||||||
import traceback
|
|
||||||
|
|
||||||
import presence
|
import presence
|
||||||
import BuddyList
|
import BuddyList
|
||||||
@ -15,6 +14,7 @@ class GroupRequestHandler(object):
|
|||||||
def message(self, message):
|
def message(self, message):
|
||||||
address = network.get_authinfo()
|
address = network.get_authinfo()
|
||||||
self._group.recv(address[0], message)
|
self._group.recv(address[0], message)
|
||||||
|
return True
|
||||||
|
|
||||||
class Owner:
|
class Owner:
|
||||||
instance = None
|
instance = None
|
||||||
@ -93,11 +93,9 @@ class Group:
|
|||||||
peer = xmlrpclib.ServerProxy(addr)
|
peer = xmlrpclib.ServerProxy(addr)
|
||||||
success = True
|
success = True
|
||||||
try:
|
try:
|
||||||
print self._serialize_msg(pipe_id, msg)
|
|
||||||
peer.message(self._serialize_msg(pipe_id, msg))
|
peer.message(self._serialize_msg(pipe_id, msg))
|
||||||
except (socket.error, xmlrpclib.Fault, xmlrpclib.ProtocolError), e:
|
except (socket.error, xmlrpclib.Fault), e:
|
||||||
print "Message Send Error:"
|
print str(e)
|
||||||
traceback.print_exc()
|
|
||||||
success = False
|
success = False
|
||||||
return success
|
return success
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user