Add some nice window icon setting abilities, plus I noticed a few options were missing from the manpage.
This commit is contained in:
parent
bc9539f187
commit
54b4223c4d
@ -63,6 +63,15 @@ Set a custom name (WM_CLASS) property on the window
|
||||
Start Terminator with a specific layout. The argument here is the name
|
||||
of a saved layout.
|
||||
.TP
|
||||
.B \-p, \-\-profile=PROFILE
|
||||
Use a different profile as the default
|
||||
.TP
|
||||
.B \-i, \-\-icon=FORCEDICON
|
||||
Set a custom icon for the window (by file or name)
|
||||
.TP
|
||||
.B \-u, \-\-no-dbus
|
||||
Disable DBus
|
||||
.TP
|
||||
.B \-d, \-\-debug
|
||||
Enable debugging output (please use this when reporting bugs). This
|
||||
can be specified twice to enable a built-in python debugging server.
|
||||
|
@ -71,6 +71,8 @@ custom name (WM_CLASS) property on the window'))
|
||||
parser.add_option('-l', '--layout', dest='layout', help=_('Select a layout'))
|
||||
parser.add_option('-p', '--profile', dest='profile', help=_('Use a \
|
||||
different profile as the default'))
|
||||
parser.add_option('-i', '--icon', dest='forcedicon', help=_('Set a custom \
|
||||
icon for the window (by file or name)'))
|
||||
parser.add_option('-u', '--no-dbus', action='store_true', dest='nodbus',
|
||||
help=_('Disable DBus'))
|
||||
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||
|
@ -60,7 +60,7 @@ class Window(Container, gtk.Window):
|
||||
self.register_signals(Window)
|
||||
|
||||
self.set_property('allow-shrink', True)
|
||||
self.apply_icon()
|
||||
icon_to_apply=''
|
||||
|
||||
self.register_callbacks()
|
||||
self.apply_config()
|
||||
@ -78,12 +78,16 @@ class Window(Container, gtk.Window):
|
||||
|
||||
if options.classname is not None:
|
||||
self.set_wmclass(options.classname, self.wmclass_class)
|
||||
|
||||
if options.forcedicon is not None:
|
||||
icon_to_apply = options.forcedicon
|
||||
|
||||
if options.geometry is not None:
|
||||
if not self.parse_geometry(options.geometry):
|
||||
err('Window::__init__: Unable to parse geometry: %s' %
|
||||
options.geometry)
|
||||
|
||||
self.apply_icon(icon_to_apply)
|
||||
self.pending_set_rough_geometry_hint = False
|
||||
|
||||
def do_get_property(self, prop):
|
||||
@ -158,15 +162,36 @@ class Window(Container, gtk.Window):
|
||||
else:
|
||||
self.set_iconified(hidden)
|
||||
|
||||
def apply_icon(self):
|
||||
def apply_icon(self, requested_icon):
|
||||
"""Set the window icon"""
|
||||
icon_theme = gtk.IconTheme()
|
||||
|
||||
try:
|
||||
icon = icon_theme.load_icon(APP_NAME, 48, 0)
|
||||
except (NameError, gobject.GError):
|
||||
dbg('Unable to load 48px Terminator icon')
|
||||
icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
|
||||
icon = None
|
||||
|
||||
if requested_icon:
|
||||
try:
|
||||
self.set_icon_from_file(requested_icon)
|
||||
icon = self.get_icon()
|
||||
except (NameError, gobject.GError):
|
||||
dbg('Unable to load 48px %s icon as file' % (repr(requested_icon)))
|
||||
|
||||
if requested_icon and icon is None:
|
||||
try:
|
||||
icon = icon_theme.load_icon(requested_icon, 48, 0)
|
||||
except (NameError, gobject.GError):
|
||||
dbg('Unable to load 48px %s icon' % (repr(requested_icon)))
|
||||
|
||||
if icon is None:
|
||||
try:
|
||||
icon = icon_theme.load_icon(self.wmclass_name, 48, 0)
|
||||
except (NameError, gobject.GError):
|
||||
dbg('Unable to load 48px %s icon' % (self.wmclass_name))
|
||||
|
||||
if icon is None:
|
||||
try:
|
||||
icon = icon_theme.load_icon(APP_NAME, 48, 0)
|
||||
except (NameError, gobject.GError):
|
||||
dbg('Unable to load 48px Terminator icon')
|
||||
icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
|
||||
|
||||
self.set_icon(icon)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user