-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

A patch for the fsel.

This patch add a menu to rename and delete files in the fsel. But, i
don't know refresh the smart when a file is removed.

Regards,

maxtoo.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFE0MSC7vwF1MVzFTgRAmkeAJ4vmsUIpCCDwcJjNjWYCtATg10tIACfc0K+
i2L+sJFg0dxOWAkrGhPgXdI=
=RjMV
-----END PGP SIGNATURE-----
--- e_fm.c	2006-08-01 16:46:48.000000000 +0000
+++ /usr/portage/distfiles/cvs-src/e17/apps/e/src/bin/e_fm.c	2006-08-02 15:06:53.000000000 +0000
@@ -137,6 +137,13 @@
 static void _e_fm2_smart_clip_set(Evas_Object *obj, Evas_Object * clip);
 static void _e_fm2_smart_clip_unset(Evas_Object *obj);
 
+static void _e_fm2_menu_action_display(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp);
+
+static void _e_fm2_file_rename (void *data, E_Menu *m, E_Menu_Item *mi);
+static void _e_fm2_file_rename_yes_cb (char *text, void *data);
+static void _e_fm2_file_delete (void *data, E_Menu *m, E_Menu_Item *mi);
+static void _e_fm2_file_delete_yes_cb (void *data, E_Dialog *dialog);
+
 static char *_meta_path = NULL;
 static Evas_Smart *_e_fm2_smart = NULL;
 
@@ -1796,6 +1803,13 @@
    
    ic = data;
    ev = event_info;
+   
+   switch(ev->button)
+     {
+       case 3:
+         _e_fm2_menu_action_display(ic, obj, ev->timestamp);
+	 break;
+     }
 }
     
 static void
@@ -1803,7 +1817,7 @@
 {
    Evas_Event_Mouse_Move *ev;
    E_Fm2_Icon *ic;
-   
+  
    ic = data;
    ev = event_info;
 }
@@ -2203,3 +2217,173 @@
    if (!sd) return;
    evas_object_clip_unset(sd->clip);
 }
+
+static void
+_e_fm2_menu_action_display(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
+{
+  E_Fm2_Smart_Data *sd;
+  E_Menu *mn;
+  E_Menu_Item *mi;
+  E_Manager *man;
+  E_Container *con;
+  E_Zone *zone;
+  int x, y;
+
+  sd = ic->sd;
+
+  if (ic->selected)
+    {
+      mn = e_menu_new();
+      e_menu_category_set(mn, "fileman/action");
+
+      mi = e_menu_item_new(mn);
+      e_menu_item_label_set(mi, _("Delete"));
+      e_menu_item_callback_set(mi, _e_fm2_file_delete, ic);
+
+      mi = e_menu_item_new(mn);
+      e_menu_item_label_set(mi, _("Rename"));
+      e_menu_item_callback_set(mi, _e_fm2_file_rename, ic);
+
+      man = e_manager_current_get();
+      if (!man) return;
+      con = e_container_current_get(man);
+      if (!con) return;
+      ecore_x_pointer_xy_get(con->win, &x, &y);
+
+      zone = e_util_zone_current_get(man);
+      if (!zone) return;
+
+      e_menu_activate_mouse(mn, zone, 
+                            x, y, 1, 1, 
+                            E_MENU_POP_DIRECTION_DOWN, timestamp);
+    }
+}
+
+static void
+_e_fm2_file_rename (void *data, E_Menu *m, E_Menu_Item *mi)
+{
+  E_Fm2_Icon *ic;
+  E_Manager *man;
+  E_Container *con;
+  E_Win *win;
+  char *old_path;
+  char text[PATH_MAX + 256];
+  
+  ic = data;
+ 
+  man = e_manager_current_get();
+  if (!man) return;
+  con = e_container_current_get(man);
+  if (!con) return;
+  win = e_win_new(con);
+  
+  snprintf(text, PATH_MAX + 256, "Rename %s to", ic->info.file);
+  e_entry_dialog_show("Rename file", NULL, text, NULL, NULL, 
+                      _e_fm2_file_rename_yes_cb, NULL, ic);
+}
+
+static void
+_e_fm2_file_rename_yes_cb (char *text, void *data)
+{
+  E_Fm2_Icon *ic;
+  E_Dialog *dialog;
+  E_Manager *man;
+  E_Container *con;
+  char newpath[PATH_MAX];
+  char oldpath[PATH_MAX];
+  char error[PATH_MAX + 256];
+  
+  ic = data;
+
+  if (text || strcmp(text, ic->info.file))
+    {
+      snprintf(newpath, PATH_MAX, "%s/%s", ic->sd->realpath, text);
+      snprintf(oldpath, PATH_MAX, "%s/%s", ic->sd->realpath, ic->info.file);
+
+      if (rename(oldpath, newpath) < 0)
+        {
+          man = e_manager_current_get();
+          if (!man) return;
+	  con = e_container_current_get(man);
+	  if (!con) return;
+	  
+	  dialog = e_dialog_new(con);
+	  e_dialog_button_add(dialog, _("OK"), NULL, NULL, NULL);
+	  e_dialog_button_focus_num(dialog, 1);
+	  e_dialog_title_set(dialog, _("Error"));
+	  snprintf(error, PATH_MAX + 256, _("Could not rename from <b>%s</b> to <b>%s</b>"), ic->info.file, text);
+	  e_dialog_text_set(dialog, error);
+	  e_dialog_show(dialog);
+	  return;
+	}
+
+      ic->info.label = NULL;
+      ic->info.file = strrchr(newpath, '/');
+      ic->info.file++;
+      _e_fm2_icon_label_set(ic, ic->obj);
+    }
+}
+
+static void
+_e_fm2_file_delete (void *data, E_Menu *m, E_Menu_Item *mi)
+{
+  E_Manager *man;
+  E_Container *con;
+  E_Dialog *dialog;
+  E_Fm2_Icon *ic;
+  char text[PATH_MAX + 256];
+
+  man = e_manager_current_get();
+  if (!man) return;
+  con = e_container_current_get(man);
+  if (!con) return;
+
+  ic = data;
+
+  dialog = e_dialog_new(con);
+  e_dialog_button_add(dialog, _("Yes"), NULL, _e_fm2_file_delete_yes_cb, ic);
+  e_dialog_button_add(dialog, _("No"), NULL, NULL, NULL);
+  e_dialog_button_focus_num(dialog, 1);
+  e_dialog_title_set(dialog, _("Confirm Delete"));
+  snprintf(text, PATH_MAX + 256, _("Are you sure you want to delete <br><b>%s/%s</b> ?"), ic->sd->realpath, ic->info.file);
+  e_dialog_text_set(dialog, text);
+  e_dialog_show(dialog);
+}
+
+static void
+_e_fm2_file_delete_yes_cb (void *data, E_Dialog *dialog)
+{
+  E_Manager *man;
+  E_Container *con;
+  E_Fm2_Icon *ic;
+  Evas_Object *obj;
+  char path[PATH_MAX];
+  int ret;
+
+  ic = data;
+
+  snprintf(path, PATH_MAX, "%s/%s", ic->sd->realpath, ic->info.file);
+
+  if (!(ecore_file_recursive_rm(path)))
+    {
+      char text[PATH_MAX + 256];
+
+      man = e_manager_current_get();
+      if (!man) return;
+      con = e_container_current_get(man);
+      if (!con) return;
+
+      e_object_del(E_OBJECT(dialog));
+      dialog = e_dialog_new(con);
+      e_dialog_button_add(dialog, _("OK"), NULL, NULL, NULL);
+      e_dialog_button_focus_num(dialog, 1);
+      e_dialog_title_set(dialog, _("Error"));
+      snprintf(text, PATH_MAX + 256, _("Could not delete <br><b>%s</b>"), path);
+      e_dialog_text_set(dialog, text);
+      e_dialog_show(dialog);
+      return;
+    }
+
+  _e_fm2_icon_unrealize(ic);
+  e_object_del(E_OBJECT(dialog));
+}
-------------------------------------------------------------------------
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-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to