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
|
Start Terminator with a specific layout. The argument here is the name
|
||||||
of a saved layout.
|
of a saved layout.
|
||||||
.TP
|
.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
|
.B \-d, \-\-debug
|
||||||
Enable debugging output (please use this when reporting bugs). This
|
Enable debugging output (please use this when reporting bugs). This
|
||||||
can be specified twice to enable a built-in python debugging server.
|
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('-l', '--layout', dest='layout', help=_('Select a layout'))
|
||||||
parser.add_option('-p', '--profile', dest='profile', help=_('Use a \
|
parser.add_option('-p', '--profile', dest='profile', help=_('Use a \
|
||||||
different profile as the default'))
|
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',
|
parser.add_option('-u', '--no-dbus', action='store_true', dest='nodbus',
|
||||||
help=_('Disable DBus'))
|
help=_('Disable DBus'))
|
||||||
parser.add_option('-d', '--debug', action='count', dest='debug',
|
parser.add_option('-d', '--debug', action='count', dest='debug',
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Window(Container, gtk.Window):
|
||||||
self.register_signals(Window)
|
self.register_signals(Window)
|
||||||
|
|
||||||
self.set_property('allow-shrink', True)
|
self.set_property('allow-shrink', True)
|
||||||
self.apply_icon()
|
icon_to_apply=''
|
||||||
|
|
||||||
self.register_callbacks()
|
self.register_callbacks()
|
||||||
self.apply_config()
|
self.apply_config()
|
||||||
|
@ -78,12 +78,16 @@ class Window(Container, gtk.Window):
|
||||||
|
|
||||||
if options.classname is not None:
|
if options.classname is not None:
|
||||||
self.set_wmclass(options.classname, self.wmclass_class)
|
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 options.geometry is not None:
|
||||||
if not self.parse_geometry(options.geometry):
|
if not self.parse_geometry(options.geometry):
|
||||||
err('Window::__init__: Unable to parse geometry: %s' %
|
err('Window::__init__: Unable to parse geometry: %s' %
|
||||||
options.geometry)
|
options.geometry)
|
||||||
|
|
||||||
|
self.apply_icon(icon_to_apply)
|
||||||
self.pending_set_rough_geometry_hint = False
|
self.pending_set_rough_geometry_hint = False
|
||||||
|
|
||||||
def do_get_property(self, prop):
|
def do_get_property(self, prop):
|
||||||
|
@ -158,15 +162,36 @@ class Window(Container, gtk.Window):
|
||||||
else:
|
else:
|
||||||
self.set_iconified(hidden)
|
self.set_iconified(hidden)
|
||||||
|
|
||||||
def apply_icon(self):
|
def apply_icon(self, requested_icon):
|
||||||
"""Set the window icon"""
|
"""Set the window icon"""
|
||||||
icon_theme = gtk.IconTheme()
|
icon_theme = gtk.IconTheme()
|
||||||
|
icon = None
|
||||||
try:
|
|
||||||
icon = icon_theme.load_icon(APP_NAME, 48, 0)
|
if requested_icon:
|
||||||
except (NameError, gobject.GError):
|
try:
|
||||||
dbg('Unable to load 48px Terminator icon')
|
self.set_icon_from_file(requested_icon)
|
||||||
icon = self.render_icon(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_BUTTON)
|
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)
|
self.set_icon(icon)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue