Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_button.c ewl_button.h ewl_icon.c ewl_stock.c ewl_stock.h Log Message: - minor cleanups =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_button.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -3 -r1.41 -r1.42 --- ewl_button.c 30 Nov 2006 19:35:46 -0000 1.41 +++ ewl_button.c 3 Dec 2006 06:21:33 -0000 1.42 @@ -4,8 +4,8 @@ #include "ewl_private.h" static Ewl_Stock_Funcs stock_funcs = { - (void*) ewl_button_label_set, - (void*) ewl_button_image_set + ewl_button_label_set, + ewl_button_image_set }; /** @@ -53,7 +53,7 @@ } ewl_widget_inherit(w, EWL_BUTTON_TYPE); - EWL_STOCK(b)->stock_funcs = &stock_funcs; + ewl_stock_functions_set(EWL_STOCK(b), &stock_funcs); ewl_stock_type_set(EWL_STOCK(b), EWL_STOCK_NONE); ewl_box_orientation_set(EWL_BOX(b), EWL_ORIENTATION_VERTICAL); @@ -139,38 +139,6 @@ DLEVEL_STABLE); DRETURN_PTR(NULL, DLEVEL_STABLE); -} - -/** - * @param b: The button to set the stock type on - * @param stock: The Ewl_Stock_Type to set on the button - * @return Returns no value. - * @brief Set the type of the stock button to use - */ -void -ewl_button_stock_type_set(Ewl_Button *b, Ewl_Stock_Type stock) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR("b", b); - DCHECK_TYPE("b", b, EWL_BUTTON_TYPE); - - ewl_stock_type_set(EWL_STOCK(b), stock); - DLEAVE_FUNCTION(DLEVEL_STABLE); -} - -/** - * @param b: The button to get the stock type from - * @return Returns the Ewl_Stock_Type of the button - * @brief Get the stock button type in use - */ -Ewl_Stock_Type -ewl_button_stock_type_get(Ewl_Button *b) -{ - DENTER_FUNCTION(DLEVEL_STABLE); - DCHECK_PARAM_PTR_RET("b", b, EWL_STOCK_NONE); - DCHECK_TYPE_RET("b", b, EWL_BUTTON_TYPE, EWL_STOCK_NONE); - - 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.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- ewl_button.h 30 Nov 2006 19:35:46 -0000 1.20 +++ ewl_button.h 3 Dec 2006 06:21:33 -0000 1.21 @@ -50,9 +50,6 @@ void ewl_button_label_set(Ewl_Button *b, const char *l); const char *ewl_button_label_get(Ewl_Button *b); -void ewl_button_stock_type_set(Ewl_Button *b, Ewl_Stock_Type stock); -Ewl_Stock_Type ewl_button_stock_type_get(Ewl_Button *b); - void ewl_button_image_set(Ewl_Button *b, const char *file, const char *key); const char *ewl_button_image_get(Ewl_Button *b); void ewl_button_image_size_set(Ewl_Button *b, int width, int height); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -3 -r1.23 -r1.24 --- ewl_icon.c 30 Nov 2006 20:54:58 -0000 1.23 +++ ewl_icon.c 3 Dec 2006 06:21:33 -0000 1.24 @@ -4,21 +4,17 @@ #include "ewl_private.h" static Ewl_Stock_Funcs stock_funcs = { - (void*) ewl_icon_label_set, - (void*) ewl_icon_image_set + ewl_icon_label_set, + ewl_icon_image_set }; /* XXX may want to make this configurable, possibly per icon? */ #define EWL_ICON_COMPRESS_SIZE 10 -static void ewl_icon_cb_label_mouse_down(Ewl_Widget *w, void *ev, - void *data); -static void ewl_icon_cb_entry_focus_out(Ewl_Widget *w, void *ev, - void *data); -static void ewl_icon_cb_entry_value_changed(Ewl_Widget *w, void *ev, - void *data); -static void ewl_icon_cb_thumb_value_changed(Ewl_Widget *w, void *ev, - void *data); +static void ewl_icon_cb_label_mouse_down(Ewl_Widget *w, void *ev, void *data); +static void ewl_icon_cb_entry_focus_out(Ewl_Widget *w, void *ev, void *data); +static void ewl_icon_cb_entry_value_changed(Ewl_Widget *w, void *ev, void *data); +static void ewl_icon_cb_thumb_value_changed(Ewl_Widget *w, void *ev, void *data); static void ewl_icon_update_label(Ewl_Icon *icon); @@ -59,8 +55,8 @@ if (!ewl_stock_init(EWL_STOCK((icon)))) DRETURN_INT(FALSE, DLEVEL_STABLE); - - EWL_STOCK(icon)->stock_funcs = &stock_funcs; + + ewl_stock_functions_set(EWL_STOCK(icon), &stock_funcs); ewl_stock_type_set(EWL_STOCK(icon), EWL_STOCK_NONE); ewl_box_orientation_set(EWL_BOX(icon), EWL_ORIENTATION_VERTICAL); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_stock.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- ewl_stock.c 1 Dec 2006 18:27:54 -0000 1.2 +++ ewl_stock.c 3 Dec 2006 06:21:33 -0000 1.3 @@ -11,23 +11,24 @@ { char *label; char *image_key; + char *tooltip; } 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} + {"Apply", EWL_ICON_DIALOG_APPLY, "Apply"}, + {/*Arrow*/"Down", EWL_ICON_GO_DOWN, "Down"}, + {/*Arrow*/"Left", EWL_ICON_GO_PREVIOUS, "Previous"}, + {/*Arrow*/"Right", EWL_ICON_GO_NEXT, "Next"}, + {/*Arrow*/"Up", EWL_ICON_GO_UP, "Up"}, + {"Cancel", EWL_ICON_DIALOG_CANCEL, "Cancel"}, + {"FF", EWL_ICON_MEDIA_SEEK_FORWARD, "Fast Forward"}, + {"Home", EWL_ICON_GO_HOME, "Home"}, + {"Ok", EWL_ICON_DIALOG_OK, "OK"}, + {"Open", EWL_ICON_DOCUMENT_OPEN, "Open"}, + {"Pause", EWL_ICON_MEDIA_PLAYBACK_PAUSE, "Pause"}, + {"Play", EWL_ICON_MEDIA_PLAYBACK_START, "Play"}, + {"Quit", EWL_ICON_SYSTEM_LOG_OUT, "Quit"}, + {"Rewind", EWL_ICON_MEDIA_SEEK_BACKWARD, "Rewind"}, + {"Save", EWL_ICON_DOCUMENT_SAVE, "Save"}, + {"Stop", EWL_ICON_MEDIA_PLAYBACK_STOP, "Stop"} }; /** @@ -41,23 +42,38 @@ int ewl_stock_init(Ewl_Stock *s) { - Ewl_Widget *w; - DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("s", s, FALSE); - w = EWL_WIDGET(s); - - if (!ewl_box_init(EWL_BOX(s))) { + if (!ewl_box_init(EWL_BOX(s))) DRETURN_INT(FALSE, DLEVEL_STABLE); - } - ewl_widget_inherit(w, EWL_STOCK_TYPE); + ewl_widget_inherit(EWL_WIDGET(s), EWL_STOCK_TYPE); DRETURN_INT(TRUE, DLEVEL_STABLE); } /** + * @internal + * @param s: The stock to work with + * @param funcs: The stock functions to set. + * @return Returns no value + * @brief Sets the given stock functions onto the stock widget + */ +void +ewl_stock_functions_set(Ewl_Stock *s, Ewl_Stock_Funcs *funcs) +{ + DENTER_FUNCTION(DLEVEL_STABLE); + DCHECK_PARAM_PTR("s", s); + DCHECK_PARAM_PTR("funcs", funcs); + DCHECK_TYPE("s", s, EWL_STOCK_TYPE); + + s->stock_funcs = funcs; + + DLEAVE_FUNCTION(DLEVEL_STABLE); +} + +/** * @param s: The stock to set the stock type on * @param stock: The Ewl_Stock_Type to set on the stock widget * @return Returns no value. @@ -70,23 +86,26 @@ DCHECK_PARAM_PTR("s", s); DCHECK_TYPE("s", s, EWL_STOCK_TYPE); - if (stock == s->stock_type) { + if (stock == s->stock_type) DRETURN(DLEVEL_STABLE); - } + s->stock_type = stock; /* we're done if it's none */ - if (s->stock_type == EWL_STOCK_NONE) { + if (s->stock_type == EWL_STOCK_NONE) + DRETURN(DLEVEL_STABLE); + + /* Can't do anything without the stock funcs */ + if (!s->stock_funcs) DRETURN(DLEVEL_STABLE); - } /* set the label */ - if (s->stock_funcs && s->stock_funcs->label_set) + if (s->stock_funcs->label_set) s->stock_funcs->label_set(s, - ewl_stock_items[s->stock_type].label); + ewl_stock_items[s->stock_type].label); /* set the image */ - if (s->stock_funcs && s->stock_funcs->image_set) { + if (s->stock_funcs->image_set) { const char *data; /* check for an image key */ @@ -97,6 +116,11 @@ s->stock_funcs->image_set(s, data, ewl_stock_items[s->stock_type].image_key); } + + /* set the tooltip */ + if (s->stock_funcs->tooltip_set) + s->stock_funcs->tooltip_set(s, + ewl_stock_items[s->stock_type].tooltip); DLEAVE_FUNCTION(DLEVEL_STABLE); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_stock.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- ewl_stock.h 30 Nov 2006 19:35:46 -0000 1.1 +++ ewl_stock.h 3 Dec 2006 06:21:33 -0000 1.2 @@ -36,19 +36,22 @@ */ struct Ewl_Stock { - Ewl_Box box; /**< Inherit from the box for adding widgets */ - Ewl_Stock_Type stock_type; /**< The stock type of the stock */ - Ewl_Stock_Funcs *stock_funcs;/**< The stock functions */ + Ewl_Box box; /**< Inherit from the box for adding widgets */ + Ewl_Stock_Type stock_type; /**< The stock type of the stock */ + Ewl_Stock_Funcs *stock_funcs; /**< The stock functions */ }; struct Ewl_Stock_Funcs { void (*label_set)(Ewl_Stock *s, const char *txt); void (*image_set)(Ewl_Stock *s, const char *file, const char *key); + void (*tooltip_set)(Ewl_Stock *s, const char *tip); }; int ewl_stock_init(Ewl_Stock *s); + +void ewl_stock_functions_set(Ewl_Stock *s, Ewl_Stock_Funcs *funcs); void ewl_stock_type_set(Ewl_Stock *s, Ewl_Stock_Type stock); Ewl_Stock_Type ewl_stock_type_get(Ewl_Stock *s); ------------------------------------------------------------------------- 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