Commit f6c3d032 authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

Rework SingleMessageWindow

parent 87bbf473
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 --> <!-- Generated with glade 3.22.1 -->
<interface> <interface>
<requires lib="gtk+" version="3.12"/> <requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="image1"> <object class="GtkImage" id="image1">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="stock">gtk-ok</property> <property name="icon_name">mail-reply-sender-symbolic</property>
</object> </object>
<object class="GtkImage" id="image2"> <object class="GtkImage" id="image2">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="stock">gtk-ok</property> <property name="icon_name">mail-send-symbolic</property>
</object> </object>
<object class="GtkImage" id="image3"> <object class="GtkImage" id="image3">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="stock">gtk-jump-to</property> <property name="icon_name">mail-send-symbolic</property>
</object>
<object class="GtkImage" id="image4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">user-info-symbolic</property>
</object> </object>
<object class="GtkWindow" id="single_message_window"> <object class="GtkWindow" id="single_message_window">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="default_width">550</property>
<property name="default_height">280</property>
<signal name="delete-event" handler="on_single_message_window_delete_event" swapped="no"/> <signal name="delete-event" handler="on_single_message_window_delete_event" swapped="no"/>
<signal name="destroy" handler="on_single_message_window_destroy" swapped="no"/> <signal name="destroy" handler="on_single_message_window_destroy" swapped="no"/>
<signal name="key-press-event" handler="on_single_message_window_key_press_event" swapped="no"/> <signal name="key-press-event" handler="on_single_message_window_key_press_event" swapped="no"/>
<child> <child>
<object class="GtkBox" id="vbox97"> <placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="border_width">18</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">6</property>
<child> <child>
<object class="GtkGrid" id="grid1"> <object class="GtkGrid" id="send_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="row_spacing">3</property> <property name="no_show_all">True</property>
<property name="column_spacing">3</property> <property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child> <child>
<object class="GtkLabel" id="from_label"> <object class="GtkLabel" id="to_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="halign">end</property>
<property name="xalign">0</property> <property name="label" translatable="yes">_To</property>
<property name="label" translatable="yes">From:</property> <property name="use_underline">True</property>
<property name="mnemonic_widget">to_entry</property>
<style>
<class name="dim-label"/>
</style>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
...@@ -51,124 +61,239 @@ ...@@ -51,124 +61,239 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="to_label"> <object class="GtkEntry" id="to_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">True</property>
<property name="no_show_all">True</property> <property name="hexpand">True</property>
<property name="xalign">0</property> <property name="placeholder_text" translatable="yes">user@example.org</property>
<property name="label" translatable="yes">To:</property>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">1</property>
<property name="top_attach">1</property> <property name="top_attach">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="label335"> <object class="GtkLabel" id="subject_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">Subject:</property> <property name="halign">end</property>
<property name="label" translatable="yes">Su_bject</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">subject_entry</property>
<property name="single_line_mode">True</property>
<style>
<class name="dim-label"/>
</style>
</object> </object>
<packing> <packing>
<property name="left_attach">0</property> <property name="left_attach">0</property>
<property name="top_attach">2</property> <property name="top_attach">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="from_entry"> <object class="GtkEntry" id="subject_entry">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="no_show_all">True</property> <property name="placeholder_text" translatable="yes">Type the subject here...</property>
<property name="hexpand">True</property> <property name="show_emoji_icon">True</property>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">0</property> <property name="top_attach">1</property>
<property name="width">2</property> <property name="width">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="to_entry"> <object class="GtkLabel" id="message_label_send">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="halign">end</property>
<property name="hexpand">True</property> <property name="label" translatable="yes">_Message</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">message_textview</property>
<style>
<class name="dim-label"/>
</style>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">0</property>
<property name="top_attach">1</property> <property name="top_attach">2</property>
<property name="width">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkEntry" id="subject_entry"> <object class="GtkScrolledWindow" id="message_scrolledwindow">
<property name="height_request">100</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="hexpand">True</property> <property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="message_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="wrap_mode">word-char</property>
<property name="left_margin">6</property>
<property name="right_margin">6</property>
<property name="top_margin">6</property>
<property name="bottom_margin">6</property>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="left_attach">1</property> <property name="left_attach">1</property>
<property name="top_attach">2</property> <property name="top_attach">2</property>
<property name="width">2</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="count_chars_label"> <object class="GtkLabel" id="count_chars_label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="label" translatable="yes">0</property> <property name="halign">end</property>
<property name="label" translatable="yes">Characters typed: 0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="show_contact_info_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Query Contact Info</property>
<property name="image">image4</property>
<signal name="clicked" handler="on_show_contact_info_button_clicked" swapped="no"/>
</object> </object>
<packing> <packing>
<property name="left_attach">2</property> <property name="left_attach">2</property>
<property name="top_attach">2</property> <property name="top_attach">0</property>
</packing> </packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkScrolledWindow" id="conversation_scrolledwindow"> <object class="GtkGrid" id="received_grid">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="shadow_type">in</property> <property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child> <child>
<placeholder/> <object class="GtkLabel" id="from_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">_From</property>
<property name="use_underline">True</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="subject_from_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Subject</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="from_entry_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;user@example.org&gt;</property>
<property name="xalign">0</property>
<style>
<class name="bold"/>
</style>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="subject_from_entry_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;from Subject&gt;</property>
<property name="wrap">True</property>
<property name="max_width_chars">50</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child> </child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow" id="message_scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="no_show_all">True</property>
<property name="shadow_type">in</property>
<child> <child>
<object class="GtkTextView" id="message_textview"> <object class="GtkScrolledWindow" id="conversation_scrolledwindow">
<property name="height_request">100</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="wrap_mode">word</property> <property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<child>
<placeholder/>
</child>
</object> </object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="message_label_received">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Message</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child> </child>
</object> </object>
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">1</property>
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkButtonBox" id="hbuttonbox26"> <object class="GtkButtonBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">12</property>
<property name="spacing">12</property> <property name="spacing">12</property>
<property name="layout_style">end</property> <property name="layout_style">end</property>
<child> <child>
...@@ -188,23 +313,6 @@ ...@@ -188,23 +313,6 @@
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkButton" id="cancel_button">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="no_show_all">True</property>
<property name="use_stock">True</property>
<signal name="clicked" handler="on_cancel_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkButton" id="send_button"> <object class="GtkButton" id="send_button">
<property name="label" translatable="yes">Sen_d</property> <property name="label" translatable="yes">Sen_d</property>
...@@ -214,7 +322,7 @@ ...@@ -214,7 +322,7 @@
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Send message</property> <property name="tooltip_text" translatable="yes">Send message</property>
<property name="image">image3</property> <property name="image">image2</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_send_button_clicked" swapped="no"/> <signal name="clicked" handler="on_send_button_clicked" swapped="no"/>
</object> </object>
...@@ -236,6 +344,9 @@ ...@@ -236,6 +344,9 @@
<property name="image">image1</property> <property name="image">image1</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_reply_button_clicked" swapped="no"/> <signal name="clicked" handler="on_reply_button_clicked" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -252,9 +363,12 @@ ...@@ -252,9 +363,12 @@
<property name="receives_default">False</property> <property name="receives_default">False</property>
<property name="no_show_all">True</property> <property name="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Send message and close window</property> <property name="tooltip_text" translatable="yes">Send message and close window</property>
<property name="image">image2</property> <property name="image">image3</property>
<property name="use_underline">True</property> <property name="use_underline">True</property>
<signal name="clicked" handler="on_send_and_close_button_clicked" swapped="no"/> <signal name="clicked" handler="on_send_and_close_button_clicked" swapped="no"/>
<style>
<class name="suggested-action"/>
</style>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
...@@ -267,7 +381,7 @@ ...@@ -267,7 +381,7 @@
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="padding">6</property> <property name="padding">6</property>
<property name="position">3</property> <property name="position">4</property>
</packing> </packing>
</child> </child>
</object> </object>
......
...@@ -16,7 +16,9 @@ from typing import List # pylint: disable=unused-import ...@@ -16,7 +16,9 @@ from typing import List # pylint: disable=unused-import
from gi.repository import Gdk from gi.repository import Gdk
from gi.repository import GLib from gi.repository import GLib
from gi.repository import Gtk
from gajim import vcard
from gajim.common import app from gajim.common import app
from gajim.common import helpers from gajim.common import helpers
from gajim.common.i18n import _ from gajim.common.i18n import _
...@@ -37,16 +39,17 @@ if app.is_installed('GSPELL'): ...@@ -37,16 +39,17 @@ if app.is_installed('GSPELL'):
from gi.repository import Gspell # pylint: disable=ungrouped-imports from gi.repository import Gspell # pylint: disable=ungrouped-imports
class SingleMessageWindow: class SingleMessageWindow(Gtk.ApplicationWindow):
""" """
SingleMessageWindow can send or show a received singled message depending on SingleMessageWindow can send or show a received singled message depending on
action argument which can be 'send' or 'receive' action argument which can be 'send' or 'receive'
""" """
# Keep a reference on windows so garbage collector don't restroy them
instances = [] # type: List[SingleMessageWindow]
def __init__(self, account, to='', action='', from_whom='', subject='', def __init__(self, account, to='', action='', from_whom='', subject='',
message='', resource='', session=None, form_node=None): message='', resource='', session=None, form_node=None):
self.instances.append(self) Gtk.ApplicationWindow.__init__(self)
self.set_application(app.app)
self.set_title(_('Send Single Message'))
self.set_name('SendSingleMessageWindow')
self.account = account self.account = account
self.action = action self.action = action
...@@ -57,51 +60,38 @@ class SingleMessageWindow: ...@@ -57,51 +60,38 @@ class SingleMessageWindow:
self.resource = resource self.resource = resource
self.session = session self.session = session
self.xml = get_builder('single_message_window.ui') self._ui = get_builder('single_message_window.ui')
self.window = self.xml.get_object('single_message_window') self.message_tv_buffer = self._ui.message_textview.get_buffer()
self.count_chars_label = self.xml.get_object('count_chars_label')
self.from_label = self.xml.get_object('from_label')
self.from_entry = self.xml.get_object('from_entry')
self.to_label = self.xml.get_object('to_label')
self.to_entry = self.xml.get_object('to_entry')
self.subject_entry = self.xml.get_object('subject_entry')
self.message_scrolledwindow = self.xml.get_object(
'message_scrolledwindow')
self.message_textview = self.xml.get_object('message_textview')
self.message_tv_buffer = self.message_textview.get_buffer()
self.conversation_scrolledwindow = self.xml.get_object(
'conversation_scrolledwindow')
self.conversation_textview = ConversationTextview( self.conversation_textview = ConversationTextview(
account, used_in_history_window=True) account, used_in_history_window=True)
self.conversation_textview.tv.show() self.conversation_textview.tv.show()
self.conversation_textview.tv.set_left_margin(6)
self.conversation_textview.tv.set_right_margin(6)
self.conversation_textview.tv.set_top_margin(6)
self.conversation_textview.tv.set_bottom_margin(6)
self.conversation_tv_buffer = self.conversation_textview.tv.get_buffer() self.conversation_tv_buffer = self.conversation_textview.tv.get_buffer()
self.xml.get_object('conversation_scrolledwindow').add( self._ui.conversation_scrolledwindow.add(
self.conversation_textview.tv) self.conversation_textview.tv)
self.form_widget = None self.form_widget = None
parent_box = self.xml.get_object('conversation_scrolledwindow').\ parent_box = self._ui.conversation_scrolledwindow.get_parent()
get_parent()
if form_node: if form_node:
self.form_widget = DataFormWidget(form_node) self.form_widget = DataFormWidget(form_node)
self.form_widget.show_all() self.form_widget.show_all()