-
Notifications
You must be signed in to change notification settings - Fork 2
/
close-on-hide.py
44 lines (36 loc) · 1.55 KB
/
close-on-hide.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- Mode: python; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; -*-
#
# Copyright (C) 2014 - fossfreedom
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of thie GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
from gi.repository import GObject, Peas, Gtk
class CloseOnHide(GObject.Object, Peas.Activatable):
object = GObject.property(type=GObject.GObject)
def __init__(self):
super(CloseOnHide, self).__init__()
def do_activate(self):
self.window = self.object.get_property("window")
self.handler_id = self.window.connect("hide", self.hide_event_cb)
self.shell = self.object
def do_deactivate(self):
self.window.show()
self.window.disconnect(self.handler_id)
def hide_event_cb(self, widget):
player = self.shell.props.shell_player
if player.get_playing():
player.stop()
self.window.emit('delete-event', None)
return False
return True