add_apt_checking.patch 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. From 451de58797ef3e270314d07da7170065d787e3e1 Mon Sep 17 00:00:00 2001
  2. From: Sam Burgos <sam.burgos1089@gmail.com>
  3. Date: Tue, 15 May 2018 16:04:11 -0600
  4. Subject: [PATCH] added checking of APT so application can show proper
  5. configuration
  6. ---
  7. usr/lib/linuxmint/mintlocale/install_remove.py | 53 ++++++++++++++++----------
  8. usr/lib/linuxmint/mintlocale/mintlocale.py | 20 +++++-----
  9. 2 files changed, 43 insertions(+), 30 deletions(-)
  10. diff --git a/usr/lib/linuxmint/mintlocale/install_remove.py b/usr/lib/linuxmint/mintlocale/install_remove.py
  11. index 205bd5b..00e2e2d 100755
  12. --- a/usr/lib/linuxmint/mintlocale/install_remove.py
  13. +++ b/usr/lib/linuxmint/mintlocale/install_remove.py
  14. @@ -2,12 +2,10 @@
  15. import os
  16. import gettext
  17. -import apt_pkg
  18. import subprocess
  19. import tempfile
  20. import locale
  21. import codecs
  22. -import mintcommon
  23. import gi
  24. gi.require_version('Gtk', '3.0')
  25. @@ -15,6 +13,13 @@
  26. from gi.repository import GdkX11
  27. from gi.repository import Gtk, GdkPixbuf, XApp
  28. +# Used to detect Debian derivatives (we don't want to show APT features in other distros)
  29. +IS_DEBIAN = os.path.exists("/etc/debian_version")
  30. +
  31. +if IS_DEBIAN:
  32. + import apt_pkg
  33. + import mintcommon
  34. +
  35. # i18n
  36. APP = 'mintlocale'
  37. LOCALE_DIR = "/usr/share/linuxmint/locale"
  38. @@ -98,7 +103,9 @@ def __init__(self):
  39. self.build_lang_list()
  40. - self.apt = mintcommon.APT(self.window)
  41. +
  42. + if IS_DEBIAN:
  43. + self.apt = mintcommon.APT(self.window)
  44. def split_locale(self, locale_code):
  45. if "_" in locale_code:
  46. @@ -244,22 +251,25 @@ def select_language(self, treeview, data=None):
  47. def button_install_clicked(self, button):
  48. if self.selected_language_packs is not None:
  49. - if self.cache_updated:
  50. - self.apt.set_finished_callback(self.on_install_finished)
  51. - self.apt.set_cancelled_callback(self.on_install_finished)
  52. - self.apt.install_packages(self.selected_language_packs)
  53. - else:
  54. - self.apt.set_finished_callback(self.on_update_finished)
  55. - self.apt.update_cache()
  56. -
  57. - def on_update_finished(self, transaction=None, exit_state=None):
  58. - self.cache_updated = True
  59. - self.apt.set_finished_callback(self.on_install_finished)
  60. - self.apt.set_cancelled_callback(self.on_install_finished)
  61. - self.apt.install_packages(self.selected_language_packs)
  62. -
  63. - def on_install_finished(self, transaction=None, exit_state=None):
  64. - self.build_lang_list()
  65. + if IS_DEBIAN:
  66. + if self.cache_updated:
  67. + self.apt.set_finished_callback(self.on_install_finished)
  68. + self.apt.set_cancelled_callback(self.on_install_finished)
  69. + self.apt.install_packages(self.selected_language_packs)
  70. + else:
  71. + self.apt.set_finished_callback(self.on_update_finished)
  72. + self.apt.update_cache()
  73. +
  74. + if IS_DEBIAN:
  75. + def on_update_finished(self, transaction=None, exit_state=None):
  76. + self.cache_updated = True
  77. + self.apt.set_finished_callback(self.on_install_finished)
  78. + self.apt.set_cancelled_callback(self.on_install_finished)
  79. + self.apt.install_packages(self.selected_language_packs)
  80. +
  81. + if IS_DEBIAN:
  82. + def on_install_finished(self, transaction=None, exit_state=None):
  83. + self.build_lang_list()
  84. def button_add_clicked(self, button):
  85. os.system("/usr/lib/linuxmint/mintlocale/add.py")
  86. @@ -284,8 +294,9 @@ def button_remove_clicked(self, button):
  87. print(pkgname)
  88. if len(installed_packs) > 0:
  89. - self.apt.set_finished_callback(self.on_install_finished)
  90. - self.apt.remove_packages(installed_packs)
  91. + if IS_DEBIAN:
  92. + self.apt.set_finished_callback(self.on_install_finished)
  93. + self.apt.remove_packages(installed_packs)
  94. self.build_lang_list()
  95. diff --git a/usr/lib/linuxmint/mintlocale/mintlocale.py b/usr/lib/linuxmint/mintlocale/mintlocale.py
  96. index cd75f75..87e0c47 100755
  97. --- a/usr/lib/linuxmint/mintlocale/mintlocale.py
  98. +++ b/usr/lib/linuxmint/mintlocale/mintlocale.py
  99. @@ -8,7 +8,6 @@
  100. import tempfile
  101. import subprocess
  102. import codecs
  103. -import mintcommon
  104. try:
  105. import _thread as thread
  106. @@ -33,6 +32,7 @@
  107. if IS_DEBIAN:
  108. import apt
  109. + import mintcommon
  110. # i18n
  111. APP = 'mintlocale'
  112. @@ -64,7 +64,8 @@ def __init__(self, codename, name, methods, app):
  113. self.app = app
  114. self.packages = []
  115. self.missing_packages = []
  116. - self.apt = mintcommon.APT(self.app.window)
  117. + if IS_DEBIAN:
  118. + self.apt = mintcommon.APT(self.app.window)
  119. self.label = Gtk.Label()
  120. self.label.set_markup(name)
  121. @@ -107,13 +108,14 @@ def __init__(self, codename, name, methods, app):
  122. def install(self, widget):
  123. if len(self.missing_packages) > 0:
  124. self.app.lock_input_methods()
  125. - if self.app.cache_updated:
  126. - self.apt.set_finished_callback(self.on_install_finished)
  127. - self.apt.set_cancelled_callback(self.on_install_finished)
  128. - self.apt.install_packages(self.missing_packages)
  129. - else:
  130. - self.apt.set_finished_callback(self.on_update_finished)
  131. - self.apt.update_cache()
  132. + if IS_DEBIAN:
  133. + if self.app.cache_updated:
  134. + self.apt.set_finished_callback(self.on_install_finished)
  135. + self.apt.set_cancelled_callback(self.on_install_finished)
  136. + self.apt.install_packages(self.missing_packages)
  137. + else:
  138. + self.apt.set_finished_callback(self.on_update_finished)
  139. + self.apt.update_cache()
  140. def on_update_finished(self, transaction=None, exit_state=None):
  141. self.app.cache_updated = True