/
gpodder-gtk-osx-application.diff
109 lines (98 loc) · 3.85 KB
/
gpodder-gtk-osx-application.diff
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
--- master/src/gpodder/gtkui/main.py 2011-11-15 19:23:04.000000000 +0100
+++ me/src/gpodder/gtkui/main.py 2011-11-15 19:29:18.000000000 +0100
@@ -35,7 +35,6 @@
import urllib
import cgi
-
import gpodder
import dbus
@@ -85,6 +84,18 @@
from gpodder.dbusproxy import DBusPodcastsProxy
from gpodder import hooks
+
+macapp = None
+if gpodder.osx and getattr(gtk.gdk, 'WINDOWING', 'x11') == 'quartz':
+ try:
+ from gtk_osxapplication import *
+ macapp = OSXApplication()
+ except ImportError:
+ print >> sys.stderr, """
+ Warning: gtk-mac-integration not found, disabling native menus
+ """
+
+
class gPodder(BuilderWidget, dbus.service.Object):
# Delay until live search is started after typing stop
LIVE_SEARCH_DELAY = 500
@@ -134,28 +145,21 @@
# Mac OS X-specific UI tweaks: Native main menu integration
# http://sourceforge.net/apps/trac/gtk-osx/wiki/Integrate
- if getattr(gtk.gdk, 'WINDOWING', 'x11') == 'quartz':
- try:
- import igemacintegration as igemi
-
- # Move the menu bar from the window to the Mac menu bar
- self.mainMenu.hide()
- igemi.ige_mac_menu_set_menu_bar(self.mainMenu)
-
- # Reparent some items to the "Application" menu
- for widget in ('/mainMenu/menuHelp/itemAbout', \
- '/mainMenu/menuPodcasts/itemPreferences'):
- item = self.uimanager1.get_widget(widget)
- group = igemi.ige_mac_menu_add_app_menu_group()
- igemi.ige_mac_menu_add_app_menu_item(group, item, None)
-
- quit_widget = '/mainMenu/menuPodcasts/itemQuit'
- quit_item = self.uimanager1.get_widget(quit_widget)
- igemi.ige_mac_menu_set_quit_menu_item(quit_item)
- except ImportError:
- print >>sys.stderr, """
- Warning: ige-mac-integration not found - no native menus.
- """
+ if macapp is not None:
+ # Move the menu bar from the window to the Mac menu bar
+ self.mainMenu.hide()
+ macapp.set_menu_bar(self.mainMenu)
+
+ # Reparent some items to the "Application" menu
+ item = self.uimanager1.get_widget('/mainMenu/menuHelp/itemAbout')
+ macapp.insert_app_menu_item(item, 0)
+ macapp.insert_app_menu_item(gtk.SeparatorMenuItem(), 1)
+ item = self.uimanager1.get_widget('/mainMenu/menuPodcasts/itemPreferences')
+ macapp.insert_app_menu_item(item, 2)
+
+ quit_item = self.uimanager1.get_widget('/mainMenu/menuPodcasts/itemQuit')
+ quit_item.hide()
+ # end Mac OS X specific UI tweaks
self.download_status_model = DownloadStatusModel()
self.download_queue_manager = download.DownloadQueueManager(self.config)
@@ -2445,6 +2449,13 @@
self.close_gpodder()
return True
+
+ def quit_cb(self, macapp):
+ """Called when OSX wants to quit the app (Cmd-Q or gPodder > Quit)
+ """
+ # event can't really be cancelled : crash when it's done
+ self.close_gpodder()
+ return False
def close_gpodder(self):
""" clean everything and exit properly
@@ -2460,7 +2471,6 @@
self.core.shutdown()
self.quit()
- sys.exit(0)
def get_expired_episodes(self):
for channel in self.channels:
@@ -3362,9 +3372,12 @@
# mac OS X stuff :
# handle "subscribe to podcast" events from firefox
- if platform.system() == 'Darwin':
+ if gpodder.osx:
from gpodder.gtkui import macosx
macosx.register_handlers(gp)
+ if macapp is not None:
+ macapp.connect("NSApplicationBlockTermination", gp.quit_cb)
+ macapp.ready()
# end mac OS X stuff
gp.run()