Merge Peter B. Jørgensen's branch improving dropdown behaviours/features

This commit is contained in:
Chris Jones 2010-10-15 12:57:30 +01:00
commit 2e94df2033
5 changed files with 215 additions and 11 deletions

View File

@ -86,6 +86,10 @@ DEFAULTS = {
'close_button_on_tab' : True,
'hide_tabbar' : False,
'scroll_tabbar' : False,
'hide_from_taskbar' : False,
'always_on_top' : False,
'hide_on_lose_focus' : False,
'sticky' : False,
'try_posix_regexp' : platform.system() != 'Linux',
'title_transmit_fg_color' : '#ffffff',
'title_transmit_bg_color' : '#c80003',

View File

@ -298,7 +298,7 @@
<child>
<object class="GtkTable" id="global_config_table">
<property name="visible">True</property>
<property name="n_rows">7</property>
<property name="n_rows">11</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<child>
@ -491,6 +491,126 @@
</child>
<child>
<object class="GtkLabel" id="label24">
<property name="visible">True</property>
<property name="label" translatable="yes">Hide from taskbar</property>
</object>
<packing>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hidefromtaskbcheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_hidefromtaskbcheck_toggled"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">7</property>
<property name="bottom_attach">8</property>
<property name="x_options"></property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label25">
<property name="visible">True</property>
<property name="label" translatable="yes">Always on top</property>
</object>
<packing>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label26">
<property name="visible">True</property>
<property name="label" translatable="yes">Hide on lose focus</property>
</object>
<packing>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="alwaysontopcheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_alwaysontopcheck_toggled"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">8</property>
<property name="bottom_attach">9</property>
<property name="x_options"></property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="hideonlosefocuscheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_hideonlosefocuscheck_toggled"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">9</property>
<property name="bottom_attach">10</property>
<property name="x_options"></property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label27">
<property name="visible">True</property>
<property name="label" translatable="yes">Show on all workspaces</property>
</object>
<packing>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="stickycheck">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
<signal name="toggled" handler="on_stickycheck_toggled"/>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">10</property>
<property name="bottom_attach">11</property>
<property name="x_options"></property>
<property name="y_options">GTK_EXPAND</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label28">
<property name="visible">True</property>
<property name="label" translatable="yes">DBus server</property>
</object>

View File

@ -218,6 +218,18 @@ class PrefsEditor:
# DBus Server
widget = guiget('dbuscheck')
widget.set_active(self.config['dbus'])
#Hide from taskbar
widget = guiget('hidefromtaskbcheck')
widget.set_active(self.config['hide_from_taskbar'])
#Always on top
widget = guiget('alwaysontopcheck')
widget.set_active(self.config['always_on_top'])
#Hide on lose focus
widget = guiget('hideonlosefocuscheck')
widget.set_active(self.config['hide_on_lose_focus'])
#Show on all workspaces
widget = guiget('stickycheck')
widget.set_active(self.config['sticky'])
## Profile tab
# Populate the profile list
@ -551,6 +563,26 @@ class PrefsEditor:
self.config['borderless'] = not widget.get_active()
self.config.save()
def on_hidefromtaskbcheck_toggled(self, widget):
"""Hide from taskbar setting changed"""
self.config['hide_from_taskbar'] = widget.get_active()
self.config.save()
def on_alwaysontopcheck_toggled(self, widget):
"""Always on top setting changed"""
self.config['always_on_top'] = widget.get_active()
self.config.save()
def on_hideonlosefocuscheck_toggled(self, widget):
"""Hide on lose focus setting changed"""
self.config['hide_on_lose_focus'] = widget.get_active()
self.config.save()
def on_stickycheck_toggled(self, widget):
"""Sticky setting changed"""
self.config['sticky'] = widget.get_active()
self.config.save()
def on_allow_bold_checkbutton_toggled(self, widget):
"""Allow bold setting changed"""
self.config['allow_bold'] = widget.get_active()

View File

@ -147,7 +147,7 @@ class Terminator(Borg):
if cwd:
terminal.set_cwd(cwd)
window.add(terminal)
window.show()
window.show(True)
terminal.spawn_child()
return(window, terminal)

View File

@ -4,6 +4,7 @@
"""window.py - class for the main Terminator window"""
import copy
import time
import pygtk
pygtk.require('2.0')
import gobject
@ -33,6 +34,9 @@ class Window(Container, gtk.Window):
ismaximised = None
hidebound = None
hidefunc = None
losefocus_time = 0
position = None
ignore_startup_show = None
zoom_data = None
@ -123,6 +127,9 @@ class Window(Container, gtk.Window):
fullscreen = self.config['window_state'] == 'fullscreen'
hidden = self.config['window_state'] == 'hidden'
borderless = self.config['borderless']
skiptaskbar = self.config['hide_from_taskbar']
alwaysontop = self.config['always_on_top']
sticky = self.config['sticky']
if options:
if options.maximise:
@ -137,9 +144,12 @@ class Window(Container, gtk.Window):
self.set_fullscreen(fullscreen)
self.set_maximised(maximise)
self.set_borderless(borderless)
self.set_always_on_top(alwaysontop)
self.set_real_transparency()
self.set_sticky(sticky)
if self.hidebound:
self.set_hidden(hidden)
self.set_skip_taskbar_hint(skiptaskbar)
else:
self.set_iconified(hidden)
@ -189,6 +199,11 @@ class Window(Container, gtk.Window):
for terminal in self.get_visible_terminals():
terminal.on_window_focus_out()
self.losefocus_time = time.time()
if self.config['hide_on_lose_focus'] and self.get_property('visible'):
self.position = self.get_position()
self.hidefunc()
def on_focus_in(self, window, event):
"""Focus has entered the window"""
self.set_urgency_hint(False)
@ -245,8 +260,19 @@ class Window(Container, gtk.Window):
def on_hide_window(self, data=None):
"""Handle a request to hide/show the window"""
# FIXME: Implement or drop, or explain why its empty
pass
if not self.get_property('visible'):
#Don't show if window has just been hidden because of
#lost focus
if (time.time() - self.losefocus_time < 0.1) and \
self.config['hide_on_lose_focus']:
return
if self.position:
self.move(self.position[0], self.position[1])
self.show()
else:
self.position = self.get_position()
self.hidefunc()
# pylint: disable-msg=W0613
def on_window_state_changed(self, window, event):
@ -255,8 +281,8 @@ class Window(Container, gtk.Window):
gtk.gdk.WINDOW_STATE_FULLSCREEN)
self.ismaximised = bool(event.new_window_state &
gtk.gdk.WINDOW_STATE_MAXIMIZED)
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s' %
(self.isfullscreen, self.ismaximised))
dbg('Window::on_window_state_changed: fullscreen=%s, maximised=%s' \
% (self.isfullscreen, self.ismaximised))
return(False)
@ -280,13 +306,24 @@ class Window(Container, gtk.Window):
def set_hidden(self, value):
"""Set the visibility of the window from the supplied value"""
# FIXME: Implement or drop this
pass
if value == True:
self.ignore_startup_show = True
else:
self.ignore_startup_show = False
def set_iconified(self, value):
"""Set the minimised state of the window from the value"""
# FIXME: Implement or drop this
pass
"""Set the minimised state of the window from the supplied value"""
if value == True:
self.iconify()
def set_always_on_top(self, value):
"""Set the always on top window hint from the supplied value"""
self.set_keep_above(value)
def set_sticky(self, value):
"""Set the sticky hint from the supplied value"""
if value == True:
self.stick()
def set_real_transparency(self, value=True):
"""Enable RGBA if supported on the current screen"""
@ -303,6 +340,17 @@ class Window(Container, gtk.Window):
if colormap:
self.set_colormap(colormap)
def show(self, startup=False):
"""Undo the startup show request if started in hidden mode"""
gtk.Window.show(self)
#Present is necessary to grab focus when window is hidden from taskbar
self.present()
#Window must be shown, then hidden for the hotkeys to be registered
if (self.ignore_startup_show and startup == True):
self.hide()
def add(self, widget):
"""Add a widget to the window by way of gtk.Window.add()"""