[Debian-live-changes] r2219 - in dists/trunk/live-magic/livemagic: controllers model views

lamby-guest at alioth.debian.org lamby-guest at alioth.debian.org
Wed Jun 20 01:22:01 UTC 2007


Author: lamby-guest
Date: 2007-06-20 01:22:00 +0000 (Wed, 20 Jun 2007)
New Revision: 2219

Modified:
   dists/trunk/live-magic/livemagic/controllers/hooks.py
   dists/trunk/live-magic/livemagic/model/folder_of_files.py
   dists/trunk/live-magic/livemagic/views/hooks.py
Log:
Partial hook deletion support.


Modified: dists/trunk/live-magic/livemagic/controllers/hooks.py
===================================================================
--- dists/trunk/live-magic/livemagic/controllers/hooks.py	2007-06-20 01:11:25 UTC (rev 2218)
+++ dists/trunk/live-magic/livemagic/controllers/hooks.py	2007-06-20 01:22:00 UTC (rev 2219)
@@ -66,7 +66,12 @@
             self.view.do_show_error("The name already exists")
 
     def on_button_hook_delete_clicked(self, *_):
-        print "delete called for", self.view.get_selected_hook()
+        res = self.view.do_show_hook_delete_confirm_window()
+        if res:
+            hook_name = self.view.get_selected_hook()
+            self.model.hooks.delete(hook_name)
+            self.notify_load_hooks()
+            self.view.do_clear_hook_contents()
 
     def on_hook_editor_changed(self, *_):
         if self.hook_select_triggers_change:

Modified: dists/trunk/live-magic/livemagic/model/folder_of_files.py
===================================================================
--- dists/trunk/live-magic/livemagic/model/folder_of_files.py	2007-06-20 01:11:25 UTC (rev 2218)
+++ dists/trunk/live-magic/livemagic/model/folder_of_files.py	2007-06-20 01:22:00 UTC (rev 2219)
@@ -75,10 +75,11 @@
 
         self._stale.clear()
 
-    def delete(self, filename):
-        if self._config_exists(filename):
-            os.remove(join(self.dir, filename))
-        del self[filename]
+    def delete(self, hook_name):
+        if self._config_exists(hook_name):
+            os.remove(join(self.dir, hook_name))
+        del self[hook_name]
+        if hook_name in self._stale: self._stale.remove(hook_name)
         self.file_deleted = True
 
     def rename(self, orig, new):
@@ -89,8 +90,7 @@
             raise ValueError
         if self._config_exists(orig):
             os.rename(join(self.dir, orig), join(self.dir, new))
-        if orig in self._stale:
-            self._stale.remove(orig)
+        if orig in self._stale: self._stale.remove(orig)
         self[new] = self[orig]
         del self[orig]
 

Modified: dists/trunk/live-magic/livemagic/views/hooks.py
===================================================================
--- dists/trunk/live-magic/livemagic/views/hooks.py	2007-06-20 01:11:25 UTC (rev 2218)
+++ dists/trunk/live-magic/livemagic/views/hooks.py	2007-06-20 01:22:00 UTC (rev 2219)
@@ -106,6 +106,18 @@
         dialog.run()
         dialog.destroy()
 
+    def do_show_hook_delete_confirm_window(self):
+        dialog = gtk.Dialog(
+            "Are you sure?",
+            self['window_main'],
+            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+            (   gtk.STOCK_OK, gtk.RESPONSE_ACCEPT,
+                gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
+
+        res = dialog.run()
+        dialog.destroy()
+        return (res == gtk.RESPONSE_ACCEPT)
+
     def do_hook_add(self, filename):
         self.cb.append_text(filename)
 
@@ -139,6 +151,12 @@
                 return
             iter = m.iter_next(iter)
 
+    def do_clear_hook_contents(self):
+        buffer = self.hook_editor.get_buffer()
+        buffer.begin_not_undoable_action()
+        buffer.set_text("")
+        buffer.end_not_undoable_action()
+
     def do_set_selected_hook_contents(self, contents):
         buffer = self.hook_editor.get_buffer()
         buffer.begin_not_undoable_action()




More information about the Debian-live-changes mailing list