コード例 #1
0
ファイル: chat_window.py プロジェクト: 19MiRkO91/amsn2
    def __on_chat_send(self, entry, event_keyval, event_keymod):
        if (event_keyval == gtk.keysyms.Return):
            buffer = entry.get_buffer()
            start, end = buffer.get_bounds()
            msg = buffer.get_text(start, end)
            entry.clear()
            entry.grab_focus()
            if (msg == ''): return False

            color = self.button_color.get_color()
            hex8 = "%.2x%.2x%.2x" % ((color.red/0x101), (color.green/0x101), (color.blue/0x101))
            style = papyon.TextFormat.NO_EFFECT
            if self.button_bold.get_active(): style |= papyon.TextFormat.BOLD
            if self.button_italic.get_active():  style |= papyon.TextFormat.ITALIC
            if self.button_underline.get_active(): style |= papyon.TextFormat.UNDERLINE
            if self.button_strikethrough.get_active(): style |= papyon.TextFormat.STRIKETHROUGH
            font_name = self.button_font.get_font_name()
            font_family = pango.FontDescription(font_name).get_family()
            format = papyon.TextFormat(font=font_family, color=hex8, style=style)
            strv = StringView()
            strv.append_text(msg)
            self._amsn_conversation.send_message(strv, format)

        elif event_keyval == gtk.keysyms.Escape:
            self._parent.destroy()
コード例 #2
0
    def __on_chat_send(self, entry, event_keyval, event_keymod):
        if (event_keyval == gtk.keysyms.Return):
            buffer = entry.get_buffer()
            start, end = buffer.get_bounds()
            msg = buffer.get_text(start, end)
            entry.clear()
            entry.grab_focus()
            if (msg == ''): return False

            color = self.button_color.get_color()
            hex8 = "%.2x%.2x%.2x" % ((color.red / 0x101),
                                     (color.green / 0x101),
                                     (color.blue / 0x101))
            style = papyon.TextFormat.NO_EFFECT
            if self.button_bold.get_active(): style |= papyon.TextFormat.BOLD
            if self.button_italic.get_active():
                style |= papyon.TextFormat.ITALIC
            if self.button_underline.get_active():
                style |= papyon.TextFormat.UNDERLINE
            if self.button_strikethrough.get_active():
                style |= papyon.TextFormat.STRIKETHROUGH
            font_name = self.button_font.get_font_name()
            font_family = pango.FontDescription(font_name).get_family()
            format = papyon.TextFormat(font=font_family,
                                       color=hex8,
                                       style=style)
            strv = StringView()
            strv.append_text(msg)
            self._amsn_conversation.send_message(strv, format)

        elif event_keyval == gtk.keysyms.Escape:
            self._parent.destroy()
コード例 #3
0
ファイル: contact_list.py プロジェクト: PappBence/amsn2
    def group_updated(self, group):
        if (group.uid == 0): group.uid = '0'
        if group.uid not in self.groups: return

        gitem = self.__search_by_id(group.uid)
        self._model.item(self._model.indexFromItem(gitem).row(),
                         3).setData(QtCore.QVariant(group), QtCore.Qt.DisplayRole)
        gname = StringView()
        gname = group.name
        self._model.item((self._model.indexFromItem(gitem)).row(),
                         0).setText('<b>'+QtCore.QString.fromUtf8(gname.to_HTML_string())+'</b>')

        try:
            cuids = self.contacts[group.uid]
        except:
            cuids = []
        self.contacts[group.uid] = group.contact_ids.copy()

        for cid in group.contact_ids:
            if cid not in cuids:
                gitem = self.__search_by_id(group.uid)
                gitem.appendRow([QtGui.QStandardItem(cid),
                                 QtGui.QStandardItem(cid),
                                 QtGui.QStandardItem("contact"),
                                 QtGui.QStandardItem()])

        # Remove unused contacts
        for cid in cuids:
            if cid not in self.contacts[group.uid]:
                citems = self.__search_by_id(cid)
                for citem in citems:
                    self._model.removeRow((self._model.indexFromItem(citem)).row())
コード例 #4
0
    def __switchFromInput(self, source, isNew):
        """ When in the editing state of nickname and psm, change back
        to the uneditable label state.
        """
        if (isNew):
            if source is self.btnNickname.get_child():
                newText = source.get_text()
                strv = StringView()
                strv.append_text(newText)
                self._myview.nick = str(strv)
            elif source is self.btnPsm.get_child():
                newText = source.get_text()
                strv = StringView()
                strv.append_text(newText)
                self._myview.psm = str(strv)
        else:
            if source is self.btnNickname.get_child():  # User discards input
                newText = self.nicklabel.get_text()  # Old nickname
            elif source is self.btnPsm.get_child():
                newText = self.psmlabel.get_text()

        parentWidget = source.get_parent()
        currWidget = parentWidget.get_child()
        currWidget.disconnect(
            self.focusOutId)  # Else we trigger focus-out-event; segfault.

        parentWidget.remove(currWidget)
        entry = gtk.Label()
        entry.set_markup(newText)

        parentWidget.add(entry)
        entry.show()
        parentWidget.set_relief(gtk.RELIEF_NONE)  # remove cool elevated effect
コード例 #5
0
    def __sendMsg(self, msg):
        bb = elementary.Bubble(self.parent)
        bb.label_set("TODO: MYSELF")
        bb.info_set("TODO: TIMESTAMP")
        #TODO: bb.icon_set()
        bb.size_hint_weight_set(evas.EVAS_HINT_EXPAND, 0.0)
        bb.size_hint_align_set(evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL)
        ab = elementary.AnchorBlock(self.parent)
        ab.text_set(msg)
        bb.content_set(ab)
        ab.show()
        self.outbx.pack_end(bb)
        bb.show()

        strv = StringView()
        strv.append_text(msg)
        self._amsn_conversation.send_message(strv)
コード例 #6
0
ファイル: contact_list.py プロジェクト: LordShadow/amsn2
    def __switchFromInput(self, source, isNew):
        """ When in the editing state of nickname and psm, change back
        to the uneditable label state.
        """
        if(isNew):
            if source is self.btnNickname.get_child():
                newText = source.get_text()
                strv = StringView()
                strv.appendText(newText)
                self._myview.nick = strv
            elif source is self.btnPsm.get_child():
                newText = source.get_text()
                strv = StringView()
                strv.appendText(newText)
                self._myview.psm = strv
        else:
            if source is self.btnNickname.get_child():  # User discards input
                newText = self.nicklabel.get_text()     # Old nickname
            elif source is self.btnPsm.get_child():
                newText = self.psmlabel.get_text()

        parentWidget    = source.get_parent()
        currWidget      = parentWidget.get_child()
        currWidget.disconnect(self.focusOutId)          # Else we trigger focus-out-event; segfault.

        parentWidget.remove(currWidget)
        entry = gtk.Label()
        entry.set_markup(newText)

        parentWidget.add(entry)
        entry.show()
        parentWidget.set_relief(gtk.RELIEF_NONE)        # remove cool elevated effect
コード例 #7
0
    def group_added(self, group):
        pi = self._model.invisibleRootItem()

        # Adding Group Item

        groupItem = QtGui.QStandardItem()
        gname = StringView()
        gname = group.name
        self._model.item(
            groupItem.row(),
            0).setText('<b>' + QtCore.QString.fromUtf8(gname.toHtmlString()) +
                       '</b>')
        self._model.item(groupItem.row(),
                         1).setText(QtCore.QString.fromUtf8(str(group.uid)))
        pi.appendRow(groupItem)

        for contact in group.contacts:
            contactItem = QtGui.QStandardItem()
            cname = StringView()
            cname = contact.name
            self._model.item(contactItem.row(), 0).setText(
                QtCore.QString.fromUtf8(cname.toHtmlString()))
            self._model.item(contactItem.row(), 1).setText(
                QtCore.QString.fromUtf8(str(contact.uid)))

            groupItem.appendRow(contactItem)

            self._contactDict[contact.uid] = contact
コード例 #8
0
ファイル: contact_list.py プロジェクト: LordShadow/amsn2
    def group_added(self, group):
        pi = self._model.invisibleRootItem()

        # Adding Group Item

        groupItem = QStandardItem()
        gname = StringView()
        gname = group.name
        self._model.item(groupItem.row(), 0).setText('<b>'+QString.fromUtf8(gname.toHtmlString())+'</b>')
        self._model.item(groupItem.row(), 1).setText(QString.fromUtf8(str(group.uid)))
        pi.appendRow(groupItem)

        for contact in group.contacts:
            contactItem = QStandardItem()
            cname = StringView()
            cname = contact.name
            self._model.item(contactItem.row(), 0).setText(QString.fromUtf8(cname.toHtmlString()))
            self._model.item(contactItem.row(), 1).setText(QString.fromUtf8(str(contact.uid)))

            groupItem.appendRow(contactItem)

            self._contactDict[contact.uid] = contact
コード例 #9
0
    def group_updated(self, group):
        if (group.uid == 0): group.uid = '0'
        if group.uid not in self.groups: return

        gitem = self.__search_by_id(group.uid)
        self._model.item(self._model.indexFromItem(gitem).row(),
                         3).setData(QtCore.QVariant(group),
                                    QtCore.Qt.DisplayRole)
        gname = StringView()
        gname = group.name
        self._model.item(
            (self._model.indexFromItem(gitem)).row(),
            0).setText('<b>' +
                       QtCore.QString.fromUtf8(gname.to_HTML_string()) +
                       '</b>')

        try:
            cuids = self.contacts[group.uid]
        except:
            cuids = []
        self.contacts[group.uid] = group.contact_ids.copy()

        for cid in group.contact_ids:
            if cid not in cuids:
                gitem = self.__search_by_id(group.uid)
                gitem.appendRow([
                    QtGui.QStandardItem(cid),
                    QtGui.QStandardItem(cid),
                    QtGui.QStandardItem("contact"),
                    QtGui.QStandardItem()
                ])

        # Remove unused contacts
        for cid in cuids:
            if cid not in self.contacts[group.uid]:
                citems = self.__search_by_id(cid)
                for citem in citems:
                    self._model.removeRow(
                        (self._model.indexFromItem(citem)).row())
コード例 #10
0
ファイル: chat_window.py プロジェクト: LordShadow/amsn2
    def __sendMessage(self):
        # TODO: Switch to this when implemented
        """ msg = self.ui.inputWidget.toHtml()
        self.ui.inputWidget.clear()
        strv = StringView()
        strv.appendElementsFromHtml(msg) """

        msg = QString.fromUtf8(self.ui.inputWidget.toPlainText())
        self.ui.inputWidget.clear()
        color = self.color
        hex8 = "%.2x%.2x%.2x" % ((color.red()), (color.green()), (color.blue()))
        style = papyon.TextFormat.NO_EFFECT
        info = QFontInfo(self.font)
        if info.bold(): style |= papyon.TextFormat.BOLD
        if info.italic():  style |= papyon.TextFormat.ITALIC
        if self.font.underline(): style |= papyon.TextFormat.UNDERLINE
        if self.font.strikeOut(): style |= papyon.TextFormat.STRIKETHROUGH
        font_family = str(info.family())
        format = papyon.TextFormat(font=font_family, color=hex8, style=style)
        strv = StringView()
        strv.append_text(str(msg))
        ## as we send our msg to the conversation:
        self._amsn_conversation.send_message(strv, format)
コード例 #11
0
    def __sendMessage(self):
        # TODO: Switch to this when implemented
        """ msg = self.ui.inputWidget.toHtml()
        self.ui.inputWidget.clear()
        strv = StringView()
        strv.appendElementsFromHtml(msg) """

        msg = QtCore.QString.fromUtf8(self.ui.inputWidget.toPlainText())
        self.ui.inputWidget.clear()
        color = self.color
        hex8 = "%.2x%.2x%.2x" % ((color.red()), (color.green()), (color.blue()))
        style = papyon.TextFormat.NO_EFFECT
        info = QtGui.QFontInfo(self.font)
        if info.bold(): style |= papyon.TextFormat.BOLD
        if info.italic():  style |= papyon.TextFormat.ITALIC
        if self.font.underline(): style |= papyon.TextFormat.UNDERLINE
        if self.font.strikeOut(): style |= papyon.TextFormat.STRIKETHROUGH
        font_family = str(info.family())
        format = papyon.TextFormat(font=font_family, color=hex8, style=style)
        strv = StringView()
        strv.append_text(str(msg))
        ## as we send our msg to the conversation:
        self._amsn_conversation.send_message(strv, format)
コード例 #12
0
    def contact_updated(self, contact):
        citems = self.__search_by_id(contact.uid)
        if citems is None: return

        dp = Image(self._parent._theme_manager, contact.dp)
        dp = dp.to_size(28, 28)
        #icon = Image(self._parent._theme_manager, contact.icon)

        for citem in citems:
            gitem = citem.parent()
            if gitem is None: continue

            gitem.child(self._model.indexFromItem(citem).row(),
                        0).setData(QtCore.QVariant(dp),
                                   QtCore.Qt.DecorationRole)
            #gitem.child(self._model.indexFromItem(citem).row(), 0).setData(QVariant(icon), Qt.DecorationRole)

            gitem.child(self._model.indexFromItem(citem).row(),
                        3).setData(QtCore.QVariant(contact),
                                   QtCore.Qt.DisplayRole)
            cname = StringView()
            cname = contact.name.to_HTML_string()
            gitem.child(self._model.indexFromItem(citem).row(),
                        0).setText(QtCore.QString.fromUtf8(cname))
コード例 #13
0
 def __psmChange(self):
     sv = StringView()
     sv.append_text(str(self.ui.statusMessage.toPlainText()))
     self._myview.psm = str(sv)
コード例 #14
0
ファイル: contact_list.py プロジェクト: LordShadow/amsn2
 def __nickChange(self):
     sv = StringView()
     sv.append_text(str(self.ui.nickName.toPlainText()))
     self._myview.nick = str(sv)
コード例 #15
0
ファイル: chat_window.py プロジェクト: 19MiRkO91/amsn2
 def send_message(self, uid, msg):
     if uid == self._uid:
         stmess = StringView()
         stmess.append_text('\n'.join(msg).decode('utf-8'))
         self._conversation.send_message(stmess)
     return True
コード例 #16
0
 def send_message(self, uid, msg):
     if uid == self._uid:
         stmess = StringView()
         stmess.append_text('\n'.join(msg).decode('utf-8'))
         self._conversation.send_message(stmess)
     return True
コード例 #17
0
ファイル: contact_list.py プロジェクト: LordShadow/amsn2
 def __psmChange(self):
     sv = StringView()
     sv.append_text(str(self.ui.statusMessage.toPlainText()))
     self._myview.psm = str(sv)
コード例 #18
0
 def __nickChange(self):
     sv = StringView()
     sv.append_text(str(self.ui.nickName.toPlainText()))
     self._myview.nick = str(sv)