Enlightenment CVS committal

Author  : devilhorns
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_actions.c e_int_border_menu.c 


Log Message:
Path from morlenxus to add a dialog for the 'kill' command so windows do not
accidentally get killed.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_actions.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -3 -r1.91 -r1.92
--- e_actions.c 27 Feb 2007 16:16:03 -0000      1.91
+++ e_actions.c 4 Mar 2007 07:03:10 -0000       1.92
@@ -249,8 +249,41 @@
 }
 
 /***************************************************************************/
+static E_Dialog *kill_dialog = NULL;
+
+static void
+_e_actions_cb_kill_dialog_ok(void *data, E_Dialog *dia)
+{
+   E_Object *obj;
+
+   obj = data;
+   e_object_del(E_OBJECT(kill_dialog));
+   kill_dialog = NULL;
+   if ((!((E_Border *)obj)->lock_close) && (!((E_Border *)obj)->internal)) 
+     e_border_act_kill_begin((E_Border *)obj);
+}
+
+static void
+_e_actions_cb_kill_dialog_cancel(void *data, E_Dialog *dia)
+{
+   e_object_del(E_OBJECT(kill_dialog));
+   kill_dialog = NULL;
+}
+
+static void
+_e_actions_cb_kill_dialog_delete(E_Win *win)
+{
+   E_Dialog *dia;
+
+   dia = win->data;
+   _e_actions_cb_kill_dialog_cancel(NULL, dia);
+}
+
 ACT_FN_GO(window_kill)
 {
+   E_Border *bd;
+   char dialog_text[1024];
+
    if (!obj) obj = E_OBJECT(e_border_focused_get());
    if (!obj) return;
    if (obj->type != E_BORDER_TYPE)
@@ -258,8 +291,31 @@
        obj = E_OBJECT(e_border_focused_get());
        if (!obj) return;
      }
-   if (!((E_Border *)obj)->lock_close)
-     e_border_act_kill_begin((E_Border *)obj);
+   bd = (E_Border *)obj;
+   snprintf(dialog_text, sizeof(dialog_text),
+           "You are about to kill %s.<br><br>"
+           "Please keep in mind that all data of this window,<br>"
+           "which has not been saved yet will be lost!<br><br>"
+           "Are you sure you want to kill this window?", 
+           bd->client.icccm.name);
+
+   if (kill_dialog) e_object_del(E_OBJECT(kill_dialog));
+   kill_dialog = 
e_dialog_new(e_container_current_get(e_manager_current_get()), 
+                             "E", "_kill_dialog");
+   if (!kill_dialog) return;
+   e_win_delete_callback_set(kill_dialog->win, 
+                            _e_actions_cb_kill_dialog_delete);
+   e_dialog_title_set(kill_dialog, 
+                     _("Are you sure you want to kill this window?"));
+   e_dialog_text_set(kill_dialog, _(dialog_text));
+   e_dialog_icon_set(kill_dialog, "enlightenment/exit", 64);
+   e_dialog_button_add(kill_dialog, _("Yes"), NULL,
+                      _e_actions_cb_kill_dialog_ok, obj);
+   e_dialog_button_add(kill_dialog, _("No"), NULL,
+                      _e_actions_cb_kill_dialog_cancel, NULL);
+   e_dialog_button_focus_num(kill_dialog, 1);
+   e_win_centered_set(kill_dialog->win, 1);
+   e_dialog_show(kill_dialog);
 }
 
 /***************************************************************************/
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_border_menu.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -3 -r1.57 -r1.58
--- e_int_border_menu.c 27 Feb 2007 16:16:03 -0000      1.57
+++ e_int_border_menu.c 4 Mar 2007 07:03:10 -0000       1.58
@@ -459,11 +459,14 @@
 static void
 _e_border_menu_cb_kill(void *data, E_Menu *m, E_Menu_Item *mi)
 {
+   E_Action *a;
    E_Border *bd;
 
    bd = data;
-   if ((!bd->lock_close) && (!bd->internal))
-     e_border_act_kill_begin(bd);
+   if ((bd->lock_close) || (bd->internal)) return;
+
+   a = e_action_find("window_kill");
+   if ((a) && (a->func.go)) a->func.go(NULL, NULL);
 }
 
 static void



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to