widget_style: filter widget style name on the style list.

This job is not finished yet.
This commit is contained in:
Daniel Juyung Seo 2014-02-26 03:46:18 +09:00
parent 98d70f2127
commit 719016b0f5
6 changed files with 122 additions and 61 deletions

View File

@ -16,6 +16,7 @@ log.c log.h \
theme.c theme.h \
widget.c widget.h \
widget_option.c widget_option.h \
widget_style.c widget_style.h \
main.c common.h \
gui_mobile.c gui_mobile.h \
util.c util.h

View File

@ -45,6 +45,7 @@ extern ETV_Data *ed;
#include "log.h"
#include "theme.h"
#include "widget_style.h"
#include "widget_option.h"
#include "gui.h"
#include "gui_mobile.h"

View File

@ -13,13 +13,6 @@ extern ETV_Data *ed;
return; \
}
typedef struct _Style_Data Style_Data;
struct _Style_Data
{
Widget_Type widget_type;
const char *style;
};
static void _gui_widget_load(void);
int
@ -561,7 +554,7 @@ _gui_widget_style_load(Evas_Object *parent, Widget_Type type)
{
Evas_Object *o = NULL;
Eina_List *styles = NULL, *l = NULL;
char *style = NULL;
const char *style = NULL;
Style_Data *sd = NULL;
// widget styles list
@ -577,6 +570,7 @@ _gui_widget_style_load(Evas_Object *parent, Widget_Type type)
sd = (Style_Data *)calloc(1, sizeof(Style_Data));
sd->widget_type = type;
sd->style = style;
style = widget_style_filter(sd);
elm_list_item_append(o, style, NULL, NULL, _style_list_sel_cb, sd);
}

View File

@ -77,59 +77,6 @@ static const char *lbl[] = {
"Edbus"
};
/*
* Get the first part from the orig_style
*
* h_item/default -> h_item (list)
* item_compress_odd/default -> item_compress_odd (list)
*/
static void
_style_split_1(const char *orig_style, char style[PATH_MAX])
{
char buf[PATH_MAX] = {0, };
const char *tok_ptr;
strncpy(buf, orig_style, sizeof(buf));
tok_ptr = strtok(buf, "/");
strcpy(style, tok_ptr);
//INF("%s", style);
}
/*
* Get the second part from the orig_style
*
* base/default -> default (actionslider)
* base/hoversel_horizontal/entry -> hoversel_horizontal (button)
* item/default/default -> default (genlist item)
* item/full/default -> full (genlist item)
*/
static const char *
_style_split_2(const char *orig_style)
{
char buf[PATH_MAX] = {0, };
const char *style;
strncpy(buf, orig_style, sizeof(buf));
style = strtok(buf, "/");
style = strtok(NULL, "/");
//INF("%s", style);
return style;
}
/* Split the style into two parts
* FIXME: DOES NOT WORK!
static void
_split_style(const char *style EINA_UNUSED, const char **style1 EINA_UNUSED, const char **style2 EINA_UNUSED)
{
char buf[PATH_MAX] = {0, };
strncpy(buf, style, sizeof(buf));
*style1 = strtok(buf, "/");
*style2 = strtok(NULL, "/");
}
*/
/* Remove "/default" from the end of string.
*
* arrow_left/default -> arrow_left (icon)

103
src/bin/widget_style.c Normal file
View File

@ -0,0 +1,103 @@
#include <Elementary.h>
#include "common.h"
/*
* Get the first part from the orig_style
*
* h_item/default -> h_item (list)
* item_compress_odd/default -> item_compress_odd (list)
*/
void
_style_split_1(const char *orig_style, char style[PATH_MAX])
{
char buf[PATH_MAX] = {0, };
const char *tok_ptr;
strncpy(buf, orig_style, sizeof(buf));
tok_ptr = strtok(buf, "/");
strcpy(style, tok_ptr);
//INF("%s", style);
}
/*
* Get the second part from the orig_style
*
* base/default -> default (actionslider)
* base/hoversel_horizontal/entry -> hoversel_horizontal (button)
* item/default/default -> default (genlist item)
* item/full/default -> full (genlist item)
*/
const char *
_style_split_2(const char *orig_style)
{
char buf[PATH_MAX] = {0, };
const char *style;
strncpy(buf, orig_style, sizeof(buf));
style = strtok(buf, "/");
style = strtok(NULL, "/");
//INF("%s", style);
return style;
}
/* Split the style into two parts
* FIXME: DOES NOT WORK!
static void
_split_style(const char *style EINA_UNUSED, const char **style1 EINA_UNUSED, const char **style2 EINA_UNUSED)
{
char buf[PATH_MAX] = {0, };
strncpy(buf, style, sizeof(buf));
*style1 = strtok(buf, "/");
*style2 = strtok(NULL, "/");
}
*/
const char *
widget_style_filter(const Style_Data *sd)
{
const char *style = NULL;
switch (sd->widget_type)
{
case ETV_ID_ACTIONSLIDER:
case ETV_ID_BG:
case ETV_ID_BORDER:
case ETV_ID_BUTTON:
case ETV_ID_CALENDAR:
case ETV_ID_CHECK:
case ETV_ID_CONFORMANT:
case ETV_ID_DATETIME:
case ETV_ID_DAYSELECTOR:
case ETV_ID_FILESELECTOR:
case ETV_ID_FILESELECTOR_ENTRY:
case ETV_ID_FLIPSELECTOR:
case ETV_ID_FRAME:
case ETV_ID_HOVER:
style = sd->style + strlen("base/");
break;
case ETV_ID_BUBBLE:
case ETV_ID_CLOCK:
case ETV_ID_COLORSELECTOR:
case ETV_ID_CTXPOPUP:
case ETV_ID_DISKSELECTOR:
case ETV_ID_ENTRY:
case ETV_ID_EWS:
case ETV_ID_FOCUS_HIGHLIGHT:
case ETV_ID_GENGRID:
case ETV_ID_GENLIST:
case ETV_ID_ICON:
case ETV_ID_INDEX:
default:
//style = _style_split_2(sd->style);
break;
}
if (style)
return style;
else
return sd->style;
}

15
src/bin/widget_style.h Normal file
View File

@ -0,0 +1,15 @@
#ifndef __INCLUDE_WIDGET_STYLE__
#define __INCLUDE_WIDGET_STYLE__
typedef struct _Style_Data Style_Data;
struct _Style_Data
{
Widget_Type widget_type;
const char *style;
};
void _style_split_1(const char *orig_style, char style[PATH_MAX]);
const char * _style_split_2(const char *orig_style);
const char * widget_style_filter(const Style_Data *sd);
#endif