pds.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. diff -Nuar service-manager-3.0.0.orig//setup.py service-manager-3.0.0/setup.py
  2. --- service-manager-3.0.0.orig//setup.py 2011-03-21 11:09:29.708000015 +0200
  3. +++ service-manager-3.0.0/setup.py 2011-03-21 11:10:08.152000017 +0200
  4. @@ -26,6 +26,12 @@
  5. from distutils.command.install import install
  6. PROJECT = about.appName
  7. +FOR_KDE_4=False
  8. +
  9. +if 'kde4' in sys.argv:
  10. + sys.argv.remove('kde4')
  11. + FOR_KDE_4=True
  12. + print 'UI files will be created for KDE 4.. '
  13. def makeDirs(directory):
  14. if not os.path.exists(directory):
  15. @@ -47,8 +53,14 @@
  16. # Collect UI files
  17. filelist = []
  18. - for filename in glob.glob1("ui", "*.ui"):
  19. - os.system("pykde4uic -o ui/ui_%s.py ui/%s" % (filename.split(".")[0], filename))
  20. + # UI files for kde4
  21. + if FOR_KDE_4:
  22. + for filename in glob.glob1("ui", "*.ui"):
  23. + os.system("pykde4uic -o ui/ui_%s.py ui/%s" % (filename.split(".")[0], filename))
  24. + #UI files for pure-qt
  25. + else :
  26. + for filename in glob.glob1("ui", "*.ui"):
  27. + os.system("pyuic4 -o ui/ui_%s.py ui/%s -g %s" % (filename.split(".")[0], filename, PROJECT))
  28. # Collect headers for desktop files
  29. for filename in glob.glob("data/*.desktop.in"):
  30. @@ -104,8 +116,15 @@
  31. os.system("intltool-merge -d po %s %s" % (filename, filename[:-3]))
  32. print "Generating UIs..."
  33. - for filename in glob.glob1("ui", "*.ui"):
  34. - os.system("pykde4uic -o build/servicemanager/ui_%s.py ui/%s" % (filename.split(".")[0], filename))
  35. + # Collect UI for kde4
  36. + if FOR_KDE_4:
  37. + for filename in glob.glob1("ui", "*.ui"):
  38. + os.system("pykde4uic -o build/servicemanager/ui_%s.py ui/%s" % (filename.split(".")[0], filename))
  39. + # Collect UI for pure-qt
  40. + else:
  41. + for filename in glob.glob1("ui", "*.ui"):
  42. + os.system("pyuic4 -o build/servicemanager/ui_%s.py ui/%s -g %s" % (filename.split(".")[0], filename, PROJECT))
  43. +
  44. print "Generating RCs..."
  45. for filename in glob.glob1("data", "*.qrc"):
  46. @@ -128,9 +147,13 @@
  47. bin_dir = "/usr/bin"
  48. locale_dir = os.path.join(root_dir, "locale")
  49. - apps_dir = os.path.join(root_dir, "applications/kde4")
  50. - services_dir = os.path.join(root_dir, "kde4/services")
  51. - project_dir = os.path.join(root_dir, "kde4/apps", PROJECT)
  52. + if FOR_KDE_4:
  53. + apps_dir = os.path.join(root_dir, "applications/kde4")
  54. + services_dir = os.path.join(root_dir, "kde4/services")
  55. + project_dir = os.path.join(root_dir, "kde4/apps", PROJECT)
  56. + else:
  57. + apps_dir = os.path.join(root_dir, "applications")
  58. + project_dir = os.path.join(root_dir, PROJECT)
  59. # Make directories
  60. print "Making directories..."
  61. @@ -138,13 +161,15 @@
  62. makeDirs(locale_dir)
  63. makeDirs(apps_dir)
  64. makeDirs(project_dir)
  65. - makeDirs(services_dir)
  66. + if FOR_KDE_4:
  67. + makeDirs(services_dir)
  68. # Install desktop files
  69. print "Installing desktop files..."
  70. shutil.copy("data/%s.desktop" % PROJECT, apps_dir)
  71. - shutil.copy("data/kcm_%s.desktop" % PROJECT, services_dir)
  72. + if FOR_KDE_4:
  73. + shutil.copy("data/kcm_%s.desktop" % PROJECT, services_dir)
  74. shutil.rmtree('build/data')
  75. # Install codes
  76. @@ -192,14 +217,19 @@
  77. bin_dir = "/usr/bin"
  78. locale_dir = os.path.join(root_dir, "locale")
  79. - apps_dir = os.path.join(root_dir, "applications/kde4")
  80. - services_dir = os.path.join(root_dir, "kde4/services")
  81. - project_dir = os.path.join(root_dir, "kde4/apps", PROJECT)
  82. + if FOR_KDE_4:
  83. + apps_dir = os.path.join(root_dir, "applications/kde4")
  84. + services_dir = os.path.join(root_dir, "kde4/services")
  85. + project_dir = os.path.join(root_dir, "kde4/apps", PROJECT)
  86. + else:
  87. + apps_dir = os.path.join(root_dir, "applications")
  88. + project_dir = os.path.join(root_dir, PROJECT)
  89. print 'Uninstalling ...'
  90. remove(project_dir)
  91. remove(apps_dir +"/%s.desktop" % PROJECT)
  92. - remove(services_dir +"/kcm_%s.desktop" % PROJECT)
  93. + if FOR_KDE_4:
  94. + remove(services_dir +"/kcm_%s.desktop" % PROJECT)
  95. for filename in glob.glob1('po', '*.po'):
  96. lang = filename.rsplit(".", 1)[0]
  97. remove(os.path.join(locale_dir, "%s/LC_MESSAGES" % lang, "%s.mo" % PROJECT))
  98. diff -Nuar service-manager-3.0.0.orig//src/servicemanager/about.py service-manager-3.0.0/src/servicemanager/about.py
  99. --- service-manager-3.0.0.orig//src/servicemanager/about.py 2011-03-21 11:09:29.711000015 +0200
  100. +++ service-manager-3.0.0/src/servicemanager/about.py 2011-03-21 11:10:08.152000017 +0200
  101. @@ -11,29 +11,35 @@
  102. # Please read the COPYING file.
  103. #
  104. -# PyKDE4 Stuff
  105. -from PyKDE4.kdecore import KAboutData, ki18n, ki18nc
  106. -
  107. -PACKAGE = "Service Manager"
  108. +# PDS Stuff
  109. +import context as ctx
  110. # Application Data
  111. +PACKAGE = "Service Manager"
  112. appName = "service-manager"
  113. modName = "servicemanager"
  114. -programName = ki18n(PACKAGE)
  115. version = "3.0.0"
  116. -description = ki18n(PACKAGE)
  117. -license = KAboutData.License_GPL
  118. -copyright = ki18n("(c) 2009-2010 TUBITAK/UEKAE")
  119. -text = ki18n(None)
  120. homePage = "http://developer.pardus.org.tr/projects/service-manager"
  121. bugEmail = "bugs@pardus.org.tr"
  122. +icon = "flag-yellow"
  123. catalog = appName
  124. -aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
  125. -# Authors
  126. -aboutData.addAuthor(ki18n("Gökmen Göksel"), ki18n("Current Maintainer"))
  127. -aboutData.addAuthor(ki18n("Bahadır Kandemir"), ki18n("COMAR Author"))
  128. -aboutData.setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"), ki18nc("EMAIL OF TRANSLATORS", "Your emails"))
  129. +if ctx.Pds.session == ctx.pds.Kde4:
  130. +
  131. + # PyKDE4 Stuff
  132. + from PyKDE4.kdecore import KAboutData, ki18n, ki18nc
  133. +
  134. + programName = ki18n(PACKAGE)
  135. + description = ki18n(PACKAGE)
  136. + license = KAboutData.License_GPL
  137. + copyright = ki18n("(c) 2009-2010 TUBITAK/UEKAE")
  138. + text = ki18n(None)
  139. + aboutData = KAboutData(appName, catalog, programName, version, description, license, copyright, text, homePage, bugEmail)
  140. +
  141. + # Authors
  142. + aboutData.addAuthor(ki18n("Gökmen Göksel"), ki18n("Current Maintainer"))
  143. + aboutData.addAuthor(ki18n("Bahadır Kandemir"), ki18n("COMAR Author"))
  144. + aboutData.setTranslator(ki18nc("NAME OF TRANSLATORS", "Your names"), ki18nc("EMAIL OF TRANSLATORS", "Your emails"))
  145. -# Use this if icon name is different than appName
  146. -aboutData.setProgramIconName("flag-yellow")
  147. + # Use this if icon name is different than appName
  148. + aboutData.setProgramIconName(icon)
  149. diff -Nuar service-manager-3.0.0.orig//src/servicemanager/base.py service-manager-3.0.0/src/servicemanager/base.py
  150. --- service-manager-3.0.0.orig//src/servicemanager/base.py 2011-03-21 11:09:29.712000015 +0200
  151. +++ service-manager-3.0.0/src/servicemanager/base.py 2011-03-21 11:10:08.157000017 +0200
  152. @@ -20,16 +20,18 @@
  153. from PyQt4.QtGui import QMessageBox
  154. from PyQt4.QtCore import *
  155. -# PyKDE4 Stuff
  156. -from PyKDE4.kdeui import *
  157. -from PyKDE4.kdecore import *
  158. -
  159. # Application Stuff
  160. from servicemanager.backend import ServiceIface
  161. -from servicemanager.about import aboutData
  162. from servicemanager.ui_main import Ui_mainManager
  163. from servicemanager.widgets import ServiceItemWidget, ServiceItem
  164. +# Pds vs KDE
  165. +import servicemanager.context as ctx
  166. +if ctx.Pds.session == ctx.pds.Kde4:
  167. + from PyKDE4.kdecore import i18n
  168. +else:
  169. + from servicemanager.context import i18n
  170. +
  171. class MainManager(QtGui.QWidget):
  172. def __init__(self, parent, standAlone=True):
  173. QtGui.QWidget.__init__(self, parent)
  174. diff -Nuar service-manager-3.0.0.orig//src/servicemanager/context.py service-manager-3.0.0/src/servicemanager/context.py
  175. --- service-manager-3.0.0.orig//src/servicemanager/context.py 1970-01-01 02:00:00.000000000 +0200
  176. +++ service-manager-3.0.0/src/servicemanager/context.py 2011-03-21 11:10:08.161000017 +0200
  177. @@ -0,0 +1,29 @@
  178. +#!/usr/bin/python
  179. +# -*- coding: utf-8 -*-
  180. +
  181. +import pds
  182. +import traceback
  183. +from time import time
  184. +from pds.qiconloader import QIconLoader
  185. +
  186. +Pds = pds.Pds('service-manager', debug = False)
  187. +# Force to use Default Session for testing
  188. +# Pds.session = pds.DefaultDe
  189. +# print 'Current session is : %s %s' % (Pds.session.Name, Pds.session.Version)
  190. +
  191. +i18n = Pds.i18n
  192. +KIconLoader = QIconLoader(Pds, forceCache=True)
  193. +KIcon = KIconLoader.icon
  194. +
  195. +time_counter = 0
  196. +start_time = time()
  197. +last_time = time()
  198. +
  199. +def _time():
  200. + global last_time, time_counter
  201. + trace = list(traceback.extract_stack())
  202. + diff = time() - start_time
  203. + print ('%s ::: %s:%s' % (time_counter, trace[-2][0].split('/')[-1], trace[-2][1])), diff, diff - last_time
  204. + last_time = diff
  205. + time_counter += 1
  206. +
  207. diff -Nuar service-manager-3.0.0.orig//src/servicemanager/widgets.py service-manager-3.0.0/src/servicemanager/widgets.py
  208. --- service-manager-3.0.0.orig//src/servicemanager/widgets.py 2011-03-21 11:09:29.712000015 +0200
  209. +++ service-manager-3.0.0/src/servicemanager/widgets.py 2011-03-21 11:10:08.163000017 +0200
  210. @@ -15,10 +15,13 @@
  211. from PyQt4 import QtGui
  212. from PyQt4.QtCore import *
  213. -# KDE Stuff
  214. -from PyKDE4 import kdeui
  215. -from PyKDE4.kdecore import i18n
  216. -from PyKDE4.kdecore import KGlobal
  217. +# Pds vs KDE
  218. +import servicemanager.context as ctx
  219. +if ctx.Pds.session == ctx.pds.Kde4:
  220. + from PyKDE4.kdeui import KIcon
  221. + from PyKDE4.kdecore import i18n
  222. +else:
  223. + from servicemanager.context import KIcon, i18n
  224. # Application Stuff
  225. from servicemanager.ui_item import Ui_ServiceItemWidget
  226. @@ -31,6 +34,7 @@
  227. # Python Stuff
  228. import time
  229. import textwrap
  230. +import locale
  231. # Pisi Stuff
  232. import pisi
  233. @@ -60,10 +64,10 @@
  234. self.toggleButtons()
  235. - self.ui.buttonStart.setIcon(kdeui.KIcon("media-playback-start"))
  236. - self.ui.buttonStop.setIcon(kdeui.KIcon("media-playback-stop"))
  237. - self.ui.buttonReload.setIcon(kdeui.KIcon("view-refresh"))
  238. - self.ui.buttonInfo.setIcon(kdeui.KIcon("dialog-information"))
  239. + self.ui.buttonStart.setIcon(KIcon("media-playback-start"))
  240. + self.ui.buttonStop.setIcon(KIcon("media-playback-stop"))
  241. + self.ui.buttonReload.setIcon(KIcon("view-refresh"))
  242. + self.ui.buttonInfo.setIcon(KIcon("dialog-information"))
  243. self.toggled = False
  244. self.root = parent
  245. @@ -100,7 +104,7 @@
  246. self.ui.buttonStop.setEnabled(self.running)
  247. self.ui.buttonReload.setEnabled(self.running)
  248. - self.ui.labelStatus.setPixmap(kdeui.KIcon(icon).pixmap(32, 32))
  249. + self.ui.labelStatus.setPixmap(KIcon(icon).pixmap(32, 32))
  250. self.showStatus()
  251. self.runningAtStart = False
  252. if state in ('on', 'stopped'):
  253. @@ -161,7 +165,7 @@
  254. try:
  255. # TODO add a package map for known services
  256. service = service.replace('_','-')
  257. - lang = str(KGlobal.locale().language())
  258. + lang = str(locale.getdefaultlocale()[0].split("_")[0])
  259. desc = pisi.api.info_name(service)[0].package.description
  260. if desc.has_key(lang):
  261. return unicode(desc[lang])
  262. @@ -178,7 +182,7 @@
  263. self.ui = Ui_InfoWidget()
  264. self.ui.setupUi(self)
  265. self.ui.buttonHide.clicked.connect(self.hideDescription)
  266. - self.ui.buttonHide.setIcon(kdeui.KIcon("dialog-close"))
  267. + self.ui.buttonHide.setIcon(KIcon("dialog-close"))
  268. self._animation = 2
  269. self._duration = 500
  270. diff -Nuar service-manager-3.0.0.orig//src/service-manager.py service-manager-3.0.0/src/service-manager.py
  271. --- service-manager-3.0.0.orig//src/service-manager.py 2011-03-21 11:09:29.712000015 +0200
  272. +++ service-manager-3.0.0/src/service-manager.py 2011-03-21 11:33:38.407000038 +0200
  273. @@ -13,46 +13,72 @@
  274. # System
  275. import sys
  276. -
  277. import dbus
  278. +# Pds Stuff
  279. +import servicemanager.context as ctx
  280. +
  281. +# Application Stuff
  282. +import servicemanager.about as about
  283. +
  284. # Qt Stuff
  285. from PyQt4.QtCore import SIGNAL
  286. -# PyKDE4 Stuff
  287. -from PyKDE4.kdeui import *
  288. -from PyKDE4.kdecore import *
  289. -
  290. -def CreatePlugin(widget_parent, parent, component_data):
  291. - from servicemanager.kcmodule import ServiceManager
  292. - return ServiceManager(component_data, parent)
  293. +# Enable plugin if session is Kde4
  294. +if ctx.Pds.session == ctx.pds.Kde4:
  295. + def CreatePlugin(widget_parent, parent, component_data):
  296. + from servicemanager.kcmodule import ServiceManager
  297. + return ServiceManager(component_data, parent)
  298. if __name__ == '__main__':
  299. - # Service Manager
  300. - from servicemanager.standalone import ServiceManager
  301. -
  302. - # Application Stuff
  303. - from servicemanager.about import aboutData
  304. -
  305. - # Set Command-line arguments
  306. - KCmdLineArgs.init(sys.argv, aboutData)
  307. -
  308. - # Create a Kapplitcation instance
  309. - app = KApplication()
  310. -
  311. # DBUS MainLoop
  312. if not dbus.get_default_main_loop():
  313. from dbus.mainloop.qt import DBusQtMainLoop
  314. DBusQtMainLoop(set_as_default = True)
  315. - # Create Main Widget
  316. - mainWindow = ServiceManager(None, 'service-manager')
  317. - mainWindow.show()
  318. + # Pds vs KDE
  319. + if ctx.Pds.session == ctx.pds.Kde4:
  320. +
  321. + # PyKDE4 Stuff
  322. + from PyKDE4.kdeui import *
  323. + from PyKDE4.kdecore import *
  324. +
  325. + # Application Stuff
  326. + from servicemanager.standalone import ServiceManager
  327. + from servicemanager.about import aboutData
  328. +
  329. + # Set Command-line arguments
  330. + KCmdLineArgs.init(sys.argv, aboutData)
  331. +
  332. + # Create a Kapplitcation instance
  333. + app = KApplication()
  334. +
  335. + # Create Main Widget
  336. + mainWindow = ServiceManager(None, aboutData.appName)
  337. + mainWindow.show()
  338. +
  339. + else:
  340. +
  341. + # Application Stuff
  342. + from servicemanager.base import MainManager
  343. +
  344. + # Pds Stuff
  345. + from pds.quniqueapp import QUniqueApplication
  346. + from servicemanager.context import KIcon, i18n
  347. +
  348. + # Create a QUniqueApllication instance
  349. + app = QUniqueApplication(sys.argv, catalog=about.appName)
  350. +
  351. + # Create Main Widget and make some settings
  352. + mainWindow = MainManager(None)
  353. + mainWindow.show()
  354. + mainWindow.resize(640, 480)
  355. + mainWindow.setWindowTitle(i18n(about.PACKAGE))
  356. + mainWindow.setWindowIcon(KIcon(about.icon))
  357. # Create connection for lastWindowClosed signal to quit app
  358. app.connect(app, SIGNAL('lastWindowClosed()'), app.quit)
  359. - # Run the application
  360. + # Run the applications
  361. app.exec_()
  362. -
  363. diff -Nuar service-manager-3.0.0.orig//ui/main.ui service-manager-3.0.0/ui/main.ui
  364. --- service-manager-3.0.0.orig//ui/main.ui 2011-03-21 11:09:29.703000015 +0200
  365. +++ service-manager-3.0.0/ui/main.ui 2011-03-21 11:10:08.165000017 +0200
  366. @@ -17,16 +17,10 @@
  367. <item row="0" column="0">
  368. <layout class="QHBoxLayout" name="horizontalLayout">
  369. <item>
  370. - <widget class="KLineEdit" name="lineSearch">
  371. - <property name="urlDropsEnabled">
  372. - <bool>false</bool>
  373. - </property>
  374. - <property name="clickMessage">
  375. + <widget class="QLineEdit" name="lineSearch">
  376. + <property name="placeholderText">
  377. <string>type service name to search...</string>
  378. </property>
  379. - <property name="showClearButton" stdset="0">
  380. - <bool>true</bool>
  381. - </property>
  382. </widget>
  383. </item>
  384. <item>
  385. @@ -106,13 +100,6 @@
  386. </item>
  387. </layout>
  388. </widget>
  389. - <customwidgets>
  390. - <customwidget>
  391. - <class>KLineEdit</class>
  392. - <extends>QLineEdit</extends>
  393. - <header>klineedit.h</header>
  394. - </customwidget>
  395. - </customwidgets>
  396. <resources/>
  397. <connections/>
  398. </ui>