Added support for a Terminator in fullscreen state.
This commit is contained in:
parent
c3e15fa084
commit
caa2650e05
89
terminator
89
terminator
|
@ -15,6 +15,16 @@
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
"""Terminator by Chris Jones <cmsj@tenshu.net>
|
||||||
|
|
||||||
|
Usage: terminator [OPTION] ...
|
||||||
|
-h, --help Show this usage information
|
||||||
|
-d, --debug Enable debugging
|
||||||
|
-m, --maximise Maximise the terminator window when it starts
|
||||||
|
-f, --fullscreen Place the window in its fullscreen state when it starts
|
||||||
|
-p, --profile=PROFILE Take settings from gnome-terminal profile PROFILE
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import sys
|
import sys
|
||||||
|
@ -356,19 +366,20 @@ class TerminatorTerm:
|
||||||
return self._box
|
return self._box
|
||||||
|
|
||||||
class Terminator:
|
class Terminator:
|
||||||
def __init__ (self, profile, maximise):
|
def __init__ (self, profile):
|
||||||
self.profile = profile
|
self.profile = profile
|
||||||
self.gconf_client = gconf.client_get_default ()
|
self.gconf_client = gconf.client_get_default ()
|
||||||
|
|
||||||
|
self._fullscreen = False
|
||||||
|
|
||||||
self.window = gtk.Window ()
|
self.window = gtk.Window ()
|
||||||
self.icon = self.window.render_icon (gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
|
self.icon = self.window.render_icon (gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
|
||||||
self.window.set_icon (self.icon)
|
self.window.set_icon (self.icon)
|
||||||
|
|
||||||
|
self.window.connect ("key-press-event", self.on_key_press)
|
||||||
self.window.connect ("delete_event", self.on_delete_event)
|
self.window.connect ("delete_event", self.on_delete_event)
|
||||||
self.window.connect ("destroy", self.on_destroy_event)
|
self.window.connect ("destroy", self.on_destroy_event)
|
||||||
|
|
||||||
if maximise:
|
|
||||||
self.window.maximize ()
|
|
||||||
|
|
||||||
self.window.set_property ('allow-shrink', True)
|
self.window.set_property ('allow-shrink', True)
|
||||||
|
|
||||||
# Start out with just one terminal
|
# Start out with just one terminal
|
||||||
|
@ -379,6 +390,21 @@ class Terminator:
|
||||||
self.window.add (term.get_box ())
|
self.window.add (term.get_box ())
|
||||||
self.window.show_all ()
|
self.window.show_all ()
|
||||||
|
|
||||||
|
def maximize (self):
|
||||||
|
""" Maximize the Terminator."""
|
||||||
|
self.window.maximize ()
|
||||||
|
|
||||||
|
def toggle_fullscreen (self):
|
||||||
|
""" Toggle the fullscreen state of the window. If it is in
|
||||||
|
fullscreen state, it will be unfullscreened. If it is not, it
|
||||||
|
will be set to fullscreen state.
|
||||||
|
"""
|
||||||
|
if self._fullscreen:
|
||||||
|
self.window.unfullscreen ()
|
||||||
|
else:
|
||||||
|
self.window.fullscreen ()
|
||||||
|
self._fullscreen = not self._fullscreen
|
||||||
|
|
||||||
def on_delete_event (self, widget, event, data=None):
|
def on_delete_event (self, widget, event, data=None):
|
||||||
if len (self.term_list) == 1:
|
if len (self.term_list) == 1:
|
||||||
return False
|
return False
|
||||||
|
@ -397,6 +423,19 @@ class Terminator:
|
||||||
def on_destroy_event (self, widget, data=None):
|
def on_destroy_event (self, widget, data=None):
|
||||||
gtk.main_quit ()
|
gtk.main_quit ()
|
||||||
|
|
||||||
|
def on_key_press (self, window, event):
|
||||||
|
""" Callback for the window to determine what to do with special
|
||||||
|
keys. Currently handled key-combo's:
|
||||||
|
* CTRL - SHIFT - F : toggle fullscreen state of the window.
|
||||||
|
"""
|
||||||
|
keyname = gtk.gdk.keyval_name (event.keyval)
|
||||||
|
mask = gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK
|
||||||
|
|
||||||
|
if (event.state & mask) == mask:
|
||||||
|
if keyname == 'F':
|
||||||
|
self.toggle_fullscreen ()
|
||||||
|
return (True)
|
||||||
|
|
||||||
def splitaxis (self, widget, vert=True):
|
def splitaxis (self, widget, vert=True):
|
||||||
term2 = TerminatorTerm (self, self.profile)
|
term2 = TerminatorTerm (self, self.profile)
|
||||||
|
|
||||||
|
@ -534,26 +573,29 @@ class Terminator:
|
||||||
self.term_list[previous]._vte.grab_focus ()
|
self.term_list[previous]._vte.grab_focus ()
|
||||||
|
|
||||||
def usage ():
|
def usage ():
|
||||||
print """Terminator by Chris Jones <cmsj@tenshu.net>
|
""" Print information on how to use this program. """
|
||||||
|
print __doc__
|
||||||
Usage: terminator [OPTION]...
|
|
||||||
-h, --help Show this usage information
|
|
||||||
-d, --debug Enable debugging
|
|
||||||
-m, --maximise Maximise the terminator window when it starts
|
|
||||||
-p, --profile=PROFILE Take settings from gnome-terminal profile PROFILE
|
|
||||||
"""
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
debug = 0
|
|
||||||
profile = "Default"
|
|
||||||
maximise = False
|
|
||||||
|
|
||||||
|
# define the options
|
||||||
|
short_opts = "hdmfp:"
|
||||||
|
long_opts = ["help", "debug", "maximise", "fullscreen", "profile="]
|
||||||
|
|
||||||
|
# parse the options
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt (sys.argv[1:], "hdmp:", ["help", "debug", "maximise", "profile="])
|
opts, args = getopt.getopt (sys.argv[1:], short_opts, long_opts)
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
usage ()
|
usage ()
|
||||||
sys.exit (2)
|
sys.exit (2)
|
||||||
|
|
||||||
|
# set some default values
|
||||||
|
debug = 0
|
||||||
|
profile = "Default"
|
||||||
|
maximise = False
|
||||||
|
fullscreen = False
|
||||||
|
|
||||||
|
# check the options
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt in ("-h", "--help"):
|
if opt in ("-h", "--help"):
|
||||||
usage ()
|
usage ()
|
||||||
|
@ -562,9 +604,20 @@ if __name__ == '__main__':
|
||||||
debug = 1
|
debug = 1
|
||||||
if opt in ("-m", "--maximise"):
|
if opt in ("-m", "--maximise"):
|
||||||
maximise = True
|
maximise = True
|
||||||
|
if opt in ("-f", "--fullscreen"):
|
||||||
|
fullscreen = True
|
||||||
if opt in ("-p", "--profile"):
|
if opt in ("-p", "--profile"):
|
||||||
profile = arg
|
profile = arg
|
||||||
|
|
||||||
term = Terminator (profile, maximise)
|
term = Terminator (profile)
|
||||||
|
|
||||||
|
# Set the Terminator in fullscreen state or maximize it.
|
||||||
|
# Fullscreen and maximise are mutually exclusive, with
|
||||||
|
# fullscreen taking precedence over maximise.
|
||||||
|
if fullscreen:
|
||||||
|
term.toggle_fullscreen ()
|
||||||
|
elif maximise:
|
||||||
|
term.maximize ()
|
||||||
|
|
||||||
gtk.main ()
|
gtk.main ()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue