Reimplement visual flash that got removed from libvte, reusing the DnD overlay to flash the terminal (gtk2->gtk3)
This commit is contained in:
parent
09faf868c9
commit
4269a99598
|
@ -198,6 +198,7 @@ DEFAULTS = {
|
|||
'default': {
|
||||
'allow_bold' : True,
|
||||
'audible_bell' : False,
|
||||
'visible_bell' : False,
|
||||
'urgent_bell' : False,
|
||||
'icon_bell' : True,
|
||||
'background_color' : '#000000',
|
||||
|
|
|
@ -1806,6 +1806,23 @@
|
|||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="visual_bell_checkbutton">
|
||||
<property name="label" translatable="yes">Visual flash</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">False</property>
|
||||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="draw_indicator">True</property>
|
||||
<signal name="toggled" handler="on_visual_bell_checkbutton_toggled" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="audible_bell_checkbutton">
|
||||
<property name="label" translatable="yes">Audible beep</property>
|
||||
|
@ -1820,7 +1837,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
|
@ -1837,7 +1854,7 @@
|
|||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">2</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -406,6 +406,9 @@ class PrefsEditor:
|
|||
# Icon terminal bell
|
||||
widget = guiget('icon_bell_checkbutton')
|
||||
widget.set_active(self.config['icon_bell'])
|
||||
# Visual terminal bell
|
||||
widget = guiget('visual_bell_checkbutton')
|
||||
widget.set_active(self.config['visible_bell'])
|
||||
# Audible terminal bell
|
||||
widget = guiget('audible_bell_checkbutton')
|
||||
widget.set_active(self.config['audible_bell'])
|
||||
|
@ -703,6 +706,11 @@ class PrefsEditor:
|
|||
self.config['icon_bell'] = widget.get_active()
|
||||
self.config.save()
|
||||
|
||||
def on_visual_bell_checkbutton_toggled(self, widget):
|
||||
"""Visual bell setting changed"""
|
||||
self.config['visible_bell'] = widget.get_active()
|
||||
self.config.save()
|
||||
|
||||
def on_audible_bell_checkbutton_toggled(self, widget):
|
||||
"""Audible bell setting changed"""
|
||||
self.config['audible_bell'] = widget.get_active()
|
||||
|
|
|
@ -744,7 +744,8 @@ class Terminal(Gtk.VBox):
|
|||
self.vte.set_audible_bell(self.config['audible_bell'])
|
||||
self.cnxids.remove_signal(self.vte, 'bell')
|
||||
if self.config['urgent_bell'] == True or \
|
||||
self.config['icon_bell'] == True:
|
||||
self.config['icon_bell'] == True or \
|
||||
self.config['visible_bell'] == True:
|
||||
try:
|
||||
self.cnxids.new(self.vte, 'bell', self.on_bell)
|
||||
except TypeError:
|
||||
|
@ -1515,13 +1516,43 @@ class Terminal(Gtk.VBox):
|
|||
return((self.vte.get_column_count(), self.vte.get_row_count()))
|
||||
|
||||
def on_bell(self, widget):
|
||||
"""Set the urgency hint for our window"""
|
||||
"""Set the urgency hint/icon/flash for our window"""
|
||||
if self.config['urgent_bell'] == True:
|
||||
window = self.get_toplevel()
|
||||
if window.is_toplevel():
|
||||
window.set_urgency_hint(True)
|
||||
if self.config['icon_bell'] == True:
|
||||
self.titlebar.icon_bell()
|
||||
if self.config['visible_bell'] == True:
|
||||
# Repurposed the code used for drag and drop overlay to provide a visual terminal flash
|
||||
alloc = widget.get_allocation()
|
||||
|
||||
if self.config['use_theme_colors']:
|
||||
color = self.vte.get_style_context().get_color(Gtk.StateType.NORMAL) # VERIFY FOR GTK3 as above
|
||||
else:
|
||||
color = Gdk.RGBA()
|
||||
color.parse(self.config['foreground_color']) # VERIFY FOR GTK3
|
||||
|
||||
coord = ( (0, 0), (alloc.width, 0), (alloc.width, alloc.height), (0, alloc.height))
|
||||
|
||||
#here, we define some widget internal values
|
||||
widget._draw_data = { 'color': color, 'coord' : coord }
|
||||
#redraw by forcing an event
|
||||
connec = widget.connect_after('draw', self.on_draw)
|
||||
widget.queue_draw_area(0, 0, alloc.width, alloc.height)
|
||||
widget.get_window().process_updates(True)
|
||||
#finaly reset the values
|
||||
widget.disconnect(connec)
|
||||
widget._draw_data = None
|
||||
|
||||
# Add timeout to clean up display
|
||||
GObject.timeout_add(100, self.on_bell_cleanup, widget, alloc)
|
||||
|
||||
def on_bell_cleanup(self, widget, alloc):
|
||||
'''Queue a redraw to clear the visual flash overlay'''
|
||||
widget.queue_draw_area(0, 0, alloc.width, alloc.height)
|
||||
widget.get_window().process_updates(True)
|
||||
return False
|
||||
|
||||
def describe_layout(self, count, parent, global_layout, child_order):
|
||||
"""Describe our layout"""
|
||||
|
|
Loading…
Reference in New Issue