~ubuntu-branches/ubuntu/wily/playonlinux/wily

« back to all changes in this revision

Viewing changes to python/mainwindow.py~

  • Committer: Bazaar Package Importer
  • Author(s): Bertrand Marc
  • Date: 2010-02-14 21:32:26 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100214213226-6xsdd3ugudkggfeh
Tags: 3.7.3-1
* New upstream release.
* Bump Standards-Version to 3.8.4 (no changes needed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
# -*- coding: utf-8 -*-
3
3
 
4
4
# Copyright (C) 2008 Pâris Quentin
 
5
# Copyright (C) 2009 Łukasz Wojniłowicz
5
6
 
6
7
# This program is free software; you can redistribute it and/or modify
7
8
# it under the terms of the GNU General Public License as published by
20
21
 
21
22
import wxversion
22
23
wxversion.select("2.8")
23
 
import wx, wx.html
 
24
import wx, wx.html, webbrowser
24
25
import gettext, os, getopt, sys, urllib, signal, socket, string, time, threading
25
26
import lib.Variables as Variables, lib.lng as lng
26
27
 
143
144
    if(self.j > 0):
144
145
        self.pluginsmenu.AppendSeparator()
145
146
 
146
 
    self.option_item_p = wx.MenuItem(self.expertmenu, 215, _("Plugins manager"))
 
147
    self.option_item_p = wx.MenuItem(self.expertmenu, 214, _("Plugins manager"))
147
148
    self.option_item_p.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/package-x-generic.png"))
148
149
    self.pluginsmenu.AppendItem(self.option_item_p)
149
150
 
154
155
    # /!\ id 117 et 118 utilisés aussi #
155
156
    self.helpmenu = wx.Menu()
156
157
    self.helpmenu.Append(wx.ID_ABOUT, _("About"))
157
 
 
 
158
    self.helpmenu.Append(500, _("Donate"))
158
159
    self.menubar = wx.MenuBar()
159
160
    self.menubar.Append(self.filemenu, _("File"))
160
161
    self.menubar.Append(self.expertmenu, _("Tools"))
169
170
    self.toolbar_remove = self.toolbar.AddLabelTool(wx.ID_DELETE, _("Remove"), wx.ArtProvider.GetBitmap("gtk-delete", wx.ART_TOOLBAR))
170
171
    #self.toolbar.AddLabelTool(wx.ID_REFRESH, _("Refresh the repository"), wx.ArtProvider.GetBitmap("gtk-refresh", wx.ART_TOOLBAR))
171
172
    self.toolbar.AddLabelTool(121, _("Configure this application"), wx.ArtProvider.GetBitmap("gtk-edit", wx.ART_TOOLBAR))
 
173
    self.toolbar_remove = self.toolbar.AddLabelTool(122, _("Close all"), wx.ArtProvider.GetBitmap("gtk-close", wx.ART_TOOLBAR))
 
174
 
172
175
    self.Reload(self)
173
176
    wx.EVT_MENU(self, wx.ID_OPEN,  self.Run)
174
177
    wx.EVT_MENU(self, wx.ID_ADD,  self.InstallMenu)
176
179
    wx.EVT_MENU(self,  wx.ID_EXIT,  self.ClosePol)
177
180
    wx.EVT_MENU(self,  wx.ID_REFRESH,  self.UpdatePol)
178
181
    wx.EVT_MENU(self,  wx.ID_DELETE,  self.UninstallGame)
179
 
    
 
182
    wx.EVT_MENU(self,  122,  self.RKillAll)
180
183
 
181
184
    # Expert
182
185
    wx.EVT_MENU(self, 101,  self.Reload)
204
207
    self.Bind(wx.EVT_TIMER, self.AutoReload, self.timer)
205
208
    self.timer.Start(200)
206
209
 
 
210
    #Pop-up menu for game list: beginning
 
211
    wx.EVT_TREE_ITEM_MENU(self, 105, self.RMBInGameList)
 
212
    wx.EVT_MENU(self, 230,  self.RWineConfigurator)
 
213
    wx.EVT_MENU(self, 231,  self.RRegistryEditor)
 
214
    wx.EVT_MENU(self, 232,  self.GoToAppDir)
 
215
    wx.EVT_MENU(self, 233,  self.ChangeIcon)
 
216
    wx.EVT_MENU(self, 234,  self.UninstallGame)
 
217
    wx.EVT_MENU(self, 235,  self.RKill)
 
218
    wx.EVT_MENU(self, 500, self.donate)
 
219
 
 
220
  def RMBInGameList(self, event):
 
221
        self.GameListPopUpMenu = wx.Menu()
 
222
 
 
223
        self.ConfigureWine = wx.MenuItem(self.GameListPopUpMenu, 230, _("Configure wine"))
 
224
        self.ConfigureWine.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/run.png"))
 
225
        self.GameListPopUpMenu.AppendItem(self.ConfigureWine)
 
226
 
 
227
        self.RegistryEditor = wx.MenuItem(self.GameListPopUpMenu, 231, _("Registry Editor"))
 
228
        self.RegistryEditor.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/regedit.png"))
 
229
        self.GameListPopUpMenu.AppendItem(self.RegistryEditor)
 
230
 
 
231
        self.GotoAppDir = wx.MenuItem(self.GameListPopUpMenu, 232, _("Go to the application directory"))
 
232
        self.GotoAppDir.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/onglet/user-desktop.png"))
 
233
        self.GameListPopUpMenu.AppendItem(self.GotoAppDir)
 
234
 
 
235
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 233, _("Set the icon"))
 
236
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/playonlinux16.png"))
 
237
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
 
238
 
 
239
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 234, _("Remove"))
 
240
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/options.png"))
 
241
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
 
242
 
 
243
        self.ChangeIcon = wx.MenuItem(self.GameListPopUpMenu, 235, _("Close this application"))
 
244
        self.ChangeIcon.SetBitmap(wx.Bitmap(Variables.playonlinux_env+"/etc/menu/wineserver.png"))
 
245
        self.GameListPopUpMenu.AppendItem(self.ChangeIcon)
 
246
 
 
247
        self.PopupMenu(self.GameListPopUpMenu, event.GetPoint())
 
248
 
 
249
  def donate(self, event):
 
250
        webbrowser.open("http://www.playonlinux.com/donate.html");
 
251
 
 
252
  def RWineConfigurator(self, event):
 
253
        self.RConfigure(_("Configure wine"), "nothing")
 
254
 
 
255
  def RKill(self, event):
 
256
        self.RConfigure(_("KillApp"), "nothing")
 
257
 
 
258
  def RKillAll(self, event):
 
259
    os.system("bash \""+Variables.playonlinux_env+"/bash/killall\"&")
 
260
 
 
261
  def RRegistryEditor(self, event):
 
262
        self.RConfigure(_("Registry Editor"), "nothing")
 
263
 
 
264
  def GoToAppDir(self, event):
 
265
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
 
266
        self.read = open(Variables.playonlinux_rep+"configurations/installed/"+game_exec,"r").readlines()
 
267
 
 
268
        if not len(self.read):
 
269
                print "err: Empty launcher"
 
270
                return
 
271
 
 
272
        self.i = 0;
 
273
        while(self.i < len(self.read)):
 
274
                if("cd \"" in self.read[self.i]):
 
275
                        break
 
276
                self.i += 1
 
277
 
 
278
        if len(self.read) == (self.i):
 
279
                print "err: No path in launcher"
 
280
                return
 
281
 
 
282
        AppDir = self.read[self.i][3:]
 
283
        if AppDir != "":
 
284
                os.system("xdg-open "+AppDir)
 
285
 
 
286
  def ChangeIcon(self, event):
 
287
        self.IconDir = Variables.homedir+"/.local/share/icons/"
 
288
        self.SupprotedIconExt = "All|*.xpm;*.XPM;*.png;*.PNG;*.ico;*.ICO;*.jpg;*.JPG;*.jpeg;*.JPEG;*.bmp;*.BMP\
 
289
        \|XPM (*.xpm)|*.xpm;*.XPM\
 
290
        \|PNG (*.png)|*.png;*.PNG\
 
291
        \|ICO (*.ico)|*.ico;*.ICO\
 
292
        \|JPG (*.jpg)|*.jpg;*.JPG\
 
293
        \|BMP (*.bmp)|*.bmp;*.BMP\
 
294
        \|JPEG (*.jpeg)|*.jpeg;*JPEG"
 
295
        self.IconDialog = wx.FileDialog(self, "Choose a icon file", self.IconDir, "", self.SupprotedIconExt, wx.OPEN | wx.FD_PREVIEW)
 
296
        if self.IconDialog.ShowModal() == wx.ID_OK:
 
297
            self.IconFilename=self.IconDialog.GetFilename()
 
298
            self.IconDirname=self.IconDialog.GetDirectory()
 
299
            IconFile=os.path.join(self.IconDirname,self.IconFilename)
 
300
            self.RConfigure("IconChange", IconFile)
 
301
        self.IconDialog.Destroy()
 
302
    #Pop-up menu for game list: ending
207
303
 
208
304
  def Select(self, event):
209
305
        game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
214
310
                if("wine " in self.read[self.i]):
215
311
                        self.wine_present = True;
216
312
                self.i += 1
217
 
 
218
 
 
219
313
  def Reload(self, event):
 
314
         time.sleep(0.5);
220
315
         self.games = os.listdir(Variables.playonlinux_rep+"configurations/installed/")
221
316
         self.games.sort()
222
317
         self.list_game.DeleteAllItems()
259
354
  def PolShell(self, event):
260
355
    os.system("bash \""+Variables.playonlinux_env+"/bash/expert/PolShell\"&")
261
356
 
 
357
  def RConfigure(self, function_to_run, firstargument):
 
358
    """Starts polconfigurator remotely."""
 
359
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
 
360
    print game_exec
 
361
    print function_to_run
 
362
   
 
363
    if(game_exec != ""):
 
364
        print("Running (remotely) configuration of "+game_exec)
 
365
        os.system("bash \""+Variables.playonlinux_env+"/bash/polconfigurator\" \""+game_exec+"\" \""+function_to_run+"\" \""+firstargument+"\"&")
 
366
 
262
367
  def Configure(self, event):
263
368
    game_exec = self.list_game.GetItemText(self.list_game.GetSelection())
264
369
    if(game_exec != ""):
319
424
    self.aboutBox.SetDescription(_("Run your Windows programs on Linux !"))
320
425
    self.aboutBox.SetCopyright(_("(C) PlayOnLinux team 2008\nUnder GPL licence version 3"))
321
426
    self.aboutBox.AddDeveloper("Developer and Website : Tinou (Pâris Quentin)")  
322
 
    self.aboutBox.AddDeveloper("Scriptors : MulX (Petit Aymeric), GNU_Raziel")
 
427
    self.aboutBox.AddDeveloper("Scriptors : MulX (Petit Aymeric), GNU_Raziel, NSLW")
323
428
    self.aboutBox.AddDeveloper("Packager : MulX (Petit Aymeric)")
324
429
    self.aboutBox.AddDeveloper("Script Creator : Zoloom (Cassarin-Grand Arthur)")
325
 
    self.aboutBox.AddDeveloper("Helped for the program : kiplantt")
 
430
    self.aboutBox.AddDeveloper("Helped for the program : kiplantt, NSLW")
326
431
    self.aboutBox.AddArtist("Icons are provided by Tango Desktop Project")
327
432
    self.aboutBox.SetWebSite("http://www.playonlinux.com")
328
433
    self.aboutBox.SetLicence(open(Variables.playonlinux_env+"/LICENCE",'r').read())