From 0ad8449864754bc547ca5d2d122c81497be7e02f Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Wed, 9 Jan 2013 22:58:51 +0400 Subject: [PATCH] fix ColorSelectionDialog in xhtml popup menu --- src/chat_control.py | 6 +++--- src/message_textview.py | 17 +++++++++++------ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index 46aa6d3f3..e307e8a5d 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -1097,9 +1097,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): self.parent_win) def on_color_menuitem_activale(self, widget): - color_dialog = Gtk.ColorSelectionDialog('Select a color') - color_dialog.connect('response', self.msg_textview.color_set, - color_dialog.colorsel) + 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_activale(self, widget): diff --git a/src/message_textview.py b/src/message_textview.py index 9700032bd..6c41be4ac 100644 --- a/src/message_textview.py +++ b/src/message_textview.py @@ -146,19 +146,24 @@ class MessageTextView(Gtk.TextView): start, finish = self.get_active_iters() _buffer.remove_all_tags(start, finish) - def color_set(self, widget, response, color): - if response == -6: + def color_set(self, widget, response): + print (response) + if response == -6 or response == -4: widget.destroy() return - _buffer = self.get_buffer() - color = color.get_current_color() + + color = widget.get_property('rgba') widget.destroy() - color_string = gtkgui_helpers.make_color_string(color) + _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: tagColor = _buffer.create_tag(tag_name) tagColor.set_property('foreground', color_string) - self.begin_tags[tag_name] = '' + self.begin_tags[tag_name] = '' % color_string self.end_tags[tag_name] = '' self.color_tags.append(tag_name)