Enlightenment CVS committal

Author  : dj2
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        ewl_menu.c ewl_menu.h ewl_menubar.c ewl_menubar.h 


Log Message:
- add convenience functions to make building typical menus and menubars
  simpler

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -3 -r1.39 -r1.40
--- ewl_menu.c  6 Feb 2007 13:42:17 -0000       1.39
+++ ewl_menu.c  6 Feb 2007 22:35:21 -0000       1.40
@@ -87,6 +87,40 @@
 }
 
 /**
+ * @param menu: The menu to setup
+ * @param info: The info to set into the menu
+ * @return Returns no value
+ * @brief Initializes @a menu with @a info
+ */
+void
+ewl_menu_from_info(Ewl_Menu *menu, Ewl_Menu_Info *info)
+{
+       int i;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("menu", menu);
+       DCHECK_PARAM_PTR("info", info);
+       DCHECK_TYPE("menu", menu, EWL_MENU_TYPE);
+
+       for (i = 0; info[i].name != NULL; i++)
+       {
+               Ewl_Widget *item;
+
+               item = ewl_menu_item_new();
+               ewl_button_label_set(EWL_BUTTON(item), info[i].name);
+               ewl_button_image_set(EWL_BUTTON(item), info[i].img, NULL);
+               ewl_container_child_append(EWL_CONTAINER(menu), item);
+
+               if (info[i].cb)
+                       ewl_callback_append(item, EWL_CALLBACK_CLICKED,
+                                                       info[i].cb, NULL);
+               ewl_widget_show(item);
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
  * @internal
  * @param w: The widget to work with
  * @param ev_data: UNUSED
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menu.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ewl_menu.h  6 Feb 2007 13:42:17 -0000       1.21
+++ ewl_menu.h  6 Feb 2007 22:35:21 -0000       1.22
@@ -48,8 +48,19 @@
        Ewl_Widget *menubar_parent;     /**< Parent menu bar */
 };
 
+typedef struct Ewl_Menu_Info Ewl_Menu_Info;
+
+struct Ewl_Menu_Info
+{
+       char *name;
+       char *img;
+       void (*cb)(Ewl_Widget *w, void *ev, void *data);
+};
+
 Ewl_Widget     *ewl_menu_new(void);
 int             ewl_menu_init(Ewl_Menu *menu);
+
+void            ewl_menu_from_info(Ewl_Menu *menu, Ewl_Menu_Info *info);
 
 /*
  * Internally used callbacks, override at your own risk.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menubar.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_menubar.c       6 Feb 2007 13:42:17 -0000       1.16
+++ ewl_menubar.c       6 Feb 2007 22:35:21 -0000       1.17
@@ -108,6 +108,38 @@
 }
 
 /**
+ * @param mb: The menubar to work with
+ * @param info: The menubar info to work with
+ * @return Returns  no value
+ * @brief Sets up the menubar @a mb with the given @a info
+ */
+void
+ewl_menubar_from_info(Ewl_Menubar *mb, Ewl_Menubar_Info *info)
+{
+       int i = 0;
+
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("mb", mb);
+       DCHECK_PARAM_PTR("info", info);
+       DCHECK_TYPE("mb", mb, EWL_MENUBAR_TYPE);
+
+       for (i = 0; info[i].name != NULL; i++)
+       {
+               Ewl_Widget *menu;
+
+               menu = ewl_menu_new();
+               ewl_button_label_set(EWL_BUTTON(menu), info[i].name);
+               ewl_menu_from_info(EWL_MENU(menu), info[i].menu);
+               ewl_container_child_append(EWL_CONTAINER(mb), menu);
+               ewl_object_fill_policy_set(EWL_OBJECT(menu), 
+                               EWL_FLAG_FILL_HSHRINK | EWL_FLAG_FILL_VFILL);
+               ewl_widget_show(menu);
+       }
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
+}
+
+/**
  * @param mb: The menubar to set the orientation on
  * @param o: The orientation to set onto the menubar
  * @return Returns no value.
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_menubar.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -3 -r1.13 -r1.14
--- ewl_menubar.h       6 Feb 2007 13:42:17 -0000       1.13
+++ ewl_menubar.h       6 Feb 2007 22:35:21 -0000       1.14
@@ -3,6 +3,7 @@
 #define EWL_MENUBAR_H
 
 #include "ewl_box.h"
+#include "ewl_menu.h"
 
 /**
  * @addtogroup Ewl_Menubar Ewl_Menubar: A menu bar widget
@@ -46,10 +47,20 @@
        Ewl_Widget      *inner_box; /**< The box to pack the widgets into */
 };
 
+typedef struct Ewl_Menubar_Info Ewl_Menubar_Info;
+struct Ewl_Menubar_Info
+{
+       char *name;
+       Ewl_Menu_Info *menu;
+};
+
 Ewl_Widget     *ewl_menubar_new(void);
 Ewl_Widget     *ewl_hmenubar_new(void);
 Ewl_Widget     *ewl_vmenubar_new(void);
+
 int             ewl_menubar_init(Ewl_Menubar *mb);
+
+void            ewl_menubar_from_info(Ewl_Menubar *mb, Ewl_Menubar_Info 
info[]);
 
 void            ewl_menubar_orientation_set(Ewl_Menubar *mb, Ewl_Orientation 
o);
 Ewl_Orientation         ewl_menubar_orientation_get(Ewl_Menubar *mb);



-------------------------------------------------------------------------
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