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

Licence file added and minimal polishing #1

Open
wants to merge 5 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
19 changes: 19 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2015 Ricardo (XenGi) Band <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
52 changes: 29 additions & 23 deletions quickedit
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/python
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
#
# [email protected] 2012-04-25

"""
You can use QuickEdit to change the Quick-launch icons on the bottom when
Expand All @@ -10,15 +8,17 @@ the Quick-launch icon you want to change and then on the new app. That's all!
Further information: http://xengi.de/quickedit
"""

__usage__ = "usage: %prog [--help]"
__version__ = "toggle [xengi.de 2012-04-25]"
import sys
import os
import errno
import fileinput

import sys,os,errno,fileinput
from PySide import QtCore
from PySide import QtGui
from PySide import QtDeclarative
from PySide import QtOpenGL


class AppWrapper(QtCore.QObject):
def __init__(self, app):
QtCore.QObject.__init__(self)
Expand All @@ -39,11 +39,12 @@ class AppWrapper(QtCore.QObject):
icon = QtCore.Property(unicode, _icon, notify=changed)
isQL = QtCore.Property(unicode, _isQL, notify=changed)


class AppListModel(QtCore.QAbstractListModel):
COLUMNS = ('app',)
COLUMNS = ('app', )

def __init__(self, apps):
QtCore.QAbstractListModel.__init__(self)
super(QtCore.QAbstractListModel, self).__init__()
self._apps = apps
self.setRoleNames(dict(enumerate(AppListModel.COLUMNS)))

Expand All @@ -55,6 +56,7 @@ class AppListModel(QtCore.QAbstractListModel):
return self._apps[index.row()]
return None


class Controller(QtCore.QObject):
@QtCore.Slot(QtCore.QObject)
def appSelected(self, wrapper):
Expand All @@ -66,23 +68,24 @@ class Controller(QtCore.QObject):
rc = view.rootContext()
rc.setContextProperty('quickListModel', AppListModel(updateQuickLaunch()))
qlSelected = wrapper._app.desktopfile[51:52]
print "quicklaunch pressed", wrapper._app.desktopfile[51:52]
# print "quicklaunch pressed", wrapper._app.desktopfile[51:52]
else:
print "app pressed", wrapper._app.name
# print "app pressed", wrapper._app.name
if qlSelected > -1:
try:
os.symlink(wrapper._app.desktopfile, "/home/user/.local/share/applications/quicklaunchbar" + qlSelected + ".desktop")
print "quick-launch", qlSelected, "updated"
# print "quick-launch", qlSelected, "updated"
except OSError, e:
if e.errno == errno.EEXIST:
os.remove("/home/user/.local/share/applications/quicklaunchbar" + qlSelected + ".desktop")
os.symlink(wrapper._app.desktopfile, "/home/user/.local/share/applications/quicklaunchbar" + qlSelected + ".desktop")
print "quick-launch", qlSelected, "force updated"
# print "quick-launch", qlSelected, "force updated"
qlSelected = -1
# update quick launch
rc = view.rootContext()
rc.setContextProperty('quickListModel', AppListModel(updateQuickLaunch()))


class App(object):
def __init__(self, name, icon, isQL, desktopfile):
self.name = name
Expand All @@ -93,6 +96,7 @@ class App(object):
def __str__(self):
return self.name


def repairQuickLaunch(quickdirlist):
global rebootNeeded

Expand All @@ -106,7 +110,7 @@ def repairQuickLaunch(quickdirlist):
if e.errno == errno.EEXIST:
os.remove(filename)
os.symlink("/usr/share/applications/browser.desktop", filename)
print "Broken quick-launch symlink fixed!"
# print "Broken quick-launch symlink fixed!"

# check if an app of the quicklaunch was uninstalled and fix it
reboot = False
Expand All @@ -120,6 +124,7 @@ def repairQuickLaunch(quickdirlist):
print "You need to reboot to repair your quick-launch."
rebootNeeded = 1


def updateQuickLaunch():
quicklist = []
quickdirlist = ["/home/user/.local/share/applications/quicklaunchbar0.desktop",
Expand All @@ -136,7 +141,7 @@ def updateQuickLaunch():
appicon = ""
for line in lines:
line = line.rstrip()
if ( line.startswith("Name=") ) and ( appname == "" ):
if line.startswith("Name=") and appname == "":
appname = line[5:]
if line.startswith("Icon="):
if "/" in line:
Expand All @@ -147,11 +152,12 @@ def updateQuickLaunch():
appicon = "/usr/share/themes/base/meegotouch/icons/" + line[5:] + ".svg"
if not os.path.isfile(appicon):
appicon = "/usr/share/icons/hicolor/64x64/apps/" + line[5:] + ".png"
if ( appname != "" ) and ( appicon != "" ):
if appname != "" and appicon != "":
quicklist.append(App(appname, appicon, "1", filename))

return [AppWrapper(app) for app in quicklist]


if __name__ == "__main__":
qapp = QtGui.QApplication(sys.argv)
view = QtDeclarative.QDeclarativeView()
Expand All @@ -163,15 +169,15 @@ if __name__ == "__main__":
path = "/usr/share/applications/"
dirList = os.listdir(path)
for filename in dirList:
if ( filename.endswith(".desktop") ) and ( not os.path.islink(path + filename) ):
f = file(path + filename)
if filename.endswith(".desktop") and not os.path.islink(os.path.join(path, filename)):
f = file(os.path.join(path, filename))
lines = f.readlines()
appname = ""
appicon = ""
show = True
for line in lines:
line = line.rstrip()
if ( line.startswith("Name=") ) and ( appname == "" ):
if line.startswith("Name=") and appname == "":
appname = line[5:]
if line.startswith("Icon="):
if "/" in line:
Expand All @@ -184,21 +190,21 @@ if __name__ == "__main__":
appicon = "/usr/share/icons/hicolor/64x64/apps/" + line[5:] + ".png"
if line.startswith("NotShowIn=X-MeeGo"):
show = False
if ( appname != "" ) and ( appicon != "" ) and show:
if appname != "" and appicon != "" and show:
applist.append(App(appname, appicon, "0", path + filename))

path = "/var/lib/apt-desktop/entries/"
dirList = os.listdir(path)
for filename in dirList:
if not os.path.islink(path + filename):
f = file(path + filename)
if not os.path.islink(os.path.join(path, filename)):
f = file(os.path.join(path, filename))
lines = f.readlines()
appname = ""
appicon = ""
show = True
for line in lines:
line = line.rstrip()
if ( line.startswith("Name=") ) and ( appname == "" ):
if line.startswith("Name=") and appname == "":
appname = line[5:]
if line.startswith("Icon="):
if "/" in line:
Expand All @@ -211,7 +217,7 @@ if __name__ == "__main__":
appicon = "/usr/share/icons/hicolor/64x64/apps/" + line[5:] + ".png"
if line.startswith("NotShowIn=X-MeeGo"):
show = False
if ( appname != "" ) and ( appicon != "" ) and show:
if appname != "" and appicon != "" and show:
applist.append(App(appname, appicon, "0", path + filename))

apps = [AppWrapper(app) for app in applist]
Expand Down
2 changes: 1 addition & 1 deletion quickedit.psa
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ section = system
pyversion = 2.6
project = quickedit
template = harmattan
email = [email protected]
email = [email protected]
desc = Change your Quick-launch icons easily.

7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

from distutils.core import setup
import os, sys, glob

Expand All @@ -8,9 +10,10 @@ def read(fname):
scripts=['quickedit'],
version='0.99.9',
maintainer="Ricardo Band",
maintainer_email="[email protected]",
maintainer_email="[email protected]",
description="Change your Quick-launch icons easily.",
long_description=read('quickedit.longdesc'),
data_files=[('share/applications',['quickedit.desktop']),
('share/icons/hicolor/64x64/apps', ['quickedit.png']),
('/opt/quickedit/qml', glob.glob('qml/*.qml')), ],)
('/opt/quickedit/qml', glob.glob('qml/*.qml')),
('', ['LICENSE']), ], )