Enlightenment CVS committal

Author  : onefang
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/bin


Modified Files:
        e_int_config_apps.c e_main.c 


Log Message:
Allow re ordering the .order files.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_int_config_apps.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- e_int_config_apps.c 1 Sep 2006 09:26:55 -0000       1.13
+++ e_int_config_apps.c 2 Sep 2006 06:16:28 -0000       1.14
@@ -23,14 +23,14 @@
 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
 static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data 
*cfdata);
 static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, 
E_Config_Dialog_Data *cfdata);
+static void _move_file_up_in_order(const char *order, const char *file);
+static void _move_file_down_in_order(const char *order, const char *file);
 
 struct _E_Config_Dialog_Data
 {
    E_Config_Dialog *cfd;
    E_Fm2_Icon_Info *info;
    int state;
-   E_App *parent;
-   E_App *parent_all;
    struct {
       Evas_Object *o_fm_all;
       Evas_Object *o_fm;
@@ -41,6 +41,8 @@
       Evas_Object *o_delete_left_button;
       Evas_Object *o_delete_right_button;
       Evas_Object *o_regen_button;
+      Evas_Object *o_move_up_button;
+      Evas_Object *o_move_down_button;
    } gui;
 };
 
@@ -99,7 +101,6 @@
    if (!homedir) return;
 
    snprintf(path_all, sizeof(path_all), "%s/.e/e/applications/all", homedir);
-   cfdata->parent_all = e_app_new(path_all, 1);
    return;
 }
 
@@ -142,21 +143,34 @@
    if (!cfdata->gui.o_fm) return;
    if (!e_fm2_has_parent_get(cfdata->gui.o_fm))
      {
-        cfdata->parent = NULL;
        if (cfdata->gui.o_up_button)
          e_widget_disabled_set(cfdata->gui.o_up_button, 1);
+       if (cfdata->gui.o_move_up_button)
+         e_widget_disabled_set(cfdata->gui.o_move_up_button, 1);
+       if (cfdata->gui.o_move_down_button)
+         e_widget_disabled_set(cfdata->gui.o_move_down_button, 1);
      }
    else
      {
         const char *realpath;
         char buf[4096];
 
-        realpath = e_fm2_real_path_get(cfdata->gui.o_fm_all);
+        realpath = e_fm2_real_path_get(cfdata->gui.o_fm);
         snprintf(buf, sizeof(buf), "%s/.order", realpath);
         if (ecore_file_exists(buf))
-           cfdata->parent = e_app_new(realpath, 1);
+          {
+             if (cfdata->gui.o_move_up_button)
+               e_widget_disabled_set(cfdata->gui.o_move_up_button, 0);
+             if (cfdata->gui.o_move_down_button)
+               e_widget_disabled_set(cfdata->gui.o_move_down_button, 0);
+          }
        else
-           cfdata->parent = NULL;
+          {
+             if (cfdata->gui.o_move_up_button)
+               e_widget_disabled_set(cfdata->gui.o_move_up_button, 1);
+             if (cfdata->gui.o_move_down_button)
+               e_widget_disabled_set(cfdata->gui.o_move_down_button, 1);
+          }
        if (cfdata->gui.o_up_button)
          e_widget_disabled_set(cfdata->gui.o_up_button, 0);
      }
@@ -285,13 +299,51 @@
             e_app_append(a, parent);
       }
 
-   snprintf(buf, sizeof(buf), "%s/.order", realpath);
-   if (ecore_file_exists(buf))
-      cfdata->parent = e_app_new(realpath, 1);
-   else
-      cfdata->parent = NULL;
+   e_fm2_refresh(cfdata->gui.o_fm);
+}
+
+static void
+_cb_button_move_up(void *data1, void *data2)
+{
+   E_Config_Dialog_Data *cfdata;
+   Evas_List *selected;
+   E_Fm2_Icon_Info *ici;
+   const char *realpath;
 
+   cfdata = data1;
+   if (!cfdata->gui.o_fm) return;
+
+   selected = e_fm2_selected_list_get(cfdata->gui.o_fm);
+   if (!selected) return;
+   ici = selected->data;
+   realpath = e_fm2_real_path_get(cfdata->gui.o_fm);
+   evas_list_free(selected);
+   _move_file_up_in_order(realpath, ici->file);
    e_fm2_refresh(cfdata->gui.o_fm);
+   /* FIXME: This doesn't seem to work, maybe I need to call it in a callback 
after the refresh is done? */
+   e_fm2_select_set(cfdata->gui.o_fm, ici->file, 1);
+}
+
+static void
+_cb_button_move_down(void *data1, void *data2)
+{
+   E_Config_Dialog_Data *cfdata;
+   Evas_List *selected;
+   E_Fm2_Icon_Info *ici;
+   const char *realpath;
+
+   cfdata = data1;
+   if (!cfdata->gui.o_fm) return;
+
+   selected = e_fm2_selected_list_get(cfdata->gui.o_fm);
+   if (!selected) return;
+   ici = selected->data;
+   realpath = e_fm2_real_path_get(cfdata->gui.o_fm);
+   evas_list_free(selected);
+   _move_file_down_in_order(realpath, ici->file);
+   e_fm2_refresh(cfdata->gui.o_fm);
+   /* FIXME: This doesn't seem to work, maybe I need to call it in a callback 
after the refresh is done? */
+   e_fm2_select_set(cfdata->gui.o_fm, ici->file, 1);
 }
 
 static void
@@ -377,6 +429,14 @@
    cfdata->gui.o_add_button = mt;
    e_widget_framelist_object_append(of, mt);
 
+   if (!once)
+      {
+         mt = e_widget_button_add(evas, _("Regenerate \"All Applications\" 
Menu"), "enlightenment/e",
+                          _cb_button_regen, cfdata, NULL);
+         cfdata->gui.o_regen_button = mt;
+         e_widget_framelist_object_append(of, mt);
+      }
+
    e_widget_table_object_append(ot, of, 0, 0, 2, 4, 1, 1, 1, 1);
 
    if (!once)
@@ -423,10 +483,17 @@
          e_widget_min_size_set(ob, 150, 220);
          e_widget_framelist_object_append(of, ob);
 
-         mt = e_widget_button_add(evas, _("Regenerate \"All Applications\" 
Menu"), "enlightenment/e",
-                          _cb_button_regen, cfdata, NULL);
-         cfdata->gui.o_regen_button = mt;
+         mt = e_widget_button_add(evas, _("Move application up"), 
"enlightenment/e",
+                          _cb_button_move_up, cfdata, NULL);
+         cfdata->gui.o_move_up_button = mt;
+         e_widget_framelist_object_append(of, mt);
+        e_widget_disabled_set(cfdata->gui.o_move_up_button, 1);
+
+         mt = e_widget_button_add(evas, _("Move application down"), 
"enlightenment/e",
+                          _cb_button_move_down, cfdata, NULL);
+         cfdata->gui.o_move_down_button = mt;
          e_widget_framelist_object_append(of, mt);
+        e_widget_disabled_set(cfdata->gui.o_move_down_button, 1);
 
          e_widget_table_object_append(ot, of, 2, 0, 2, 4, 1, 1, 1, 1);
       }
@@ -435,4 +502,133 @@
    e_dialog_resizable_set(cfd->dia, 1);
 
    return o;
+}
+
+static void
+_move_file_up_in_order(const char *order, const char *file)
+{
+   char buf[4096];
+   Evas_List *list = NULL, *l;
+   int ret = 0;
+   FILE *f;
+
+   snprintf(buf, sizeof(buf), "%s/.order", order);
+   if (!ecore_file_exists(buf)) return;
+   f = fopen(buf, "rb");
+   if (!f) return;
+
+   while (fgets(buf, sizeof(buf), f))
+     {
+       int len;
+
+       len = strlen(buf);
+       if (len > 0)
+         {
+            if (buf[len - 1] == '\n')
+              {
+                 buf[len - 1] = 0;
+                 len--;
+              }
+            if (strcmp(buf, file) != 0)
+                list = evas_list_append(list, strdup(buf));
+            else
+               {
+                  l = evas_list_last(list);
+                  if (l)
+                      list = evas_list_prepend_relative_list(list, 
strdup(buf), l);
+                  else
+                      list = evas_list_append(list, strdup(buf));
+               }
+         }
+     }
+   fclose(f);
+
+   snprintf(buf, sizeof(buf), "%s/.order", order);
+   ecore_file_unlink(buf);
+   f = fopen(buf, "wb");
+   if (!f) return;
+   for (l = list; l; l = l->next)
+     {
+        char *text;
+
+        text = l->data;
+       fprintf(f, "%s\n", text);
+       free(text);
+     }
+   fclose(f);
+   evas_list_free(list);
+
+   snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", order);
+   ecore_file_unlink(buf);
+
+   return;
+}
+
+static void
+_move_file_down_in_order(const char *order, const char *file)
+{
+   char buf[4096], *last;
+   Evas_List *list = NULL, *l;
+   int ret = 0;
+   FILE *f;
+
+   snprintf(buf, sizeof(buf), "%s/.order", order);
+   if (!ecore_file_exists(buf)) return;
+   f = fopen(buf, "rb");
+   if (!f) return;
+
+   last = NULL;
+   while (fgets(buf, sizeof(buf), f))
+     {
+       int len;
+
+       len = strlen(buf);
+       if (len > 0)
+         {
+            if (buf[len - 1] == '\n')
+              {
+                 buf[len - 1] = 0;
+                 len--;
+              }
+            if (strcmp(buf, file) != 0)
+               {
+                   list = evas_list_append(list, strdup(buf));
+                  if (last)
+                     {
+                         list = evas_list_append(list, last);
+                        last = NULL;
+                     }
+               }
+            else
+               {
+                  last = strdup(buf);
+               }
+         }
+     }
+   if (last)
+      {
+          list = evas_list_append(list, last);
+         last = NULL;
+      }
+   fclose(f);
+
+   snprintf(buf, sizeof(buf), "%s/.order", order);
+   ecore_file_unlink(buf);
+   f = fopen(buf, "wb");
+   if (!f) return;
+   for (l = list; l; l = l->next)
+     {
+        char *text;
+
+        text = l->data;
+       fprintf(f, "%s\n", text);
+       free(text);
+     }
+   fclose(f);
+   evas_list_free(list);
+
+   snprintf(buf, sizeof(buf), "%s/.eap.cache.cfg", order);
+   ecore_file_unlink(buf);
+
+   return;
 }
===================================================================
RCS file: /cvs/e/e17/apps/e/src/bin/e_main.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -3 -r1.182 -r1.183
--- e_main.c    2 Sep 2006 04:20:10 -0000       1.182
+++ e_main.c    2 Sep 2006 06:16:28 -0000       1.183
@@ -888,10 +888,9 @@
         e_fdo_menu_to_order();
      }
    /* FIXME: Add another temporary hack to keep the users happy.
-    * Move ~/.e/e/applications/all/*.eap to ~/.e/e/icons/*.edje
-    * Read the non .edje info from them and construct a matching 
~/.e/e/applications/all/*.desktop
-    * Add an icon path to these .desktop files that points to the 
~/.e/e/icons/*.edje files.
-    * Add ~/.e/e/icons/ to the top of the icon search path.
+    * Move ~/.e/e/applications/all/*.eap to ~/.e/e/icons/*.edj
+    * Read the non .edj info from them and construct a matching 
~/.e/e/applications/all/*.desktop
+    * Add an icon path to these .desktop files that points to the 
~/.e/e/icons/*.edj files.
     */
    /* FIXME: THIS is to get people started - shoudl be in a wizard */
    snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites", homedir);



-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to