Commit be7391a2 authored by André's avatar André

Remove color and font formatting

parent 61828eb7
Pipeline #4551 passed with stages
in 3 minutes
......@@ -1291,18 +1291,6 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
emoji_chooser.text_widget = self.msg_textview
self.xml.emoticons_button.set_popover(emoji_chooser)
def on_color_menuitem_activate(self, _widget):
color_dialog = Gtk.ColorChooserDialog(None, self.parent_win.window)
color_dialog.set_use_alpha(False)
color_dialog.connect('response', self.msg_textview.color_set)
color_dialog.show_all()
def on_font_menuitem_activate(self, _widget):
font_dialog = Gtk.FontChooserDialog(None, self.parent_win.window)
start, finish = self.msg_textview.get_active_iters()
font_dialog.connect('response', self.msg_textview.font_set, start, finish)
font_dialog.show_all()
def on_formatting_menuitem_activate(self, widget):
tag = widget.get_name()
self.msg_textview.set_tag(tag)
......
......@@ -311,28 +311,6 @@
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="color">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Color</property>
<signal name="activate" handler="on_color_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="font">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Font</property>
<signal name="activate" handler="on_font_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="clear_formatting">
<property name="visible">True</property>
......
......@@ -47,28 +47,6 @@
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="color">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Color</property>
<signal name="activate" handler="on_color_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkMenuItem" id="font">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Font</property>
<signal name="activate" handler="on_font_menuitem_activate" swapped="no"/>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="clear_formatting">
<property name="visible">True</property>
......
......@@ -72,8 +72,6 @@ class MessageInputTextView(Gtk.TextView):
self.begin_tags = {}
self.end_tags = {}
self.color_tags = []
self.fonts_tags = []
self.other_tags = {}
color = app.css_config.get_value(
......@@ -233,77 +231,6 @@ class MessageInputTextView(Gtk.TextView):
start, finish = self.get_active_iters()
_buffer.remove_all_tags(start, finish)
def color_set(self, widget, response):
if response in (-6, -4):
widget.destroy()
return
color = widget.get_property('rgba')
widget.destroy()
_buffer = self.get_buffer()
# Create #aabbcc color string from rgba color
color_string = '#%02X%02X%02X' % (round(color.red*255),
round(color.green*255),
round(color.blue*255))
tag_name = 'color' + color_string
if not tag_name in self.color_tags:
tag_color = _buffer.create_tag(tag_name)
tag_color.set_property('foreground', color_string)
begin = '<span style="color: %s;">' % color_string
self.begin_tags[tag_name] = begin
self.end_tags[tag_name] = '</span>'
self.color_tags.append(tag_name)
start, finish = self.get_active_iters()
for tag in self.color_tags:
_buffer.remove_tag_by_name(tag, start, finish)
_buffer.apply_tag_by_name(tag_name, start, finish)
def font_set(self, widget, response, start, finish):
if response in (-6, -4):
widget.destroy()
return
font = widget.get_font()
font_desc = widget.get_font_desc()
family = font_desc.get_family()
size = font_desc.get_size()
size = size / Pango.SCALE
weight = font_desc.get_weight()
style = font_desc.get_style()
widget.destroy()
_buffer = self.get_buffer()
tag_name = 'font' + font
if not tag_name in self.fonts_tags:
tag_font = _buffer.create_tag(tag_name)
tag_font.set_property('font', family + ' ' + str(size))
self.begin_tags[tag_name] = \
'<span style="font-family: ' + family + '; ' + \
'font-size: ' + str(size) + 'px">'
self.end_tags[tag_name] = '</span>'
self.fonts_tags.append(tag_name)
for tag in self.fonts_tags:
_buffer.remove_tag_by_name(tag, start, finish)
_buffer.apply_tag_by_name(tag_name, start, finish)
if weight == Pango.Weight.BOLD:
_buffer.apply_tag_by_name('bold', start, finish)
else:
_buffer.remove_tag_by_name('bold', start, finish)
if style == Pango.Style.ITALIC:
_buffer.apply_tag_by_name('italic', start, finish)
else:
_buffer.remove_tag_by_name('italic', start, finish)
def get_xhtml(self):
_buffer = self.get_buffer()
old = _buffer.get_start_iter()
......
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