mirror of
https://github.com/lutris/lutris
synced 2024-10-07 08:19:07 +00:00
Initial project creation with Quickly!
This commit is contained in:
commit
470f546e9f
3
.quickly
Normal file
3
.quickly
Normal file
|
@ -0,0 +1,3 @@
|
|||
project = lutris
|
||||
template = ubuntu-project
|
||||
format = 0.2.5
|
3
Copyright
Normal file
3
Copyright
Normal file
|
@ -0,0 +1,3 @@
|
|||
# Copyright (C) YYYY <Your Name> <Your E-mail>
|
||||
### BEGIN AUTOMATIC LICENSE GENERATION
|
||||
### END AUTOMATIC LICENSE GENERATION
|
114
bin/lutris
Executable file
114
bin/lutris
Executable file
|
@ -0,0 +1,114 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
### BEGIN LICENSE
|
||||
# This file is in the public domain
|
||||
### END LICENSE
|
||||
|
||||
import sys
|
||||
import os
|
||||
import gtk
|
||||
|
||||
# Check if we are working in the source tree or from the installed
|
||||
# package and mangle the python path accordingly
|
||||
if os.path.dirname(sys.argv[0]) != ".":
|
||||
if sys.argv[0][0] == "/":
|
||||
fullPath = os.path.dirname(sys.argv[0])
|
||||
else:
|
||||
fullPath = os.getcwd() + "/" + os.path.dirname(sys.argv[0])
|
||||
else:
|
||||
fullPath = os.getcwd()
|
||||
sys.path.insert(0, os.path.dirname(fullPath))
|
||||
|
||||
from lutris import AboutLutrisDialog, PreferencesLutrisDialog
|
||||
from lutris.lutrisconfig import getdatapath
|
||||
|
||||
class LutrisWindow(gtk.Window):
|
||||
__gtype_name__ = "LutrisWindow"
|
||||
|
||||
def __init__(self):
|
||||
"""__init__ - This function is typically not called directly.
|
||||
Creation a LutrisWindow requires redeading the associated ui
|
||||
file and parsing the ui definition extrenally,
|
||||
and then calling LutrisWindow.finish_initializing().
|
||||
|
||||
Use the convenience function NewLutrisWindow to create
|
||||
LutrisWindow object.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def finish_initializing(self, builder):
|
||||
"""finish_initalizing should be called after parsing the ui definition
|
||||
and creating a LutrisWindow object with it in order to finish
|
||||
initializing the start of the new LutrisWindow instance.
|
||||
|
||||
"""
|
||||
#get a reference to the builder and set up the signals
|
||||
self.builder = builder
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
#uncomment the following code to read in preferences at start up
|
||||
#dlg = PreferencesLutrisDialog.NewPreferencesLutrisDialog()
|
||||
#self.preferences = dlg.get_preferences()
|
||||
|
||||
#code for other initialization actions should be added here
|
||||
|
||||
def about(self, widget, data=None):
|
||||
"""about - display the about box for lutris """
|
||||
about = AboutLutrisDialog.NewAboutLutrisDialog()
|
||||
response = about.run()
|
||||
about.destroy()
|
||||
|
||||
def preferences(self, widget, data=None):
|
||||
"""preferences - display the preferences window for lutris """
|
||||
prefs = PreferencesLutrisDialog.NewPreferencesLutrisDialog()
|
||||
response = prefs.run()
|
||||
if response == gtk.RESPONSE_OK:
|
||||
#make any updates based on changed preferences here
|
||||
pass
|
||||
prefs.destroy()
|
||||
|
||||
def quit(self, widget, data=None):
|
||||
"""quit - signal handler for closing the LutrisWindow"""
|
||||
self.destroy()
|
||||
|
||||
def on_destroy(self, widget, data=None):
|
||||
"""on_destroy - called when the LutrisWindow is close. """
|
||||
#clean up code for saving application state should be added here
|
||||
|
||||
gtk.main_quit()
|
||||
|
||||
def NewLutrisWindow():
|
||||
"""NewLutrisWindow - returns a fully instantiated
|
||||
LutrisWindow object. Use this function rather than
|
||||
creating a LutrisWindow directly.
|
||||
"""
|
||||
|
||||
#look for the ui file that describes the ui
|
||||
ui_filename = os.path.join(getdatapath(), 'ui', 'LutrisWindow.ui')
|
||||
if not os.path.exists(ui_filename):
|
||||
ui_filename = None
|
||||
|
||||
builder = gtk.Builder()
|
||||
builder.add_from_file(ui_filename)
|
||||
window = builder.get_object("lutris_window")
|
||||
window.finish_initializing(builder)
|
||||
return window
|
||||
|
||||
if __name__ == "__main__":
|
||||
#support for command line options
|
||||
import logging, optparse
|
||||
parser = optparse.OptionParser(version="%prog %ver")
|
||||
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", help="Show debug messages")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
#set the logging level to show debug messages
|
||||
if options.verbose:
|
||||
logging.basicConfig(level=logging.DEBUG)
|
||||
logging.debug('logging enabled')
|
||||
|
||||
#run the application
|
||||
window = NewLutrisWindow()
|
||||
window.show()
|
||||
gtk.main()
|
||||
|
BIN
data/media/background.png
Normal file
BIN
data/media/background.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
BIN
data/media/icon.png
Normal file
BIN
data/media/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 552 B |
BIN
data/media/logo.png
Normal file
BIN
data/media/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
150
data/media/logo.svg
Normal file
150
data/media/logo.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 86 KiB |
34
data/ui/AboutLutrisDialog.ui
Normal file
34
data/ui/AboutLutrisDialog.ui
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-requires about_lutris_dialog 1.0 -->
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="AboutLutrisDialog" id="about_lutris_dialog">
|
||||
<property name="border_width">5</property>
|
||||
<property name="icon">../media/icon.png</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<property name="has_separator">False</property>
|
||||
<property name="program_name">Lutris</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
226
data/ui/LutrisWindow.ui
Normal file
226
data/ui/LutrisWindow.ui
Normal file
|
@ -0,0 +1,226 @@
|
|||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-requires lutris_window 1.0 -->
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<!-- interface-local-resource-path ../media -->
|
||||
<object class="LutrisWindow" id="lutris_window">
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">500</property>
|
||||
<property name="title" translatable="yes">Lutris</property>
|
||||
<property name="icon">../media/icon.png</property>
|
||||
<signal name="destroy" handler="on_destroy"/>
|
||||
<child>
|
||||
<object class="GtkVBox" id="vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">5</property>
|
||||
<child>
|
||||
<object class="GtkMenuBar" id="menubar1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_File</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem1">
|
||||
<property name="label">gtk-new</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_action_appearance">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem2">
|
||||
<property name="label">gtk-open</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem3">
|
||||
<property name="label">gtk-save</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem4">
|
||||
<property name="label">gtk-save-as</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem5">
|
||||
<property name="label">gtk-quit</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="quit"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem2">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Edit</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu2">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem6">
|
||||
<property name="label">gtk-cut</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem7">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem8">
|
||||
<property name="label">gtk-paste</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem9">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem2">
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem11">
|
||||
<property name="label">gtk-preferences</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="preferences"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem3">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_View</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem" id="menuitem4">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu3">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="imagemenuitem10">
|
||||
<property name="label">gtk-about</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="activate" handler="about"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="xpad">5</property>
|
||||
<property name="ypad">5</property>
|
||||
<property name="label" translatable="yes">Your application has been created!
|
||||
|
||||
To start changing this user interface, run 'quickly glade', which will open Glade so you can edit the default windows and dialogs.
|
||||
|
||||
To change the behavior and edit the python code, run 'quickly edit', which will bring up a text editor.</property>
|
||||
<property name="wrap">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImage" id="image1">
|
||||
<property name="visible">True</property>
|
||||
<property name="xpad">5</property>
|
||||
<property name="ypad">5</property>
|
||||
<property name="pixbuf">../media/background.png</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="padding">15</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStatusbar" id="statusbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label2">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="xpad">5</property>
|
||||
<property name="ypad">5</property>
|
||||
<property name="label" translatable="yes">Status Area</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
67
data/ui/PreferencesLutrisDialog.ui
Normal file
67
data/ui/PreferencesLutrisDialog.ui
Normal file
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0"?>
|
||||
<interface>
|
||||
<requires lib="gtk+" version="2.16"/>
|
||||
<!-- interface-requires preferences_lutris_dialog 1.0 -->
|
||||
<!-- interface-naming-policy project-wide -->
|
||||
<object class="PreferencesLutrisDialog" id="preferences_lutris_dialog">
|
||||
<property name="border_width">5</property>
|
||||
<property name="icon">../media/icon.png</property>
|
||||
<property name="type_hint">normal</property>
|
||||
<property name="has_separator">False</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<object class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="button2">
|
||||
<property name="label" translatable="yes">gtk-cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="cancel"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="button1">
|
||||
<property name="label" translatable="yes">gtk-ok</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
<signal name="clicked" handler="ok"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-6">button2</action-widget>
|
||||
<action-widget response="-5">button1</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
9
data/ui/about_lutris_dialog.xml
Normal file
9
data/ui/about_lutris_dialog.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<glade-catalog name="about_lutris_dialog" domain="glade-3"
|
||||
depends="gtk+" version="1.0">
|
||||
<glade-widget-classes>
|
||||
<glade-widget-class title="About Lutris Dialog" name="AboutLutrisDialog"
|
||||
generic-name="AboutLutrisDialog" parent="GtkAboutDialog"
|
||||
icon-name="widget-gtk-about-dialog"/>
|
||||
</glade-widget-classes>
|
||||
|
||||
</glade-catalog>
|
8
data/ui/lutris_window.xml
Normal file
8
data/ui/lutris_window.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<glade-catalog name="lutris_window" domain="glade-3"
|
||||
depends="gtk+" version="1.0">
|
||||
<glade-widget-classes>
|
||||
<glade-widget-class title="Lutris Window" name="LutrisWindow"
|
||||
generic-name="LutrisWindow" parent="GtkWindow"
|
||||
icon-name="widget-gtk-window"/>
|
||||
</glade-widget-classes>
|
||||
</glade-catalog>
|
9
data/ui/preferences_lutris_dialog.xml
Normal file
9
data/ui/preferences_lutris_dialog.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<glade-catalog name="preferences_lutris_dialog" domain="glade-3"
|
||||
depends="gtk+" version="1.0">
|
||||
<glade-widget-classes>
|
||||
<glade-widget-class title="Lutris Preferences Dialog" name="PreferencesLutrisDialog"
|
||||
generic-name="PreferenceLutrisDialog" parent="GtkDialog"
|
||||
icon-name="widget-gtk-dialog"/>
|
||||
</glade-widget-classes>
|
||||
|
||||
</glade-catalog>
|
8
lutris.desktop.in
Normal file
8
lutris.desktop.in
Normal file
|
@ -0,0 +1,8 @@
|
|||
[Desktop Entry]
|
||||
Name=Lutris
|
||||
Comment=Lutris application
|
||||
Categories=GNOME;Utility;
|
||||
Exec=lutris
|
||||
Icon=lutris
|
||||
Terminal=false
|
||||
Type=Application
|
61
lutris/AboutLutrisDialog.py
Normal file
61
lutris/AboutLutrisDialog.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
### BEGIN LICENSE
|
||||
# This file is in the public domain
|
||||
### END LICENSE
|
||||
|
||||
import sys
|
||||
import os
|
||||
import gtk
|
||||
|
||||
from lutris.lutrisconfig import getdatapath
|
||||
|
||||
class AboutLutrisDialog(gtk.AboutDialog):
|
||||
__gtype_name__ = "AboutLutrisDialog"
|
||||
|
||||
def __init__(self):
|
||||
"""__init__ - This function is typically not called directly.
|
||||
Creation of a AboutLutrisDialog requires redeading the associated ui
|
||||
file and parsing the ui definition extrenally,
|
||||
and then calling AboutLutrisDialog.finish_initializing().
|
||||
|
||||
Use the convenience function NewAboutLutrisDialog to create
|
||||
NewAboutLutrisDialog objects.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def finish_initializing(self, builder):
|
||||
"""finish_initalizing should be called after parsing the ui definition
|
||||
and creating a AboutLutrisDialog object with it in order to finish
|
||||
initializing the start of the new AboutLutrisDialog instance.
|
||||
|
||||
"""
|
||||
#get a reference to the builder and set up the signals
|
||||
self.builder = builder
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
#code for other initialization actions should be added here
|
||||
|
||||
def NewAboutLutrisDialog():
|
||||
"""NewAboutLutrisDialog - returns a fully instantiated
|
||||
AboutLutrisDialog object. Use this function rather than
|
||||
creating a AboutLutrisDialog instance directly.
|
||||
|
||||
"""
|
||||
|
||||
#look for the ui file that describes the ui
|
||||
ui_filename = os.path.join(getdatapath(), 'ui', 'AboutLutrisDialog.ui')
|
||||
if not os.path.exists(ui_filename):
|
||||
ui_filename = None
|
||||
|
||||
builder = gtk.Builder()
|
||||
builder.add_from_file(ui_filename)
|
||||
dialog = builder.get_object("about_lutris_dialog")
|
||||
dialog.finish_initializing(builder)
|
||||
return dialog
|
||||
|
||||
if __name__ == "__main__":
|
||||
dialog = NewAboutLutrisDialog()
|
||||
dialog.show()
|
||||
gtk.main()
|
||||
|
119
lutris/PreferencesLutrisDialog.py
Normal file
119
lutris/PreferencesLutrisDialog.py
Normal file
|
@ -0,0 +1,119 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
### BEGIN LICENSE
|
||||
# This file is in the public domain
|
||||
### END LICENSE
|
||||
|
||||
import sys
|
||||
import os
|
||||
import gtk
|
||||
from desktopcouch.records.server import CouchDatabase
|
||||
from desktopcouch.records.record import Record
|
||||
|
||||
from lutris.lutrisconfig import getdatapath
|
||||
|
||||
class PreferencesLutrisDialog(gtk.Dialog):
|
||||
__gtype_name__ = "PreferencesLutrisDialog"
|
||||
prefernces = {}
|
||||
|
||||
def __init__(self):
|
||||
"""__init__ - This function is typically not called directly.
|
||||
Creation of a PreferencesLutrisDialog requires redeading the associated ui
|
||||
file and parsing the ui definition extrenally,
|
||||
and then calling PreferencesLutrisDialog.finish_initializing().
|
||||
|
||||
Use the convenience function NewPreferencesLutrisDialog to create
|
||||
NewAboutLutrisDialog objects.
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
def finish_initializing(self, builder):
|
||||
"""finish_initalizing should be called after parsing the ui definition
|
||||
and creating a AboutLutrisDialog object with it in order to finish
|
||||
initializing the start of the new AboutLutrisDialog instance.
|
||||
"""
|
||||
|
||||
#get a reference to the builder and set up the signals
|
||||
self.builder = builder
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
#set up couchdb and the preference info
|
||||
self.__db_name = "lutris"
|
||||
self.__database = CouchDatabase(self.__db_name, create=True)
|
||||
self.__preferences = None
|
||||
self.__key = None
|
||||
|
||||
#set the record type and then initalize the preferences
|
||||
self.__record_type = "http://wiki.ubuntu.com/Quickly/RecordTypes/Lutris/Preferences"
|
||||
self.__preferences = self.get_preferences()
|
||||
#TODO:code for other initialization actions should be added here
|
||||
|
||||
def get_preferences(self):
|
||||
"""get_preferences -returns a dictionary object that contain
|
||||
preferences for lutris. Creates a couchdb record if
|
||||
necessary.
|
||||
"""
|
||||
|
||||
if self.__preferences == None: #the dialog is initializing
|
||||
self.__load_preferences()
|
||||
|
||||
#if there were no saved preference, this
|
||||
return self.__preferences
|
||||
|
||||
def __load_preferences(self):
|
||||
#TODO: add prefernces to the self.__preferences dict
|
||||
#default preferences that will be overwritten if some are saved
|
||||
self.__preferences = {"record_type":self.__record_type}
|
||||
|
||||
results = self.__database.get_records(record_type=self.__record_type, create_view=True)
|
||||
|
||||
if len(results.rows) == 0:
|
||||
#no preferences have ever been saved
|
||||
#save them before returning
|
||||
self.__key = self.__database.put_record(Record(self.__preferences))
|
||||
else:
|
||||
self.__preferences = results.rows[0].value
|
||||
self.__key = results.rows[0].value["_id"]
|
||||
|
||||
def __save_preferences(self):
|
||||
self.__database.update_fields(self.__key, self.__preferences)
|
||||
|
||||
def ok(self, widget, data=None):
|
||||
"""ok - The user has elected to save the changes.
|
||||
Called before the dialog returns gtk.RESONSE_OK from run().
|
||||
"""
|
||||
|
||||
#make any updates to self.__preferences here
|
||||
#self.__preferences["preference1"] = "value2"
|
||||
self.__save_preferences()
|
||||
|
||||
def cancel(self, widget, data=None):
|
||||
"""cancel - The user has elected cancel changes.
|
||||
Called before the dialog returns gtk.RESPONSE_CANCEL for run()
|
||||
"""
|
||||
|
||||
#restore any changes to self.__preferences here
|
||||
pass
|
||||
|
||||
def NewPreferencesLutrisDialog():
|
||||
"""NewPreferencesLutrisDialog - returns a fully instantiated
|
||||
PreferencesLutrisDialog object. Use this function rather than
|
||||
creating a PreferencesLutrisDialog instance directly.
|
||||
"""
|
||||
|
||||
#look for the ui file that describes the ui
|
||||
ui_filename = os.path.join(getdatapath(), 'ui', 'PreferencesLutrisDialog.ui')
|
||||
if not os.path.exists(ui_filename):
|
||||
ui_filename = None
|
||||
|
||||
builder = gtk.Builder()
|
||||
builder.add_from_file(ui_filename)
|
||||
dialog = builder.get_object("preferences_lutris_dialog")
|
||||
dialog.finish_initializing(builder)
|
||||
return dialog
|
||||
|
||||
if __name__ == "__main__":
|
||||
dialog = NewPreferencesLutrisDialog()
|
||||
dialog.show()
|
||||
gtk.main()
|
||||
|
0
lutris/__init__.py
Normal file
0
lutris/__init__.py
Normal file
40
lutris/lutrisconfig.py
Normal file
40
lutris/lutrisconfig.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
### BEGIN LICENSE
|
||||
# This file is in the public domain
|
||||
### END LICENSE
|
||||
|
||||
# THIS IS Lutris CONFIGURATION FILE
|
||||
# YOU CAN PUT THERE SOME GLOBAL VALUE
|
||||
# Do not touch until you know what you're doing.
|
||||
# you're warned :)
|
||||
|
||||
# where your project will head for your data (for instance, images and ui files)
|
||||
# by default, this is ../data, relative your trunk layout
|
||||
__lutris_data_directory__ = '../data/'
|
||||
|
||||
|
||||
import os
|
||||
|
||||
class project_path_not_found(Exception):
|
||||
pass
|
||||
|
||||
def getdatapath():
|
||||
"""Retrieve lutris data path
|
||||
|
||||
This path is by default <lutris_lib_path>/../data/ in trunk
|
||||
and /usr/share/lutris in an installed version but this path
|
||||
is specified at installation time.
|
||||
"""
|
||||
|
||||
# get pathname absolute or relative
|
||||
if __lutris_data_directory__.startswith('/'):
|
||||
pathname = __lutris_data_directory__
|
||||
else:
|
||||
pathname = os.path.dirname(__file__) + '/' + __lutris_data_directory__
|
||||
|
||||
abs_data_path = os.path.abspath(pathname)
|
||||
if os.path.exists(abs_data_path):
|
||||
return abs_data_path
|
||||
else:
|
||||
raise project_path_not_found
|
||||
|
94
setup.py
Normal file
94
setup.py
Normal file
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
### BEGIN LICENSE
|
||||
# This file is in the public domain
|
||||
### END LICENSE
|
||||
|
||||
###################### DO NOT TOUCH THIS (HEAD TO THE SECOND PART) ######################
|
||||
|
||||
try:
|
||||
import DistUtilsExtra.auto
|
||||
except ImportError:
|
||||
import sys
|
||||
print >> sys.stderr, 'To build lutris you need https://launchpad.net/python-distutils-extra'
|
||||
sys.exit(1)
|
||||
|
||||
assert DistUtilsExtra.auto.__version__ >= '2.10', 'needs DistUtilsExtra.auto >= 2.10'
|
||||
import os
|
||||
|
||||
|
||||
def update_data_path(prefix, oldvalue=None):
|
||||
|
||||
try:
|
||||
fin = file('lutris/lutrisconfig.py', 'r')
|
||||
fout = file(fin.name + '.new', 'w')
|
||||
|
||||
for line in fin:
|
||||
fields = line.split(' = ') # Separate variable from value
|
||||
if fields[0] == '__lutris_data_directory__':
|
||||
# update to prefix, store oldvalue
|
||||
if not oldvalue:
|
||||
oldvalue = fields[1]
|
||||
line = "%s = '%s'\n" % (fields[0], prefix)
|
||||
else: # restore oldvalue
|
||||
line = "%s = %s" % (fields[0], oldvalue)
|
||||
fout.write(line)
|
||||
|
||||
fout.flush()
|
||||
fout.close()
|
||||
fin.close()
|
||||
os.rename(fout.name, fin.name)
|
||||
except (OSError, IOError), e:
|
||||
print ("ERROR: Can't find lutris/lutrisconfig.py")
|
||||
sys.exit(1)
|
||||
return oldvalue
|
||||
|
||||
|
||||
def update_desktop_file(datadir):
|
||||
|
||||
try:
|
||||
fin = file('lutris.desktop.in', 'r')
|
||||
fout = file(fin.name + '.new', 'w')
|
||||
|
||||
for line in fin:
|
||||
if 'Icon=' in line:
|
||||
line = "Icon=%s\n" % (datadir + 'media/icon.png')
|
||||
fout.write(line)
|
||||
fout.flush()
|
||||
fout.close()
|
||||
fin.close()
|
||||
os.rename(fout.name, fin.name)
|
||||
except (OSError, IOError), e:
|
||||
print ("ERROR: Can't find lutris.desktop.in")
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class InstallAndUpdateDataDirectory(DistUtilsExtra.auto.install_auto):
|
||||
def run(self):
|
||||
if self.root or self.home:
|
||||
print "WARNING: You don't use a standard --prefix installation, take care that you eventually " \
|
||||
"need to update quickly/quicklyconfig.py file to adjust __quickly_data_directory__. You can " \
|
||||
"ignore this warning if you are packaging and uses --prefix."
|
||||
previous_value = update_data_path(self.prefix + '/share/lutris/')
|
||||
update_desktop_file(self.prefix + '/share/lutris/')
|
||||
DistUtilsExtra.auto.install_auto.run(self)
|
||||
update_data_path(self.prefix, previous_value)
|
||||
|
||||
|
||||
|
||||
##################################################################################
|
||||
###################### YOU SHOULD MODIFY ONLY WHAT IS BELOW ######################
|
||||
##################################################################################
|
||||
|
||||
DistUtilsExtra.auto.setup(
|
||||
name='lutris',
|
||||
version='0.1',
|
||||
#license='GPL v3',
|
||||
#author='Your Name',
|
||||
#author_email='email@ubuntu.com',
|
||||
#description='UI for managing …',
|
||||
#long_description='Here a longer description',
|
||||
#url='https://launchpad.net/lutris',
|
||||
cmdclass={'install': InstallAndUpdateDataDirectory}
|
||||
)
|
||||
|
Loading…
Reference in a new issue