Commit 20576605 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

start

parent 2ea9fc69
......@@ -843,11 +843,13 @@ def _nec_decrypted_message_received(self, obj):
typ = 'out'
if obj.jid != app.get_jid_from_account(obj.conn.name):
xep0184_id = obj.id_
self.print_conversation(obj.msgtxt, typ,
tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
xhtml=obj.xhtml, displaymarking=obj.displaymarking,
msg_log_id=obj.msg_log_id, msg_stanza_id=obj.id_, correct_id=obj.correct_id,
xep0184_id=xep0184_id, additional_data=obj.additional_data)
if obj.msg_log_id:
pw = self.parent_win
end = self.conv_textview.autoscroll
......@@ -1024,6 +1026,7 @@ def print_conversation(self, text, frm='', tim=None, encrypted=None,
msg_log_id=msg_log_id, msg_stanza_id=msg_stanza_id,
correct_id=correct_id, additional_data=additional_data,
encrypted=encrypted)
self.con_view.add_message(text)
if text.startswith('/me ') or text.startswith('/me\n'):
self.old_msg_kind = None
else:
......
......@@ -52,6 +52,7 @@
from gajim.message_textview import MessageTextView
from gajim.common.contacts import GC_Contact
from gajim.common.connection_handlers_events import MessageOutgoingEvent
from gajim.conversation_view import ConversationView
from gajim.command_system.implementation.middleware import ChatCommandProcessor
from gajim.command_system.implementation.middleware import CommandTools
......@@ -282,6 +283,7 @@ def __init__(self, type_id, parent_win, widget_name, contact, acct,
# Create textviews and connect signals
self.conv_textview = ConversationTextview(self.account)
self.con_view = ConversationView()
id_ = self.conv_textview.connect('quote', self.on_quote)
self.handlers[id_] = self.conv_textview.tv
id_ = self.conv_textview.tv.connect('key_press_event',
......@@ -302,7 +304,8 @@ def __init__(self, type_id, parent_win, widget_name, contact, acct,
self.conv_scrolledwindow = self.xml.get_object(
'conversation_scrolledwindow')
self.conv_scrolledwindow.add(self.conv_textview.tv)
# self.conv_scrolledwindow.add(self.conv_textview.tv)
self.conv_scrolledwindow.add(self.con_view)
widget = self.conv_scrolledwindow.get_vadjustment()
id_ = widget.connect('changed',
self.on_conversation_vadjustment_changed)
......
from gajim.gtkgui_helpers import get_gtk_builder
from gajim.conversation_textview2 import ConversationTextView
from gi.repository import Gtk
class Message(Gtk.ListBoxRow):
def __init__(self):
Gtk.ListBoxRow.__init__(self)
self._builder = get_gtk_builder('message.ui')
grid = self._builder.get_object('message_grid')
self.add(grid)
self.received_image = self._builder.get_object('received_image')
self.encrypted_image = self._builder.get_object('encrypted_image')
self.con_view = ConversationTextView()
grid.attach_next_to(self.con_view,
self.encrypted_image.get_parent(),
Gtk.PositionType.RIGHT, 1, 1)
self.show_all()
......@@ -370,7 +370,9 @@ def update_tags(self):
def scroll_to_end(self, force=False):
if self.autoscroll or force:
gtkgui_helpers.scroll_to_end(self.tv.get_parent())
pass
#TODO
# gtkgui_helpers.scroll_to_end(self.tv.get_parent())
def correct_message(self, correct_id, kind, name):
allowed = True
......
from gi.repository import Gtk
class ConversationTextView(Gtk.TextView):
def __init__(self):
Gtk.TextView.__init__(self)
self._textline = None
self.set_accepts_tab(True)
self.set_editable(False)
self.set_cursor_visible(False)
self.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
self.set_hexpand(True)
self.show()
def set_text_line(self, text):
self._textline = TextViewLine(self)
self._textline.set_text(text)
class TextViewLine:
def __init__(self, textview):
self._textview = textview
self._buffer = textview.get_buffer()
_iter = self._create_mark_bounds('text', self._buffer.get_start_iter())
_iter = self._create_mark_bounds('time', _iter)
def _create_mark_bounds(self, name, _iter):
mark = self._buffer.create_mark('start-' + name, _iter, True)
self._buffer.insert(_iter, ' ')
# _iter is now invalid, textbuffer has changed
_iter = self._buffer.get_iter_at_mark(mark)
self._buffer.create_mark('end-' + name, _iter, False)
_iter.forward_char()
return _iter
def set_text(self, text):
_iter = self._get_iter_from_name('start-text')
self._buffer.insert(_iter, text)
def set_time(self, text):
_iter = self._get_iter_from_name('start-time')
self._buffer.insert(_iter, text)
def _get_iter_from_name(self, mark_name):
mark = self._buffer.get_mark(mark_name)
return self._buffer.get_iter_at_mark(mark)
\ No newline at end of file
from gi.repository import Gtk
from gajim.conversation_items.message import Message
class ConversationView(Gtk.ListBox):
def __init__(self):
Gtk.ListBox.__init__(self)
self.show_all()
def add_message(self, text):
t = Message()
t.con_view.set_text_line(text)
self.add(t)
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.21.0 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkGrid" id="message_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="width_request">16</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="encrypted_image">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="halign">start</property>
<property name="valign">start</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="width_request">16</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkImage" id="received_image">
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment