diff --git a/usr/lib/linuxmint/mintMenu/capi.py b/usr/lib/linuxmint/mintMenu/capi.py index f947996..c02421e 100644 --- a/usr/lib/linuxmint/mintMenu/capi.py +++ b/usr/lib/linuxmint/mintMenu/capi.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi import ctypes diff --git a/usr/lib/linuxmint/mintMenu/compile.py b/usr/lib/linuxmint/mintMenu/compile.py index cb8757e..9ed83c1 100755 --- a/usr/lib/linuxmint/mintMenu/compile.py +++ b/usr/lib/linuxmint/mintMenu/compile.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import compileall diff --git a/usr/lib/linuxmint/mintMenu/keybinding.py b/usr/lib/linuxmint/mintMenu/keybinding.py index 38510dd..783cc86 100644 --- a/usr/lib/linuxmint/mintMenu/keybinding.py +++ b/usr/lib/linuxmint/mintMenu/keybinding.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python # -*- coding: utf-8; -*- # Copyright (C) 2013 Ozcan Esen diff --git a/usr/lib/linuxmint/mintMenu/mintMenu.py b/usr/lib/linuxmint/mintMenu/mintMenu.py index 1121fd5..1b4fd07 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenu.py +++ b/usr/lib/linuxmint/mintMenu/mintMenu.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi gi.require_version("Gtk", "2.0") diff --git a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py index 75f8aa3..90f54ce 100755 --- a/usr/lib/linuxmint/mintMenu/mintMenuConfig.py +++ b/usr/lib/linuxmint/mintMenu/mintMenuConfig.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import sys diff --git a/usr/lib/linuxmint/mintMenu/mintRemove.py b/usr/lib/linuxmint/mintMenu/mintRemove.py new file mode 100755 index 0000000..f3105be --- /dev/null +++ b/usr/lib/linuxmint/mintMenu/mintRemove.py @@ -0,0 +1,148 @@ +#!/usr/bin/python + +import gi +gi.require_version("Gtk", "2.0") + +from gi.repository import Gtk, Gdk, GObject + +try: + import sys + import string + import os + import commands + import threading + import tempfile + import gettext + +except Exception, detail: + print detail + sys.exit(1) + +from subprocess import Popen, PIPE + +GObject.threads_init() + +# i18n +gettext.install("mintmenu", "/usr/share/linuxmint/locale") + +class RemoveExecuter(threading.Thread): + + def __init__(self, window_id, package): + threading.Thread.__init__(self) + self.window_id = window_id + self.package = package + + def run(self): + removePackages = string.split(self.package) + cmd = ["sudo", "/usr/sbin/synaptic", "--hide-main-window", \ + "--non-interactive", "--parent-window-id", self.window_id] + cmd.append("--progress-str") + cmd.append("\"" + _("Please wait, this can take some time") + "\"") + cmd.append("--finish-str") + cmd.append("\"" + _("Application removed successfully") + "\"") + f = tempfile.NamedTemporaryFile() + for pkg in removePackages: + f.write("%s\tdeinstall\n" % pkg) + cmd.append("--set-selections-file") + cmd.append("%s" % f.name) + f.flush() + comnd = Popen(' '.join(cmd), shell=True) + returnCode = comnd.wait() + f.close() + Gtk.main_quit() + sys.exit(0) + +class mintRemoveWindow: + + def __init__(self, desktopFile): + self.desktopFile = desktopFile + + #Set the Glade file + + + self.builder = Gtk.Builder() + self.builder.add_from_file ("/usr/lib/linuxmint/mintMenu/mintRemove.glade") + self.builder.get_object("main_window").set_icon_from_file("/usr/lib/linuxmint/mintMenu/icon.svg") + self.builder.get_object("main_window").set_title("") + self.builder.get_object("main_window").connect("destroy", self.giveUp) + + # Get the window socket (needed for synaptic later on) + vbox = self.builder.get_object("vbox1") + socket = Gtk.Socket() + vbox.pack_start(socket, False, False, 0) + socket.show() + window_id = repr(socket.get_id()) + + package = commands.getoutput("dpkg -S " + self.desktopFile) + package = package[:package.find(":")] + if package == "dpkg": + warnDlg = Gtk.Dialog("MintMenu", None, 0, + Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, + Gtk.STOCK_REMOVE, Gtk.ResponseType.OK) + warnDlg.vbox.set_spacing(10) + warnDlg.set_icon_from_file("/usr/share/linuxmint/logo.png") + labelSpc = Gtk.Label(" ") + warnDlg.vbox.pack_start(labelSpc, False, False, 0) + labelSpc.show() + warnText = "" + _("No matching package found") + "" + infoText = _("Do you want to remove this menu entry?") + " (" + self.desktopFile + ")" + label = Gtk.Label(warnText) + lblInfo = Gtk.Label(infoText) + label.set_use_markup(True) + lblInfo.set_use_markup(True) + warnDlg.vbox.pack_start(label) + warnDlg.vbox.pack_start(lblInfo) + label.show() + lblInfo.show() + response = warnDlg.run() + if response == Gtk.ResponseType.OK : + print "removing " + self.desktopFile + "*.desktop" + os.system("rm -f " + self.desktopFile) + os.system("rm -f " + self.desktopFile + "*.desktop") + warnDlg.destroy() + Gtk.main_quit() + sys.exit(0) + + self.builder.get_object("txt_name").set_text("" + _("Remove %s?") % package + "") + self.builder.get_object("txt_name").set_use_markup(True) + + self.builder.get_object("txt_guidance").set_text(_("The following packages will be removed:")) + + treeview = self.builder.get_object("tree") + column1 = Gtk.TreeViewColumn(_("Packages to be removed")) + renderer = Gtk.CellRendererText() + column1.pack_start(renderer, False) + column1.add_attribute(renderer, "text", 0) + treeview.append_column(column1) + + model = Gtk.ListStore(str) + dependenciesString = commands.getoutput("apt-get -s -q remove " + package + " | grep Remv") + dependencies = string.split(dependenciesString, "\n") + for dependency in dependencies: + dependency = dependency.replace("Remv ", "") + model.append([dependency]) + treeview.set_model(model) + treeview.show() + + + self.builder.get_object("remove_button").connect ("clicked", self.MainButtonClicked, window_id, package) + self.builder.get_object("cancel_button").connect ("clicked", self.giveUp) + + self.builder.get_object("main_window").show() + + + def MainButtonClicked(self, widget, window_id, package): + self.builder.get_object("main_window").window.set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH)) + self.builder.get_object("main_window").set_sensitive(False) + executer = RemoveExecuter(window_id, package) + executer.start() + return True + + def giveUp(self, widget): + Gtk.main_quit() + sys.exit(0) + +if __name__ == "__main__": + mainwin = mintRemoveWindow(sys.argv[1]) + Gtk.main() + diff --git a/usr/lib/linuxmint/mintMenu/plugins/__init__.py b/usr/lib/linuxmint/mintMenu/plugins/__init__.py index 4265cc3..013e4b7 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/__init__.py +++ b/usr/lib/linuxmint/mintMenu/plugins/__init__.py @@ -1 +1 @@ -#!/usr/bin/env python +#!/usr/bin/python diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index fd62351..e698fbb 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi gi.require_version("Gtk", "2.0") diff --git a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py index 48b7382..fe16e6e 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easybuttons.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python from gi.repository import Gtk, Gdk, GLib from gi.repository import Pango diff --git a/usr/lib/linuxmint/mintMenu/plugins/easyfiles.py b/usr/lib/linuxmint/mintMenu/plugins/easyfiles.py index d179e41..9359070 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/easyfiles.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easyfiles.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import os import os.path diff --git a/usr/lib/linuxmint/mintMenu/plugins/easygsettings.py b/usr/lib/linuxmint/mintMenu/plugins/easygsettings.py index ca93f7e..52c964e 100644 --- a/usr/lib/linuxmint/mintMenu/plugins/easygsettings.py +++ b/usr/lib/linuxmint/mintMenu/plugins/easygsettings.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python from gi.repository import Gio diff --git a/usr/lib/linuxmint/mintMenu/plugins/execute.py b/usr/lib/linuxmint/mintMenu/plugins/execute.py index 51b6212..ab5d494 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/execute.py +++ b/usr/lib/linuxmint/mintMenu/plugins/execute.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import os import subprocess diff --git a/usr/lib/linuxmint/mintMenu/plugins/filemonitor.py b/usr/lib/linuxmint/mintMenu/plugins/filemonitor.py index 47c3c39..0637232 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/filemonitor.py +++ b/usr/lib/linuxmint/mintMenu/plugins/filemonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import os import os.path diff --git a/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py b/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py index 37e9c23..265a61f 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py +++ b/usr/lib/linuxmint/mintMenu/plugins/get_apt_cache.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import apt, sys diff --git a/usr/lib/linuxmint/mintMenu/plugins/places.py b/usr/lib/linuxmint/mintMenu/plugins/places.py index c5a55fa..e49e696 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/places.py +++ b/usr/lib/linuxmint/mintMenu/plugins/places.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python from gi.repository import Gtk, Gio import os diff --git a/usr/lib/linuxmint/mintMenu/plugins/recent.py b/usr/lib/linuxmint/mintMenu/plugins/recent.py index 891f9be..740340e 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/recent.py +++ b/usr/lib/linuxmint/mintMenu/plugins/recent.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi gi.require_version("Gtk", "2.0") diff --git a/usr/lib/linuxmint/mintMenu/plugins/system_management.py b/usr/lib/linuxmint/mintMenu/plugins/system_management.py index 040b98b..617a799 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/system_management.py +++ b/usr/lib/linuxmint/mintMenu/plugins/system_management.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi gi.require_version("Gtk", "2.0") diff --git a/usr/lib/linuxmint/mintMenu/pointerMonitor.py b/usr/lib/linuxmint/mintMenu/pointerMonitor.py index 1229576..43e10a2 100644 --- a/usr/lib/linuxmint/mintMenu/pointerMonitor.py +++ b/usr/lib/linuxmint/mintMenu/pointerMonitor.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python import gi gi.require_version("Gtk", "2.0")