Exemplo n.º 1
0
    def refresh_reply_cb (self, data=None):
        label = self.builder.get_object ("label_current_status")
        status = self.office.get_current_status ()
        if len (status) != 0:
            label.set_text (status['message'])
        user = self.office.get_current_user ()
        pic_square = self.builder.get_object ("image_pic_square")
        user_icon_path = self.office.get_user_icons_dir ()

        if len (user) != 0:
            pic_square.set_from_file (user_icon_path + '/' + user['pic_square_local'])
        else:
            img_file = pkg_resources.resource_filename \
                        (__name__, "data/images/q_silhouette.gif")
            pic_square.set_from_file (img_file)
            

        nlist = self.office.get_notification_list ()
        liststore = self.builder.get_object ("list_notification")
        liststore.clear ()
        has_unread = False
        for nid in nlist:
            entry = self.office.get_notification_entry (nid)
            text = None
            has_detail = False
            
            if entry['is_unread'] == True:
                has_unread = True

            if len (entry['body_text']) == 0:
                text = entry['title_text']
            else:
                text = entry['body_text']

            if int (entry['app_id']) == 19675640871:
                has_detail = True
            liststore.append \
                ([entry['app_id'], text, has_detail, int(entry['notification_id'])])

        if has_unread == True:
            self.emit ("has-unread")

        keys = [k for k in self.comments]
        for k in keys:
            self.comments[k].window.destroy ()
            del self.comments[k]

        utils.set_scollbar_height (self.window, self.treeview, self.scrolledwindow)
Exemplo n.º 2
0
    def __init__ (self, post_id):
        logging.basicConfig (level=defs.log_level)
        self.post_id = post_id
        self.builder = gtk.Builder ()

        ui_file = pkg_resources.resource_filename \
                    (__name__, "data/comment.ui")

        self.builder.add_from_file (ui_file)
        self.builder.connect_signals (self, None)
        self.window = self.builder.get_object ("comment_window")

        self.entry_comment = self.builder.get_object ("entry_comment")
        self.entry_comment.grab_focus ()

        bus = dbus.SessionBus ()
        obj = bus.get_object ("org.wallbox.PostOfficeService", \
            "/org/wallbox/PostOfficeObject")

        self.office = dbus.Interface \
            (obj, "org.wallbox.PostOfficeInterface")


        liststore = self.builder.get_object ("liststore_comment")
        clist = self.office.get_comments_list (post_id)
        for id in clist:
            comment = self.office.get_comment_entry (post_id, id)
            liststore.append \
                ([comment['text'], int (comment['time']), \
                str (comment['fromid'])])

        self.status = self.office.get_status (post_id)
        label_status = self.builder.get_object ("label_status")
        label_status.set_text (self.status['message'])
        label_status.set_size_request (STATUS_WIDTH, -1)

        user = self.office.get_user (self.status['source_id'])
        main_user_icon = self.builder.get_object ("main_pic")
        user_icons_dir = self.office.get_user_icons_dir ()

        if not user.has_key ("pic_square_local"):
            img_file = pkg_resources.resource_filename \
                        (__name__, "data/images/q_silhouette.gif")
        else:
            img_file = "%s/%s" % (user_icons_dir, user['pic_square_local'])

        main_user_icon.set_from_file (img_file)

        current_pic = self.builder.get_object ("current_user_pic")
        current_user = self.office.get_current_user ()
        icon_path = "%s/%s" % \
            (user_icons_dir, current_user['pic_square_local'])
        pixbuf = None
        try:
            pixbuf = gtk.image_new_from_file (icon_path).get_pixbuf ()
        except:
            logging.debug ("no icon: comment.py:59 [%s]" % icon_path)
            img_file = pkg_resources.resource_filename \
                        (__name__, "data/images/q_silhouette.gif")
            icon = gtk.image_new_from_file (img_file)
            pixbuf = icon.get_pixbuf ()
            
        scaled_buf = \
            pixbuf.scale_simple \
            (COMMENT_ICON_SIZE, COMMENT_ICON_SIZE, gtk.gdk.INTERP_BILINEAR)
        current_pic = current_pic.set_from_pixbuf (scaled_buf)
        self.user = user

        self.init_view ()

        utils.set_scollbar_height (self.window, self.treeview, self.builder.get_object ("scrolledwindow"))