示例#1
0
    def __init__(self, gui):
        GUI_Page.__init__(self, 'Key exchange')

        self.keymanagement = get_plugin_by_type(PLUGIN_TYPE_KEY_MANAGEMENT)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.main_gui = gui
        self.user = None
        self.entered_key = ''
        self.request_dialog = None

        self.main_vbox = gtk.VBox()
        self.notebook = gtk.Notebook()
        self.notebook.set_show_tabs(False)
        self.main_vbox.pack_start(self.notebook)

        # notebook pages for differents stages of key exchange
        lock_image = gtk.image_new_from_file(join(get_dir(ICON_DIR),
            'Padlock.png'))
        # page 1: show messages
        page1 = gtk.VBox()
        self.messagelabel = gtk.Label()
        page1.pack_start(self.messagelabel)
        self.notebook.append_page(page1)
        # page 2: show generated symmetric key
        page2 = gtk.VBox()
        self.show_key_header = gtk.Label()
        page2.pack_start(self.show_key_header, False, True, 10)
        self.keylabel = gtk.Label()
        page2.pack_start(self.keylabel)
        key_show_eventbox = gtk.EventBox()
        key_show_eventbox.modify_bg(gtk.STATE_NORMAL,
            key_show_eventbox.get_colormap().alloc_color('red'))
        key_show_eventbox.add(page2)
        self.notebook.append_page(key_show_eventbox)
        # page 3: ask for symmetric key
        page3 = gtk.VBox()
        self.key_entry_header = gtk.Label()
        page3.pack_start(self.key_entry_header, False, True, 10)
        page3_hbox = gtk.HBox()
        page3.pack_start(page3_hbox)
        self.keyentry = gtk.Label()
        page3_hbox.pack_start(self.keyentry)
        page3_hbox.pack_start(lock_image, False, False)
        self.key_eventbox = gtk.EventBox()
        self.key_eventbox.set_events(gtk.gdk.KEY_PRESS_MASK)
        self.key_eventbox.set_flags(gtk.HAS_FOCUS | gtk.CAN_FOCUS)
        self.key_eventbox.modify_bg(gtk.STATE_NORMAL,
            self.key_eventbox.get_colormap().alloc_color('red'))
        self.key_eventbox.add(page3)
        self.notebook.append_page(self.key_eventbox)

        self.key_eventbox.connect('button-press-event', self.save_temp_key_clicked)
        self.key_eventbox.connect('key-press-event', self.key_entry_modify)

        self.pack_start(self.main_vbox)
        self.show_all()
        self.main_gui.add_page(self)

        self.keymanagement.register_ui(self)
示例#2
0
    def __init__(self, gui, community_gui, user):
        """User_Page class is for showing user's profile information
        defined in the Edit Profile dialog and for showing user's
        communities.

        update_user_page() have to be called after user's profile
        is changed or after user's communities are changed so that
        new values are loaded into GUI"""

        GUI_Page.__init__(self, user.get('nick'))

        self.main_gui = gui
        self.community_gui = community_gui
        self.user = user

        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.state_plugin = get_plugin_by_type(PLUGIN_TYPE_STATE)

        self.notebook = gtk.Notebook()
        self.notebook.set_show_tabs(True)
        self.notebook.set_show_border(False)
        self.initialize_profile_page()
        self.initialize_user_action_page()
        self.initialize_communities_page()
        self.pack_start(self.notebook)

        self.show_all()
示例#3
0
    def __init__(self, community_gui, gui, com):
        GUI_Page.__init__(self, com.get('name'))

        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)

        self.item_double_clicking = None
        self.community_gui = community_gui
        self.main_gui = gui
        self.com = com

        self.list_view = community_gui.list_view_setting.value

        self.profile_widgets = {}

        # model (icon, item, text)
        self.itemlist = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT, str, str)
        self.update_members()

        self.pic_dialog = Picture_Choose_Dialog(gui, self.got_picture)

        self.notebook = gtk.Notebook()
        self.notebook.set_show_tabs(True)
        self.notebook.set_show_border(False)
        self.initialize_members_page()
        self.initialize_profile_page()
        self.initialize_modify_page()
        self.pack_start(self.notebook)
示例#4
0
    def __init__(self, fs_gui, title):
        GUI_Page.__init__(self, title)
        self.fs_gui = fs_gui
        self.target = None
        self.is_community = False
        self.items = 0

        self.vbox = gtk.VBox()
        self.pack_start(self.vbox)

        self.folders = {}

        self.content_list = gtk.TreeStore(gobject.TYPE_PYOBJECT, str, gobject.TYPE_PYOBJECT, bool, gtk.gdk.Pixbuf, str, str, str, str, int)
        self.content_list.set_sort_column_id(self.COL_HOPS, gtk.SORT_ASCENDING)

        self.initialize_browse_list()
        self.initialize_action_list()

        self.title = gtk.Label("Content Browsing")
        self.vbox.pack_start(self.title, False, False)
        scrollwin = new_scrollarea()
        scrollwin.add_with_viewport(self.browse_list_view)
        self.vbox.pack_start(scrollwin, True, True)

        self.show_all()
        main_gui.add_page(self)
示例#5
0
    def __init__(self, fs_gui):
        GUI_Page.__init__(self, 'Publish content')
        self.fs_gui = fs_gui

        self.icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), \
                                                      "64px-publish_content_icon.png"))
    
        self.vbox = gtk.VBox()
        self.pack_start(self.vbox)

        self.folders = {}

        self.sharelist = gtk.TreeStore(gobject.TYPE_PYOBJECT, str, bool, gtk.gdk.Pixbuf, str, str)

        self.initialize_share_list()
        self.initialize_action_list()

        self.title = gtk.Label("Content Publishing")
        self.vbox.pack_start(self.title, False, False)
        scrollwin = new_scrollarea()
        scrollwin.add_with_viewport(self.sharelist_view)
        self.vbox.pack_start(scrollwin, True, True)

        self.show_all()
        main_gui.add_page(self)
示例#6
0
    def __init__(self, gui):
        global community, msgboard, chat

        GUI_Page.__init__(self, 'Messageboard')
        community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        chat = get_plugin_by_type(PLUGIN_TYPE_MESSAGING)
        msgboard = get_plugin_by_type(PLUGIN_TYPE_MESSAGE_BOARD)

        self.notify = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION).notify

        self.main_gui = gui

        # Store Message_Page instances, key = sharemeta of the message
        self.message_pages = {}

        messageboard_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.MSGBOARD_ICON))

        community.community_gui.register_user_event(messageboard_icon, 'Msg board', self.start_messageboard_cb)
        community.community_gui.register_com_event(messageboard_icon, 'Msg board', self.start_messageboard_cb)

        self.message_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.MESSAGE_ICON))

        self.in_search_mode = False
        self.store = None
        self.search_store = None
        self.target = None

        # create widgets here
        self.create_action_list()
        self.message_list, self.message_view = self.create_message_list()

        self.search_hbox = gtk.HBox()
        self.search_entry = new_entry('Enter search keywords')
        self.search_entry.connect('activate', self.search_activate_cb)
        self.search_close = gtk.Button(stock=gtk.STOCK_CLOSE)
        self.search_close.connect('clicked', self.search_close_cb)
        self.search_now = gtk.Button(stock=gtk.STOCK_FIND)
        self.search_now.connect('clicked', self.search_now_cb)
        self.search_hbox.pack_start(self.search_entry, True, True)
        self.search_hbox.pack_start(self.search_close, False, True)
        self.search_hbox.pack_start(self.search_now, False, True)

        self.vbox = gtk.VBox()
        self.vbox.pack_start(self.message_list, True, True)
        self.vbox.pack_start(self.search_hbox, False, True)

        self.pack_start(self.vbox, True, True)
        self.pack_start(self.actions.get_widget(), False, True)

        self.show_all()
        self.search_hbox.hide()
        gui.add_page(self)

        gui.add_key_binding(gtk.gdk.CONTROL_MASK, gtk.keysyms.m, self.key_pressed_ctrl_m)

        msgboard.register_ui(self)

        self.watch_dialog = Watches_GUI(self.main_gui, msgboard.get_state, msgboard.modify_state)
示例#7
0
    def __init__(self, gui):
        GUI_Page.__init__(self, 'Home')
        self.main_gui = gui

        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)

        # store User_Page instances key = user
        self.user_pages = {}

        # store Community_Page instances key = community
        self.com_pages = {}

        self.com_events = []
        self.user_events = []
        self.user_action_lists = []
        self.com_action_lists = []

        self.item_double_clicking = None

        self.initialize_menu()

        icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.COMMUNITY_ICON))
        self.com_events.append((icon, "Community", self.manage_community_cb))

        self.itemlist = gtk.ListStore(gtk.gdk.Pixbuf, gobject.TYPE_PYOBJECT, str)
        self.update_communities()

        self.initialize_item_list()
        self.action_list = Community_Action_List(self, self.get_selected)
        self.pack_start(self.action_list.get_widget(), False, True)

        self.show_all()
        gui.add_page(self)
        gui.show_page(self)

        myself = self.community.get_myself()

        page = My_User_Page(gui, myself)
        self.user_pages[myself] = page
        page.show_all()
        gui.add_page(page)

        status_icon_pic = get_status_icon(myself.get('status_icon'), STATUSBAR_ICON_SIZE)
        self.status_icon = gui.add_statusbar_icon(status_icon_pic, 'Change status', self.status_icon_clicked)

        settings = get_plugin_by_type(PLUGIN_TYPE_SETTINGS)
        self.list_view_setting = settings.register('community.list_view', bool, 'Display community members as a list', default=False)

        self.community.register_ui(self)
示例#8
0
class Radar_Plugin(Plugin):
    def __init__(self, main_gui):
        self.register_plugin(PLUGIN_TYPE_RADAR)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.myself = self.community.get_myself()
        self.main_gui = main_gui

        self.page = GUI_Page('Radar')
        self.user_radar = UserRadar(main_gui)
        self.page.pack_start(self.user_radar)
        self.action_list = User_Action_List(self.community.community_gui,
            self.user_radar.get_selected)
        self.page.pack_start(self.action_list.get_widget(), False, True)
        self.page.show_all()
        self.main_gui.add_page(self.page)
    
        # Press 'r' to switch to radar view
        self.main_gui.add_key_binding(gtk.gdk.CONTROL_MASK, gtk.keysyms.r, self.key_pressed_r)

        self.radar_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR),
            'radar.png'))
        self.main_gui.add_statusbar_icon(self.radar_icon, 'Open radar',
            self.statusbar_icon_clicked)

    def key_pressed_r(self, target, ctx):
        self.run()

    def statusbar_icon_clicked(self):
        if self.page.is_visible:
            self.main_gui.hide_page(self.page)
        else:
            self.run()

    def run(self):
        # get the last opened community from the main gui
        open_community = self.community.get_default_community()
        for page in reversed(self.main_gui.page_history):
            com = page.get_community()
            if com != None:
                open_community = com
                break
        cname = open_community.get('name')
        debug('radar: Opening radar view for community %s\n' % cname)
        self.page.set_page_title(cname, sub=True)
        self.user_radar.set_community(open_community)
        self.main_gui.show_page(self.page)

    def user_appears(self, user):
        if user != self.myself and self.main_gui:
            self.user_radar.new_user(user)

    def user_changes(self, user, what=None):
        if user != self.myself and self.main_gui:
            self.user_radar.update_user(user, what)

    def user_disappears(self, user):
        if user != self.myself and self.main_gui:
            self.user_radar.remove_user(user)
示例#9
0
    def __init__(self, gui):
        GUI_Page.__init__(self, 'Settings')

        self.settings = get_plugin_by_type(PLUGIN_TYPE_SETTINGS)
        self.main_gui = gui

        self.vbox = gtk.VBox(False, 5)

        for s in self.settings.settings:
            self.add_setting(s)

        self.settings.new_setting_cb.append(self.add_setting)

        self.initialize_menu()

        self.pack_start(self.vbox)
        self.show_all()
        self.main_gui.add_page(self)
示例#10
0
    def __init__(self, fs_gui):
        GUI_Page.__init__(self, 'Search content')
        self.fs_gui = fs_gui
        self.target = None
        self.is_community = False

        self.vbox = gtk.VBox()
        self.pack_start(self.vbox)

        self.entries = {}
        self.initialize_search_window()
        self.initialize_action_list()
        
        self.title = gtk.Label('Search Content')
        self.vbox.pack_start(self.title, False, False)
        self.vbox.pack_start(gtk.HSeparator(), False, False)
        self.vbox.pack_start(self.search_fwindow, True, True)

        self.show_all()
        main_gui.add_page(self)
示例#11
0
    def __init__(self, gui, user):
        """User_Page class is for showing user's profile information
        defined in the Edit Profile dialog and for showing user's
        communities.

        update_user_page() have to be called after user's profile
        is changed or after user's communities are changed so that
        new values are loaded into GUI"""

        GUI_Page.__init__(self, 'My profile')
        # references to gui components which text or other
        # attribute will be modified if user's profile changes
        self.profile_widgets = {}

        self.main_gui = gui
        self.user = user

        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)

        self.initialize_profile_page_widgets()

        self.pic_dialog = Picture_Choose_Dialog(self.main_gui, self.got_picture)
示例#12
0
    def __init__(self, main_gui, getstatecb, modifycb):
        self.main_gui = main_gui

        self.modifycb = modifycb
        self.getstatecb = getstatecb

        self.guistate = 0

        self.page = GUI_Page('Watches')

        # self.watch_list stores columns: possible picture, keyword, target
        self.watch_list = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
        self.update()

        self.watch_view = gtk.TreeView(self.watch_list)
        self.pic_cell = gtk.CellRendererPixbuf()
        self.name_cell = gtk.CellRendererText()
        self.target_cell = gtk.CellRendererText()
        self.pic_column = self.watch_view.insert_column_with_attributes(
            self.COL_ICON, '', self.pic_cell, pixbuf=self.COL_ICON)
        self.name_column = self.watch_view.insert_column_with_attributes(
            self.COL_NAME, '', self.name_cell, text=self.COL_NAME)
        self.target_column = self.watch_view.insert_column_with_attributes(
            self.COL_TARGET, '', self.target_cell, text=self.COL_TARGET)
        self.page.pack_start(self.watch_view, True, True)

        add_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), "64px-add_content_icon.png"))
        remove_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), "64px-remove_content_icon.png"))

        action_buttons = [(add_icon, 'Add', self.add_clicked),
                          (remove_icon, 'Remove', self.remove_clicked)
                         ]

        self.actions = Action_List()

        for action in action_buttons:
            (icon, text, cb) = action
            self.actions.add_button(icon, text, cb)

        self.page.pack_start(self.actions.get_widget(), False, True)

        self.main_gui.add_page(self.page)
示例#13
0
    def __init__(self, main_gui):
        self.register_plugin(PLUGIN_TYPE_RADAR)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.myself = self.community.get_myself()
        self.main_gui = main_gui

        self.page = GUI_Page('Radar')
        self.user_radar = UserRadar(main_gui)
        self.page.pack_start(self.user_radar)
        self.action_list = User_Action_List(self.community.community_gui,
            self.user_radar.get_selected)
        self.page.pack_start(self.action_list.get_widget(), False, True)
        self.page.show_all()
        self.main_gui.add_page(self.page)
    
        # Press 'r' to switch to radar view
        self.main_gui.add_key_binding(gtk.gdk.CONTROL_MASK, gtk.keysyms.r, self.key_pressed_r)

        self.radar_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR),
            'radar.png'))
        self.main_gui.add_statusbar_icon(self.radar_icon, 'Open radar',
            self.statusbar_icon_clicked)
示例#14
0
class Watches_GUI:

    # list store columns
    COL_ICON = 0
    COL_NAME = 1
    COL_TARGET = 2

    def __init__(self, main_gui, getstatecb, modifycb):
        self.main_gui = main_gui

        self.modifycb = modifycb
        self.getstatecb = getstatecb

        self.guistate = 0

        self.page = GUI_Page('Watches')

        # self.watch_list stores columns: possible picture, keyword, target
        self.watch_list = gtk.ListStore(gtk.gdk.Pixbuf, str, str)
        self.update()

        self.watch_view = gtk.TreeView(self.watch_list)
        self.pic_cell = gtk.CellRendererPixbuf()
        self.name_cell = gtk.CellRendererText()
        self.target_cell = gtk.CellRendererText()
        self.pic_column = self.watch_view.insert_column_with_attributes(
            self.COL_ICON, '', self.pic_cell, pixbuf=self.COL_ICON)
        self.name_column = self.watch_view.insert_column_with_attributes(
            self.COL_NAME, '', self.name_cell, text=self.COL_NAME)
        self.target_column = self.watch_view.insert_column_with_attributes(
            self.COL_TARGET, '', self.target_cell, text=self.COL_TARGET)
        self.page.pack_start(self.watch_view, True, True)

        add_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), "64px-add_content_icon.png"))
        remove_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), "64px-remove_content_icon.png"))

        action_buttons = [(add_icon, 'Add', self.add_clicked),
                          (remove_icon, 'Remove', self.remove_clicked)
                         ]

        self.actions = Action_List()

        for action in action_buttons:
            (icon, text, cb) = action
            self.actions.add_button(icon, text, cb)

        self.page.pack_start(self.actions.get_widget(), False, True)

        self.main_gui.add_page(self.page)

    def show(self):
        self.page.show_all()
        self.main_gui.show_page(self.page)

    def add_clicked(self, widget):
        if self.guistate != 0:
            return
        self.guistate = 1
        Input_Dialog(self.main_gui.main_window, 'Add watch', 'Please give a keyword:', self.watch_added)

    def remove_clicked(self, widget):
        if self.guistate != 0:
            return
        selection = self.watch_view.get_selection()
        if selection == None:
            return
        model, selected = selection.get_selected()
        if selected != None:
            keyword = model[selected][1]
            self.modifycb(False, keyword)
        self.update()

    def update(self):
        self.watch_list.clear()
        for keyword in self.getstatecb():
            self.watch_list.append([None, keyword, ''])

    def watch_added(self, keyword, ctx=None):
        self.guistate = 0
        if keyword:
            self.modifycb(True, keyword)
        self.update()
示例#15
0
    def __init__(self, gui, msg):

        self.gui = gui
        self.main_gui = gui.main_gui
        self.msg = msg

        self.user = None
        uid = msg.get('src')
        if uid != None:
            self.user = community.get_user(uid)

        if self.user == community.get_myself():
            sender = 'Myself'
        elif self.user != None:
            sender = self.user.tag()
        else:
            sender = msg.get('from')

        subject = msg.get('subject')
        title = 'Message from %s: %s' % (sender, subject)
        GUI_Page.__init__(self, title)

        self.vbox = gtk.VBox()

        self.top_hbox = gtk.HBox(False, 10)

        if self.user != None:
            self.profile_image = gtk.Image()
            self.profile_image.set_size_request(64+5, 64+5)
            icon = get_user_profile_picture(self.user).scale_simple(64, 64, gtk.gdk.INTERP_BILINEAR)
            self.profile_image.set_from_pixbuf(icon)
            eventbox = gtk.EventBox()
            eventbox.connect("button-press-event", self.image_clicked)
            eventbox.add(self.profile_image)
            self.top_hbox.pack_start(eventbox, False, True)

        self.info_widgets = {}

        info_vbox = gtk.VBox()

        label = gtk.Label()
        label.set_markup('<b>From:</b>')
        label.set_size_request(100, -1)
        label.set_alignment(1, 0)
        widget = gtk.Label()
        widget.set_markup('<span color="#ff0000"><u>%s</u></span>' % pango_escape(sender))
        widget.set_alignment(0, 0)
        eventbox = gtk.EventBox()
        eventbox.connect("button-press-event", self.image_clicked)
        eventbox.add(widget)

        hbox = gtk.HBox(False, 5)
        hbox.pack_start(label, False, False)
        hbox.pack_start(eventbox, True, True)
        info_vbox.pack_start(hbox, False, True)

        for name in ('subject', 'date'):
            label = gtk.Label()
            label.set_markup('<b>%s:</b>' % name.title())
            label.set_size_request(100, -1)
            label.set_alignment(1, 0)
            if name == 'date':
                value = msgtime(msg)
            else:
                value = msg.get(name)
            widget = gtk.Label(value)
            widget.set_alignment(0, 0)

            hbox = gtk.HBox(False, 5)
            hbox.pack_start(label, False, False)
            hbox.pack_start(widget, True, True)
            info_vbox.pack_start(hbox, False, False)

            self.info_widgets[name] = widget

        self.edit_button = gtk.Button(label='Edit', stock=gtk.STOCK_EDIT)
        self.edit_button.connect('clicked', self.edit_cb)

        self.delete_button = gtk.Button(label='Delete', stock=gtk.STOCK_DELETE)
        self.delete_button.connect('clicked', self.delete_cb)

        self.top_hbox.pack_start(info_vbox, True, True)
        self.top_hbox.pack_start(self.edit_button, False, False)
        self.top_hbox.pack_start(self.delete_button, False, False)

        # Message textview
        message_scrollarea = new_scrollarea()
        self.messagebuffer = gtk.TextBuffer()
        self.messageview = new_textview()
        self.messageview.set_buffer(self.messagebuffer)
        self.messageview.set_wrap_mode(gtk.WRAP_WORD)
        self.messageview.set_editable(False)
        self.messageview.set_cursor_visible(False)
        message_scrollarea.add(self.messageview)

        self.vbox.pack_start(self.top_hbox, expand=False, fill=True)
        self.vbox.pack_start(message_scrollarea, expand=True, fill=True)
        self.pack_start(self.vbox)

        self.urltag = self.messagebuffer.create_tag()
        self.urltag.set_property('foreground', '#0000ff')
        self.urltag.set_property('underline', pango.UNDERLINE_SINGLE)
        self.urltag.connect('event', self.urltag_event_cb)

        self.load_message()

        self.show_all()
        self.main_gui.add_page(self)
示例#16
0
    def __init__(self, gui):
        GUI_Page.__init__(self, 'Notifications')
        self.main_gui = gui
        self.queue = []
        self.queue_highpri = []
        self.atbottom = True
        self.notification_plugin = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)

        self.dialog = gtk.Dialog('Proximate', gui.get_main_window(), gtk.DIALOG_DESTROY_WITH_PARENT)
        self.dialog.add_events(gtk.gdk.BUTTON_PRESS_MASK)
        self.dialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
        self.dialog.set_default_size(200, 150)
        self.dialog.set_has_separator(False)
        self.text = gtk.Label()
        self.text.set_line_wrap(True)
        self.dialog.vbox.pack_start(self.text)
        self.dialog.connect('button-press-event', self.dialog_clicked)
        self.dialog.connect('delete-event', self.dialog_deleted)
        self.dialog.connect('response', self.response_handler)

        self.notebook = gtk.Notebook()
        self.events_label = gtk.Label('Events')
        self.notifications_label = gtk.Label('Notifications')

        # The other notification log display
        # store = (icon, message, callback, ctx, apply_icon, cancel_icon)
        self.notification_list = gtk.ListStore(gtk.gdk.Pixbuf, str, object, object, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf)

        self.notification_view = gtk.TreeView(self.notification_list)
        self.notification_view.set_headers_visible(False)
        self.notification_view.connect('row-activated', self.notification_row_activated_cb)

        cr_icon = gtk.CellRendererPixbuf()
        cr_msg = gtk.CellRendererText()
        cr_apply_icon = gtk.CellRendererPixbuf()
        cr_cancel_icon = gtk.CellRendererPixbuf()

        column = gtk.TreeViewColumn('')
        column.pack_start(cr_icon, False)
        column.pack_start(cr_msg)
        column.add_attribute(cr_icon, 'pixbuf', self.COL_ICON)
        column.add_attribute(cr_msg, 'text', self.COL_MSG)
        column.set_expand(True)
        self.notification_view.append_column(column)

        self.apply_column = gtk.TreeViewColumn('')
        self.apply_column.pack_start(cr_apply_icon, False)
        self.apply_column.add_attribute(cr_apply_icon, 'pixbuf', self.COL_APPLY)
        self.notification_view.append_column(self.apply_column)

        self.cancel_column = gtk.TreeViewColumn('')
        self.cancel_column.pack_start(cr_cancel_icon, False)
        self.cancel_column.add_attribute(cr_cancel_icon, 'pixbuf', self.COL_CANCEL)
        self.notification_view.append_column(self.cancel_column)

        scrollwin = new_scrollarea()
        scrollwin.add(self.notification_view)
        self.notebook.append_page(scrollwin, self.notifications_label)

        # Event log display
        self.event_list = gtk.ListStore(gtk.gdk.Pixbuf, str, object, object)

        self.event_view = gtk.TreeView(self.event_list)
        self.event_view.set_headers_visible(False)
        self.event_view.connect('row-activated', self.event_row_activated_cb)

        cell_pic = gtk.CellRendererPixbuf()
        cell_msg = gtk.CellRendererText()

        column = gtk.TreeViewColumn('')
        column.pack_start(cell_pic, False)
        column.pack_start(cell_msg)
        column.add_attribute(cell_pic, 'pixbuf', self.COL_ICON)
        self.event_view.append_column(column)

        column.add_attribute(cell_msg, 'text', self.COL_MSG)
        scrollwin = new_scrollarea()
        scrollwin.add(self.event_view)
        scrollwin.get_vadjustment().connect('value-changed', self.event_view_scrolled)
        self.notebook.append_page(scrollwin, self.events_label)

        style = self.notification_view.get_style()
        apply_iconset = style.lookup_icon_set(gtk.STOCK_APPLY)
        self.apply_icon = apply_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)
        cancel_iconset = style.lookup_icon_set(gtk.STOCK_CANCEL)
        self.cancel_icon = cancel_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)

        self.connect('expose-event', self.exposed)

        self.pack_start(self.notebook)

        gui.add_page(self)
        self.show_all()

        self.active_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.ICON))
        self.inactive_icon = self.active_icon.copy()
        self.active_icon.saturate_and_pixelate(self.inactive_icon, 0.0, False)
        self.information_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.INFORMATION))
        self.important_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.IMPORTANT))

        self.statusbar_icon = gui.add_statusbar_icon(self.inactive_icon, 'Notifications', self.statusbar_icon_clicked)

        self.notification_plugin.register_ui(self)
示例#17
0
    def __init__(self, gui):
        self.register_plugin(PLUGIN_TYPE_FILE_TRANSFER)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.filesharing = get_plugin_by_type(PLUGIN_TYPE_FILE_SHARING)

        self.main_gui = gui
        self.ft_statusbar_icon = gtk.gdk.pixbuf_new_from_file_at_size(
            join(get_dir(ICON_DIR), self.STATUSBAR_ICON), STATUSBAR_ICON_SIZE, STATUSBAR_ICON_SIZE
        )
        self.ft_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.STATUSBAR_ICON))

        self.statusbar_icon = None

        self.page = GUI_Page("File transfers")
        self.main_vbox = gtk.VBox()

        # Top row
        top_hbox = gtk.HBox()
        headline = gtk.Label("File Transfers")
        close_eb = gtk.EventBox()
        close_img = gtk.Image()
        close_eb.add(close_img)
        close_img.set_from_file(join(get_dir(ICON_DIR), self.CLOSE_ICON))
        top_hbox.pack_start(headline)
        top_hbox.pack_end(close_eb, expand=False)
        self.main_vbox.pack_start(top_hbox, False, False)

        # store = (icon, message, transfer, delete_icon)
        self.transfer_list = gtk.ListStore(gtk.gdk.Pixbuf, str, int, object, gtk.gdk.Pixbuf)

        cr_icon = gtk.CellRendererPixbuf()
        cr_msg = gtk.CellRendererText()
        cr_prog = ProgressCellRenderer()
        cr_delete_icon = gtk.CellRendererPixbuf()

        self.transfer_view = gtk.TreeView(self.transfer_list)
        self.transfer_view.set_headers_visible(False)
        self.transfer_view.connect("row-activated", self.row_activated_cb)

        column = gtk.TreeViewColumn("")
        column.pack_start(cr_icon, False)
        column.pack_start(cr_msg)
        column.add_attribute(cr_icon, "pixbuf", self.COL_ICON)
        column.add_attribute(cr_msg, "text", self.COL_MSG)
        column.set_expand(True)
        self.transfer_view.append_column(column)

        column = gtk.TreeViewColumn("")
        column.pack_start(cr_prog)
        column.add_attribute(cr_prog, "percent", self.COL_PROG)
        self.transfer_view.append_column(column)

        self.delete_column = gtk.TreeViewColumn("")
        self.delete_column.pack_start(cr_delete_icon, False)
        self.delete_column.add_attribute(cr_delete_icon, "pixbuf", self.COL_DELETE)
        self.transfer_view.append_column(self.delete_column)

        scrollwin = new_scrollarea()
        scrollwin.add(self.transfer_view)
        self.main_vbox.pack_start(scrollwin, True, True)

        style = self.transfer_view.get_style()
        abort_iconset = style.lookup_icon_set(gtk.STOCK_CLOSE)
        self.abort_icon = abort_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)
        delete_iconset = style.lookup_icon_set(gtk.STOCK_DELETE)
        self.delete_icon = delete_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)

        self.statusLabel = gtk.Label("")
        self.statusLabel.set_padding(3, 3)
        self.abort_all = gtk.Button("Abort all")
        self.delete_all = gtk.Button("Delete all")
        self.open_dldir = gtk.Button("Open download directory")

        status_hbox = gtk.HBox()
        status_hbox.set_size_request(-1, 50)
        status_hbox.pack_start(self.statusLabel, True, True)
        status_hbox.pack_start(self.open_dldir, False, False, padding=5)
        status_hbox.pack_start(self.delete_all, False, False, padding=5)
        status_hbox.pack_start(self.abort_all, False, False, padding=5)
        self.main_vbox.pack_start(status_hbox, False, False)

        # callbacks
        self.delete_all.connect("clicked", self.delete_all_cb)
        self.abort_all.connect("clicked", self.abort_all_cb)
        self.open_dldir.connect("clicked", self.open_dldir_cb)
        close_eb.connect("button-press-event", self.close_cb)

        self.page.pack_start(self.main_vbox)
        self.page.show_all()
        self.main_gui.add_page(self.page)
示例#18
0
    def __init__(self, gui):
        GUI_Page.__init__(self, 'Messaging')
        self.main_gui = gui
        self.toggle_dialog = None
        self.statusbar_icon = None
        self.atbottom = True

        self.active_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.STATUSBAR_ICON))
        self.inactive_icon = self.active_icon.copy()
        self.active_icon.saturate_and_pixelate(self.inactive_icon, 0.0, False)

        # GUI stores liststores and buttos as (store, button) tuples indexed
        # by Conversation
        self.gui_storebutton = {}

        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.messaging = get_plugin_by_type(PLUGIN_TYPE_MESSAGING)
        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)

        # the currently active conversation
        self.active_conversation = None

        messaging_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.MESSAGING_ICON))

        self.community.community_gui.register_user_event(messaging_icon, 'Chat', self.start_messaging_cb)
        self.community.community_gui.register_com_event(messaging_icon, 'Chat', self.start_messaging_cb)

        self.right_vbox = gtk.VBox()
        self.left_vbox = gtk.VBox()
        vseparator = gtk.VSeparator()
        self.pack_start(self.left_vbox, False, True)
        self.pack_start(vseparator, False, False)
        self.pack_start(self.right_vbox, True, True)
        self.top_hbox = gtk.HBox()
        separator1 = gtk.HSeparator()
        scrollwin = new_scrollarea()
        separator2 = gtk.HSeparator()
        self.bottom_hbox = gtk.HBox()

        # adding top level
        self.right_vbox.pack_start(self.top_hbox, expand = False)
        self.right_vbox.pack_start(separator1, expand = False)
        self.right_vbox.pack_start(scrollwin)
        self.right_vbox.pack_end(self.bottom_hbox, expand = False)
        self.right_vbox.pack_end(separator2, expand = False)

        # creatind the top row
        self.headline = gtk.Label()
        self.end_chat_eb = gtk.EventBox()
        self.end_chat_img = gtk.Image()

        # setting up the button icons in the top row
        self.end_chat_eb.add(self.end_chat_img)
        self.end_chat_img.set_from_file(join(get_dir(ICON_DIR), self.END_CHAT_ICON))

        # forming the top row
        self.top_hbox.pack_start(self.headline)
        self.top_hbox.pack_end(self.end_chat_eb, expand = False)

        # creating the chat area
        cr_icon = gtk.CellRendererPixbuf()
        self.chat_tw = gtk.TreeView()
        self.chat_tw_cr1 = gtk.CellRendererText()
        self.chat_tw_cr2 = gtk.CellRendererText()
        self.chat_tw_cr3 = gtk.CellRendererText()

        column = gtk.TreeViewColumn('Time')
        column.pack_start(cr_icon)
        column.pack_start(self.chat_tw_cr1)
        column.add_attribute(cr_icon, "pixbuf", self.COL_ICON)
        column.add_attribute(self.chat_tw_cr1, "text", self.COL_TIME)
        self.chat_tw.append_column(column)

        self.nick_column = gtk.TreeViewColumn('Nick')
        self.nick_column.pack_start(self.chat_tw_cr2)
        self.nick_column.add_attribute(self.chat_tw_cr2, "text", self.COL_NICK)
        self.chat_tw.append_column(self.nick_column)

        column = gtk.TreeViewColumn('Message')
        column.pack_start(self.chat_tw_cr3)
        column.add_attribute(self.chat_tw_cr3, "text", self.COL_MESSAGE)
        self.chat_tw.append_column(column)

        # to keep the fields aligned to the top of each row
        self.chat_tw_cr1.set_property('yalign', 0.0)
        self.chat_tw_cr2.set_property('yalign', 0.0)
        self.chat_tw_cr3.set_property('yalign', 0.0)

        self.chat_tw_cr3.set_property('wrap-mode', pango.WRAP_WORD_CHAR)
        self.chat_tw.set_property('enable-search', False)
        self.chat_tw.set_property('headers-visible', False)
        self.chat_tw.connect('size-allocate', self.resized)
        self.chat_tw.connect('row-activated', self.chat_row_activated_cb)

        scrollwin.add(self.chat_tw)
        scrollwin.get_vadjustment().connect('value-changed', self.chat_tw_scrolled)

        # creating the left area for chat tabs
        self.left_vbox.set_size_request(200, -1)
        chatlist_label = gtk.Label('Active chats')
        self.left_vbox.pack_start(chatlist_label, False, True)
        self.chatlist_scroll = new_scrollarea()
        self.left_vbox.pack_start(self.chatlist_scroll, True, True)
        self.chatlist = gtk.VBox()
        self.chatlist.set_size_request(200-2, -1)
        self.chatlist_scroll.add_with_viewport(self.chatlist)

        # creating the bottom area
        self.entry = gtk.Entry()
        self.bottom_hbox.pack_start(self.entry)

        self.show_all()
        gui.add_page(self)

        style = self.headline.get_style()
        self.normal_text_color = style.fg[gtk.STATE_NORMAL].copy()

        self.warning_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.WARNING_ICON))

        # callbacks:
        # connecting press of enter to sending message
        self.entry.connect('activate', self.entry_activate_cb)
        self.end_chat_eb.connect('button-press-event', self.close_active_conversation_cb)

        # monitor chat page visibility
        self.connect('expose-event', self.exposed)

        self.messaging.register_ui(self)
示例#19
0
class File_Transfer_Plugin(Plugin):
    """FileTransferGui forms a window for active file transfers.
    Construct it from the main gui when the first transfer starts
    and destroy it when they're all done.

    """

    STATUSBAR_ICON = "transfer_status_icon.png"
    CLOSE_ICON = "48px-messaging_close.png"

    COL_ICON = 0
    COL_MSG = 1
    COL_PROG = 2
    COL_TRANSFER = 3
    COL_DELETE = 4

    def __init__(self, gui):
        self.register_plugin(PLUGIN_TYPE_FILE_TRANSFER)
        self.community = get_plugin_by_type(PLUGIN_TYPE_COMMUNITY)
        self.notification = get_plugin_by_type(PLUGIN_TYPE_NOTIFICATION)
        self.filesharing = get_plugin_by_type(PLUGIN_TYPE_FILE_SHARING)

        self.main_gui = gui
        self.ft_statusbar_icon = gtk.gdk.pixbuf_new_from_file_at_size(
            join(get_dir(ICON_DIR), self.STATUSBAR_ICON), STATUSBAR_ICON_SIZE, STATUSBAR_ICON_SIZE
        )
        self.ft_icon = gtk.gdk.pixbuf_new_from_file(join(get_dir(ICON_DIR), self.STATUSBAR_ICON))

        self.statusbar_icon = None

        self.page = GUI_Page("File transfers")
        self.main_vbox = gtk.VBox()

        # Top row
        top_hbox = gtk.HBox()
        headline = gtk.Label("File Transfers")
        close_eb = gtk.EventBox()
        close_img = gtk.Image()
        close_eb.add(close_img)
        close_img.set_from_file(join(get_dir(ICON_DIR), self.CLOSE_ICON))
        top_hbox.pack_start(headline)
        top_hbox.pack_end(close_eb, expand=False)
        self.main_vbox.pack_start(top_hbox, False, False)

        # store = (icon, message, transfer, delete_icon)
        self.transfer_list = gtk.ListStore(gtk.gdk.Pixbuf, str, int, object, gtk.gdk.Pixbuf)

        cr_icon = gtk.CellRendererPixbuf()
        cr_msg = gtk.CellRendererText()
        cr_prog = ProgressCellRenderer()
        cr_delete_icon = gtk.CellRendererPixbuf()

        self.transfer_view = gtk.TreeView(self.transfer_list)
        self.transfer_view.set_headers_visible(False)
        self.transfer_view.connect("row-activated", self.row_activated_cb)

        column = gtk.TreeViewColumn("")
        column.pack_start(cr_icon, False)
        column.pack_start(cr_msg)
        column.add_attribute(cr_icon, "pixbuf", self.COL_ICON)
        column.add_attribute(cr_msg, "text", self.COL_MSG)
        column.set_expand(True)
        self.transfer_view.append_column(column)

        column = gtk.TreeViewColumn("")
        column.pack_start(cr_prog)
        column.add_attribute(cr_prog, "percent", self.COL_PROG)
        self.transfer_view.append_column(column)

        self.delete_column = gtk.TreeViewColumn("")
        self.delete_column.pack_start(cr_delete_icon, False)
        self.delete_column.add_attribute(cr_delete_icon, "pixbuf", self.COL_DELETE)
        self.transfer_view.append_column(self.delete_column)

        scrollwin = new_scrollarea()
        scrollwin.add(self.transfer_view)
        self.main_vbox.pack_start(scrollwin, True, True)

        style = self.transfer_view.get_style()
        abort_iconset = style.lookup_icon_set(gtk.STOCK_CLOSE)
        self.abort_icon = abort_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)
        delete_iconset = style.lookup_icon_set(gtk.STOCK_DELETE)
        self.delete_icon = delete_iconset.render_icon(style, gtk.TEXT_DIR_NONE, gtk.STATE_NORMAL, gtk.ICON_SIZE_BUTTON)

        self.statusLabel = gtk.Label("")
        self.statusLabel.set_padding(3, 3)
        self.abort_all = gtk.Button("Abort all")
        self.delete_all = gtk.Button("Delete all")
        self.open_dldir = gtk.Button("Open download directory")

        status_hbox = gtk.HBox()
        status_hbox.set_size_request(-1, 50)
        status_hbox.pack_start(self.statusLabel, True, True)
        status_hbox.pack_start(self.open_dldir, False, False, padding=5)
        status_hbox.pack_start(self.delete_all, False, False, padding=5)
        status_hbox.pack_start(self.abort_all, False, False, padding=5)
        self.main_vbox.pack_start(status_hbox, False, False)

        # callbacks
        self.delete_all.connect("clicked", self.delete_all_cb)
        self.abort_all.connect("clicked", self.abort_all_cb)
        self.open_dldir.connect("clicked", self.open_dldir_cb)
        close_eb.connect("button-press-event", self.close_cb)

        self.page.pack_start(self.main_vbox)
        self.page.show_all()
        self.main_gui.add_page(self.page)

    def row_activated_cb(self, treeview, path, view_column):
        row = self.transfer_list[path]

        transfer = row[self.COL_TRANSFER]

        if view_column == self.delete_column:
            transfer.clicked()

    def abort_all_cb(self, widget, data=None):
        for row in self.transfer_list:
            transfer = row[self.COL_TRANSFER]
            transfer.abort()

    def delete_all_cb(self, widget, data=None):
        for row in self.transfer_list:
            transfer = row[self.COL_TRANSFER]
            transfer.delete()

    def open_dldir_cb(self, widget, data=None):
        open_with_file_manager(self.filesharing.get_download_path())

    def close_cb(self, widget, event):
        if self.page.is_visible:
            self.main_gui.hide_page(self.page)

        if self.statusbar_icon != None:
            self.main_gui.remove_statusbar_icon(self.statusbar_icon)
            self.statusbar_icon = None
        return True

    def open_filetransfergui(self):
        if self.statusbar_icon == None:
            self.statusbar_icon = self.main_gui.add_statusbar_icon(
                self.ft_statusbar_icon, "File Transfers", self.statusbar_icon_clicked
            )

    def statusbar_icon_clicked(self):
        if self.page.is_visible:
            self.main_gui.hide_page(self.page)
        else:
            self.main_gui.show_page(self.page)

    def add_transfer(self, title, size, abort_cb, ctx=None, silent=False):
        self.open_filetransfergui()

        title = cut_text(title, MAX_TITLE)

        # popping up the transfer notification window, that returns
        # a handel to a function advancing its progressbar
        dialog = None
        if not silent:
            dialog = Transfer_Dialog(self.main_gui.get_main_window(), title, abort_cb, ctx)

        transfer = Transfer_Item(self, title, size, abort_cb, ctx, dialog)
        riter = self.transfer_list.append([self.ft_icon, title, 0, transfer, self.abort_icon])
        transfer.iter = riter

        return transfer