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

ChatControl: Add Send Message button

parent eb1737a4
Pipeline #6262 passed with stages
in 3 minutes and 49 seconds
......@@ -312,6 +312,11 @@ class ChatControl(ChatControlBase):
win.lookup_action('toggle-video-' + self.control_id).set_enabled(
online and self.jingle['video'].available)
# Send message
has_text = self.msg_textview.has_text()
win.lookup_action(
f'send-message-{self.control_id}').set_enabled(online and has_text)
# Send file (HTTP File Upload)
httpupload = win.lookup_action(
'send-file-httpupload-' + self.control_id)
......
......@@ -192,6 +192,16 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
self.msg_textview.connect('text-changed',
self._on_message_tv_buffer_changed)
# Send message button
self.xml.send_message_button.set_action_name(
'win.send-message-%s' % self.control_id)
self.xml.send_message_button.set_visible(
app.settings.get('show_send_message_button'))
app.settings.bind_signal(
'show_send_message_button',
self.xml.send_message_button,
'set_visible')
self.msg_scrolledwindow = ScrolledWindow()
self.msg_scrolledwindow.add(self.msg_textview)
......@@ -513,6 +523,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
self.parent_win.window.add_action(action)
actions = {
'send-message-%s': self._on_send_message,
'send-file-%s': self._on_send_file,
'send-file-httpupload-%s': self._on_send_file,
'send-file-jingle-%s': self._on_send_file,
......@@ -526,6 +537,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
def remove_actions(self):
actions = [
'send-message-',
'set-encryption-',
'send-file-',
'send-file-httpupload-',
......@@ -911,10 +923,7 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
app.interface.raise_dialog('not-connected-while-sending')
return True
textview.replace_emojis()
message = textview.get_text()
xhtml = textview.get_xhtml()
self.send_message(message, xhtml=xhtml)
self._on_send_message()
return True
elif event.keyval == Gdk.KEY_z: # CTRL+z
......@@ -963,6 +972,12 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
label = labels[lname]
return label
def _on_send_message(self, *args):
self.msg_textview.replace_emojis()
message = self.msg_textview.get_text()
xhtml = self.msg_textview.get_xhtml()
self.send_message(message, xhtml=xhtml)
def send_message(self,
message,
type_='chat',
......@@ -1029,6 +1044,10 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
self.contact, self.msg_textview.has_text())
def _on_message_tv_buffer_changed(self, textview, textbuffer):
has_text = self.msg_textview.has_text()
self.parent_win.window.lookup_action(
'send-message-' + self.control_id).set_enabled(has_text)
if textbuffer.get_char_count() and self.encryption:
app.plugin_manager.extension_point(
'typing' + self.encryption, self)
......
......@@ -187,6 +187,7 @@ APP_SETTINGS = {
'check_for_update': True,
'last_update_check': '',
'always_ask_for_status_message': False,
'show_send_message_button': False,
}
ACCOUNT_SETTINGS = {
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<!-- Generated with glade 3.36.0 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkAdjustment" id="adjustment1">
......@@ -982,6 +982,32 @@ microphone-sensitivity-high-symbolic</property>
<property name="position">7</property>
</packing>
</child>
<child>
<object class="GtkButton" id="send_message_button">
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Send Message</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-send</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">8</property>
</packing>
</child>
<child>
<placeholder/>
</child>
......
......@@ -301,20 +301,21 @@
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<object class="GtkMenuButton" id="settings_menu">
<object class="GtkButton" id="quick_invite_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="relief">none</property>
<property name="tooltip_text" translatable="yes">Invite Contacts…</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
<property name="icon_name">list-add-symbolic</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
<class name="flat"/>
</style>
</object>
<packing>
......@@ -325,28 +326,27 @@
</packing>
</child>
<child>
<object class="GtkButton" id="quick_invite_button">
<object class="GtkMenuButton" id="settings_menu">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Invite Contacts…</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">list-add-symbolic</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
<class name="flat"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
......@@ -374,7 +374,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>
......@@ -395,7 +395,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -420,7 +420,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">4</property>
<property name="position">3</property>
</packing>
</child>
<child>
......@@ -447,6 +447,32 @@
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkButton" id="send_message_button">
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="no_show_all">True</property>
<property name="tooltip_text" translatable="yes">Send Message</property>
<property name="relief">none</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-send</property>
</object>
</child>
<style>
<class name="chatcontrol-actionbar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">6</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="formattings_button">
<property name="visible">True</property>
......@@ -473,12 +499,9 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">7</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkComboBox" id="label_selector">
<property name="visible">True</property>
......@@ -491,6 +514,9 @@
<property name="position">8</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -393,6 +393,11 @@ class GroupchatControl(ChatControlBase):
# Execute command
self._get_action('execute-command-').set_enabled(self.is_connected)
# Send message
has_text = self.msg_textview.has_text()
self._get_action('send-message-').set_enabled(
self.is_connected and has_text)
# Send file (HTTP File Upload)
httpupload = self._get_action(
'send-file-httpupload-')
......
Markdown is supported
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