-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_gcedit
executable file
·47 lines (41 loc) · 1.42 KB
/
run_gcedit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#! /usr/bin/env python
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
import sys
from distutils import sysconfig
_LIB_PREFIX = '/usr/local'
sys.path.append(sysconfig.get_python_lib(prefix = _LIB_PREFIX))
# non-lowercase modules = evil
from gi.repository import Gtk as gtk, Gdk as gdk, GObject as gobject
from gcedit import conf
from gcedit import loader
# add icons under current dir to icon search path
gtk.IconTheme.get_default().append_search_path('icons')
gtk.Window.set_default_icon_name(conf.IDENTIFIER)
fn_hist = conf.read_lines('disk_history')
if __name__ == '__main__':
# initialise threading support
gobject.threads_init()
gdk.threads_init()
gdk.threads_enter()
ldr = None
try:
# use the first argument as a filename to load, if given
fn = sys.argv[1]
except IndexError:
# ask for a disk image
ldr = loader.LoadDisk(fn_hist)
else:
# try to load given file
if loader.run_editor(fn):
loader.add_to_hist(fn_hist, fn)
else:
# failed: fall back to loader
ldr = loader.LoadDisk(fn_hist)
# kind of hacky
if ldr is None or not ldr.do_quit:
# start GTK main loop
gtk.main()
gdk.threads_leave()