Enlightenment CVS committal Author : dj2 Project : e17 Module : libs/ewl
Dir : e17/libs/ewl/src/lib Modified Files: ewl_calendar.c ewl_filelist_column.c ewl_filelist_icon.c ewl_icon.c ewl_icon_theme.c ewl_icon_theme.h ewl_stock.c ewl_text.c ewl_theme.c ewl_theme.h Log Message: - change ewl_theme_path() get to return const - start working on default icons. - the ewl_icon_theme_icon_path_get() function will return the current theme .edj file if the icon is not found - you can call ewl_icon_theme_icon_key_get() to retrieve the key the icon should be looked up under. If this is in the icon theme it will just return the icon again otherwise it will return the EWL theme group name for the icon - currently only folders have a default icon. we need to decide what we want in the default theme for icons =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_calendar.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -3 -r1.21 -r1.22 --- ewl_calendar.c 16 Nov 2006 19:13:46 -0000 1.21 +++ ewl_calendar.c 13 Dec 2006 07:18:59 -0000 1.22 @@ -60,6 +60,7 @@ Ewl_Widget *w, *vbox, *top_hbox, *prev_button, *next_button; struct tm *ptr; time_t tm; + const char *path, *key; DENTER_FUNCTION(DLEVEL_STABLE); DCHECK_PARAM_PTR_RET("ib", ib, FALSE); @@ -83,14 +84,15 @@ ewl_container_child_append(EWL_CONTAINER(vbox), top_hbox); ewl_widget_show(top_hbox); + path = ewl_icon_theme_icon_path_get(EWL_ICON_GO_PREVIOUS, + EWL_ICON_SIZE_SMALL), + key = ewl_icon_theme_icon_key_get(path, EWL_ICON_GO_PREVIOUS); + prev_button = ewl_button_new(); ewl_container_child_append(EWL_CONTAINER(top_hbox), prev_button); ewl_object_fill_policy_set(EWL_OBJECT(prev_button), EWL_FLAG_FILL_NONE); ewl_object_alignment_set(EWL_OBJECT(prev_button), EWL_FLAG_ALIGN_LEFT); - ewl_button_image_set(EWL_BUTTON(prev_button), - ewl_icon_theme_icon_path_get(EWL_ICON_GO_PREVIOUS, - EWL_ICON_SIZE_SMALL), - EWL_ICON_GO_PREVIOUS); + ewl_button_image_set(EWL_BUTTON(prev_button), path, key); ewl_callback_append(prev_button, EWL_CALLBACK_MOUSE_DOWN, ewl_calendar_prev_month_cb, ib); ewl_widget_show(prev_button); @@ -103,14 +105,15 @@ ewl_label_text_set(EWL_LABEL(ib->month_label), "Disp"); ewl_widget_show(ib->month_label); + path = ewl_icon_theme_icon_path_get(EWL_ICON_GO_NEXT, + EWL_ICON_SIZE_SMALL), + key = ewl_icon_theme_icon_key_get(path, EWL_ICON_GO_NEXT); + next_button = ewl_button_new(); ewl_object_fill_policy_set(EWL_OBJECT(next_button), EWL_FLAG_FILL_NONE); ewl_object_alignment_set(EWL_OBJECT(next_button), EWL_FLAG_ALIGN_RIGHT); ewl_container_child_append(EWL_CONTAINER(top_hbox), next_button); - ewl_button_image_set(EWL_BUTTON(next_button), - ewl_icon_theme_icon_path_get(EWL_ICON_GO_NEXT, - EWL_ICON_SIZE_SMALL), - EWL_ICON_GO_NEXT); + ewl_button_image_set(EWL_BUTTON(next_button), path, key); ewl_callback_append(next_button, EWL_CALLBACK_MOUSE_DOWN, ewl_calendar_next_month_cb, ib); ewl_widget_show(next_button); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_column.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -3 -r1.19 -r1.20 --- ewl_filelist_column.c 8 Dec 2006 02:39:47 -0000 1.19 +++ ewl_filelist_column.c 13 Dec 2006 07:18:59 -0000 1.20 @@ -433,7 +433,7 @@ { Ewl_Filelist_Column *list; Ewl_Widget *icon; - const char *stock, *img; + const char *stock, *img, *key; char path[PATH_MAX]; DENTER_FUNCTION(DLEVEL_STABLE); @@ -461,7 +461,8 @@ stock = ewl_filelist_stock_icon_get(fl, path); img = ewl_icon_theme_icon_path_get(stock, NULL); - if (img) ewl_icon_image_set(EWL_ICON(icon), img, stock); + key = ewl_icon_theme_icon_key_get(img, stock); + if (img) ewl_icon_image_set(EWL_ICON(icon), img, key); ewl_container_child_append(EWL_CONTAINER(data), icon); ewl_widget_show(icon); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_filelist_icon.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -3 -r1.13 -r1.14 --- ewl_filelist_icon.c 8 Dec 2006 02:39:47 -0000 1.13 +++ ewl_filelist_icon.c 13 Dec 2006 07:18:59 -0000 1.14 @@ -242,7 +242,7 @@ { Ewl_Filelist_Icon *list; Ewl_Widget *icon; - const char *img, *stock; + const char *img, *stock, *key; char path[PATH_MAX]; DENTER_FUNCTION(DLEVEL_STABLE); @@ -268,7 +268,8 @@ stock = ewl_filelist_stock_icon_get(fl, path); img = ewl_icon_theme_icon_path_get(stock, NULL); - if (img) ewl_icon_image_set(EWL_ICON(icon), img, stock); + key = ewl_icon_theme_icon_key_get(img, stock); + if (img) ewl_icon_image_set(EWL_ICON(icon), img, key); ewl_container_child_append(EWL_CONTAINER(list->freebox), icon); ewl_widget_show(icon); =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- ewl_icon.c 12 Dec 2006 15:53:35 -0000 1.27 +++ ewl_icon.c 13 Dec 2006 07:18:59 -0000 1.28 @@ -229,10 +229,14 @@ ewl_icon_parts_update(icon); else if (!icon->alt) { - ewl_image_file_set(EWL_IMAGE(icon->image), - ewl_icon_theme_icon_path_get( - EWL_ICON_IMAGE_LOADING, NULL), + const char *path, *key; + + path = ewl_icon_theme_icon_path_get( + EWL_ICON_IMAGE_LOADING, NULL), + key = ewl_icon_theme_icon_key_get(path, EWL_ICON_IMAGE_LOADING); + + ewl_image_file_set(EWL_IMAGE(icon->image), path, key); ewl_widget_show(icon->image); } else =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon_theme.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- ewl_icon_theme.c 26 Oct 2006 05:32:03 -0000 1.10 +++ ewl_icon_theme.c 13 Dec 2006 07:18:59 -0000 1.11 @@ -96,7 +96,7 @@ /* make sure we have an icon theme */ if (!icon_theme) - DRETURN_PTR(NULL, DLEVEL_STABLE); + DRETURN_PTR(ewl_theme_path_get(), DLEVEL_STABLE); /* if our theme is an edje just return the .edj file */ if (ewl_icon_theme_is_edje) @@ -119,9 +119,39 @@ } if (ret == EWL_THEME_KEY_NOMATCH) - ret = NULL; + ret = ewl_theme_path_get(); DRETURN_PTR(ret, DLEVEL_STABLE); +} + +/** + * @param path: The path to the icon + * @param icon: The name of the icon + * @return Returns the icon key. + * @brief Returns the icon key or NULL if icon not available + */ +const char * +ewl_icon_theme_icon_key_get(const char *path, const char *icon) +{ + int len; + + if (!path || !icon) + DRETURN_PTR(NULL, DLEVEL_STABLE); + + len = strlen(path); + if (!strcmp((path + len - 4), ".edj")) + { + char key[128]; + const char *ref; + + /* XXX this is a memory leak. We string share the string but + * the user won't be freeing it as it's const char *.... we + * end up leaking it */ + snprintf(key, sizeof(key), "/stock/icon/%s", icon); + DRETURN_PTR(ecore_string_instance(key), DLEVEL_STABLE); + } + + DRETURN_PTR(icon, DLEVEL_STABLE); } static void =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_icon_theme.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- ewl_icon_theme.h 20 Oct 2006 04:37:34 -0000 1.5 +++ ewl_icon_theme.h 13 Dec 2006 07:18:59 -0000 1.6 @@ -15,6 +15,8 @@ const char *ewl_icon_theme_icon_path_get(const char *icon, const char *size); +const char *ewl_icon_theme_icon_key_get(const char *path, + const char *icon); #define EWL_ICON_SIZE_SMALL "16x16" /**< 16x16 icons */ #define EWL_ICON_SIZE_MEDIUM "22x22" /**< 22x22 icons */ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_stock.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -3 -r1.3 -r1.4 --- ewl_stock.c 3 Dec 2006 06:21:33 -0000 1.3 +++ ewl_stock.c 13 Dec 2006 07:18:59 -0000 1.4 @@ -106,15 +106,16 @@ /* set the image */ if (s->stock_funcs->image_set) { - const char *data; + const char *data, *key; /* check for an image key */ data = ewl_icon_theme_icon_path_get( ewl_stock_items[s->stock_type].image_key, EWL_ICON_SIZE_MEDIUM); - - s->stock_funcs->image_set(s, data, + key = ewl_icon_theme_icon_key_get(data, ewl_stock_items[s->stock_type].image_key); + + s->stock_funcs->image_set(s, data, key); } /* set the tooltip */ =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_text.c,v retrieving revision 1.144 retrieving revision 1.145 diff -u -3 -r1.144 -r1.145 --- ewl_text.c 6 Dec 2006 16:27:10 -0000 1.144 +++ ewl_text.c 13 Dec 2006 07:18:59 -0000 1.145 @@ -3190,7 +3190,7 @@ else { fmt[pos].val = ewl_theme_path_get(); - fmt[pos++].free = TRUE; + fmt[pos++].free = FALSE; snprintf(t, 128, "fonts/%s", ctx->font); } =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_theme.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- ewl_theme.c 26 Oct 2006 16:11:56 -0000 1.27 +++ ewl_theme.c 13 Dec 2006 07:18:59 -0000 1.28 @@ -149,14 +149,14 @@ /** * @brief Return the path of the current theme - * @return Returns a copy of the current theme path on success, NULL on failure + * @return Returns the current theme path on success, NULL on failure */ -char * +const char * ewl_theme_path_get(void) { DENTER_FUNCTION(DLEVEL_STABLE); - DRETURN_PTR((ewl_theme_path ? strdup(ewl_theme_path) : NULL), DLEVEL_STABLE); + DRETURN_PTR(ewl_theme_path, DLEVEL_STABLE); } /** =================================================================== RCS file: /cvs/e/e17/libs/ewl/src/lib/ewl_theme.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -3 -r1.11 -r1.12 --- ewl_theme.h 6 Dec 2006 20:14:53 -0000 1.11 +++ ewl_theme.h 13 Dec 2006 07:18:59 -0000 1.12 @@ -32,7 +32,7 @@ int ewl_theme_widget_init(Ewl_Widget *w); void ewl_theme_widget_shutdown(Ewl_Widget *w); -char *ewl_theme_path_get(void); +const char *ewl_theme_path_get(void); int ewl_theme_theme_set(const char *theme); Ecore_List *ewl_theme_font_path_get(void); ------------------------------------------------------------------------- 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