Fixup the chat toolbar layout a bit
This commit is contained in:
parent
974ef81c1e
commit
8797223ccd
@ -8,19 +8,20 @@ import richtext
|
|||||||
|
|
||||||
class ChatToolbar(gtk.HBox):
|
class ChatToolbar(gtk.HBox):
|
||||||
def __init__(self, editor):
|
def __init__(self, editor):
|
||||||
gtk.HBox.__init__(self)
|
gtk.HBox.__init__(self, False, 24)
|
||||||
|
|
||||||
self._editor = editor
|
self._editor = editor
|
||||||
self._emt_popup = None
|
self._emt_popup = None
|
||||||
|
|
||||||
# spring = gtk.Label('')
|
spring = gtk.Label('')
|
||||||
# self.pack_start(spring, True)
|
self.pack_start(spring, True)
|
||||||
# spring.show()
|
spring.show()
|
||||||
|
|
||||||
toolbar = richtext.RichTextToolbar(editor.get_buffer())
|
toolbox = richtext.RichTextToolbox(editor.get_buffer())
|
||||||
toolbar.set_show_arrow(False)
|
self.pack_start(toolbox, False)
|
||||||
|
toolbox.show()
|
||||||
|
|
||||||
item = gtk.ToolButton()
|
item = gtk.Button()
|
||||||
|
|
||||||
e_hbox = gtk.HBox(False, 6)
|
e_hbox = gtk.HBox(False, 6)
|
||||||
|
|
||||||
@ -33,10 +34,9 @@ class ChatToolbar(gtk.HBox):
|
|||||||
e_hbox.pack_start(arrow)
|
e_hbox.pack_start(arrow)
|
||||||
arrow.show()
|
arrow.show()
|
||||||
|
|
||||||
item.set_icon_widget(e_hbox)
|
item.set_image(e_hbox)
|
||||||
item.set_homogeneous(False)
|
|
||||||
item.connect("clicked", self.__emoticons_button_clicked_cb)
|
item.connect("clicked", self.__emoticons_button_clicked_cb)
|
||||||
toolbar.insert(item, -1)
|
toolbox.pack_start(item, False)
|
||||||
item.show()
|
item.show()
|
||||||
|
|
||||||
# separator = gtk.SeparatorToolItem()
|
# separator = gtk.SeparatorToolItem()
|
||||||
@ -49,17 +49,14 @@ class ChatToolbar(gtk.HBox):
|
|||||||
# toolbar.insert(item, -1)
|
# toolbar.insert(item, -1)
|
||||||
# item.show()
|
# item.show()
|
||||||
|
|
||||||
self.pack_start(toolbar)
|
|
||||||
toolbar.show()
|
|
||||||
|
|
||||||
toolbox = Toolbox()
|
toolbox = Toolbox()
|
||||||
toolbox.connect('color-selected', self._color_selected)
|
toolbox.connect('color-selected', self._color_selected)
|
||||||
self.pack_start(toolbox, False)
|
self.pack_start(toolbox, False)
|
||||||
toolbox.show()
|
toolbox.show()
|
||||||
|
|
||||||
# spring = gtk.Label('')
|
spring = gtk.Label('')
|
||||||
# self.pack_start(spring, True)
|
self.pack_start(spring, True)
|
||||||
# spring.show()
|
spring.show()
|
||||||
|
|
||||||
def _color_selected(self, toolbox, color):
|
def _color_selected(self, toolbox, color):
|
||||||
self._editor.set_color(color)
|
self._editor.set_color(color)
|
||||||
|
@ -149,39 +149,59 @@ class RichTextBuffer(gtk.TextBuffer):
|
|||||||
pos_end.backward_chars(length)
|
pos_end.backward_chars(length)
|
||||||
self.apply_tag_by_name(tag, pos, pos_end)
|
self.apply_tag_by_name(tag, pos, pos_end)
|
||||||
|
|
||||||
class RichTextToolbar(gtk.Toolbar):
|
class RichTextToolbox(gtk.HBox):
|
||||||
def __init__(self, buf):
|
def __init__(self, buf):
|
||||||
gtk.Toolbar.__init__(self)
|
gtk.HBox.__init__(self, False, 6)
|
||||||
|
|
||||||
self.buf = buf
|
self.buf = buf
|
||||||
|
|
||||||
self.set_style(gtk.TOOLBAR_ICONS)
|
|
||||||
|
|
||||||
self._font_size = "normal"
|
self._font_size = "normal"
|
||||||
self._font_scales = [ "xx-small", "x-small", "small", \
|
self._font_scales = [ "xx-small", "x-small", "small", \
|
||||||
"normal", \
|
"normal", \
|
||||||
"large", "x-large", "xx-large" ]
|
"large", "x-large", "xx-large" ]
|
||||||
|
|
||||||
item = gtk.ToggleToolButton(gtk.STOCK_BOLD)
|
image = gtk.Image()
|
||||||
|
image.set_from_stock(gtk.STOCK_BOLD, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
|
|
||||||
|
item = gtk.ToggleButton()
|
||||||
|
item.set_image(image)
|
||||||
item.connect("toggled", self.__toggle_style_cb, "bold")
|
item.connect("toggled", self.__toggle_style_cb, "bold")
|
||||||
self.insert(item, -1)
|
self.pack_start(item, False)
|
||||||
item.show()
|
item.show()
|
||||||
|
|
||||||
item = gtk.ToggleToolButton(gtk.STOCK_ITALIC)
|
image.show()
|
||||||
|
|
||||||
|
image = gtk.Image()
|
||||||
|
image.set_from_stock(gtk.STOCK_ITALIC, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
|
|
||||||
|
item = gtk.ToggleButton()
|
||||||
|
item.set_image(image)
|
||||||
item.connect("toggled", self.__toggle_style_cb, "italic")
|
item.connect("toggled", self.__toggle_style_cb, "italic")
|
||||||
self.insert(item, -1)
|
self.pack_start(item, False)
|
||||||
item.show()
|
item.show()
|
||||||
|
|
||||||
self._font_size_up = gtk.ToolButton(gtk.STOCK_GO_UP)
|
image = gtk.Image()
|
||||||
|
image.set_from_stock(gtk.STOCK_GO_UP, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
|
|
||||||
|
self._font_size_up = gtk.Button()
|
||||||
|
self._font_size_up.set_image(image)
|
||||||
self._font_size_up.connect("clicked", self.__font_size_up_cb)
|
self._font_size_up.connect("clicked", self.__font_size_up_cb)
|
||||||
self.insert(self._font_size_up, -1)
|
self.pack_start(self._font_size_up, False)
|
||||||
self._font_size_up.show()
|
self._font_size_up.show()
|
||||||
|
|
||||||
self._font_size_down = gtk.ToolButton(gtk.STOCK_GO_DOWN)
|
image.show()
|
||||||
|
|
||||||
|
image = gtk.Image()
|
||||||
|
image.set_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_SMALL_TOOLBAR)
|
||||||
|
|
||||||
|
self._font_size_down = gtk.Button()
|
||||||
|
self._font_size_down.set_image(image)
|
||||||
self._font_size_down.connect("clicked", self.__font_size_down_cb)
|
self._font_size_down.connect("clicked", self.__font_size_down_cb)
|
||||||
self.insert(self._font_size_down, -1)
|
self.pack_start(self._font_size_down, False)
|
||||||
self._font_size_down.show()
|
self._font_size_down.show()
|
||||||
|
|
||||||
|
image.show()
|
||||||
|
|
||||||
def _get_font_size_index(self):
|
def _get_font_size_index(self):
|
||||||
return self._font_scales.index(self._font_size);
|
return self._font_scales.index(self._font_size);
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class ColorButton(gtk.RadioButton):
|
|||||||
self.set_relief(gtk.RELIEF_NONE)
|
self.set_relief(gtk.RELIEF_NONE)
|
||||||
|
|
||||||
drawing_area = gtk.DrawingArea()
|
drawing_area = gtk.DrawingArea()
|
||||||
drawing_area.set_size_request(16, 16)
|
drawing_area.set_size_request(24, 24)
|
||||||
drawing_area.connect('expose_event', self.expose)
|
drawing_area.connect('expose_event', self.expose)
|
||||||
self.add(drawing_area)
|
self.add(drawing_area)
|
||||||
drawing_area.show()
|
drawing_area.show()
|
||||||
|
Loading…
Reference in New Issue
Block a user