Verified Commit d8808d11 authored by André's avatar André
Browse files

Remove color and font formatting

parent 6f25997b
Pipeline #7498 passed with stages
in 8 minutes and 18 seconds
...@@ -1290,18 +1290,6 @@ def _on_emoticon_button_clicked(self, _widget): ...@@ -1290,18 +1290,6 @@ def _on_emoticon_button_clicked(self, _widget):
self.msg_textview.emit('insert-emoji') self.msg_textview.emit('insert-emoji')
self.xml.emoticons_button.set_property('active', False) self.xml.emoticons_button.set_property('active', False)
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): def on_formatting_menuitem_activate(self, widget):
tag = widget.get_name() tag = widget.get_name()
self.msg_textview.set_tag(tag) self.msg_textview.set_tag(tag)
......
...@@ -356,28 +356,6 @@ ...@@ -356,28 +356,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
</object> </object>
</child> </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> <child>
<object class="GtkMenuItem" id="clear_formatting"> <object class="GtkMenuItem" id="clear_formatting">
<property name="visible">True</property> <property name="visible">True</property>
......
...@@ -92,28 +92,6 @@ ...@@ -92,28 +92,6 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
</object> </object>
</child> </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> <child>
<object class="GtkMenuItem" id="clear_formatting"> <object class="GtkMenuItem" id="clear_formatting">
<property name="visible">True</property> <property name="visible">True</property>
......
...@@ -76,8 +76,6 @@ def __init__(self): ...@@ -76,8 +76,6 @@ def __init__(self):
self.begin_tags = {} self.begin_tags = {}
self.end_tags = {} self.end_tags = {}
self.color_tags = []
self.fonts_tags = []
self.other_tags = {} self.other_tags = {}
color = app.css_config.get_value( color = app.css_config.get_value(
...@@ -260,77 +258,6 @@ def clear_tags(self): ...@@ -260,77 +258,6 @@ def clear_tags(self):
start, finish = self.get_active_iters() start, finish = self.get_active_iters()
_buffer.remove_all_tags(start, finish) _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): def get_xhtml(self):
_buffer = self.get_buffer() _buffer = self.get_buffer()
old = _buffer.get_start_iter() 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