commit 8d82dc58fcb6984f834e6dacf043c52866df58a3 Author: Nis Wechselberg Date: Thu Aug 2 13:47:53 2018 +0200 Initial version, modified original by als diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f9ff3fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,124 @@ +###SublimeText### + +# cache files for sublime text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# workspace files are user-specific +*.sublime-workspace + +# project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using SublimeText +# *.sublime-project + +# sftp configuration file +sftp-config.json + + +###Python### + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +.static_storage/ +.media/ +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0e259d4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/PyEclipseLaunch.py b/PyEclipseLaunch.py new file mode 100755 index 0000000..ae5873f --- /dev/null +++ b/PyEclipseLaunch.py @@ -0,0 +1,150 @@ +#!/usr/bin/env python3 + +# Python Eclipse Launcher by Alexander Schulz-Rosengarten +# Modified by Nis Wechselberg +# +# To the extent possible under law, the person who associated CC0 with +# Python Eclipse Launcher has waived all copyright and related or +# neighboring rights to Python Eclipse Launcher. +# +# You should have received a copy of the CC0 legalcode along with this +# work. If not, see . + +""" +Python Eclipse Launcher + +Small launcher application to access the different eclipse installations +in a common main directory. +""" + +from subprocess import Popen +import sys +import os +import re + +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +# The common main directory for the eclipse installations +ECLIPSES_DIR = "/home/enbewe/Software/Eclipse" + + + ###### ## ## #### +## ## ## ## ## +## ## ## ## +## #### ## ## ## +## ## ## ## ## +## ## ## ## ## + ###### ####### #### + +class LauncherWindow(Gtk.ApplicationWindow): + """GTK window construction""" + def __init__(self, app): + Gtk.Window.__init__(self, title="Eclipse Launcher", application=app) + # configure window + self.set_default_size(200, 400) + #self.set_resizable(False) + self.set_position(Gtk.WindowPosition.CENTER) + self.set_icon_from_file(get_resource_path(ECLIPSES_DIR+"/icon.png")) + + # the scrolled panel + scrolled_window = Gtk.ScrolledWindow() + scrolled_window.set_border_width(15) + scrolled_window.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + + # a grid + grid = Gtk.Grid() + # some space between the row of the grid + grid.set_row_spacing(2) + + eclipses = [] + for entry in [edir for edir in os.listdir(ECLIPSE_DIR_RES) if is_eclipse_dir(edir)]: + eclipses.append(entry) + + eclipses.sort(key=natural_sort_key) + if eclipses: + eclipse_label = Gtk.Button() + eclipse_label.set_label(to_label(eclipses[0])) + eclipse_label.set_relief(Gtk.ReliefStyle.NONE) + eclipse_label.connect("clicked", start_eclipse, eclipses[0]) + eclipse_label.set_hexpand(True) + grid.attach(eclipse_label, 0, 0, 1, 1) + + for eclipse in eclipses[1:]: + next_eclipse_label = Gtk.Button() + next_eclipse_label.set_label(to_label(eclipse)) + next_eclipse_label.set_relief(Gtk.ReliefStyle.NONE) + next_eclipse_label.connect("clicked", start_eclipse, eclipse) + next_eclipse_label.set_hexpand(True) + grid.attach_next_to( + next_eclipse_label, eclipse_label, Gtk.PositionType.BOTTOM, 1, 1) + eclipse_label = next_eclipse_label + + # add the grid to the scrolled window + scrolled_window.add_with_viewport(grid) + # add the scrolled window to the window + self.add(scrolled_window) + +class LauncherApp(Gtk.Application): + """Main GTK application""" + def __init__(self): + Gtk.Application.__init__(self) + + def do_activate(self): + """Create and activate a window""" + win = LauncherWindow(self) + win.show_all() + + def do_startup(self): + """Application startup handler""" + Gtk.Application.do_startup(self) + +## ## ######## #### ## #### ######## ## ## +## ## ## ## ## ## ## ## ## +## ## ## ## ## ## ## #### +## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## +## ## ## ## ## ## ## ## + ####### ## #### ######## #### ## ## + +def get_resource_path(rel_path): + """Resolve a relative or absolute path""" + dir_of_py_file = os.path.dirname(__file__) + rel_path_to_resource = os.path.join(dir_of_py_file, rel_path) + abs_path_to_resource = os.path.abspath(rel_path_to_resource) + return abs_path_to_resource + +def start_eclipse(_self, eclipse): + """Fork eclipse process""" + menv = os.environ.copy() + # menv["SWT_GTK3"] = "0" + Popen([ECLIPSE_DIR_RES+"/"+eclipse+"/eclipse/eclipse"], env=menv, start_new_session=True) + sys.exit(1) + +def to_label(name): + """Extract button label from folder name""" + return " ".join(map(str.capitalize, name.split("-"))) + +def natural_sort_key(line, _nsre=re.compile('([0-9]+)')): + """Extract sort keys from given lines""" + return [int(text) if text.isdigit() else text.lower() for text in re.split(_nsre, line)] + +def is_eclipse_dir(dirname): + """Check if the given path points to an eclipse installation""" + path = ECLIPSE_DIR_RES+"/"+dirname + return os.path.isdir(path) and os.path.isfile(path+"/eclipse/eclipse") + +## ## ### #### ## ## +### ### ## ## ## ### ## +#### #### ## ## ## #### ## +## ### ## ## ## ## ## ## ## +## ## ######### ## ## #### +## ## ## ## ## ## ### +## ## ## ## #### ## ## + +# Create and run the application +ECLIPSE_DIR_RES = get_resource_path(ECLIPSES_DIR) +EXIT_STATE = LauncherApp().run(sys.argv) +# exit with the value returned by running the program +sys.exit(EXIT_STATE) diff --git a/PyEclipseLaunch.sublime-project b/PyEclipseLaunch.sublime-project new file mode 100644 index 0000000..24db303 --- /dev/null +++ b/PyEclipseLaunch.sublime-project @@ -0,0 +1,8 @@ +{ + "folders": + [ + { + "path": "." + } + ] +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..af21ee2 --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# Python Eclipse Launcher Tool + +Small GTK based tool to start Eclipse installations stored in a common +directory. This is primarily useful when using multiple Eclipse Installations +created through the Oomph installer. + +## Installation + +* Clone the repository to any location +* Adjust the variable `ECLIPSES_DIR` to point to your common Eclipse root. +* Create a launcher shortcut to this script. + +## License + +``` +Python Eclipse Launcher by Alexander Schulz-Rosengarten +Modified by Nis Wechselberg + +To the extent possible under law, the person who associated CC0 with +Python Eclipse Launcher has waived all copyright and related or +neighboring rights to Python Eclipse Launcher. + +You should have received a copy of the CC0 legalcode along with this +work. If not, see . +``` + +The full copy of the CC0 legalcode can be found in the file LICENSE.