Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add python3 support. #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ obt/obt-3.5.pc
tools/gnome-panel-control/gnome-panel-control
tools/gdm-control/gdm-control
tools/obxprop/obxprop
tools/themeupdate/themeupdate.py
version.h
.libs
.deps
Expand All @@ -77,6 +78,7 @@ tests/grouptran
tests/grouptran2
tests/grouptrancircular
tests/grouptrancircular2
tests/hideshow.py
tests/iconifydelay
tests/icons
tests/mapiconic
Expand All @@ -102,6 +104,7 @@ tests/urgent
tests/usertimewin
tests/wmhints
data/autostart/openbox-autostart
data/autostart/openbox-xdg-autostart
data/autostart/autostart
obrender/rendertest
obt/tests/bstest
Expand Down
5 changes: 5 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ AC_CHECK_HEADERS(ctype.h dirent.h errno.h fcntl.h grp.h locale.h pwd.h)
AC_CHECK_HEADERS(signal.h string.h stdio.h stdlib.h unistd.h sys/stat.h)
AC_CHECK_HEADERS(sys/select.h sys/socket.h sys/time.h sys/types.h sys/wait.h)

AM_PATH_PYTHON([2],,)

AC_PATH_PROG([SED], [sed], [no])
if test "$SED" = "no"; then
AC_MSG_ERROR([The program "sed" is not available. This program is required to build Openbox.])
Expand Down Expand Up @@ -259,6 +261,9 @@ AC_CONFIG_FILES([
obrender/version.h
obt/version.h
version.h
data/autostart/openbox-xdg-autostart
tests/hideshow.py
tools/themeupdate/themeupdate.py
])
AC_CONFIG_COMMANDS([doc],
[test -d doc || mkdir doc])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!@PYTHON@

# openbox-xdg-autostart runs things based on the XDG autostart specification
# Copyright (C) 2008 Dana Jansens
Expand Down Expand Up @@ -28,9 +28,7 @@ try:
from xdg.DesktopEntry import DesktopEntry
from xdg.Exceptions import ParsingError
except ImportError:
print
print >>sys.stderr, "ERROR:", ME, "requires PyXDG to be installed"
print
sys.stderr.write("\nERROR: %s requires PyXDG to be installed\n" % ME)
sys.exit(1)

def main(argv=sys.argv):
Expand All @@ -51,7 +49,7 @@ def main(argv=sys.argv):
try:
autofile = AutostartFile(path)
except ParsingError:
print "Invalid .desktop file: " + path
print("Invalid .desktop file: " + path)
else:
if not autofile in files:
files.append(autofile)
Expand Down Expand Up @@ -99,9 +97,9 @@ class AutostartFile:

def _alert(self, str, info=False):
if info:
print "\t ", str
print("\t ", str)
else:
print "\t*", str
print("\t*", str)

def _showInEnvironment(self, envs, verbose=False):
default = not self.de.getOnlyShowIn()
Expand Down Expand Up @@ -146,14 +144,14 @@ class AutostartFile:

def display(self, envs):
if self._shouldRun(envs):
print "[*] " + self.de.getName()
print("[*] " + self.de.getName())
else:
print "[ ] " + self.de.getName()
print("[ ] " + self.de.getName())
self._alert("File: " + self.path, info=True)
if self.de.getExec():
self._alert("Executes: " + self.de.getExec(), info=True)
self._shouldRun(envs, True)
print
print()

def run(self, envs):
here = os.getcwd()
Expand All @@ -165,34 +163,34 @@ class AutostartFile:
os.chdir(here)

def show_help():
print "Usage:", ME, "[OPTION]... [ENVIRONMENT]..."
print
print "This tool will run xdg autostart .desktop files"
print
print "OPTIONS"
print " --list Show a list of the files which would be run"
print " Files which would be run are marked with an asterix"
print " symbol [*]. For files which would not be run,"
print " information is given for why they are excluded"
print " --help Show this help and exit"
print " --version Show version and copyright information"
print
print "ENVIRONMENT specifies a list of environments for which to run autostart"
print "applications. If none are specified, only applications which do not "
print "limit themselves to certain environments will be run."
print
print "ENVIRONMENT can be one or more of:"
print " GNOME Gnome Desktop"
print " KDE KDE Desktop"
print " ROX ROX Desktop"
print " XFCE XFCE Desktop"
print " Old Legacy systems"
print
print("Usage:", ME, "[OPTION]... [ENVIRONMENT]...")
print()
print("This tool will run xdg autostart .desktop files")
print()
print("OPTIONS")
print(" --list Show a list of the files which would be run")
print(" Files which would be run are marked with an asterix")
print(" symbol [*]. For files which would not be run,")
print(" information is given for why they are excluded")
print(" --help Show this help and exit")
print(" --version Show version and copyright information")
print()
print("ENVIRONMENT specifies a list of environments for which to run autostart")
print("applications. If none are specified, only applications which do not ")
print("limit themselves to certain environments will be run.")
print()
print("ENVIRONMENT can be one or more of:")
print(" GNOME Gnome Desktop")
print(" KDE KDE Desktop")
print(" ROX ROX Desktop")
print(" XFCE XFCE Desktop")
print(" Old Legacy systems")
print()

def show_version():
print ME, VERSION
print "Copyright (c) 2008 Dana Jansens"
print
print(ME, VERSION)
print("Copyright (c) 2008 Dana Jansens")
print()

if __name__ == "__main__":
sys.exit(main())
46 changes: 23 additions & 23 deletions tests/hideshow.py → tests/hideshow.py.in
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
#!/usr/bin/env python
#!@PYTHON@

import pygtk
import gtk
import gobject
pygtk.require('2.0')
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import GObject

class FolderSelector(gtk.Window):
class FolderSelector(Gtk.Window):
def __init__(self, jules):
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
print "init folder selector", self, jules
Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)
print("init folder selector", self, jules)
self.set_title("Select Folder")
self.jules = jules

self.set_size_request(140, 200)

self.list_model = gtk.ListStore(gobject.TYPE_STRING)
self.tree = gtk.TreeView(self.list_model)
self.folder_column = gtk.TreeViewColumn('Folder')
self.list_model = Gtk.ListStore(GObject.TYPE_STRING)
self.tree = Gtk.TreeView(self.list_model)
self.folder_column = Gtk.TreeViewColumn('Folder')
self.tree.append_column(self.folder_column)

self.folder_cell = gtk.CellRendererText()
self.folder_cell = Gtk.CellRendererText()
self.folder_column.pack_start(self.folder_cell, True)
self.folder_column.add_attribute(self.folder_cell, 'text', 0)

self.tree.set_search_column(0)

self.icon_theme = gtk.icon_theme_get_default()
self.icon_theme = Gtk.IconTheme.get_default()

self.add(self.tree)
self.show_all()
self.tree.columns_autosize()
print "done init"
print("done init")

class Jules(gtk.Window):
class Jules(Gtk.Window):
def __init__(self):
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
Gtk.Window.__init__(self, Gtk.WindowType.TOPLEVEL)
self.set_title("Jules")
self.set_size_request(150, 320)
self.connect("delete_event", self.on_delete_event)
self.connect("destroy", self.on_destroy)
self.scroll = gtk.ScrolledWindow()
self.scroll = Gtk.ScrolledWindow()

self.tree_model = gtk.TreeStore(gobject.TYPE_STRING,
gobject.TYPE_STRING)
self.tree = gtk.TreeView(self.tree_model)
self.file_column = gtk.TreeViewColumn('name', gtk.CellRendererText(),
self.tree_model = Gtk.TreeStore(GObject.TYPE_STRING,
GObject.TYPE_STRING)
self.tree = Gtk.TreeView(self.tree_model)
self.file_column = Gtk.TreeViewColumn('name', Gtk.CellRendererText(),
markup=0)
self.file_column.set_sort_indicator(True)
self.file_column.set_clickable(True)
Expand All @@ -67,10 +67,10 @@ def on_delete_event(self, widget, event):
return False

def on_destroy(self, widget):
gtk.main_quit()
Gtk.main_quit()

def run(self):
gtk.main()
Gtk.main()


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/python
#! @PYTHON@

# themeupdate.py for the Openbox window manager
# This utility is for updating old themes from Blackbox, Fluxbox, and Openbox2
Expand Down Expand Up @@ -63,7 +63,7 @@ def simple_replace(data):
pairs['textColor'] = 'text.color'
pairs['interlaceColor'] = 'interlace.color'

for k in pairs.keys():
for k in list(pairs.keys()):
while 1:
i, key, nul = find_key(data, k);
if i >= 0:
Expand Down Expand Up @@ -120,7 +120,7 @@ def simple_replace(data):
pairs['window.button.hover.focus'] = 'window.active.button.hover.bg'
pairs['window.button.hover.unfocus'] = 'window.inactive.button.hover.bg'

for k in pairs.keys():
for k in list(pairs.keys()):
while 1:
i, key, nul = find_key(data, k, True);
if i >= 0:
Expand Down Expand Up @@ -173,7 +173,7 @@ def simple_replace(data):
pairs['window.button.toggled.focus'] = 'window.active.button.toggled'
pairs['window.button.toggled.unfocus'] = 'window.inactive.button.toggled'

for k in pairs.keys():
for k in list(pairs.keys()):
while 1:
i, key, nul = find_key(data, k);
if i >= 0:
Expand Down Expand Up @@ -292,7 +292,7 @@ def xft_fonts(data):
fonts['window'] = 'window.label.focus.font'
fonts['menu.items'] = 'menu.items.font'
fonts['menu.title'] = 'menu.title.font'
for f in fonts.keys():
for f in list(fonts.keys()):
li, nul, flags = find_key(data, f + '.xft.flags')
if li < 0:
li, nul, flags = find_key(data, '*.xft.flags')
Expand Down Expand Up @@ -405,6 +405,6 @@ def usage():
err_missing(data)

for l in data:
print l
print(l)

sys.exit(not valid)