Enlightenment CVS committal

Author  : pfritz
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src/lib


Modified Files:
        Ewl.h Makefile.am ewl_button.c ewl_button.h ewl_colordialog.c 
        ewl_filepicker.c ewl_icon.c ewl_icon.h 
Added Files:
        ewl_stock.h ewl_stock.c 


Log Message:
- add Ewl_Stock: an abstact widget that is now used as a base for button and 
icon, thus you can have now also stock icons

Note: ewl_button_stock_type_set/get() will be removed in near future, use 
ewl_stock_type_set/get() instead

===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Ewl.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- Ewl.h       18 Nov 2006 06:15:57 -0000      1.19
+++ Ewl.h       30 Nov 2006 19:35:46 -0000      1.20
@@ -291,6 +291,7 @@
 #include <ewl_io_manager.h>
 
 #include <ewl_label.h>
+#include <ewl_stock.h>
 #include <ewl_button.h>
 #include <ewl_floater.h>
 #include <ewl_overlay.h>
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/Makefile.am,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- Makefile.am 18 Nov 2006 06:15:57 -0000      1.42
+++ Makefile.am 30 Nov 2006 19:35:46 -0000      1.43
@@ -81,6 +81,7 @@
        ewl_spectrum.h \
        ewl_spinner.h \
        ewl_statusbar.h \
+       ewl_stock.h \
        ewl_text.h \
        ewl_table.h \
        ewl_tree.h \
@@ -161,6 +162,7 @@
        ewl_spectrum.c \
        ewl_spinner.c \
        ewl_statusbar.c \
+       ewl_stock.c \
        ewl_table.c \
        ewl_text.c \
        ewl_theme.c \
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_button.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -3 -r1.40 -r1.41
--- ewl_button.c        9 Nov 2006 20:03:33 -0000       1.40
+++ ewl_button.c        30 Nov 2006 19:35:46 -0000      1.41
@@ -3,32 +3,10 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
-/*
- * this array needs to have it's items in the same order as they
- * appear in the Ewl_Stock_Type enum
- */
-struct 
-{
-       char *label;
-       char *image_key;
-} ewl_stock_items[] = {
-               {"Apply",       EWL_ICON_DIALOG_APPLY},
-               {/*Arrow*/"Down",       EWL_ICON_GO_DOWN},
-               {/*Arrow*/"Left",       EWL_ICON_GO_PREVIOUS},
-               {/*Arrow*/"Right",      EWL_ICON_GO_NEXT},
-               {/*Arrow*/"Up",         EWL_ICON_GO_UP},
-               {"Cancel",              EWL_ICON_DIALOG_CANCEL},
-               {"FF",                  EWL_ICON_MEDIA_SEEK_FORWARD},
-               {"Home",        EWL_ICON_GO_HOME},
-               {"Ok",          EWL_ICON_DIALOG_OK},
-               {"Open",        EWL_ICON_DOCUMENT_OPEN},
-               {"Pause",       EWL_ICON_MEDIA_PLAYBACK_PAUSE},
-               {"Play",        EWL_ICON_MEDIA_PLAYBACK_START},
-               {"Quit",        EWL_ICON_SYSTEM_LOG_OUT},
-               {"Rewind",      EWL_ICON_MEDIA_SEEK_BACKWARD},
-               {"Save",        EWL_ICON_DOCUMENT_SAVE},
-               {"Stop",        EWL_ICON_MEDIA_PLAYBACK_STOP}
-       };
+static Ewl_Stock_Funcs stock_funcs = {
+       (void*) ewl_button_label_set,
+       (void*) ewl_button_image_set
+};
 
 /**
  * @return Returns NULL on failure, a pointer to a new button on success
@@ -70,12 +48,13 @@
 
        w = EWL_WIDGET(b);
 
-       if (!ewl_box_init(EWL_BOX(b))) {
+       if (!ewl_stock_init(EWL_STOCK(b))) {
                DRETURN_INT(FALSE, DLEVEL_STABLE);
        }
-       ewl_widget_inherit(w, EWL_BUTTON_TYPE);
 
-       ewl_button_stock_type_set(b, EWL_STOCK_NONE);
+       ewl_widget_inherit(w, EWL_BUTTON_TYPE);
+       EWL_STOCK(b)->stock_funcs = &stock_funcs;
+       ewl_stock_type_set(EWL_STOCK(b), EWL_STOCK_NONE);
 
        ewl_box_orientation_set(EWL_BOX(b), EWL_ORIENTATION_VERTICAL);
        ewl_container_callback_notify(EWL_CONTAINER(b), EWL_CALLBACK_FOCUS_IN);
@@ -171,32 +150,11 @@
 void
 ewl_button_stock_type_set(Ewl_Button *b, Ewl_Stock_Type stock)
 {
-       const char *data;
-
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR("b", b);
        DCHECK_TYPE("b", b, EWL_BUTTON_TYPE);
 
-       if (stock == b->stock_type) {
-               DRETURN(DLEVEL_STABLE);
-       }
-       b->stock_type = stock;
-
-       /* we're done if it's none */
-       if (b->stock_type == EWL_STOCK_NONE) {
-               DRETURN(DLEVEL_STABLE);
-       }
-
-       ewl_button_label_set(b, ewl_stock_items[b->stock_type].label);
-
-       /* check for an image key */
-       data = ewl_icon_theme_icon_path_get(
-                               ewl_stock_items[b->stock_type].image_key,
-                               EWL_ICON_SIZE_MEDIUM);
-
-       ewl_button_image_set(b, data, 
-                ewl_stock_items[b->stock_type].image_key);
-
+       ewl_stock_type_set(EWL_STOCK(b), stock);
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
@@ -212,7 +170,7 @@
        DCHECK_PARAM_PTR_RET("b", b, EWL_STOCK_NONE);
        DCHECK_TYPE_RET("b", b, EWL_BUTTON_TYPE, EWL_STOCK_NONE);
 
-       DRETURN_INT(b->stock_type, DLEVEL_STABLE);
+       DRETURN_INT(ewl_stock_type_get(EWL_STOCK(b)), DLEVEL_STABLE);
 }
 
 /**
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_button.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- ewl_button.h        13 Apr 2006 20:37:22 -0000      1.19
+++ ewl_button.h        30 Nov 2006 19:35:46 -0000      1.20
@@ -34,16 +34,15 @@
 
 /**
  * @brief A simple Ewl_Widget to provide for a clickable button in the UI.
- * Provides easy facilities for adding a Ewl_Text label to the button, and
+ * Provides easy facilities for adding a Ewl_Label label to the button, and
  * a Ewl_Image but allows for placing any number of Ewl_Widget's in the 
Ewl_Button.
  */
 struct Ewl_Button
 {
-       Ewl_Box         box;            /**< Inherit from the box for adding 
widgets */
+       Ewl_Stock       stock;          /**< Inherit from the box for adding 
widgets */
        Ewl_Widget     *body;           /**< The body of the button */
        Ewl_Widget     *label_object;   /**< Labels are common, make it easy */
        Ewl_Widget     *image_object;   /**< Add an image to the button if 
needed */
-       Ewl_Stock_Type  stock_type;     /**< The stock type of the button */
 };
 
 Ewl_Widget     *ewl_button_new(void);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_colordialog.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -3 -r1.23 -r1.24
--- ewl_colordialog.c   26 May 2006 15:35:02 -0000      1.23
+++ ewl_colordialog.c   30 Nov 2006 19:35:46 -0000      1.24
@@ -72,13 +72,13 @@
        /* create the buttons */
        o = ewl_button_new();
        ewl_container_child_append(EWL_CONTAINER(cd), o);
-       ewl_button_stock_type_set(EWL_BUTTON(o), EWL_STOCK_OK);
+       ewl_stock_type_set(EWL_BUTTON(o), EWL_STOCK_OK);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED, 
ewl_colordialog_cb_button_click, cd);
        ewl_widget_show(o);
 
        o = ewl_button_new();
        ewl_container_child_append(EWL_CONTAINER(cd), o);
-       ewl_button_stock_type_set(EWL_BUTTON(o), EWL_STOCK_CANCEL);
+       ewl_stock_type_set(EWL_BUTTON(o), EWL_STOCK_CANCEL);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED, 
ewl_colordialog_cb_button_click, cd);
        ewl_widget_show(o);
 
@@ -301,7 +301,7 @@
        DCHECK_PARAM_PTR("w", w);
        DCHECK_TYPE("w", w, EWL_WIDGET_TYPE);
 
-       type = ewl_button_stock_type_get(EWL_BUTTON(w));
+       type = ewl_stock_type_get(EWL_BUTTON(w));
        ewl_colordialog_respond(EWL_COLORDIALOG(data), type);
         
        DLEAVE_FUNCTION(DLEVEL_STABLE);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filepicker.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- ewl_filepicker.c    7 Nov 2006 03:05:10 -0000       1.16
+++ ewl_filepicker.c    30 Nov 2006 19:35:46 -0000      1.17
@@ -158,7 +158,7 @@
 
        o = ewl_button_new();
        ewl_container_child_append(EWL_CONTAINER(box), o);
-       ewl_button_stock_type_set(EWL_BUTTON(o), EWL_STOCK_OK);
+       ewl_stock_type_set(EWL_STOCK(o), EWL_STOCK_OK);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED, 
                                ewl_filepicker_cb_button_clicked, fp);
        ewl_object_fill_policy_set(EWL_OBJECT(o), 
@@ -167,7 +167,7 @@
 
        o = ewl_button_new();
        ewl_container_child_append(EWL_CONTAINER(box), o);
-       ewl_button_stock_type_set(EWL_BUTTON(o), EWL_STOCK_CANCEL);
+       ewl_stock_type_set(EWL_STOCK(o), EWL_STOCK_CANCEL);
        ewl_callback_append(o, EWL_CALLBACK_CLICKED, 
                                ewl_filepicker_cb_button_clicked, fp);
        ewl_object_fill_policy_set(EWL_OBJECT(o), EWL_FLAG_FILL_SHRINK);
@@ -606,7 +606,7 @@
        fp = data;
        b = EWL_BUTTON(w);
 
-       e.response = ewl_button_stock_type_get(b);
+       e.response = ewl_stock_type_get(b);
 
        if (e.response == EWL_STOCK_CANCEL)
        {
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -3 -r1.21 -r1.22
--- ewl_icon.c  17 Nov 2006 05:53:31 -0000      1.21
+++ ewl_icon.c  30 Nov 2006 19:35:46 -0000      1.22
@@ -3,6 +3,11 @@
 #include "ewl_macros.h"
 #include "ewl_private.h"
 
+static Ewl_Stock_Funcs stock_funcs = {
+       (void*) ewl_icon_label_set,
+       (void*) ewl_icon_image_set
+};
+
 /* XXX may want to make this configurable, possibly per icon? */
 #define EWL_ICON_COMPRESS_SIZE 10
 
@@ -52,8 +57,11 @@
        DENTER_FUNCTION(DLEVEL_STABLE);
        DCHECK_PARAM_PTR_RET("icon", icon, FALSE);
 
-       if (!ewl_box_init(EWL_BOX(icon)))
+       if (!ewl_stock_init(EWL_STOCK((icon))))
                DRETURN_INT(FALSE, DLEVEL_STABLE);
+       
+       EWL_STOCK(icon)->stock_funcs = &stock_funcs;
+       ewl_stock_type_set(EWL_STOCK(icon), EWL_STOCK_NONE);
 
        ewl_box_orientation_set(EWL_BOX(icon), EWL_ORIENTATION_VERTICAL);
        ewl_box_spacing_set(EWL_BOX(icon), 4);
===================================================================
RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- ewl_icon.h  8 Oct 2006 17:26:22 -0000       1.8
+++ ewl_icon.h  30 Nov 2006 19:35:46 -0000      1.9
@@ -30,7 +30,7 @@
  */
 struct Ewl_Icon
 {
-       Ewl_Box box;            /**< Inherit from Ewl_Box */
+       Ewl_Stock   stock;      /**< Inherit from Ewl_Box */
        Ewl_Widget *label;      /**< The icons label */
        Ewl_Widget *image;      /**< The icons image */
        Ewl_Widget *alt;        /**< The icons alt text */



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