Enlightenment CVS committal

Author  : raster
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src/modules/wizard


Modified Files:
        e_mod_main.c e_wizard.c e_wizard.h 


Log Message:


workin on da wiz - working on page infrastructure - just test pages right now.

===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/wizard/e_mod_main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_mod_main.c        12 Aug 2007 10:16:26 -0000      1.1
+++ e_mod_main.c        13 Sep 2007 13:56:36 -0000      1.2
@@ -28,11 +28,73 @@
      "Wizard"
 };
 
+
+static int t_init     (E_Wizard_Page *pg){
+   return 1;
+}
+static int t_shutdown (E_Wizard_Page *pg){
+   return 1;
+}
+static int t_show     (E_Wizard_Page *pg){
+   Evas_Object *ob, *o;
+   
+   ob = e_widget_list_add(pg->evas, 1, 0);
+   o = e_widget_button_add(pg->evas,
+                           "Hello World", NULL, 
+                           NULL, NULL, NULL);
+   e_widget_list_object_append(ob, o, 0, 0, 0.5);
+   evas_object_show(o);
+   e_wizard_page_show(ob);
+   pg->data = ob;
+   return 0;
+}
+static int t_hide     (E_Wizard_Page *pg){
+   evas_object_del(pg->data);
+   return 1;
+}
+static int t_apply    (E_Wizard_Page *pg){
+   return 1;
+}
+
+static int t2_init     (E_Wizard_Page *pg){
+   return 1;
+}
+static int t2_shutdown (E_Wizard_Page *pg){
+   return 1;
+}
+static int t2_show     (E_Wizard_Page *pg){
+   Evas_Object *ob, *o;
+   
+   ob = e_widget_list_add(pg->evas, 1, 0);
+   o = e_widget_button_add(pg->evas,
+                           "Hello to Another World", NULL, 
+                           NULL, NULL, NULL);
+   e_widget_list_object_append(ob, o, 0, 0, 0.5);
+   evas_object_show(o);
+   e_wizard_page_show(ob);
+   pg->data = ob;
+   return 0;
+}
+static int t2_hide     (E_Wizard_Page *pg){
+   evas_object_del(pg->data);
+   return 1;
+}
+static int t2_apply    (E_Wizard_Page *pg){
+   return 1;
+}
+
+
 EAPI void *
 e_modapi_init(E_Module *m)
 {
    conf_module = m;
    e_wizard_init();
+   
+   e_wizard_page_add(t_init, t_shutdown, t_show, t_hide, t_apply);
+   e_wizard_page_add(t2_init, t2_shutdown, t2_show, t2_hide, t2_apply);
+   
+   e_wizard_go();
+   
    return m;
 }
 
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/wizard/e_wizard.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- e_wizard.c  18 Aug 2007 15:55:48 -0000      1.3
+++ e_wizard.c  13 Sep 2007 13:56:36 -0000      1.4
@@ -14,6 +14,8 @@
 static Evas_List *pops = NULL;
 static Evas_Object *o_bg = NULL;
 static Evas_Object *o_content = NULL;
+static Evas_List *pages = NULL;
+static E_Wizard_Page *curpage = NULL;
 
 EAPI int
 e_wizard_init(void)
@@ -63,6 +65,136 @@
    return 1;
 }
 
+EAPI void
+e_wizard_go(void)
+{
+   if (!curpage)
+     {
+       if (pages) curpage = pages->data;
+     }
+   if (curpage)
+     {
+       if (!curpage->data) curpage->init(curpage);
+       curpage->show(curpage);
+     }
+}
+
+EAPI void
+e_wizard_next(void)
+{
+   Evas_List *l;
+   
+   for (l = pages; l; l = l->next)
+     {
+       if (l->data == curpage)
+         {
+            if (l->next)
+              {
+                 if (curpage)
+                   {
+                      curpage->hide(curpage);
+                   }
+                 curpage = l->next->data;
+                 if (!curpage->data)
+                   {
+                      curpage->init(curpage);
+                   }
+                 if (curpage->show(curpage))
+                   {
+                      break;
+                   }
+              }
+            else
+              {
+                 /* FINISH */
+                 break;
+              }
+         }
+     }
+}
+
+EAPI void
+e_wizard_back(void)
+{
+   Evas_List *l;
+   
+   for (l = evas_list_last(pages); l; l = l->prev)
+     {
+       if (l->data == curpage)
+         {
+            if (l->prev)
+              {
+                 if (curpage)
+                   {
+                      curpage->hide(curpage);
+                   }
+                 curpage = l->prev->data;
+                 if (!curpage->data)
+                   {
+                      curpage->init(curpage);
+                   }
+                 if (curpage->show(curpage))
+                   {
+                      break;
+                   }
+              }
+            else
+              {
+                 break;
+              }
+         }
+     }
+}
+
+EAPI void
+e_wizard_page_show(Evas_Object *obj)
+{
+   Evas_Coord minw, minh;
+
+   if (o_content) evas_object_del(o_content);
+   o_content = obj;
+   if (obj)
+     {
+       e_widget_min_size_get(obj, &minw, &minh);
+       edje_extern_object_min_size_set(obj, minw, minh);
+       edje_object_part_swallow(o_bg, "e.swallow.content", obj);
+       evas_object_show(obj);
+       e_widget_focus_set(obj, 1);
+       edje_object_signal_emit(o_bg, "e,action,page,new", "e");
+     }
+}
+
+/* FIXME: decide how pages are defined - how about an array of page structs? */
+EAPI E_Wizard_Page *
+e_wizard_page_add(int (*init)     (E_Wizard_Page *pg),
+                 int (*shutdown) (E_Wizard_Page *pg),
+                 int (*show)     (E_Wizard_Page *pg),
+                 int (*hide)     (E_Wizard_Page *pg),
+                 int (*apply)    (E_Wizard_Page *pg)
+                 )
+{
+   E_Wizard_Page *pg;
+   
+   pg = E_NEW(E_Wizard_Page, 1);
+   if (!pg) return NULL;
+   
+   pages = evas_list_append(pages, pg);
+   pg->evas = pop->evas;
+   pg->init = init;
+   pg->shutdown = shutdown;
+   pg->show = show;
+   pg->hide = hide;
+   pg->apply = apply;
+   return pg;
+}
+
+EAPI void
+e_wizard_page_del(E_Wizard_Page *pg)
+{
+   pages = evas_list_remove(pages, pg);
+   free(pg);
+}
+
 static E_Popup *
 _e_wizard_main_new(E_Zone *zone)
 {
@@ -79,9 +211,9 @@
    evas_object_move(o, 0, 0);
    evas_object_resize(o, zone->w, zone->h);
    evas_object_show(o);
-   edje_object_signal_callback_add(o_bg, "e,action,next", "e",
+   edje_object_signal_callback_add(o, "e,action,next", "",
                                   _e_wizard_cb_next, pop);
-   edje_object_signal_callback_add(o_bg, "e,action,back", "e",
+   edje_object_signal_callback_add(o, "e,action,back", "",
                                   _e_wizard_cb_back, pop);
    o_bg = o;
    
@@ -154,7 +286,7 @@
    if (!o_content) return;
    if (!strcmp(ev->keyname, "Tab"))
      {
-       if (evas_key_modifier_is_set(pop->evas, "Shift"))
+       if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
          e_widget_focus_jump(o_content, 0);
        else
          e_widget_focus_jump(o_content, 1);
@@ -168,14 +300,20 @@
        o = e_widget_focused_object_get(o_content);
        if (o) e_widget_activate(o);
      }
+   else if (!strcmp(ev->keyname, "Escape"))
+     {
+       e_wizard_shutdown();
+     }
 }
 
 static void
 _e_wizard_cb_next(void *data, Evas_Object *obj, const char *emission, const 
char *source)
 {
+   e_wizard_next();
 }
 
 static void
 _e_wizard_cb_back(void *data, Evas_Object *obj, const char *emission, const 
char *source)
 {
+   e_wizard_back();
 }
===================================================================
RCS file: /cvs/e/e17/apps/e/src/modules/wizard/e_wizard.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_wizard.h  12 Aug 2007 10:16:26 -0000      1.1
+++ e_wizard.h  13 Sep 2007 13:56:36 -0000      1.2
@@ -3,12 +3,38 @@
  */
 #ifdef E_TYPEDEFS
 
+typedef struct _E_Wizard_Page E_Wizard_Page;
+
 #else
 #ifndef E_WIZARD_H
 #define E_WIZARD_H
 
+struct _E_Wizard_Page
+{
+   Evas *evas;
+   int (*init)     (E_Wizard_Page *pg);
+   int (*shutdown) (E_Wizard_Page *pg);
+   int (*show)     (E_Wizard_Page *pg);
+   int (*hide)     (E_Wizard_Page *pg);
+   int (*apply)    (E_Wizard_Page *pg);
+   void *data;
+};
+
 EAPI int e_wizard_init(void);
 EAPI int e_wizard_shutdown(void);
-
+EAPI void e_wizard_go(void);
+EAPI void e_wizard_next(void);
+EAPI void e_wizard_prev(void);
+EAPI void e_wizard_page_show(Evas_Object *obj);
+EAPI E_Wizard_Page *
+  e_wizard_page_add(int (*init)     (E_Wizard_Page *pg),
+                   int (*shutdown) (E_Wizard_Page *pg),
+                   int (*show)     (E_Wizard_Page *pg),
+                   int (*hide)     (E_Wizard_Page *pg),
+                   int (*apply)    (E_Wizard_Page *pg)
+                   );
+EAPI void
+  e_wizard_page_del(E_Wizard_Page *pg);
+    
 #endif
 #endif



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to