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):
|
||||
def __init__(self, editor):
|
||||
gtk.HBox.__init__(self)
|
||||
gtk.HBox.__init__(self, False, 24)
|
||||
|
||||
self._editor = editor
|
||||
self._emt_popup = None
|
||||
|
||||
# spring = gtk.Label('')
|
||||
# self.pack_start(spring, True)
|
||||
# spring.show()
|
||||
spring = gtk.Label('')
|
||||
self.pack_start(spring, True)
|
||||
spring.show()
|
||||
|
||||
toolbar = richtext.RichTextToolbar(editor.get_buffer())
|
||||
toolbar.set_show_arrow(False)
|
||||
toolbox = richtext.RichTextToolbox(editor.get_buffer())
|
||||
self.pack_start(toolbox, False)
|
||||
toolbox.show()
|
||||
|
||||
item = gtk.ToolButton()
|
||||
item = gtk.Button()
|
||||
|
||||
e_hbox = gtk.HBox(False, 6)
|
||||
|
||||
@ -33,10 +34,9 @@ class ChatToolbar(gtk.HBox):
|
||||
e_hbox.pack_start(arrow)
|
||||
arrow.show()
|
||||
|
||||
item.set_icon_widget(e_hbox)
|
||||
item.set_homogeneous(False)
|
||||
item.set_image(e_hbox)
|
||||
item.connect("clicked", self.__emoticons_button_clicked_cb)
|
||||
toolbar.insert(item, -1)
|
||||
toolbox.pack_start(item, False)
|
||||
item.show()
|
||||
|
||||
# separator = gtk.SeparatorToolItem()
|
||||
@ -49,17 +49,14 @@ class ChatToolbar(gtk.HBox):
|
||||
# toolbar.insert(item, -1)
|
||||
# item.show()
|
||||
|
||||
self.pack_start(toolbar)
|
||||
toolbar.show()
|
||||
|
||||
toolbox = Toolbox()
|
||||
toolbox.connect('color-selected', self._color_selected)
|
||||
self.pack_start(toolbox, False)
|
||||
toolbox.show()
|
||||
|
||||
# spring = gtk.Label('')
|
||||
# self.pack_start(spring, True)
|
||||
# spring.show()
|
||||
spring = gtk.Label('')
|
||||
self.pack_start(spring, True)
|
||||
spring.show()
|
||||
|
||||
def _color_selected(self, toolbox, color):
|
||||
self._editor.set_color(color)
|
||||
|
@ -149,39 +149,59 @@ class RichTextBuffer(gtk.TextBuffer):
|
||||
pos_end.backward_chars(length)
|
||||
self.apply_tag_by_name(tag, pos, pos_end)
|
||||
|
||||
class RichTextToolbar(gtk.Toolbar):
|
||||
class RichTextToolbox(gtk.HBox):
|
||||
def __init__(self, buf):
|
||||
gtk.Toolbar.__init__(self)
|
||||
gtk.HBox.__init__(self, False, 6)
|
||||
|
||||
self.buf = buf
|
||||
|
||||
self.set_style(gtk.TOOLBAR_ICONS)
|
||||
|
||||
self._font_size = "normal"
|
||||
self._font_scales = [ "xx-small", "x-small", "small", \
|
||||
"normal", \
|
||||
"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")
|
||||
self.insert(item, -1)
|
||||
self.pack_start(item, False)
|
||||
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")
|
||||
self.insert(item, -1)
|
||||
self.pack_start(item, False)
|
||||
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.insert(self._font_size_up, -1)
|
||||
self.pack_start(self._font_size_up, False)
|
||||
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.insert(self._font_size_down, -1)
|
||||
self.pack_start(self._font_size_down, False)
|
||||
self._font_size_down.show()
|
||||
|
||||
image.show()
|
||||
|
||||
def _get_font_size_index(self):
|
||||
return self._font_scales.index(self._font_size);
|
||||
|
||||
|
@ -13,7 +13,7 @@ class ColorButton(gtk.RadioButton):
|
||||
self.set_relief(gtk.RELIEF_NONE)
|
||||
|
||||
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)
|
||||
self.add(drawing_area)
|
||||
drawing_area.show()
|
||||
|
Loading…
Reference in New Issue
Block a user