Clean ups, abstract the widgets a bit, and don't segfault when not finding an unsuitable write mode.
This commit is contained in:
parent
2d514dcf28
commit
8f7fe94f52
@ -215,7 +215,7 @@ group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
part {
|
part {
|
||||||
name: "label";
|
name: "ecdb.label";
|
||||||
type: TEXT;
|
type: TEXT;
|
||||||
mouse_events: 1;
|
mouse_events: 1;
|
||||||
|
|
||||||
@ -226,16 +226,16 @@ group {
|
|||||||
fixed: 1 1;
|
fixed: 1 1;
|
||||||
|
|
||||||
rel1 {
|
rel1 {
|
||||||
to: "icon";
|
to: "ecdb.swallow.icon";
|
||||||
offset: 40 0;
|
offset: 40 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rel2 {
|
rel2 {
|
||||||
to: "icon";
|
to: "ecdb.swallow.icon";
|
||||||
}
|
}
|
||||||
|
|
||||||
text {
|
text {
|
||||||
text: "Burn Audio CD";
|
text: "";
|
||||||
font: "ecdb/default";
|
font: "ecdb/default";
|
||||||
min: 1 1;
|
min: 1 1;
|
||||||
size: 11;
|
size: 11;
|
||||||
@ -245,7 +245,7 @@ group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
part {
|
part {
|
||||||
name: "icon";
|
name: "ecdb.swallow.icon";
|
||||||
type: SWALLOW;
|
type: SWALLOW;
|
||||||
mouse_events: 1;
|
mouse_events: 1;
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
part {
|
part {
|
||||||
name: "label";
|
name: "ecdb.label";
|
||||||
type: TEXT;
|
type: TEXT;
|
||||||
|
|
||||||
description {
|
description {
|
||||||
@ -171,7 +171,7 @@ group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
text {
|
text {
|
||||||
text: "Change Burn Speed";
|
text: "";
|
||||||
font: "ecdb/default";
|
font: "ecdb/default";
|
||||||
min: 1 1;
|
min: 1 1;
|
||||||
size: 11;
|
size: 11;
|
||||||
@ -254,5 +254,31 @@ group {
|
|||||||
set_state(PART:"check", "default", 0.0);
|
set_state(PART:"check", "default", 0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name: "check_off";
|
||||||
|
signal: "ecdb,check,off";
|
||||||
|
source: "ecdb";
|
||||||
|
|
||||||
|
script {
|
||||||
|
set_int(s, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
action: STATE_SET "default" 0.0;
|
||||||
|
target: "check";
|
||||||
|
}
|
||||||
|
|
||||||
|
program {
|
||||||
|
name: "check_on";
|
||||||
|
signal: "ecdb,check,on";
|
||||||
|
source: "ecdb";
|
||||||
|
|
||||||
|
script {
|
||||||
|
set_int(s, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
action: STATE_SET "active" 0.0;
|
||||||
|
target: "check";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,13 +60,14 @@ group {
|
|||||||
}
|
}
|
||||||
|
|
||||||
part {
|
part {
|
||||||
name: "label";
|
name: "ecdb.text";
|
||||||
type: TEXTBLOCK;
|
type: TEXTBLOCK;
|
||||||
mouse_events: 1;
|
mouse_events: 1;
|
||||||
entry_mode: EDITABLE;
|
entry_mode: EDITABLE;
|
||||||
multiline: 0;
|
multiline: 0;
|
||||||
source2: "entry/selection/default";
|
source2: "entry/selection/default";
|
||||||
source3: "entry/cursor/default";
|
//source3: "entry/cursor/default";
|
||||||
|
source3: "entry/selection/default";
|
||||||
|
|
||||||
description {
|
description {
|
||||||
state: "default" 0.0;
|
state: "default" 0.0;
|
||||||
@ -92,7 +93,7 @@ group {
|
|||||||
program {
|
program {
|
||||||
name: "focus_set";
|
name: "focus_set";
|
||||||
action: FOCUS_SET;
|
action: FOCUS_SET;
|
||||||
target: "label";
|
target: "ecdb.text";
|
||||||
}
|
}
|
||||||
|
|
||||||
program {
|
program {
|
||||||
@ -142,6 +143,7 @@ group {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
group {
|
group {
|
||||||
name: "entry/cursor/default";
|
name: "entry/cursor/default";
|
||||||
|
|
||||||
@ -169,6 +171,7 @@ group {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
group {
|
group {
|
||||||
name: "entry/selection/default";
|
name: "entry/selection/default";
|
||||||
|
@ -11,6 +11,7 @@ ecdb_SOURCES = \
|
|||||||
ecdb_audio.c ecdb_audio.h \
|
ecdb_audio.c ecdb_audio.h \
|
||||||
ecdb_gui.c ecdb_gui.h \
|
ecdb_gui.c ecdb_gui.h \
|
||||||
ecdb_erase.c ecdb_erase.h \
|
ecdb_erase.c ecdb_erase.h \
|
||||||
|
ecdb_widgets.c ecdb_widgets.h \
|
||||||
ecdb_common.h
|
ecdb_common.h
|
||||||
|
|
||||||
ecdb_CFLAGS = @ECDB_CFLAGS@
|
ecdb_CFLAGS = @ECDB_CFLAGS@
|
||||||
|
@ -54,6 +54,7 @@ extern int ECDB_DRIVE_ACTION_UPDATE;
|
|||||||
#include "ecdb_misc.h"
|
#include "ecdb_misc.h"
|
||||||
#include "ecdb_audio.h"
|
#include "ecdb_audio.h"
|
||||||
#include "ecdb_gui.h"
|
#include "ecdb_gui.h"
|
||||||
|
#include "ecdb_widgets.h"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ ecdb_burn_project(Ecdb_Burn_Project *proj)
|
|||||||
burn_write_opts_free(opts);
|
burn_write_opts_free(opts);
|
||||||
ecdb_sources_list_free(data->sources);
|
ecdb_sources_list_free(data->sources);
|
||||||
ecdb_tracks_list_free(data->tracks);
|
ecdb_tracks_list_free(data->tracks);
|
||||||
FREE(proj);
|
FREE(data);
|
||||||
return ECDB_ERROR_WRITE_MODE;
|
return ECDB_ERROR_WRITE_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,41 +506,29 @@ ecdb_cb_burn_image_page_buttons_clicked(void *data, Evas_Object *o,
|
|||||||
Ecdb_Burn_Project *proj;
|
Ecdb_Burn_Project *proj;
|
||||||
Evas_Object *entry;
|
Evas_Object *entry;
|
||||||
Ecdb_Source *iso_file;
|
Ecdb_Source *iso_file;
|
||||||
const char *file;
|
char *file;
|
||||||
char *sanitized_file;
|
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
Ecdb_Burn_Result burn_result;
|
Ecdb_Burn_Result burn_result;
|
||||||
|
|
||||||
entry = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
entry = evas_object_name_find(ecore_evas_get(em->main_win_ee),
|
||||||
"ecdb/burn_image/file");
|
"ecdb/burn_image/file");
|
||||||
file = edje_object_part_text_get(entry, "label");
|
file = ecdb_entry_text_get(entry);
|
||||||
|
printf("file: '%s'\n", file);
|
||||||
//Textblock returns a <br> at the end, so chop that off
|
|
||||||
if (!strcmp(&file[strlen(file) - 4], "<br>"))
|
|
||||||
{
|
|
||||||
sanitized_file = alloca(sizeof(char) * (strlen(file) - 3));
|
|
||||||
sanitized_file[0] = '\0';
|
|
||||||
ecore_strlcpy(sanitized_file, file, strlen(file) - 3);
|
|
||||||
printf("Sanitized_file: %s\n", sanitized_file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We aren't altering sanitized_file after this
|
|
||||||
sanitized_file = (char *)file;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure that file actually exists
|
// Make sure that file actually exists
|
||||||
if (!ecore_file_exists(sanitized_file))
|
if (!ecore_file_exists(file))
|
||||||
{
|
{
|
||||||
edje_object_part_text_set(swallow, "progress_text", "File doesn't "
|
edje_object_part_text_set(swallow, "progress_text", "File doesn't "
|
||||||
"exists!");
|
"exists!");
|
||||||
|
FREE(file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
proj = ecdb_burn_project_new();
|
proj = ecdb_burn_project_new();
|
||||||
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT);
|
ecdb_project_type_set(ECDB_PROJECT(proj), ECDB_IMAGE_PROJECT);
|
||||||
iso_file = ecdb_source_new();
|
iso_file = ecdb_source_new();
|
||||||
ecdb_source_data_set(iso_file, sanitized_file);
|
ecdb_source_data_set(iso_file, file);
|
||||||
|
FREE(file);
|
||||||
ecdb_source_child_append(proj->files, iso_file);
|
ecdb_source_child_append(proj->files, iso_file);
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "Commencing...");
|
snprintf(buf, sizeof(buf), "Commencing...");
|
||||||
@ -610,6 +598,8 @@ ecdb_welcome_page_show(void)
|
|||||||
|
|
||||||
if (!swallow)
|
if (!swallow)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Evas_Object *b;
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
||||||
@ -627,7 +617,6 @@ ecdb_welcome_page_show(void)
|
|||||||
ecdb_cb_page_hide_finished, NULL);
|
ecdb_cb_page_hide_finished, NULL);
|
||||||
evas_object_show(swallow);
|
evas_object_show(swallow);
|
||||||
|
|
||||||
Evas_Object *b;
|
|
||||||
int i;
|
int i;
|
||||||
char *labels[] = {"Burn Data CD", "Burn Audio CD", "Burn Image",
|
char *labels[] = {"Burn Data CD", "Burn Audio CD", "Burn Image",
|
||||||
"Erase Re-writable Disc"};
|
"Erase Re-writable Disc"};
|
||||||
@ -635,18 +624,10 @@ ecdb_welcome_page_show(void)
|
|||||||
"ecdb/erase"};
|
"ecdb/erase"};
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
b = edje_object_add(ecore_evas_get(em->main_win_ee));
|
b = ecdb_button_add(swallow, ids[i]);
|
||||||
evas_object_name_set(b, ids[i]);
|
ecdb_button_label_set(b, labels[i]);
|
||||||
edje_object_file_set(b, em->theme_path, "ecdb/button");
|
|
||||||
edje_object_part_geometry_get(swallow, ids[i], &x, &y, &w, &h);
|
|
||||||
edje_object_part_text_set(b, "label", labels[i]);
|
|
||||||
evas_object_move(b, x, y);
|
|
||||||
evas_object_resize(b, w, h);
|
|
||||||
edje_object_part_swallow(swallow, ids[i], b);
|
|
||||||
evas_object_show(b);
|
evas_object_show(b);
|
||||||
|
ecdb_button_icon_set(b, ids[i]);
|
||||||
/* Place this after */
|
|
||||||
ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b, ids[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,6 +733,7 @@ ecdb_erase_page_show(void)
|
|||||||
|
|
||||||
if (!swallow)
|
if (!swallow)
|
||||||
{
|
{
|
||||||
|
Evas_Object *b;
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
||||||
@ -772,32 +754,19 @@ ecdb_erase_page_show(void)
|
|||||||
ecdb_cb_page_hide_finished, NULL);
|
ecdb_cb_page_hide_finished, NULL);
|
||||||
evas_object_show(swallow);
|
evas_object_show(swallow);
|
||||||
|
|
||||||
int i;
|
b = ecdb_button_add(swallow, "ecdb/erase/return");
|
||||||
char *labels[] = {"Return to Main Page", "Start Erase",
|
ecdb_button_label_set(b, "Return to Main Page");
|
||||||
"Quick Erase"};
|
evas_object_show(b);
|
||||||
char *ids[] = {"ecdb/erase/return", "ecdb/erase/begin",
|
ecdb_button_icon_set(b, "ecdb/erase/return");
|
||||||
"ecdb/erase/speed"};
|
|
||||||
char *wtype[] = {"ecdb/button", "ecdb/button", "ecdb/check"};
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
b = ecdb_button_add(swallow, "ecdb/erase/begin");
|
||||||
{
|
ecdb_button_label_set(b, "Start Erase");
|
||||||
Evas_Object *b;
|
evas_object_show(b);
|
||||||
b = edje_object_add(ecore_evas_get(em->main_win_ee));
|
ecdb_button_icon_set(b, "ecdb/erase/begin");
|
||||||
evas_object_name_set(b, ids[i]);
|
|
||||||
edje_object_file_set(b, em->theme_path, wtype[i]);
|
|
||||||
edje_object_part_geometry_get(swallow, ids[i], &x, &y, &w, &h);
|
|
||||||
evas_object_move(b, x, y);
|
|
||||||
evas_object_resize(b, w, h);
|
|
||||||
edje_object_part_text_set(b, "label", labels[i]);
|
|
||||||
edje_object_part_swallow(swallow, ids[i], b);
|
|
||||||
evas_object_show(b);
|
|
||||||
|
|
||||||
if (!strcmp("ecdb/button", wtype[i]))
|
b = ecdb_check_add(swallow, "ecdb/erase/speed");
|
||||||
{
|
ecdb_check_label_set(b, "Quick Erase");
|
||||||
ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b,
|
evas_object_show(b);
|
||||||
ids[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
|
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
|
||||||
@ -821,6 +790,7 @@ ecdb_burn_image_page_show(void)
|
|||||||
|
|
||||||
if (!swallow)
|
if (!swallow)
|
||||||
{
|
{
|
||||||
|
Evas_Object *b;
|
||||||
Evas_Coord x, y, w, h;
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
swallow = edje_object_add(ecore_evas_get(em->main_win_ee));
|
||||||
@ -843,36 +813,19 @@ ecdb_burn_image_page_show(void)
|
|||||||
ecdb_cb_page_hide_finished, NULL);
|
ecdb_cb_page_hide_finished, NULL);
|
||||||
evas_object_show(swallow);
|
evas_object_show(swallow);
|
||||||
|
|
||||||
int i;
|
b = ecdb_button_add(swallow, "ecdb/burn_image/return");
|
||||||
char *labels[] = {"Return to Main Page", "Start Burn", "Burn File"};
|
ecdb_button_label_set(b, "Return to Main Page");
|
||||||
char *ids[] = {"ecdb/burn_image/return", "ecdb/burn_image/begin",
|
evas_object_show(b);
|
||||||
"ecdb/burn_image/file"};
|
ecdb_button_icon_set(b, "ecdb/burn_image/return");
|
||||||
char *wtype[] = {"ecdb/button", "ecdb/button", "ecdb/entry"};
|
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
b = ecdb_button_add(swallow, "ecdb/burn_image/begin");
|
||||||
{
|
ecdb_button_label_set(b, "Start Burn");
|
||||||
Evas_Object *b;
|
evas_object_show(b);
|
||||||
b = edje_object_add(ecore_evas_get(em->main_win_ee));
|
ecdb_button_icon_set(b, "ecdb/burn_image/begin");
|
||||||
evas_object_name_set(b, ids[i]);
|
|
||||||
edje_object_file_set(b, em->theme_path, wtype[i]);
|
|
||||||
edje_object_part_geometry_get(swallow, ids[i], &x, &y, &w, &h);
|
|
||||||
evas_object_move(b, x, y);
|
|
||||||
evas_object_resize(b, w, h);
|
|
||||||
edje_object_part_text_set(b, "label", labels[i]);
|
|
||||||
edje_object_part_swallow(swallow, ids[i], b);
|
|
||||||
evas_object_show(b);
|
|
||||||
|
|
||||||
if (!strcmp("ecdb/button", wtype[i]))
|
b = ecdb_entry_add(swallow, "ecdb/burn_image/file");
|
||||||
{
|
ecdb_entry_text_set(b, "Burn File");
|
||||||
ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b,
|
evas_object_show(b);
|
||||||
ids[i]);
|
|
||||||
}
|
|
||||||
else if (!strcmp("ecdb/entry", wtype[i]))
|
|
||||||
{
|
|
||||||
em->dnd_candidates = eina_list_append(em->dnd_candidates, b);
|
|
||||||
evas_object_data_set(b, "dnd_call_func", ecdb_dnd_entry_dnd_set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
|
else if (edje_object_part_swallow_get(gui, "action_area") != swallow)
|
||||||
|
@ -163,21 +163,6 @@ ecdb_strip_next_argument(const char *strip)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname)
|
|
||||||
{
|
|
||||||
Evas_Object *icon;
|
|
||||||
Evas_Coord x, y, w, h;
|
|
||||||
|
|
||||||
icon = edje_object_add(e);
|
|
||||||
edje_object_file_set(icon, em->theme_path, iname);
|
|
||||||
edje_object_part_geometry_get(b, "icon", &x, &y, &w, &h);
|
|
||||||
evas_object_move(icon, x, y);
|
|
||||||
evas_object_resize(icon, w, h);
|
|
||||||
edje_object_part_swallow(b, "icon", icon);
|
|
||||||
evas_object_show(icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
ecdb_dnd_position(void *data, int type, void *event)
|
ecdb_dnd_position(void *data, int type, void *event)
|
||||||
{
|
{
|
||||||
@ -274,6 +259,6 @@ ecdb_dnd_entry_dnd_set(Evas_Object *o, Ecore_X_Selection_Data_Files *files)
|
|||||||
Efreet_Uri *uri;
|
Efreet_Uri *uri;
|
||||||
|
|
||||||
uri = efreet_uri_decode(files->files[0]);
|
uri = efreet_uri_decode(files->files[0]);
|
||||||
edje_object_part_text_set(o, "label", uri->path);
|
ecdb_entry_text_set(o, uri->path);
|
||||||
efreet_uri_free(uri);
|
efreet_uri_free(uri);
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,6 @@ int ecdb_image_init(void);
|
|||||||
int ecdb_match_keyword(const char *chk, const char *key, int len);
|
int ecdb_match_keyword(const char *chk, const char *key, int len);
|
||||||
char *ecdb_strip_next_argument(const char *strip);
|
char *ecdb_strip_next_argument(const char *strip);
|
||||||
char *ecdb_strip_string(const char *strip);
|
char *ecdb_strip_string(const char *strip);
|
||||||
void ecdb_button_icon_swallow(Evas *e, Evas_Object *b,
|
|
||||||
const char *iname);
|
|
||||||
|
|
||||||
// Also consider moving dnd stuff into its own file
|
// Also consider moving dnd stuff into its own file
|
||||||
int ecdb_dnd_position(void *data, int type, void *event);
|
int ecdb_dnd_position(void *data, int type, void *event);
|
||||||
|
260
ecdb/trunk/src/ecdb_widgets.c
Normal file
260
ecdb/trunk/src/ecdb_widgets.c
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
||||||
|
#include "ecdb.h"
|
||||||
|
|
||||||
|
static char *ecdb_entry_markup_to_text(const char *mkup);
|
||||||
|
static char *_str_append(char *str, const char *txt, int *len, int *alloc);
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
ecdb_widget_add(Evas_Object *parent, const char *name)
|
||||||
|
{
|
||||||
|
Evas_Object *o;
|
||||||
|
int x, y, w, h;
|
||||||
|
|
||||||
|
o = edje_object_add(evas_object_evas_get(parent));
|
||||||
|
evas_object_name_set(o, name);
|
||||||
|
edje_object_part_geometry_get(parent, name, &x, &y, &w, &h);
|
||||||
|
evas_object_move(o, x, y);
|
||||||
|
evas_object_resize(o, w, h);
|
||||||
|
edje_object_part_swallow(parent, name, o);
|
||||||
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
ecdb_button_add(Evas_Object *parent, const char *name)
|
||||||
|
{
|
||||||
|
Evas_Object *b;
|
||||||
|
|
||||||
|
b = ecdb_widget_add(parent, name);
|
||||||
|
edje_object_file_set(b, em->theme_path, "ecdb/button");
|
||||||
|
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_button_label_set(Evas_Object *b, const char *label)
|
||||||
|
{
|
||||||
|
edje_object_part_text_set(b, "ecdb.label", label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_button_icon_set(Evas_Object *b, const char *group)
|
||||||
|
{
|
||||||
|
Evas_Object *icon;
|
||||||
|
|
||||||
|
icon = ecdb_widget_add(b, "ecdb.swallow.icon");
|
||||||
|
edje_object_file_set(icon, em->theme_path, group);
|
||||||
|
evas_object_show(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
ecdb_check_add(Evas_Object *parent, const char *name)
|
||||||
|
{
|
||||||
|
Evas_Object *c;
|
||||||
|
|
||||||
|
c = ecdb_widget_add(parent, name);
|
||||||
|
edje_object_file_set(c, em->theme_path, "ecdb/check");
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_check_label_set(Evas_Object *c, const char *label)
|
||||||
|
{
|
||||||
|
edje_object_part_text_set(c, "ecdb.label", label);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_check_states_set(Evas_Object *c, const char *ystate, const char *nstate)
|
||||||
|
{
|
||||||
|
edje_object_part_text_set(c, "ecdb.ystate", ystate);
|
||||||
|
edje_object_part_text_set(c, "ecdb.nstate", nstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_check_state_set(Evas_Object *c, int state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(c, "ecdb,check,on", "ecdb");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
edje_object_signal_emit(c, "ecdb,check,off", "ecdb");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Evas_Object *
|
||||||
|
ecdb_entry_add(Evas_Object *parent, const char *name)
|
||||||
|
{
|
||||||
|
Evas_Object *e;
|
||||||
|
|
||||||
|
e = ecdb_widget_add(parent, name);
|
||||||
|
edje_object_file_set(e, em->theme_path, "ecdb/entry");
|
||||||
|
em->dnd_candidates = eina_list_append(em->dnd_candidates, e);
|
||||||
|
evas_object_data_set(e, "dnd_call_func", ecdb_dnd_entry_dnd_set);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ecdb_entry_text_set(Evas_Object *e, const char *text)
|
||||||
|
{
|
||||||
|
edje_object_part_text_set(e, "ecdb.text", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
ecdb_entry_text_get(Evas_Object *e)
|
||||||
|
{
|
||||||
|
return ecdb_entry_markup_to_text(edje_object_part_text_get(e, "ecdb.text"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Shamelessly stolen from Elementary... */
|
||||||
|
static char *
|
||||||
|
ecdb_entry_markup_to_text(const char *mkup)
|
||||||
|
{
|
||||||
|
char *str = NULL;
|
||||||
|
int str_len = 0, str_alloc = 0;
|
||||||
|
// FIXME: markup -> text
|
||||||
|
char *s, *p;
|
||||||
|
char *tag_start, *tag_end, *esc_start, *esc_end, *ts;
|
||||||
|
|
||||||
|
tag_start = tag_end = esc_start = esc_end = NULL;
|
||||||
|
p = (char *)mkup;
|
||||||
|
s = p;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if ((*p == 0) ||
|
||||||
|
(tag_end) || (esc_end) ||
|
||||||
|
(tag_start) || (esc_start))
|
||||||
|
{
|
||||||
|
if (tag_end)
|
||||||
|
{
|
||||||
|
char *ttag;
|
||||||
|
|
||||||
|
ttag = malloc(tag_end - tag_start);
|
||||||
|
if (ttag)
|
||||||
|
{
|
||||||
|
strncpy(ttag, tag_start + 1, tag_end - tag_start - 1);
|
||||||
|
ttag[tag_end - tag_start - 1] = 0;
|
||||||
|
/*
|
||||||
|
if (!strcmp(ttag, "br"))
|
||||||
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
||||||
|
*/
|
||||||
|
if (!strcmp(ttag, "\n"))
|
||||||
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
||||||
|
else if (!strcmp(ttag, "\\n"))
|
||||||
|
str = _str_append(str, "\n", &str_len, &str_alloc);
|
||||||
|
else if (!strcmp(ttag, "\t"))
|
||||||
|
str = _str_append(str, "\t", &str_len, &str_alloc);
|
||||||
|
else if (!strcmp(ttag, "\\t"))
|
||||||
|
str = _str_append(str, "\t", &str_len, &str_alloc);
|
||||||
|
free(ttag);
|
||||||
|
}
|
||||||
|
tag_start = tag_end = NULL;
|
||||||
|
}
|
||||||
|
else if (esc_end)
|
||||||
|
{
|
||||||
|
ts = malloc(esc_end - esc_start + 1);
|
||||||
|
if (ts)
|
||||||
|
{
|
||||||
|
const char *esc;
|
||||||
|
strncpy(ts, esc_start, esc_end - esc_start);
|
||||||
|
ts[esc_end - esc_start] = 0;
|
||||||
|
esc = evas_textblock_escape_string_get(ts);
|
||||||
|
if (esc)
|
||||||
|
str = _str_append(str, esc, &str_len, &str_alloc);
|
||||||
|
free(ts);
|
||||||
|
}
|
||||||
|
esc_start = esc_end = NULL;
|
||||||
|
}
|
||||||
|
else if (*p == 0)
|
||||||
|
{
|
||||||
|
ts = malloc(p - s + 1);
|
||||||
|
if (ts)
|
||||||
|
{
|
||||||
|
strncpy(ts, s, p - s);
|
||||||
|
ts[p - s] = 0;
|
||||||
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
||||||
|
free(ts);
|
||||||
|
}
|
||||||
|
s = NULL;
|
||||||
|
}
|
||||||
|
if (*p == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*p == '<')
|
||||||
|
{
|
||||||
|
if (!esc_start)
|
||||||
|
{
|
||||||
|
tag_start = p;
|
||||||
|
tag_end = NULL;
|
||||||
|
ts = malloc(p - s + 1);
|
||||||
|
if (ts)
|
||||||
|
{
|
||||||
|
strncpy(ts, s, p - s);
|
||||||
|
ts[p - s] = 0;
|
||||||
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
||||||
|
free(ts);
|
||||||
|
}
|
||||||
|
s = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*p == '>')
|
||||||
|
{
|
||||||
|
if (tag_start)
|
||||||
|
{
|
||||||
|
tag_end = p;
|
||||||
|
s = p + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*p == '&')
|
||||||
|
{
|
||||||
|
if (!tag_start)
|
||||||
|
{
|
||||||
|
esc_start = p;
|
||||||
|
esc_end = NULL;
|
||||||
|
ts = malloc(p - s + 1);
|
||||||
|
if (ts)
|
||||||
|
{
|
||||||
|
strncpy(ts, s, p - s);
|
||||||
|
ts[p - s] = 0;
|
||||||
|
str = _str_append(str, ts, &str_len, &str_alloc);
|
||||||
|
free(ts);
|
||||||
|
}
|
||||||
|
s = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (*p == ';')
|
||||||
|
{
|
||||||
|
if (esc_start)
|
||||||
|
{
|
||||||
|
esc_end = p;
|
||||||
|
s = p + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
_str_append(char *str, const char *txt, int *len, int *alloc)
|
||||||
|
{
|
||||||
|
int txt_len = strlen(txt);
|
||||||
|
if (txt_len <= 0) return str;
|
||||||
|
if ((*len + txt_len) >= *alloc)
|
||||||
|
{
|
||||||
|
char *str2;
|
||||||
|
int alloc2;
|
||||||
|
|
||||||
|
alloc2 = *alloc + txt_len + 128;
|
||||||
|
str2 = realloc(str, alloc2);
|
||||||
|
if (!str2) return str;
|
||||||
|
*alloc = alloc2;
|
||||||
|
str = str2;
|
||||||
|
}
|
||||||
|
strcpy(str + *len, txt);
|
||||||
|
*len += txt_len;
|
||||||
|
return str;
|
||||||
|
}
|
19
ecdb/trunk/src/ecdb_widgets.h
Normal file
19
ecdb/trunk/src/ecdb_widgets.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* vim: set sw=3 ts=3 sts=3 expandtab: */
|
||||||
|
#ifndef ECDB_WIDGETS_H
|
||||||
|
#define ECDB_WIDGETS_H
|
||||||
|
|
||||||
|
Evas_Object *ecdb_button_add(Evas_Object *parent, const char *name);
|
||||||
|
void ecdb_button_label_set(Evas_Object *b, const char *label);
|
||||||
|
void ecdb_button_icon_set(Evas_Object *b, const char *group);
|
||||||
|
|
||||||
|
Evas_Object *ecdb_check_add(Evas_Object *parent, const char *name);
|
||||||
|
void ecdb_check_label_set(Evas_Object *c, const char *label);
|
||||||
|
void ecdb_check_states_set(Evas_Object *c, const char *ystate,
|
||||||
|
const char *nstate);
|
||||||
|
void ecdb_check_state_set(Evas_Object *c, int state);
|
||||||
|
|
||||||
|
Evas_Object *ecdb_entry_add(Evas_Object *parent, const char *name);
|
||||||
|
void ecdb_entry_text_set(Evas_Object *e, const char *text);
|
||||||
|
char *ecdb_entry_text_get(Evas_Object *e);
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user