~ubuntu-branches/debian/wheezy/playonlinux/wheezy

« back to all changes in this revision

Viewing changes to python/mainwindow.py

  • Committer: Bazaar Package Importer
  • Author(s): Bertrand Marc
  • Date: 2011-09-17 11:14:44 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110917111444-b02ft5g75aljjkrp
Tags: 4.0.12-1
* New upstream release (Closes: #639558).
* Remove patches/license.diff, not necessary any more.
* debian/rules: remove permission fixing.
* debian/rules: add build-arch and build-indep.
* Migrate to dh_python2.
* debian/patches: disable update alert on new release
  (Closes: #639463).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
 
4
 
# Copyright (C) 2007-2010 PlayOnLinux Team
5
4
# Copyright (C) 2008 Pâris Quentin
6
 
# Copyright (C) 2009 Łukasz Wojniłowicz
7
5
 
8
6
# This program is free software; you can redistribute it and/or modify
9
7
# it under the terms of the GNU General Public License as published by
18
16
# You should have received a copy of the GNU General Public License along
19
17
# with this program; if not, write to the Free Software Foundation, Inc.,
20
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
21
 
 
22
 
 
23
 
import wxversion
24
 
wxversion.select("2.8")
25
 
import wx, wx.html, webbrowser
26
 
import gettext, os, getopt, sys, urllib, signal, socket, string, time, threading
 
19
encoding = 'utf-8'
 
20
 
 
21
import os, getopt, sys, urllib, signal, string, time, webbrowser, gettext, locale, sys, shutil
 
22
#locale.setlocale(locale.CODESET,'fr_FR.utf8')
 
23
 
 
24
#try:
 
25
#       locale.getlocale()
 
26
#except:
 
27
#       os.environ["LANG"] = "en_US.utf-8"
 
28
#locale.setlocale(locale.LC_ALL, '.utf-8')
 
29
 
 
30
import wx
 
31
        
27
32
import lib.Variables as Variables, lib.lng as lng
28
 
 
29
 
 
 
33
import lib.playonlinux as playonlinux
 
34
import guiv3 as gui, install, options, wine_versions as wver, sp, configure, threading
 
35
import irc as ircgui
 
36
class POLWeb(threading.Thread):
 
37
        def __init__(self):
 
38
                threading.Thread.__init__(self)
 
39
                self.sendToStatusBarStr = ""
 
40
                self.sendAlertStr = None
 
41
                self.Gauge = False
 
42
                self.WebVersion = ""
 
43
                self.Show = False
 
44
                
 
45
        def sendToStatusBar(self, message, gauge):
 
46
                self.sendToStatusBarStr = message
 
47
                self.Gauge = gauge
 
48
                self.Show = True
 
49
 
 
50
        def sendAlert(self, message):
 
51
                self.sendAlertStr = message
 
52
                        
 
53
        def LastVersion(self):
 
54
                if(os.environ["POL_OS"] == "Mac"):
 
55
                        fichier_online="version_mac"
 
56
                else:
 
57
                        fichier_online="version2"
 
58
                return os.popen('wget -q "$SITE/'+fichier_online+'.php?v=$VERSION" -T 10 -O-','r').read()
 
59
        
 
60
        def real_check(self):
 
61
                self.WebVersion = self.LastVersion()
 
62
                
 
63
                if(self.WebVersion == ""):
 
64
                        self.sendToStatusBar(_('{0} website is unavailable. Please check your connexion').format(os.environ["APPLICATION_TITLE"]), False)
 
65
                else:
 
66
                        self.sendToStatusBar(_("Refreshing {0}").format(os.environ["APPLICATION_TITLE"]), True)
 
67
                        os.system("bash \""+Variables.playonlinux_env+"/bash/pol_update_list\"")
 
68
                
 
69
                        if(playonlinux.convertVersionToInt(os.environ["VERSION"]) < playonlinux.convertVersionToInt(self.WebVersion)):
 
70
                                self.sendToStatusBar(_('An updated version of {0} is available').format(os.environ["APPLICATION_TITLE"])+" ("+self.WebVersion+")",False)
 
71
                                #self.sendAlert(_('An updated version of {0} is available').format(os.environ["APPLICATION_TITLE"])+" ("+self.WebVersion+")")
 
72
                        else:
 
73
                                self.Show = False
 
74
                
 
75
                self.wantcheck = False
 
76
                        
 
77
        def check(self):
 
78
                self.wantcheck = True   
 
79
                        
 
80
        def run(self):
 
81
                self.check()
 
82
                while(1):
 
83
                        if(self.wantcheck == True):
 
84
                                self.real_check()
 
85
                        time.sleep(1)
 
86
                
 
87
 
 
88
                    
30
89
class MainWindow(wx.Frame):
31
90
  def __init__(self,parent,id,title):
32
 
    wx.Frame.__init__(self, parent, -1, title, size = (600, 565))
33
 
    self.SetIcon(wx.Icon(Variables.playonlinux_env+"/etc/playonlinux.png", wx.BITMAP_TYPE_ANY))
34
 
    self.timer = wx.Timer(self, 1)
35
 
 
36
 
 
37
 
    self.images = wx.ImageList(32, 32)
38
 
   
39
 
    if(len(sys.argv) > 1):
40
 
                self.panel_games = wx.Panel(self, -1)
41
 
                self.panel_update = wx.Panel(self.panel_games, -1)
42
 
                #self.panel_update.SetBackgroundColour((255,255,225))
43
 
 
44
 
                self.fontText = wx.Font(10, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD,False, "", wx.FONTENCODING_DEFAULT)
45
 
                #argv[1] = 1 nvversion -- argv[2] = version
46
 
                #argv[1] = 2 no net
47
 
                #argv[1] = 3 version de dev
48
 
                #argv[1] = 4 unofficial website used
49
 
                if(int(sys.argv[1]) == 1):
50
 
                        self.image_logo = wx.StaticBitmap(self.panel_update, -1, wx.ArtProvider.GetBitmap("gtk-refresh", wx.ART_MENU), pos=(15,0))
51
 
                        self.texte_update = wx.StaticText(self.panel_update, -1, _("An updated version of PlayOnLinux is available.")+" ("+sys.argv[2]+")",pos=(35,0))
52
 
                elif(int(sys.argv[1]) == 2):
53
 
                        self.image_logo = wx.StaticBitmap(self.panel_update, -1, wx.ArtProvider.GetBitmap("gtk-dialog-warning", wx.ART_MENU), pos=(15,0))
54
 
                        self.texte_update = wx.StaticText(self.panel_update, -1, _("You do not seem to be connected to the Internet."),pos=(35,0))
55
 
                        self.texte_update.SetForegroundColour("red")
56
 
                elif(int(sys.argv[1]) == 3):
57
 
                        self.image_logo = wx.StaticBitmap(self.panel_update, -1, wx.ArtProvider.GetBitmap("gtk-dialog-warning", wx.ART_MENU), pos=(15,0))
58
 
                        self.texte_update = wx.StaticText(self.panel_update, -1, _("Your are using a development version, be careful."),pos=(35,0))
59
 
                        self.texte_update.SetForegroundColour("orange")
60
 
                elif(int(sys.argv[1]) == 4):
61
 
                        self.image_logo = wx.StaticBitmap(self.panel_update, -1, wx.ArtProvider.GetBitmap("gtk-dialog-warning", wx.ART_MENU), pos=(15,0))
62
 
                        self.texte_update = wx.StaticText(self.panel_update, -1, _("You seem to be using the Offline PlayOnLinux plugin."),pos=(35,0))
63
 
                        self.texte_update.SetForegroundColour("green")
64
 
                else:
65
 
                        self.image_logo = wx.StaticBitmap(self.panel_update, -1, wx.ArtProvider.GetBitmap("gtk-dialog-error", wx.ART_MENU), pos=(15,0))
66
 
                        self.texte_update = wx.StaticText(self.panel_update, -1, _("Internal error when starting GUI. Please file a bug report ASAP!"),pos=(35,0))
67
 
                        
68
 
                self.texte_update.SetFont(self.fontText)
69
 
                self.list_game = wx.TreeCtrl(self.panel_games, 105, style=wx.TR_HIDE_ROOT|wx.TR_FULL_ROW_HIGHLIGHT)
70
 
 
71
 
                self.sizer_games = wx.BoxSizer(wx.VERTICAL)
72
 
                self.sizer_games.Add(self.panel_update, 1, wx.EXPAND|wx.ALL, 2)
73
 
                self.sizer_games.Add(self.list_game, 20, wx.EXPAND|wx.ALL, 2)
74
 
        
75
 
                self.panel_games.SetSizer(self.sizer_games)
76
 
                self.panel_games.SetAutoLayout(True)
77
 
 
78
 
    else :
79
 
                self.list_game = wx.TreeCtrl(self, 105, style=wx.TR_HIDE_ROOT|wx.TR_FULL_ROW_HIGHLIGHT) 
80
 
 
81
 
    self.list_game.SetSpacing(0);
82
 
    self.list_game.SetImageList(self.images)
83
 
 
84
 
 
85
 
    self.oldreload = ""
86
 
    self.oldimg = ""
87
 
 
88
 
    self.filemenu = wx.Menu()
89
 
    self.filemenu.Append(wx.ID_OPEN, _("Run"))
90
 
    self.filemenu.Append(wx.ID_ADD, _("Install"))
91
 
    self.filemenu.Append(wx.ID_DELETE, _("Remove"))
92
 
    self.filemenu.Append(wx.ID_REFRESH, _("Refresh the repository"))
93
 
    self.filemenu.AppendSeparator()
94
 
    self.filemenu.Append(wx.ID_EXIT, _("Exit"))
95
 
 
96
 
    self.expertmenu = wx.Menu()
97
 
 
98
 
 
99
 
    self.winever_item = wx.MenuItem(self.expertmenu, 107, _("Manage Wine versions"))
100
 
    self.winever_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/wine.png"))
101
 
    self.expertmenu.AppendItem(self.winever_item)
102
 
 
103
 
    #self.wineserv_item = wx.MenuItem(self.expertmenu, 115, _("Kill wineserver process"))
104
 
    #self.wineserv_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/wineserver.png"))
105
 
    #self.expertmenu.AppendItem(self.wineserv_item)
106
 
 
107
 
    self.run_item = wx.MenuItem(self.expertmenu, 108, _("Run a local script"))
108
 
    self.run_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/run.png"))
109
 
    self.expertmenu.AppendItem(self.run_item)
110
 
 
111
 
    self.polshell_item = wx.MenuItem(self.expertmenu, 109, _("PlayOnLinux debugger"))
112
 
    self.polshell_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/polshell.png"))
113
 
    self.expertmenu.AppendItem(self.polshell_item)
114
 
 
115
 
    self.cdrom_item = wx.MenuItem(self.expertmenu, 120, _("Autorun"))
116
 
    self.cdrom_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/cdrom.png"))
117
 
    self.expertmenu.AppendItem(self.cdrom_item)
118
 
 
119
 
    self.optionmenu = wx.Menu()
120
 
 
121
 
    self.option_item = wx.MenuItem(self.expertmenu, 210, _("General"))
122
 
    self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/input-gaming.png"))
123
 
    self.optionmenu.AppendItem(self.option_item)
124
 
 
125
 
    self.option_item = wx.MenuItem(self.expertmenu, 211, _("Internet"))
126
 
    self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/internet-web-browser.png"))
127
 
    self.optionmenu.AppendItem(self.option_item)
128
 
 
129
 
    self.option_item = wx.MenuItem(self.expertmenu, 212, _("Environment"))
130
 
    self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/user-desktop.png"))
131
 
    self.optionmenu.AppendItem(self.option_item)
132
 
 
133
 
    self.option_item = wx.MenuItem(self.expertmenu, 213, _("System"))
134
 
    self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/application-x-executable.png"))
135
 
    self.optionmenu.AppendItem(self.option_item)
136
 
 
137
 
    self.option_item = wx.MenuItem(self.expertmenu, 214, _("Plugins"))
138
 
    self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/package-x-generic.png"))
139
 
    self.optionmenu.AppendItem(self.option_item)
140
 
 
141
 
    self.pluginsmenu = wx.Menu()
142
 
 
143
 
    files=os.listdir(Variables.playonlinux_rep+"/plugins")
144
 
    files.sort()
145
 
    self.plugin_list = []
146
 
    self.i = 0
147
 
    self.j = 0
148
 
    while(self.i < len(files)):
149
 
        if(os.path.exists(Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/scripts/menu")):
150
 
                if(os.path.exists(Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/enabled")):
151
 
                        self.plugin_item = wx.MenuItem(self.expertmenu, 300+self.j, files[self.i])
152
 
 
153
 
                        self.icon_look_for = Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/icon"
154
 
                        if(os.path.exists(self.icon_look_for)):
155
 
                                self.bitmap = wx.Bitmap(self.icon_look_for)
156
 
                        else:   
157
 
                                self.bitmap = wx.Bitmap(Variables.playonlinux_env+"/etc/playonlinux16.png")
158
 
                        
159
 
                        self.plugin_item.SetBitmap(self.bitmap)
160
 
                        self.pluginsmenu.AppendItem(self.plugin_item)
161
 
                        wx.EVT_MENU(self, 300+self.j,  self.run_plugin)
162
 
                        self.plugin_list.append(files[self.i])
163
 
                        self.j += 1
164
 
        self.i += 1
165
 
    
166
 
    if(self.j > 0):
167
 
        self.pluginsmenu.AppendSeparator()
168
 
 
169
 
    self.option_item_p = wx.MenuItem(self.expertmenu, 214, _("Plugin manager"))
170
 
    self.option_item_p.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/package-x-generic.png"))
171
 
    self.pluginsmenu.AppendItem(self.option_item_p)
172
 
 
173
 
    self.last_string = ""
174
 
 
175
 
 
176
 
    # /!\ id 115 utilisé par wineserver #
177
 
    # /!\ id 117 et 118 utilisés aussi #
178
 
    self.helpmenu = wx.Menu()
179
 
    self.helpmenu.Append(wx.ID_ABOUT, _("About"))
180
 
    self.helpmenu.Append(500, _("Donate"))
181
 
    self.menubar = wx.MenuBar()
182
 
    self.menubar.Append(self.filemenu, _("File"))
183
 
    self.menubar.Append(self.expertmenu, _("Tools"))
184
 
    self.menubar.Append(self.optionmenu, _("Settings"))
185
 
    self.menubar.Append(self.pluginsmenu, _("Plugins"))
186
 
    self.menubar.Append(self.helpmenu, _("Help"))
187
 
    self.SetMenuBar(self.menubar)
188
 
 
189
 
    self.toolbar = self.CreateToolBar(wx.TB_TEXT)
190
 
    self.toolbar.AddLabelTool(wx.ID_OPEN, _("Run"), wx.ArtProvider.GetBitmap("gtk-open", wx.ART_TOOLBAR))
191
 
    self.toolbar.AddLabelTool(wx.ID_ADD, _("Install"), wx.ArtProvider.GetBitmap("gtk-add", wx.ART_TOOLBAR))
192
 
    self.toolbar_remove = self.toolbar.AddLabelTool(wx.ID_DELETE, _("Remove"), wx.ArtProvider.GetBitmap("gtk-delete", wx.ART_TOOLBAR))
193
 
    #self.toolbar.AddLabelTool(wx.ID_REFRESH, _("Refresh the repository"), wx.ArtProvider.GetBitmap("gtk-refresh", wx.ART_TOOLBAR))
194
 
    self.toolbar.AddLabelTool(121, _("Configure this application"), wx.ArtProvider.GetBitmap("gtk-edit", wx.ART_TOOLBAR))
195
 
    self.toolbar_remove = self.toolbar.AddLabelTool(122, _("Close all"), wx.ArtProvider.GetBitmap("gtk-close", wx.ART_TOOLBAR))
196
 
 
197
 
    self.Reload(self)
198
 
    wx.EVT_MENU(self, wx.ID_OPEN,  self.Run)
199
 
    wx.EVT_MENU(self, wx.ID_ADD,  self.InstallMenu)
200
 
    wx.EVT_MENU(self, wx.ID_ABOUT,  self.About)
201
 
    wx.EVT_MENU(self,  wx.ID_EXIT,  self.ClosePol)
202
 
    wx.EVT_MENU(self,  wx.ID_REFRESH,  self.UpdatePol)
203
 
    wx.EVT_MENU(self,  wx.ID_DELETE,  self.UninstallGame)
204
 
    wx.EVT_MENU(self,  122,  self.RKillAll)
205
 
 
206
 
    # Expert
207
 
    wx.EVT_MENU(self, 101,  self.Reload)
208
 
    wx.EVT_MENU(self, 107,  self.WineVersion)
209
 
    wx.EVT_MENU(self, 108,  self.Executer)
210
 
    wx.EVT_MENU(self, 109,  self.PolShell)
211
 
    wx.EVT_MENU(self, 115,  self.killwineserver)
212
 
    wx.EVT_MENU(self, 120,  self.Autorun)
213
 
    wx.EVT_MENU(self, 121,  self.Configure)
214
 
 
215
 
    #Options
216
 
    wx.EVT_MENU(self, 210,  self.Options)
217
 
    wx.EVT_MENU(self, 211,  self.Options)
218
 
    wx.EVT_MENU(self, 212,  self.Options)
219
 
    wx.EVT_MENU(self, 213,  self.Options)
220
 
    wx.EVT_MENU(self, 214,  self.Options)
221
 
    wx.EVT_MENU(self, 215,  self.Options)
222
 
 
223
 
    wx.EVT_CLOSE(self, self.ClosePol)
224
 
    wx.EVT_TREE_ITEM_ACTIVATED(self, 105, self.Run)
225
 
    wx.EVT_TREE_SEL_CHANGED(self, 105, self.Select)
226
 
    #wx.EVT_TREE_ITEM_MENU(self, 105, self.OnRightDown)
227
 
 
228
 
    #Timer, regarde toute les secondes si il faut actualiser la liste
229
 
    self.Bind(wx.EVT_TIMER, self.AutoReload, self.timer)
230
 
    self.timer.Start(200)
231
 
 
232
 
    #Pop-up menu for game list: beginning
233
 
    wx.EVT_TREE_ITEM_MENU(self, 105, self.RMBInGameList)
234
 
    wx.EVT_MENU(self, 230,  self.RWineConfigurator)
235
 
    wx.EVT_MENU(self, 231,  self.RRegistryEditor)
236
 
    wx.EVT_MENU(self, 232,  self.GoToAppDir)
237
 
    wx.EVT_MENU(self, 233,  self.ChangeIcon)
238
 
    wx.EVT_MENU(self, 234,  self.UninstallGame)
239
 
    wx.EVT_MENU(self, 235,  self.RKill)
240
 
    wx.EVT_MENU(self, 500, self.donate)
241
 
 
 
91
        wx.Frame.__init__(self, parent, 1000, title, size = (430, 430))
 
92
 
 
93
                
 
94
        self.SetIcon(wx.Icon(Variables.playonlinux_env+"/etc/playonlinux.png", wx.BITMAP_TYPE_ANY))
 
95
        self.timer = wx.Timer(self, 1)
 
96
        self.images = wx.ImageList(32, 32)
 
97
 
 
98
        self.updater = POLWeb()
 
99
        self.updater.start()
 
100
        self.sendAlertStr = None
 
101
        
 
102
        self.list_game = wx.TreeCtrl(self, 105, style=wx.TR_HIDE_ROOT|wx.TR_FULL_ROW_HIGHLIGHT) 
 
103
        self.list_game.SetSpacing(0);
 
104
        self.list_game.SetImageList(self.images)
 
105
 
 
106
        
 
107
        self.oldreload = ""     
 
108
        self.oldimg = ""
 
109
        
 
110
        self.filemenu = wx.Menu()
 
111
        self.filemenu.Append(wx.ID_OPEN, _("Run"))
 
112
        self.filemenu.Append(wx.ID_ADD, _("Install"))
 
113
        self.filemenu.Append(wx.ID_DELETE, _("Remove"))
 
114
        self.filemenu.AppendSeparator()
 
115
        self.filemenu.Append(216, _("Donate"))
 
116
        self.filemenu.Append(wx.ID_EXIT, _("Exit"))
 
117
 
 
118
        self.expertmenu = wx.Menu()
 
119
 
 
120
        self.winever_item = wx.MenuItem(self.expertmenu, 107, _("Manage Wine versions"))
 
121
        self.winever_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/wine.png"))
 
122
        self.expertmenu.AppendItem(self.winever_item)
 
123
 
 
124
        #self.wineprefix_item = wx.MenuItem(self.expertmenu, 111, _("Manage virtual drives"))
 
125
        #self.wineprefix_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/prefix-manager.png"))
 
126
        #self.expertmenu.AppendItem(self.wineprefix_item)
 
127
 
 
128
        self.expertmenu.AppendSeparator()
 
129
 
 
130
        self.run_item = wx.MenuItem(self.expertmenu, 108, _("Run a local script"))
 
131
        self.run_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/run.png"))
 
132
        self.expertmenu.AppendItem(self.run_item)
 
133
                
 
134
        self.wineserv_item = wx.MenuItem(self.expertmenu, 115, _('Close all {0} software').format(os.environ["APPLICATION_TITLE"]))
 
135
        self.wineserv_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/wineserver.png"))
 
136
        self.expertmenu.AppendItem(self.wineserv_item)
 
137
 
 
138
        self.polshell_item = wx.MenuItem(self.expertmenu, 109, _('{0} console').format(os.environ["APPLICATION_TITLE"]))
 
139
        self.polshell_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/polshell.png"))
 
140
        self.expertmenu.AppendItem(self.polshell_item)
 
141
 
 
142
        self.expertmenu.AppendSeparator()
 
143
 
 
144
        self.pol_online = wx.MenuItem(self.expertmenu, 112, os.environ["APPLICATION_TITLE"]+" online")
 
145
        self.pol_online.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/playonlinux_online.png"))
 
146
        self.expertmenu.AppendItem(self.pol_online)
 
147
 
 
148
        self.chat_item = wx.MenuItem(self.expertmenu, 111, _("{0} messenger").format(os.environ["APPLICATION_TITLE"]))
 
149
        self.chat_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/people.png"))
 
150
        self.expertmenu.AppendItem(self.chat_item)
 
151
                
 
152
        self.bug_item = wx.MenuItem(self.expertmenu, 110, _("Report a bug"))
 
153
        self.bug_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/bug.png"))
 
154
        self.expertmenu.AppendItem(self.bug_item)
 
155
        
 
156
        
 
157
        self.optionmenu = wx.Menu()
 
158
 
 
159
#       self.option_item = wx.MenuItem(self.expertmenu, 210, _("General"))
 
160
#       self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/input-gaming.png"))
 
161
#       self.optionmenu.AppendItem(self.option_item)
 
162
 
 
163
        self.option_item = wx.MenuItem(self.expertmenu, 211, _("Internet"))
 
164
        self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/internet-web-browser.png"))
 
165
        self.optionmenu.AppendItem(self.option_item)
 
166
 
 
167
        #self.option_item = wx.MenuItem(self.expertmenu, 212, _("Environment"))
 
168
        #self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/user-desktop.png"))
 
169
        #self.optionmenu.AppendItem(self.option_item)
 
170
 
 
171
        #self.option_item = wx.MenuItem(self.expertmenu, 213, _("System"))
 
172
        #self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/application-x-executable.png"))
 
173
        #self.optionmenu.AppendItem(self.option_item)
 
174
 
 
175
        
 
176
        self.help_menu = wx.Menu()
 
177
        self.help_menu.Append(wx.ID_ABOUT, _('About {0}').format(os.environ["APPLICATION_TITLE"]))
 
178
 
 
179
        self.pluginsmenu = wx.Menu()
 
180
 
 
181
        files=os.listdir(Variables.playonlinux_rep+"/plugins")
 
182
        files.sort()
 
183
        self.plugin_list = []
 
184
        self.i = 0
 
185
        self.j = 0
 
186
        while(self.i < len(files)):
 
187
                if(os.path.exists(Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/scripts/menu")):
 
188
                        if(os.path.exists(Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/enabled")):
 
189
                                self.plugin_item = wx.MenuItem(self.expertmenu, 300+self.j, files[self.i])
 
190
                                
 
191
                                self.icon_look_for = Variables.playonlinux_rep+"/plugins/"+files[self.i]+"/icon"
 
192
                                if(os.path.exists(self.icon_look_for)):
 
193
                                        self.bitmap = wx.Bitmap(self.icon_look_for)
 
194
                                else:
 
195
                                        self.bitmap = wx.Bitmap(Variables.playonlinux_env+"/etc/playonlinux16.png")
 
196
 
 
197
                                self.plugin_item.SetBitmap(self.bitmap)
 
198
                                self.pluginsmenu.AppendItem(self.plugin_item)
 
199
                                wx.EVT_MENU(self, 300+self.j,  self.run_plugin)
 
200
                                self.plugin_list.append(files[self.i])
 
201
                                self.j += 1
 
202
                self.i += 1
 
203
 
 
204
        if(self.j > 0):
 
205
                self.pluginsmenu.AppendSeparator()
 
206
 
 
207
        self.option_item_p = wx.MenuItem(self.expertmenu, 214, _("Plugin manager"))
 
208
        self.option_item_p.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/package-x-generic.png"))
 
209
        self.pluginsmenu.AppendItem(self.option_item_p)
 
210
        
 
211
        self.option_item = wx.MenuItem(self.expertmenu, 214, _("Plugin manager"))
 
212
        self.option_item.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/package-x-generic.png"))
 
213
        self.optionmenu.AppendItem(self.option_item)
 
214
 
 
215
        
 
216
        self.last_string = ""
 
217
 
 
218
        self.sb = wx.StatusBar(self, -1 )
 
219
        self.sb.SetFieldsCount(2)
 
220
        self.sb.SetStatusWidths([400, -1])
 
221
        self.sb.SetStatusText("", 0)
 
222
        
 
223
        if(os.environ["POL_OS"] == "Mac"):
 
224
                hauteur = 2;
 
225
        else:
 
226
                hauteur = 6;
 
227
        self.jauge_update = wx.Gauge(self.sb, -1, 100, (300, hauteur), size=(100,16))
 
228
        self.jauge_update.Pulse()
 
229
        self.jauge_update.Hide()
 
230
        self.SetStatusBar(self.sb)
 
231
 
 
232
        #self.helpmenu = wx.MenuItem()
 
233
        #self.helpmenu.Append(wx.ID_ABOUT, _("About"))
 
234
 
 
235
        self.menubar = wx.MenuBar()
 
236
        self.menubar.Append(self.filemenu, _("File"))
 
237
        self.menubar.Append(self.expertmenu, _("Tools"))
 
238
        self.menubar.Append(self.optionmenu, _("Settings"))
 
239
        self.menubar.Append(self.pluginsmenu, _("Plugins"))
 
240
        self.menubar.Append(self.help_menu, "&Help")
 
241
        
 
242
        #self.menubar.Append(self.help_menu, _("About"))
 
243
        self.SetMenuBar(self.menubar)
 
244
        iconSize = (32,32)
 
245
 
 
246
        self.toolbar = self.CreateToolBar(wx.TB_TEXT)
 
247
        self.toolbar.SetToolBitmapSize(iconSize)
 
248
        self.toolbar.AddLabelTool(wx.ID_OPEN, _("Run"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/run.png"))
 
249
        self.toolbar.AddSeparator()
 
250
        self.toolbar.AddLabelTool(wx.ID_ADD, _("Install"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/install.png"))
 
251
        self.toolbar_remove = self.toolbar.AddLabelTool(wx.ID_DELETE, _("Remove"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/delete.png"))
 
252
        #self.toolbar.AddLabelTool(120, _("CD-ROM"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/cdrom.png"))
 
253
        
 
254
        self.toolbar.AddSeparator()
 
255
        self.toolbar.AddLabelTool(121, _("Configure"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/configure.png"))
 
256
        self.toolbar.AddLabelTool(122, _("Shortcut"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/package.png"))
 
257
        self.toolbar.AddLabelTool(123, _("Messenger"), wx.Bitmap(Variables.playonlinux_env+"/resources/images/toolbar/messenger.png"))
 
258
 
 
259
        #self.toolbar.DoMenuUpdate(self.toolbar)
 
260
        self.toolbar.Realize()
 
261
        self.Reload(self)
 
262
        wx.EVT_MENU(self, wx.ID_OPEN,  self.Run)
 
263
        wx.EVT_MENU(self, wx.ID_ADD,  self.InstallMenu)
 
264
        wx.EVT_MENU(self, wx.ID_ABOUT,  self.About)
 
265
        wx.EVT_MENU(self,  wx.ID_EXIT,  self.ClosePol)
 
266
        wx.EVT_MENU(self,  wx.ID_DELETE,  self.UninstallGame)
 
267
        
 
268
 
 
269
        # Expert
 
270
        wx.EVT_MENU(self, 101,  self.Reload)
 
271
        wx.EVT_MENU(self, 107,  self.WineVersion)
 
272
        wx.EVT_MENU(self, 108,  self.Executer)
 
273
        wx.EVT_MENU(self, 109,  self.PolShell)
 
274
        wx.EVT_MENU(self, 110,  self.BugReport)
 
275
        wx.EVT_MENU(self, 111,  self.OpenIrc)
 
276
        wx.EVT_MENU(self, 112,  self.POLOnline)
 
277
        
 
278
        wx.EVT_MENU(self, 115,  self.killall)
 
279
        wx.EVT_MENU(self, 121,  self.Configure)
 
280
        wx.EVT_MENU(self, 122,  self.Package)
 
281
        wx.EVT_MENU(self, 123,  self.OpenIrc)
 
282
 
 
283
        #Options
 
284
        wx.EVT_MENU(self, 210,  self.Options)
 
285
        wx.EVT_MENU(self, 211,  self.Options)
 
286
        wx.EVT_MENU(self, 212,  self.Options)
 
287
        wx.EVT_MENU(self, 213,  self.Options)
 
288
        wx.EVT_MENU(self, 214,  self.Options)
 
289
        wx.EVT_MENU(self, 215,  self.Options)
 
290
 
 
291
        wx.EVT_MENU(self, 216,  self.donate)
 
292
 
 
293
        wx.EVT_CLOSE(self, self.ClosePol)
 
294
        wx.EVT_TREE_ITEM_ACTIVATED(self, 105, self.Run)
 
295
        wx.EVT_TREE_SEL_CHANGED(self, 105, self.Select)
 
296
        #wx.EVT_TREE_ITEM_MENU(self, 105, self.OnRightDown)
 
297
 
 
298
        #Timer, regarde toute les secondes si il faut actualiser la liste
 
299
        
 
300
        self.Bind(wx.EVT_TIMER, self.AutoReload, self.timer)
 
301
        self.timer.Start(1000)
 
302
 
 
303
        #Pop-up menu for game list: beginning
 
304
        wx.EVT_TREE_ITEM_MENU(self, 105, self.RMBInGameList)
 
305
        wx.EVT_MENU(self, 230, self.RWineConfigurator)
 
306
        wx.EVT_MENU(self, 231, self.RRegistryEditor)
 
307
        wx.EVT_MENU(self, 232, self.GoToAppDir)
 
308
        wx.EVT_MENU(self, 233, self.ChangeIcon)
 
309
        wx.EVT_MENU(self, 234, self.UninstallGame)
 
310
        wx.EVT_MENU(self, 235, self.RKill)
 
311
        #self.sb.Hide()
 
312
        
 
313
  def StatusRead(self):
 
314
        self.sb.SetStatusText(self.updater.sendToStatusBarStr, 0)
 
315
        if(self.updater.Gauge == True):
 
316
                self.jauge_update.Pulse()
 
317
                self.jauge_update.Show()
 
318
        else:
 
319
                self.jauge_update.Hide()
 
320
 
 
321
        if(self.updater.Show == True):
 
322
                self.sb.Show()
 
323
        else:
 
324
                self.sb.Hide()  
 
325
        if(self.updater.sendAlertStr != self.sendAlertStr):
 
326
                wx.MessageBox(self.updater.sendAlertStr, os.environ["APPLICATION_TITLE"])
 
327
                self.sendAlertStr = self.updater.sendAlertStr
 
328
                
242
329
  def RMBInGameList(self, event):
243
330
        self.GameListPopUpMenu = wx.Menu()
244
331
 
245
332
        self.ConfigureWine = wx.MenuItem(self.GameListPopUpMenu, 230, _("Configure Wine"))
246
 
        self.ConfigureWine.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/run.png"))
 
333
        self.ConfigureWine.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/run.png"))
247
334
        self.GameListPopUpMenu.AppendItem(self.ConfigureWine)
248
335
 
249
336
        self.RegistryEditor = wx.MenuItem(self.GameListPopUpMenu, 231, _("Registry Editor"))
250
 
        self.RegistryEditor.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/regedit.png"))
 
337
        self.RegistryEditor.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/regedit.png"))
251
338
        self.GameListPopUpMenu.AppendItem(self.RegistryEditor)
252
339
 
253
340
        self.GotoAppDir = wx.MenuItem(self.GameListPopUpMenu, 232, _("Open the application's directory"))
254
 
        self.GotoAppDir.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/user-desktop.png"))
 
341
        self.GotoAppDir.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/folder-wine.png"))
255
342
        self.GameListPopUpMenu.AppendItem(self.GotoAppDir)
256
343
 
257
344
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 233, _("Set the icon"))
258
 
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/playonlinux16.png"))
 
345
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/change_icon.png"))
259
346
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
260
347
 
261
348
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 234, _("Remove"))
262
 
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/options.png"))
 
349
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/delete.png"))
263
350
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
264
351
 
265
352
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 235, _("Close this application"))
266
 
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/wineserver.png"))
 
353
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/resources/images/menu/wineserver.png"))
267
354
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
268
355
 
269
356
        self.PopupMenu(self.GameListPopUpMenu, event.GetPoint())
270
 
 
271
 
  def donate(self, event):
272
 
        webbrowser.open("http://www.playonlinux.com/donate.html");
 
357
    #if(len(sys.argv) >= 1):
 
358
 
 
359
    #wx.MessageBox(str(sys.argv), "PlayOnLinux", wx.OK)
 
360
 
273
361
 
274
362
  def RWineConfigurator(self, event):
275
363
        self.RConfigure(_("Configure Wine"), "nothing")
277
365
  def RKill(self, event):
278
366
        self.RConfigure(_("KillApp"), "nothing")
279
367
 
280
 
  def RKillAll(self, event):
281
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/killall\"&")
282
 
 
283
368
  def RRegistryEditor(self, event):
284
369
        self.RConfigure(_("Registry Editor"), "nothing")
285
370
 
 
371
  def run_plugin(self, event):
 
372
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
 
373
        plugin=self.plugin_list[event.GetId()-300]
 
374
        try :
 
375
                os.system("bash \""+Variables.playonlinux_rep+"/plugins/"+plugin+"/scripts/menu\" \""+game_exec+"\"&")
 
376
        except : 
 
377
                pass
 
378
                
 
379
  def OpenIrc(self, event):
 
380
        self.irc = ircgui.IrcClient(self)
 
381
        self.irc.Center(wx.BOTH)
 
382
        self.irc.Show(True)
 
383
                
286
384
  def GoToAppDir(self, event):
287
 
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
288
 
        self.read = open(Variables.playonlinux_rep+"configurations/installed/"+game_exec,"r").readlines()
289
 
 
290
 
        if not len(self.read):
291
 
                print "err: Empty launcher"
292
 
                return
293
 
 
294
 
        self.i = 0;
295
 
        while(self.i < len(self.read)):
296
 
                if("cd \"" in self.read[self.i]):
297
 
                        break
298
 
                self.i += 1
299
 
 
300
 
        if len(self.read) == (self.i):
301
 
                print "err: No path in launcher"
302
 
                return
303
 
 
304
 
        AppDir = self.read[self.i][3:]
305
 
        if AppDir != "":
306
 
                os.system("xdg-open "+AppDir)
307
 
 
 
385
                self.game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
 
386
                playonlinux.open_folder(self.game_exec)
 
387
                
308
388
  def ChangeIcon(self, event):
309
 
        self.IconDir = Variables.homedir+"/.local/share/icons/"
310
 
        self.SupprotedIconExt = "All|*.xpm;*.XPM;*.png;*.PNG;*.ico;*.ICO;*.jpg;*.JPG;*.jpeg;*.JPEG;*.bmp;*.BMP\
311
 
        \|XPM (*.xpm)|*.xpm;*.XPM\
312
 
        \|PNG (*.png)|*.png;*.PNG\
313
 
        \|ICO (*.ico)|*.ico;*.ICO\
314
 
        \|JPG (*.jpg)|*.jpg;*.JPG\
315
 
        \|BMP (*.bmp)|*.bmp;*.BMP\
316
 
        \|JPEG (*.jpeg)|*.jpeg;*JPEG"
317
 
        self.IconDialog = wx.FileDialog(self, "Choose a icon file", self.IconDir, "", self.SupprotedIconExt, wx.OPEN | wx.FD_PREVIEW)
318
 
        if self.IconDialog.ShowModal() == wx.ID_OK:
319
 
            self.IconFilename=self.IconDialog.GetFilename()
320
 
            self.IconDirname=self.IconDialog.GetDirectory()
321
 
            IconFile=os.path.join(self.IconDirname,self.IconFilename)
322
 
            self.RConfigure("IconChange", IconFile)
323
 
        self.IconDialog.Destroy()
324
 
    #Pop-up menu for game list: ending
 
389
                self.IconDir = Variables.homedir+"/.local/share/icons/"
 
390
                self.SupprotedIconExt = "All|*.xpm;*.XPM;*.png;*.PNG;*.ico;*.ICO;*.jpg;*.JPG;*.jpeg;*.JPEG;*.bmp;*.BMP\
 
391
                \|XPM (*.xpm)|*.xpm;*.XPM\
 
392
                \|PNG (*.png)|*.png;*.PNG\
 
393
                \|ICO (*.ico)|*.ico;*.ICO\
 
394
                \|JPG (*.jpg)|*.jpg;*.JPG\
 
395
                \|BMP (*.bmp)|*.bmp;*.BMP\
 
396
                \|JPEG (*.jpeg)|*.jpeg;*JPEG"
 
397
                self.IconDialog = wx.FileDialog(self, "Choose a icon file", self.IconDir, "", self.SupprotedIconExt, wx.OPEN | wx.FD_PREVIEW)
 
398
                if self.IconDialog.ShowModal() == wx.ID_OK:
 
399
                        self.IconFilename=self.IconDialog.GetFilename()
 
400
                        self.IconDirname=self.IconDialog.GetDirectory()
 
401
                        IconFile=os.path.join(self.IconDirname,self.IconFilename)
 
402
                        self.RConfigure("IconChange", IconFile)
 
403
                        self.IconDialog.Destroy()
 
404
                        #Pop-up menu for game list: ending
325
405
 
326
406
  def Select(self, event):
327
 
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
328
 
        self.read = open(Variables.playonlinux_rep+"configurations/installed/"+game_exec,"r").readlines()
 
407
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
 
408
        self.read = open(Variables.playonlinux_rep+"shortcuts/"+game_exec,"r").readlines()
329
409
        self.i = 0;
330
410
        self.wine_present = False;
331
411
        while(self.i < len(self.read)):
332
412
                if("wine " in self.read[self.i]):
333
413
                        self.wine_present = True;
334
414
                self.i += 1
 
415
 
 
416
  def donate(self, event):
 
417
        if(os.environ["POL_OS"] == "Mac"):
 
418
                webbrowser.open("http://www.playonmac.com/en/donate.html")
 
419
        else:
 
420
                webbrowser.open("http://www.playonlinux.com/en/donate.html")
 
421
        
335
422
  def Reload(self, event):
336
 
         time.sleep(0.5);
337
 
         self.games = os.listdir(Variables.playonlinux_rep+"configurations/installed/")
 
423
         self.games = os.listdir(Variables.playonlinux_rep+"shortcuts/")
338
424
         self.games.sort()
 
425
         try:
 
426
                self.games.remove(".DS_Store")
 
427
         except:
 
428
                pass
339
429
         self.list_game.DeleteAllItems()
340
 
         self.images.RemoveAll()
 
430
         self.images.RemoveAll()
341
431
         root = self.list_game.AddRoot("")
342
432
         self.i = 0
343
433
         for game in self.games: #METTRE EN 32x32
344
434
                if(os.path.exists(Variables.playonlinux_rep+"/icones/32/"+game)):
345
435
                        file_icone = Variables.playonlinux_rep+"/icones/32/"+game
346
436
                else:
347
 
                        file_icone = Variables.playonlinux_rep+"/icones/32/playonlinux.png"
 
437
                        file_icone = Variables.playonlinux_env+"/etc/playonlinux32.png"
348
438
 
349
 
                self.images.Add(wx.Bitmap(file_icone))
 
439
                try:
 
440
                        self.images.Add(wx.Bitmap(file_icone))
 
441
                except:
 
442
                        pass
350
443
                item = self.list_game.AppendItem(root, game, self.i)
351
444
                self.i += 1
352
 
 
353
 
 
 
445
        
 
446
 
 
447
  def RConfigure(self, function_to_run, firstargument):
 
448
                """Starts polconfigurator remotely."""
 
449
                game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
 
450
                if(game_exec != ""):
 
451
                        os.system("bash \""+Variables.playonlinux_env+"/bash/polconfigurator\" \""+game_exec+"\" \""+function_to_run+"\" \""+firstargument+"\"&")
354
452
        
355
453
            
356
454
        
357
455
  def Options(self, event):
358
 
    print("Running options")
359
 
    onglet=event.GetId()-210
360
 
    os.system(os.popen("printf $PYTHON",'r').read()+" \""+Variables.playonlinux_env+"/python/options.py\" "+str(onglet)+"&")
361
 
 
362
 
  def run_plugin(self, event):
363
 
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
364
 
    plugin=self.plugin_list[event.GetId()-300]
365
 
    try :
366
 
        os.system("bash \""+Variables.playonlinux_rep+"/plugins/"+plugin+"/scripts/menu\" \""+game_exec+"\"&")
367
 
    except : 
368
 
        print("bash \""+Variables.playonlinux_rep+"/plugins/"+plugin+"/scripts/menu\" "+game_exec+"&")
369
 
 
370
 
  def killwineserver(self, event):
371
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/expert/kill_wineserver\"&")
 
456
    onglet=event.GetId()
 
457
    if(onglet == 211):
 
458
        self.optionFrame = options.MainWindow(self, -1, _("{0} settings").format(os.environ["APPLICATION_TITLE"]), 2)
 
459
    if(onglet == 214):
 
460
        self.optionFrame = options.MainWindow(self, -1, _("{0} settings").format(os.environ["APPLICATION_TITLE"]), 1)
 
461
    self.optionFrame.Center(wx.BOTH)
 
462
    self.optionFrame.Show(True)
 
463
 
 
464
  def killall(self, event):
 
465
    os.system("bash \""+Variables.playonlinux_env+"/bash/killall\"&")
372
466
 
373
467
  def Executer(self, event):
374
468
    os.system("bash \""+Variables.playonlinux_env+"/bash/expert/Executer\"&")
375
469
 
 
470
  def BugReport(self, event):
 
471
    os.system("bash \""+Variables.playonlinux_env+"/bash/bug_report\"&")
 
472
 
 
473
  def POLOnline(self, event):
 
474
    os.system("bash \""+Variables.playonlinux_env+"/bash/playonlinux_online\" &")
 
475
 
376
476
  def PolShell(self, event):
 
477
    #Variables.run_x_server()
377
478
    os.system("bash \""+Variables.playonlinux_env+"/bash/expert/PolShell\"&")
378
479
 
379
 
  def RConfigure(self, function_to_run, firstargument):
380
 
    """Starts polconfigurator remotely."""
381
 
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
382
 
    print game_exec
383
 
    print function_to_run
384
 
   
385
 
    if(game_exec != ""):
386
 
        print("Running (remotely) configuration of "+game_exec)
387
 
        os.system("bash \""+Variables.playonlinux_env+"/bash/polconfigurator\" \""+game_exec+"\" \""+function_to_run+"\" \""+firstargument+"\"&")
388
 
 
389
480
  def Configure(self, event):
 
481
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
 
482
        if(game_exec == ""):
 
483
                configureFrame = configure.MainWindow(None, -1, _("{0} configuration").format(os.environ["APPLICATION_TITLE"]),"default",True)
 
484
        else:
 
485
                configureFrame = configure.MainWindow(None, -1, _("{0} configuration").format(os.environ["APPLICATION_TITLE"]),game_exec,False)
 
486
                #self.SetTopWindow(installFrame)
 
487
        configureFrame.Center(wx.BOTH)
 
488
        configureFrame.Show(True)
 
489
 
 
490
    #os.system("bash \""+Variables.playonlinux_env+"/bash/polconfigurator\" \""+game_exec+"\"&")
 
491
 
 
492
  def Package(self, event):
390
493
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
391
 
    if(game_exec != ""):
392
 
        print("Running configuration of "+game_exec)
393
 
        os.system("bash \""+Variables.playonlinux_env+"/bash/polconfigurator\" \""+game_exec+"\"&")
394
 
 
 
494
    os.system("bash \""+Variables.playonlinux_env+"/bash/make_shortcut\" \""+game_exec.encode("utf-8")+"\"&")
395
495
 
396
496
  def UninstallGame(self, event):
397
497
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
398
 
    if(game_exec != ""):
399
 
        print("Uninstall "+game_exec)
400
 
        os.system("bash \""+Variables.playonlinux_env+"/bash/uninstall\" \""+game_exec+"\"&")
401
 
        
 
498
    os.system("bash \""+Variables.playonlinux_env+"/bash/uninstall\" \""+game_exec.encode("utf-8")+"\"&")
 
499
 
402
500
 
403
501
  def AutoReload(self, event):
404
 
    reload = os.listdir(Variables.playonlinux_rep+"/configurations/installed")
405
 
    if(reload != self.oldreload):
406
 
        self.Reload(self)
407
 
        self.oldreload = reload
408
 
 
409
 
    reloadimg = os.listdir(Variables.playonlinux_rep+"/icones/32")
410
 
    if(reloadimg != self.oldimg):
411
 
        self.Reload(self)
412
 
        self.oldimg = reloadimg
 
502
        self.StatusRead()
 
503
        fichier_index = os.environ["REPERTOIRE"]+"/configurations/guis/index_"+os.environ["POL_ID"]
 
504
        #print(fichier_index)
 
505
        try:
 
506
                message = open(fichier_index,'r').read()
 
507
        except:
 
508
                open(fichier_index,'a').write('')
 
509
                message = open(fichier_index,'r').read()
 
510
        message = string.split(message, "\n")
 
511
        if(message[0] == "Open"):
 
512
                self.frame = gui.POL_SetupFrame(os.environ["APPLICATION_TITLE"],message[1].replace("\n",""),message[2].replace("\n",""),message[3].replace("\n",""),message[4].replace("\n",""))
 
513
                self.frame.Center(wx.BOTH)
 
514
                self.frame.Show(True)
 
515
                open(fichier_index,'w').write("Wait")
 
516
 
 
517
        reload = os.listdir(Variables.playonlinux_rep+"/shortcuts")
 
518
        if(reload != self.oldreload):
 
519
                self.Reload(self)
 
520
                self.oldreload = reload
 
521
 
 
522
        reloadimg = os.listdir(Variables.playonlinux_rep+"/icones/32")
 
523
        if(reloadimg != self.oldimg):
 
524
                self.Reload(self)
 
525
                self.oldimg = reloadimg
413
526
   
414
527
 
415
528
  def InstallMenu(self, event):
416
 
    print("Running install menu")
417
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/install\"&")
418
 
    
419
 
  def UpdatePol(self, event):
420
 
    print("Running update menu")
421
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/check_maj\"&")
422
 
  
423
 
  def Autorun(self, event):
424
 
    print("Autorun")
425
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/autorun\"&")
426
 
 
 
529
    installFrame = install.InstallWindow(self, -1, _('{0} install menu').format(os.environ["APPLICATION_TITLE"]))
 
530
    #self.SetTopWindow(installFrame)
 
531
    installFrame.Center(wx.BOTH)
 
532
    installFrame.Show(True)
 
533
        
427
534
  def WineVersion(self, event):
428
 
    print("Running wineversion menu")
429
 
    os.system("bash \""+Variables.playonlinux_env+"/bash/wineversion\"&")
 
535
    wversion = wver.MainWindow(None, -1, _('{0} wine versions manager').format(os.environ["APPLICATION_TITLE"]))
 
536
    wversion.Center(wx.BOTH)
 
537
    wversion.Show(True)
 
538
        #os.system("bash \""+Variables.playonlinux_env+"/bash/wineversion\"&")
430
539
 
431
540
  def Run(self, event):
432
541
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection()).encode("utf-8")
433
542
    if(game_exec != ""):
434
 
        print("Running "+game_exec)
435
 
        os.system("cd \""+Variables.playonlinux_rep+"/configurations/installed/\" && bash \""+game_exec+"\"&")
 
543
                os.system("bash "+Variables.playonlinux_env+"/bash/run_app \""+game_exec+"\"&")
 
544
                #os.system("cd \""+Variables.playonlinux_rep+"/shortcuts/\"  && bash \""+game_exec+"\"&")
436
545
 
437
546
 
438
547
  def ClosePol(self, event):
439
 
    sys.exit(0)
 
548
    if(wx.YES == wx.MessageBox(_('Are you sure you want to close all {0} Windows?').format(os.environ["APPLICATION_TITLE"]).decode("utf-8"), style=wx.YES_NO | wx.ICON_QUESTION)):
 
549
                os.remove(Variables.playonlinux_rep+"/configurations/guis/index_"+os.environ["POL_ID"])
 
550
                os._exit(0)
 
551
    return None
440
552
    
441
553
  def About(self, event):
442
554
    self.aboutBox = wx.AboutDialogInfo()
443
 
    self.aboutBox.SetIcon(wx.Icon(Variables.playonlinux_env+"/etc/playonlinux.png", wx.BITMAP_TYPE_ANY))
444
 
    self.aboutBox.SetName("PlayOnLinux")
 
555
    if(os.environ["POL_OS"] == "Linux"):
 
556
        self.aboutBox.SetIcon(wx.Icon(Variables.playonlinux_env+"/etc/playonlinux.png", wx.BITMAP_TYPE_ANY))
 
557
 
 
558
 
 
559
    self.aboutBox.SetName(os.environ["APPLICATION_TITLE"])
445
560
    self.aboutBox.SetVersion(Variables.version)
446
 
    self.aboutBox.SetDescription(_("Run your Windows programs on Linux!"))
447
 
    self.aboutBox.SetCopyright("(C) PlayOnLinux team 2007-2010\n"+_("Under GPL licence version 3."))
448
 
    self.aboutBox.AddDeveloper(_("Developer and Website: ")+"Tinou (Pâris Quentin), MulX (Petit Aymeric)")       
 
561
    self.aboutBox.SetDescription(_("Run your Windows programs on "+os.environ["POL_OS"]+" !"))
 
562
    self.aboutBox.SetCopyright(_("(C) PlayOnLinux and PlayOnMac team 2011\nUnder GPL licence version 3"))
 
563
    self.aboutBox.AddDeveloper(_("Developer and Website: ")+"Tinou (Pâris Quentin), MulX (Petit Aymeric)")
449
564
    self.aboutBox.AddDeveloper(_("Scriptors: ")+"GNU_Raziel")
450
 
    self.aboutBox.AddDeveloper(_("Packager: ")+"MulX (Petit Aymeric)")
451
 
    #self.aboutBox.AddDeveloper(_("Script Creator: ")+"Zoloom (Cassarin-Grand Arthur)")
452
 
    self.aboutBox.AddDeveloper(_("The following people contributed to this program: ")+"kiplantt, NSLW, Salvatos, Minchul")
 
565
    self.aboutBox.AddDeveloper(_("Packager: ")+"MulX (Petit Aymeric), Tinou (Pâris Quentin)")
 
566
    self.aboutBox.AddDeveloper(_("Icons:")+"Faenza-Icons http://tiheum.deviantart.com/art/Faenza-Icons-173323228")
 
567
    self.aboutBox.AddDeveloper(_("The following people contributed to this program: ")+"kiplantt, Salvatos, Minchul")
453
568
    self.aboutBox.AddTranslator(_("Translation made on Launchpad:"))
454
569
    self.aboutBox.AddTranslator("https://translations.launchpad.net/playonlinux/")
455
 
    self.aboutBox.AddArtist(_("Icons are provided by the Tango Desktop Project"))
456
 
    self.aboutBox.SetWebSite("http://www.playonlinux.com")
457
 
    self.aboutBox.SetLicence(open("/usr/share/common-licenses/GPL",'r').read())
458
 
    self.about = wx.AboutBox(self.aboutBox)
 
570
 
 
571
    if(os.environ["POL_OS"] == "Mac"):
 
572
        self.aboutBox.SetWebSite("http://www.playonmac.com")
 
573
    else:
 
574
        self.aboutBox.SetWebSite("http://www.playonlinux.com")
 
575
    wx.AboutBox(self.aboutBox)
459
576
 
460
577
class PlayOnLinuxApp(wx.App):
461
 
   def OnInit(self):
462
 
        self.frame = MainWindow(None, -1, "PlayOnLinux")
463
 
        self.SetTopWindow(self.frame)
464
 
        self.frame.Center(wx.BOTH)
465
 
        self.frame.Show(True)
466
 
        return True
 
578
        def OnInit(self):
 
579
                lng.iLang()
 
580
                close = False
 
581
                exe_present = False
 
582
                if(os.popen("id -u").read() == "0"):
 
583
                        wx.MessageBox(_("{0} is not supposed to be run as root. Sorry").format(os.environ["APPLICATION_TITLE"]))
 
584
                        sys.exit()
 
585
                        
 
586
                
 
587
                for f in  sys.argv[1:]:
 
588
                        
 
589
                        self.MacOpenFile(f)
 
590
                        if(".exe" in f or ".EXE" in f):
 
591
                                exe_present = True
 
592
                        close = True
 
593
                        
 
594
                if(close == True and exe_present == False):
 
595
                        sys.exit()
 
596
                        
 
597
                self.SetClassName(os.environ["APPLICATION_TITLE"])
 
598
                self.SetAppName(os.environ["APPLICATION_TITLE"])
 
599
                #self.icon = wx.TaskBarIcon()
 
600
                #self.icon.SetIcon(wx.Icon(Variables.playonlinux_env+"/etc/playonmac.png", wx.BITMAP_TYPE_ANY))
 
601
                self.frame = MainWindow(None, -1, os.environ["APPLICATION_TITLE"])
 
602
                self.SetTopWindow(self.frame)
 
603
                self.frame.Center(wx.BOTH)
 
604
                self.frame.Show(True)
 
605
                
 
606
                return True
 
607
        
 
608
        def BringWindowToFront(self):
 
609
                        try: # it's possible for this event to come when the frame is closed
 
610
                            self.GetTopWindow().Raise()
 
611
                        except:
 
612
                            pass
467
613
 
 
614
        def MacOpenFile(self, filename):
 
615
                file_extension = string.split(filename,".")
 
616
                file_extension = file_extension[len(file_extension) - 1]
 
617
                if(file_extension == "desktop"): # Un raccourcis Linux
 
618
                        content = open(filename,"r").readlines()
 
619
                        i = 0
 
620
                        while(i < len(content)):
 
621
                        #       wx.MessageBox(content[i], "PlayOnLinux", wx.OK)
 
622
                                
 
623
                                if("Path=" in content[i]):
 
624
                                        cd_app = content[i].replace("Path=","").replace("\n","")
 
625
                                if("Exec=" in content[i]):
 
626
                                        exec_app = content[i].replace("Exec=","").replace("\n","")
 
627
                                i += 1
 
628
                        if(":\\\\\\\\" in exec_app):
 
629
                                        exec_app = exec_app.replace("\\\\","\\")
 
630
                        try:
 
631
                                os.system("cd \""+cd_app+"\" && "+exec_app+" &")
 
632
                        except:
 
633
                                pass
 
634
                
 
635
                if(file_extension == "exe" or file_extension == "EXE"):
 
636
                        os.system("bash \"$PLAYONLINUX/bash/run_exe\" \""+filename+"\" &")
 
637
                
 
638
                if(file_extension == "pol" or file_extension == "POL"):
 
639
                        if(wx.YES == wx.MessageBox(_('Are you sure you want to  want to install {0} package?').format(filename).decode("utf-8"), style=wx.YES_NO | wx.ICON_QUESTION)):
 
640
                                os.system("bash \"$PLAYONLINUX/bash/playonlinux-pkg\" -i \""+filename+"\" &")
 
641
        
 
642
        def MacOpenURL(self, url):
 
643
                if(os.environ["POL_OS"] == "Mac" and "playonlinux://" in url):
 
644
                        wx.MessageBox("You are trying to open a script design for PlayOnLinux! It might not work as expected")
 
645
                if(os.environ["POL_OS"] == "Linux" and "playonmac://" in url):
 
646
                        wx.MessageBox("You are trying to open a script design for PlayOnMac! It might not work as expected")
 
647
                        
 
648
                os.system("bash \"$PLAYONLINUX/bash/playonlinux-url_handler\" \""+url+"\" &")
 
649
                
 
650
        def MacReopenApp(self):
 
651
                #sys.exit()
 
652
                self.BringWindowToFront()
468
653
 
469
654
 
470
655
lng.Lang()
471
 
app = PlayOnLinuxApp()
 
656
#os.system("bash \""+os.environ["PLAYONLINUX"]+"/bash/startup\"")
 
657
app = PlayOnLinuxApp(redirect=False)
472
658
app.MainLoop()
473
 
sys.exit(0)
 
659
#sys.exit(0)