[gedit-plugins] [commander] Embed info popup
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] [commander] Embed info popup
- Date: Thu, 4 Sep 2014 16:59:22 +0000 (UTC)
commit 44f6bb9bcfa8036fedb707400d98d690e9cc336f
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Thu Sep 4 18:01:07 2014 +0200
[commander] Embed info popup
plugins/commander/Makefile.am | 1 -
plugins/commander/commander/entry.py | 133 ++++++---
plugins/commander/commander/info.py | 319 +++++++++-------------
plugins/commander/commander/transparentwindow.py | 81 ------
4 files changed, 217 insertions(+), 317 deletions(-)
---
diff --git a/plugins/commander/Makefile.am b/plugins/commander/Makefile.am
index 5920d4c..ff53d2c 100644
--- a/plugins/commander/Makefile.am
+++ b/plugins/commander/Makefile.am
@@ -6,7 +6,6 @@ plugins_commander_PYTHON = \
plugins/commander/commander/history.py \
plugins/commander/commander/info.py \
plugins/commander/commander/modules.py \
- plugins/commander/commander/transparentwindow.py \
plugins/commander/commander/utils.py \
plugins/commander/commander/appactivatable.py \
plugins/commander/commander/windowactivatable.py
diff --git a/plugins/commander/commander/entry.py b/plugins/commander/commander/entry.py
index 710fb70..a0171a5 100644
--- a/plugins/commander/commander/entry.py
+++ b/plugins/commander/commander/entry.py
@@ -47,7 +47,7 @@ class Entry(Gtk.Box):
self._reveal.set_reveal_child(False)
def __init__(self, view):
- Gtk.Box.__init__(self)
+ super(Entry, self).__init__()
self._view = view
@@ -58,7 +58,8 @@ class Entry(Gtk.Box):
self._accel_group = None
self._wait_timeout = 0
- self._info_window = None
+ self._info = None
+ self._info_revealer = None
self._suspended = None
@@ -120,18 +121,30 @@ GtkEntry#gedit-commander-entry {
return parent
def _build_ui(self):
- self.set_orientation(Gtk.Orientation.HORIZONTAL)
- self.set_spacing(6)
+ self.set_orientation(Gtk.Orientation.VERTICAL)
self._overlay = self._find_overlay(self._view)
+ hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
+ hbox.show()
+
+ self.pack_end(hbox, False, False, 0)
+
+ self._info_revealer = Gtk.Revealer()
+
+ self._info_revealer.set_transition_type(Gtk.RevealerTransitionType.SLIDE_UP)
+ self._info_revealer.set_transition_duration(100)
+
+ self.pack_start(self._info_revealer, False, False, 0)
+ self._info_revealer.connect('notify::child-revealed', self._on_info_revealer_child_revealed)
+
self._prompt_label = Gtk.Label(label='<b>>>></b>', use_markup=True)
self._prompt_label.set_margin_top(3)
self._prompt_label.set_margin_bottom(3)
self._prompt_label.set_margin_start(3)
self._prompt_label.show()
- self.add(self._prompt_label)
+ hbox.add(self._prompt_label)
self._entry = Gtk.Entry()
self._entry.set_has_frame(False)
@@ -145,7 +158,7 @@ GtkEntry#gedit-commander-entry {
self._entry.connect('key-press-event', self._on_entry_key_press)
self._entry.show()
- self.add(self._entry)
+ hbox.add(self._entry)
self._copy_style_from_view()
self._view_style_updated_id = self._view.connect('style-updated', self._on_view_style_updated)
@@ -157,7 +170,7 @@ GtkEntry#gedit-commander-entry {
def _border_color(self):
style = self._view.get_buffer().get_style_scheme().get_style('right-margin')
- if style.props.foreground_set:
+ if not style is None and style.props.foreground_set:
color = Gdk.RGBA()
color.parse(style.props.foreground)
else:
@@ -166,7 +179,7 @@ GtkEntry#gedit-commander-entry {
color.green = 1 - color.green
color.blue = 1 - color.blue
- color.alpha = 0.5
+ color.alpha = 0.3
return color
@property
@@ -200,15 +213,28 @@ GtkEntry#gedit-commander-entry {
context = self._view.get_style_context()
return context.get_font(Gtk.StateFlags.NORMAL)
- def _copy_style_from_view(self):
+ def _copy_style_from_view(self, widgets=None):
font = self.font
fg = self.foreground_color
bg = self.background_color
- cursor = Gdk.RGBA.from_color(self._view.style_get_property('cursor-color'))
- second = Gdk.RGBA.from_color(self._view.style_get_property('secondary-cursor-color'))
+ cursor = self._view.style_get_property('cursor-color')
+
+ if not cursor is None:
+ cursor = Gdk.RGBA.from_color(cursor)
+
+ secondary_cursor = self._view.style_get_property('secondary-cursor-color')
+
+ if not secondary_cursor is None:
+ secondary_cursor = Gdk.RGBA.from_color(secondary_cursor)
+
+ if widgets is None:
+ widgets = [self, self._entry, self._prompt_label]
+
+ if not self._info is None:
+ widgets.append(self._info.text_view)
- for widget in (self, self._entry, self._prompt_label):
+ for widget in widgets:
widget.override_color(Gtk.StateFlags.NORMAL, fg)
widget.override_color(Gtk.StateFlags.SELECTED, bg)
@@ -216,7 +242,8 @@ GtkEntry#gedit-commander-entry {
widget.override_background_color(Gtk.StateFlags.SELECTED, fg)
widget.override_font(font)
- widget.override_cursor(cursor, second)
+
+ widget.override_cursor(cursor, secondary_cursor)
def _attach(self):
reveal = Gtk.Revealer()
@@ -241,6 +268,7 @@ GtkEntry#gedit-commander-entry {
def _on_child_revealed(self, widget, spec):
if not self._reveal.get_child_revealed():
self.destroy()
+ widget.destroy()
def _on_entry_focus_out(self, widget, evnt):
if self._entry.get_sensitive():
@@ -251,12 +279,12 @@ GtkEntry#gedit-commander-entry {
text = self._entry.get_text()
if evnt.keyval == Gdk.KEY_Escape:
- if self._info_window:
- if self._suspended:
+ if not self._info is None:
+ if not self._suspended is None:
self._suspended.resume()
- if self._info_window:
- self._info_window.destroy()
+ if not self._info is None:
+ self._info_revealer.set_reveal_child(False)
self._entry.set_sensitive(True)
elif self._accel_group:
@@ -306,8 +334,8 @@ GtkEntry#gedit-commander-entry {
if (handler[0] == None or handler[0] == state) and evnt.keyval == handler[1] and
handler[2](handler[3], state):
return True
- if self._info_window and self._info_window.empty():
- self._info_window.destroy()
+ if not self._info is None and self._info.is_empty:
+ self._info_revealer.set_reveal_child(False)
self._history_prefix = None
return False
@@ -350,26 +378,38 @@ GtkEntry#gedit-commander-entry {
self._prompt_label.set_markup('<b>>>></b>%s' % pr)
def _make_info(self):
- if self._info_window == None:
- self._info_window = Info(self)
- self._info_window.show()
+ if self._info is None:
+ self._info = Info()
+
+ self._copy_style_from_view([self._info.text_view])
+
+ self._info_revealer.add(self._info)
+ self._info.show()
+
+ self._info_revealer.show()
+ self._info_revealer.set_reveal_child(True)
+
+ self._info.connect('destroy', self._on_info_destroy)
- self._info_window.connect('destroy', self._on_info_window_destroy)
+ def _on_info_revealer_child_revealed(self, widget, pspec):
+ if not self._info_revealer.get_child_revealed():
+ self._info.destroy()
+ self._info_revealer.hide()
- def _on_info_window_destroy(self, widget):
- self._info_window = None
+ def _on_info_destroy(self, widget):
+ self._info = None
def info_show(self, text='', use_markup=False):
self._make_info()
- self._info_window.add_lines(text, use_markup)
+ self._info.add_lines(text, use_markup)
def info_status(self, text):
self._make_info()
- self._info_window.status(text)
+ self._info.status(text)
def _info_add_action(self, stock, callback, data=None):
self._make_info()
- return self._info_window.add_action(stock, callback, data)
+ return self._info.add_action(stock, callback, data)
def _command_history_done(self):
self._history.add(self._entry.get_text())
@@ -383,8 +423,8 @@ GtkEntry#gedit-commander-entry {
if self._cancel_button:
self._cancel_button.destroy()
- if self._info_window and self._info_window.empty():
- self._info_window.destroy()
+ if not self._info is None and self._info.is_empty:
+ self._info_revealer.set_reveal_child(False)
self._entry.grab_focus()
self._entry.set_sensitive(True)
@@ -412,7 +452,7 @@ GtkEntry#gedit-commander-entry {
self._entry.set_sensitive(True)
self._command_history_done()
- if self._entry.props.has_focus or (self._info_window and not self._info_window.empty()):
+ if self._entry.props.has_focus or (not self._info is None and not self._info.is_empty):
self._entry.grab_focus()
self._on_execute(None, 0)
@@ -451,7 +491,7 @@ GtkEntry#gedit-commander-entry {
if ret == mod.Result.PROMPT:
self._prompt(ret.prompt)
- elif (ret == None or ret == mod.HIDE) and not self._prompt_text and (not self._info_window or
self._info_window.empty()):
+ elif (ret == None or ret == mod.HIDE) and not self._prompt_text and (self._info is None or
self._info.is_empty):
self._command_state.clear()
self._view.grab_focus()
self._reveal.set_reveal_child(False)
@@ -488,8 +528,8 @@ GtkEntry#gedit-commander-entry {
return r
def _on_execute(self, dummy, modifier):
- if self._info_window and not self._suspended:
- self._info_window.destroy()
+ if not self._info is None and not self._suspended:
+ self._info_revealer.set_reveal_child(False)
text = self._entry.get_text().strip()
words = list(self._re_complete.finditer(text))
@@ -663,12 +703,12 @@ GtkEntry#gedit-commander-entry {
self._entry.insert_text('.', lastpos)
self._entry.set_position(lastpos + 1)
- if self._info_window:
- self._info_window.destroy()
+ if not self._info is None:
+ self._info_revealer.set_reveal_child(False)
else:
# Show popup with completed items
- if self._info_window:
- self._info_window.clear()
+ if not self._info is None:
+ self._info.clear()
ret = []
@@ -690,18 +730,25 @@ GtkEntry#gedit-commander-entry {
ctx.set_line_width(1)
ctx.set_source_rgba(col.red, col.green, col.blue, col.alpha)
- ctx.move_to(0, 0)
- ctx.line_to(self.get_allocated_width(), 0)
+ w = self.get_allocated_width()
+
+ ctx.move_to(0, 0.5)
+ ctx.line_to(w, 0.5)
ctx.stroke()
+ if not self._info is None:
+ alloc = self._info.get_allocation()
+ y = alloc.y + alloc.height + 0.5 + self._info.get_border_width()
+
+ ctx.move_to(0, y)
+ ctx.line_to(w, y)
+ ctx.stroke()
+
return ret
def do_destroy(self):
self._view.disconnect(self._view_style_updated_id)
- if self._info_window:
- self._info_window.destroy()
-
self._history.save()
self._view = None
diff --git a/plugins/commander/commander/info.py b/plugins/commander/commander/info.py
index 02a20f0..044466a 100644
--- a/plugins/commander/commander/info.py
+++ b/plugins/commander/commander/info.py
@@ -19,95 +19,74 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
-from transparentwindow import TransparentWindow
from gi.repository import Pango, Gdk, Gtk
import math
-class Info(TransparentWindow):
+class Info(Gtk.Box):
__gtype_name__ = "CommanderInfo"
- def __init__(self, entry):
- super(Info, self).__init__(Gtk.WindowType.POPUP)
+ def __init__(self):
+ super(Info, self).__init__()
- self._entry = entry
- self._vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
+ self._button_bar = None
+ self._status_label = None
+ self._max_lines = 10
- ev = Gtk.EventBox()
- ev.show()
+ self._build_ui()
- self.set_transient_for(entry.get_toplevel())
+ def _build_ui(self):
+ self.set_orientation(Gtk.Orientation.VERTICAL)
+ self.set_spacing(3)
+ self.set_can_focus(False)
+ self.set_border_width(3)
self._vw = Gtk.ScrolledWindow()
self._vw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
- self._vw.show()
-
- ev.add(self._vw)
-
- self._text = Gtk.TextView()
- font = self._entry.font
- fgcolor = self._entry.foreground_color
- bgcolor = self.background_color
+ css = Gtk.CssProvider()
+ css.load_from_data(bytes("""
+.trough {
+ background: transparent;
+}
+""", 'utf-8'))
- self._text.override_font(font)
- self._text.override_color(Gtk.StateFlags.NORMAL, fgcolor)
- self._text.override_background_color(Gtk.StateFlags.NORMAL, bgcolor)
+ self._vw.get_vscrollbar().get_style_context().add_provider(css,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
- ev.override_background_color(Gtk.StateFlags.NORMAL, bgcolor)
+ self._vw.show()
+ self.add(self._vw)
+ self._text = Gtk.TextView()
self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
-
- buf = self._text.get_buffer()
-
- buf.connect_after('insert-text', self.on_text_insert_text)
- buf.connect_after('delete-range', self.on_text_delete_range)
-
self._text.set_editable(False)
-
- self._vw.add(self._text)
- self._vbox.pack_end(ev, False, False, 0)
- self._vbox.show()
- self._button_bar = None
-
- self.add(self._vbox)
self._text.show()
- self._status_label = None
- self.props.can_focus = False
- self.set_border_width(8)
-
- self.attach()
- self.show()
+ buf = self._text.get_buffer()
- self.max_lines = 10
+ buf.connect_after('insert-text', self._on_text_insert_text)
+ buf.connect_after('delete-range', self._on_text_delete_range)
- self.connect_after('size-allocate', self.on_size_allocate)
- self.connect_after('draw', self.on_draw)
+ self._vw.add(self._text)
self._attr_map = {
- Pango.AttrType.STYLE: 'style',
- Pango.AttrType.WEIGHT: 'weight',
- Pango.AttrType.VARIANT: 'variant',
- Pango.AttrType.STRETCH: 'stretch',
- Pango.AttrType.SIZE: 'size',
- Pango.AttrType.FOREGROUND: 'foreground',
- Pango.AttrType.BACKGROUND: 'background',
- Pango.AttrType.UNDERLINE: 'underline',
- Pango.AttrType.STRIKETHROUGH: 'strikethrough',
- Pango.AttrType.RISE: 'rise',
- Pango.AttrType.SCALE: 'scale'
+ Pango.AttrType.STYLE: ('style', Pango.AttrInt),
+ Pango.AttrType.WEIGHT: ('weight', Pango.AttrInt),
+ Pango.AttrType.VARIANT: ('variant', Pango.AttrInt),
+ Pango.AttrType.STRETCH: ('stretch', Pango.AttrInt),
+ Pango.AttrType.SIZE: ('size', Pango.AttrInt),
+ Pango.AttrType.FOREGROUND: ('foreground', Pango.AttrColor),
+ Pango.AttrType.BACKGROUND: ('background', Pango.AttrColor),
+ Pango.AttrType.UNDERLINE: ('underline', Pango.AttrInt),
+ Pango.AttrType.STRIKETHROUGH: ('strikethrough', Pango.AttrInt),
+ Pango.AttrType.RISE: ('rise', Pango.AttrInt),
+ Pango.AttrType.SCALE: ('scale', Pango.AttrFloat)
}
- css = Gtk.CssProvider()
- css.load_from_data(bytes("""
-.trough {
- background: transparent;
-}
-""", 'utf-8'))
-
- self._vw.get_vscrollbar().get_style_context().add_provider(css, 600)
+ @property
+ def text_view(self):
+ return self._text
- def empty(self):
+ @property
+ def is_empty(self):
buf = self._text.get_buffer()
return buf.get_start_iter().equal(buf.get_end_iter())
@@ -135,34 +114,42 @@ class Info(TransparentWindow):
elif self._status_label:
self._status_label.destroy()
- if not self._button_bar and self.empty():
+ if not self._button_bar and self.is_empty:
self.destroy()
- def attrs_to_tags(self, attrs):
+ def _attr_to_tag(self, attr):
buf = self._text.get_buffer()
table = buf.get_tag_table()
ret = []
- for attr in attrs:
- if not attr.type in self._attr_map:
- continue
+ tp = attr.klass.type
- if attr.type == Pango.AttrType.FOREGROUND or attr.type == Pango.AttrType.BACKGROUND:
- value = attr.color
- else:
- value = attr.value
+ if not tp in self._attr_map:
+ return None
- tagname = str(attr.type) + ':' + str(value)
+ propname, klass = self._attr_map[tp]
+
+ # The hack! Set __class__ so we can access .value/.color,
+ # then set __class__ back. This is expected to break at any time
+ cls = attr.__class__
+ attr.__class__ = klass
+
+ if tp == Pango.AttrType.FOREGROUND or tp == Pango.AttrType.BACKGROUND:
+ value = attr.color
+ else:
+ value = attr.value
- tag = table.lookup(tagname)
+ attr.__class__ = cls
- if not tag:
- tag = buf.create_tag(tagname)
- tag.set_property(self._attr_map[attr.type], value)
+ tagname = str(tp) + ':' + str(value)
- ret.append(tag)
+ tag = table.lookup(tagname)
- return ret
+ if not tag:
+ tag = buf.create_tag(tagname)
+ tag.set_property(propname, value)
+
+ return tag
def add_lines(self, line, use_markup=False):
buf = self._text.get_buffer()
@@ -181,25 +168,57 @@ class Info(TransparentWindow):
buf.insert(buf.get_end_iter(), line)
return
- # TODO: fix this when pango supports get_iterator
text = ret[2]
+
+ mark = buf.create_mark(None, buf.get_end_iter(), True)
buf.insert(buf.get_end_iter(), text)
- return
+ attrs = []
+ ret[1].filter(lambda x: attrs.append(x))
+
+ for attr in attrs:
+ # Try/catch everything since the _attr_to_tag stuff is a big
+ # hack
+ try:
+ tag = self._attr_to_tag(attr)
+ except:
+ continue
+
+ if not tag is None:
+ start = buf.get_iter_at_mark(mark)
+ end = start.copy()
+
+ start.forward_chars(attr.start_index)
+ end.forward_chars(attr.end_index)
+
+ buf.apply_tag(tag, start, end)
+
+ def add_action(self, stock, callback, data=None):
+ image = Gtk.Image.new_from_stock(stock, Gtk.IconSize.MENU)
+ image.show()
+
+ image.commander_action_stock_item = (stock, Gtk.IconSize.MENU)
+
+ self._ensure_button_bar()
+
+ ev = Gtk.EventBox()
+ ev.set_visible_window(False)
+ ev.add(image)
+ ev.show()
- piter = ret[1].get_iterator()
+ self._button_bar.pack_end(ev, False, False, 0)
- while piter:
- attrs = piter.get_attrs()
- begin, end = piter.range()
+ ev.connect('button-press-event', self._on_action_activate, callback, data)
+ ev.connect('enter-notify-event', self._on_action_enter_notify)
+ ev.connect('leave-notify-event', self._on_action_leave_notify)
- tags = self.attrs_to_tags(attrs)
- buf.insert_with_tags(buf.get_end_iter(), text[begin:end], *tags)
+ ev.connect_after('destroy', self._on_action_destroy)
+ return ev
- if not piter.next():
- break
+ def clear(self):
+ self._text.get_buffer().set_text('')
- def toomany_lines(self):
+ def _has_too_many_lines(self):
buf = self._text.get_buffer()
piter = buf.get_start_iter()
num = 0
@@ -207,63 +226,43 @@ class Info(TransparentWindow):
while self._text.forward_display_line(piter):
num += 1
- if num > self.max_lines:
+ if num > self._max_lines:
return True
return False
- def contents_changed(self):
+ def _contents_changed(self):
buf = self._text.get_buffer()
- if self.toomany_lines() and (self._vw.get_policy()[1] != Gtk.PolicyType.ALWAYS):
+ too_many = self._has_too_many_lines()
+
+ if too_many and (self._vw.get_policy()[1] != Gtk.PolicyType.ALWAYS):
self._vw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.ALWAYS)
layout = self._text.create_pango_layout('Some text to measure')
extents = layout.get_pixel_extents()
- self._vw.set_min_content_height(extents[1].height * self.max_lines)
- elif not self.toomany_lines() and (self._vw.get_policy()[1] == Gtk.PolicyType.ALWAYS):
+ self._vw.set_min_content_height(extents[1].height * self._max_lines)
+ elif not too_many and (self._vw.get_policy()[1] == Gtk.PolicyType.ALWAYS):
self._vw.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER)
self._vw.set_min_content_height(0)
- if not self.toomany_lines():
+ if not too_many:
size = self.get_size()
self.resize(size[0], 1)
- def ensure_button_bar(self):
+ def _ensure_button_bar(self):
if not self._button_bar:
self._button_bar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=3)
self._button_bar.show()
- self._vbox.pack_start(self._button_bar, False, False, 0)
-
- def add_action(self, stock, callback, data=None):
- image = Gtk.Image.new_from_stock(stock, Gtk.IconSize.MENU)
- image.show()
-
- image.commander_action_stock_item = (stock, Gtk.IconSize.MENU)
-
- self.ensure_button_bar()
-
- ev = Gtk.EventBox()
- ev.set_visible_window(False)
- ev.add(image)
- ev.show()
+ self.pack_start(self._button_bar, False, False, 0)
- self._button_bar.pack_end(ev, False, False, 0)
-
- ev.connect('button-press-event', self.on_action_activate, callback, data)
- ev.connect('enter-notify-event', self.on_action_enter_notify)
- ev.connect('leave-notify-event', self.on_action_leave_notify)
-
- ev.connect_after('destroy', self.on_action_destroy)
- return ev
-
- def on_action_destroy(self, widget):
+ def _on_action_destroy(self, widget):
if self._button_bar and len(self._button_bar.get_children()) == 0:
self._button_bar.destroy()
self._button_bar = None
- def on_action_enter_notify(self, widget, evnt):
+ def _on_action_enter_notify(self, widget, evnt):
img = widget.get_child()
img.set_state(Gtk.StateType.PRELIGHT)
widget.get_window().set_cursor(Gdk.Cursor.new(Gdk.HAND2))
@@ -271,7 +270,7 @@ class Info(TransparentWindow):
pix = img.render_icon(*img.commander_action_stock_item)
img.set_from_pixbuf(pix)
- def on_action_leave_notify(self, widget, evnt):
+ def _on_action_leave_notify(self, widget, evnt):
img = widget.get_child()
img.set_state(Gtk.StateType.NORMAL)
widget.get_window().set_cursor(None)
@@ -279,80 +278,16 @@ class Info(TransparentWindow):
pix = img.render_icon(*img.commander_action_stock_item)
img.set_from_pixbuf(pix)
- def on_action_activate(self, widget, evnt, callback, data):
+ def _on_action_activate(self, widget, evnt, callback, data):
if data:
callback(data)
else:
callback()
- def clear(self):
- self._text.get_buffer().set_text('')
-
- def attach(self):
- vwwnd = self._entry._view.get_window(Gtk.TextWindowType.TEXT)
- origin = vwwnd.get_origin()
- geom = vwwnd.get_geometry()
-
- margin = 5
-
- self.realize()
-
- alloc = self.get_allocation()
-
- self.move(origin[1], origin[2] + geom[3] - alloc.height)
- self.resize(geom[2] - margin * 2, alloc.height)
-
- def on_text_insert_text(self, buf, piter, text, length):
- self.contents_changed()
-
- def on_text_delete_range(self, buf, start, end):
- self.contents_changed()
-
- def on_size_allocate(self, widget, allocation):
- vwwnd = self._entry.view().get_window(Gtk.TextWindowType.TEXT)
- origin = vwwnd.get_origin()
- geom = vwwnd.get_geometry()
-
- alloc = self.get_allocation()
-
- self.move(origin[1] + (geom[2] - alloc.width) / 2, origin[2] + geom[3] - alloc.height)
-
- def on_draw(self, widget, ct):
- color = self._entry.get_border_color()
-
- self.background_shape(ct, self.get_allocation())
-
- ct.set_source_rgba(color.red, color.green, color.blue, color.alpha)
- ct.stroke()
-
- return False
-
- def background_shape(self, ct, alloc):
- w = alloc.width
- h = alloc.height
-
- ct.set_line_width(1)
- radius = 10
-
- ct.move_to(0.5, h)
-
- if self.is_composited():
- ct.arc(radius + 0.5, radius + 0.5, radius, math.pi, math.pi * 1.5)
- ct.arc(w - radius - 0.5, radius + 0.5, radius, math.pi * 1.5, math.pi * 2)
- else:
- ct.line_to(0.5, 0)
- ct.line_to(w - 0.5, 0)
-
- ct.line_to(w - 0.5, h)
-
- @property
- def background_color(self):
- color = self._entry.get_background_color().copy()
- color.alpha = 0.9
-
- return color
+ def _on_text_insert_text(self, buf, piter, text, length):
+ self._contents_changed()
- def on_text_size_allocate(self, widget, alloc):
- pass
+ def _on_text_delete_range(self, buf, start, end):
+ self._contents_changed()
# vi:ex:ts=4:et
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]