From c73c78469864af0cc20f0c154797a37370fe95ad Mon Sep 17 00:00:00 2001 From: codewarrior Date: Wed, 12 Oct 2005 22:21:50 +0000 Subject: [PATCH] - Add label widget (futur work: ability to tie its focus to another widget) - Redo properties dialog in EFM to show more info and file permissions. (needs more work so it can do and apply things, and load permissions) SVN revision: 17468 --- data/themes/default.edc | 1 + data/themes/default_fileman.edc | 172 --------------- data/themes/default_label.edc | 119 +++++++++++ src/bin/Makefile.am | 4 +- src/bin/e_fileman_smart.c | 356 ++++++++++---------------------- src/bin/e_widget_label.c | 119 +++++++++++ src/bin/e_widget_label.h | 12 ++ 7 files changed, 359 insertions(+), 424 deletions(-) create mode 100644 data/themes/default_label.edc create mode 100644 src/bin/e_widget_label.c create mode 100644 src/bin/e_widget_label.h diff --git a/data/themes/default.edc b/data/themes/default.edc index 2496867bf..7ccd29f2d 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -53,5 +53,6 @@ collections { #include "default_radio.edc" #include "default_frame.edc" #include "default_button.edc" +#include "default_label.edc" } diff --git a/data/themes/default_fileman.edc b/data/themes/default_fileman.edc index e77522ce5..9f8ceb763 100644 --- a/data/themes/default_fileman.edc +++ b/data/themes/default_fileman.edc @@ -117,11 +117,7 @@ images image: "e17_menu_bg_border.png" COMP; image: "e17_button2.png" COMP; image: "e17_button.png" COMP; - image: "e17_dialog_watermark.png" COMP; - image: "e17_ibar_bg_v.png" COMP; image: "e17_logo.png" COMP; - image: "e17_menu_bg.png" COMP; - image: "e17_ibar_over_v.png" COMP; } styles @@ -358,174 +354,6 @@ group { } } - -group { - name: "fileman/properties"; - parts { - part { - name: "base"; - mouse_events: 0; - type: RECT; - description { - state: "default" 0.0; - rel1 { - relative: 0.0 0.0; - offset: 1 1; - } - rel2 { - relative: 1.0 1.0; - offset: -2 -2; - } - color: 221 221 221 255; - } - } - part { - name: "conf_bg"; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - to: "conf"; - offset: -7 -7; - } - rel2 { - to: "conf"; - offset: 6 6; - } - image { - normal: "e17_ibar_bg_v.png"; - border: 7 7 7 7; - } - } - } - part { - name: "base3"; - mouse_events: 0; - description { - state: "default" 0.0; - image { - normal: "e17_menu_bg_border.png"; - border: 1 1 1 1; - middle: 0; - } - fill { - smooth: 0; - } - } - } - part { - name: "conf"; - type: RECT; - mouse_events: 0; - description { - state: "default" 0.0; -// max: 1000 1000; - min: 200 100; - rel1 { - to_y: "title"; - relative: 0.0 1.0; - offset: 8 8; - } - rel2 { - relative: 1.0 1.0; - offset: -9 -9; - } - } - } - part { - name: "watermark"; - mouse_events: 0; - description { - state: "default" 0.0; - min: 200 138; - max: 200 138; - align: 1.0 1.0; - fixed: 1 1; - rel1 { - relative: 1.0 1.0; - offset: 29 9; - } - rel2 { - relative: 1.0 1.0; - offset: 29 9; - } - image { - normal: "e17_dialog_watermark.png"; - } - } - } - part { - name: "conf_over"; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - to: "conf_bg"; - } - rel2 { - to: "conf_bg"; - } - image { - normal: "e17_ibar_over_v.png"; - border: 13 13 13 13; - } - } - } - part { - name: "title"; - type: TEXT; - effect: SOFT_SHADOW; - mouse_events: 0; - description { - state: "default" 0.0; - fixed: 0 1; - align: 0.5 0.0; - rel1 { - //to_y: "logo"; - relative: 0.0 0.0; - offset: 6 6; - } - rel2 { - //to_y: "logo"; - relative: 1.0 0.0; - offset: -7 6; - } - color: 255 255 255 255; - color3: 0 0 0 32; - text { - text: "Title Text"; - font: "Edje-Vera-Bold"; - size: 14; - min: 0 1; - align: 0.5 0.5; - } - } - } - part { - name: "content_swallow"; - type: SWALLOW; - description { - state: "default" 0.0; - align: 0.0 0.5; - color: 0 0 0 0; - rel1 { - to_y: "title"; - relative: 0.0 0.0; - offset: 11 11; - to: "conf_bg"; - } - rel2 { - relative: 1.0 1.0; - offset: -12 -12; - to: "conf_bg"; - } - } - } - } - programs { - } -} - group { name: "fileman/rubberband"; parts { diff --git a/data/themes/default_label.edc b/data/themes/default_label.edc new file mode 100644 index 000000000..5e5518144 --- /dev/null +++ b/data/themes/default_label.edc @@ -0,0 +1,119 @@ +images { + image: "focus.png" COMP; +} +group { + name: "widgets/label"; + parts { + part { + name: "label"; + type: TEXT; + effect: SHADOW; + mouse_events: 0; + description { + state: "default" 0.0; + min: 16 16; + rel1 { + relative: 0.0 0.0; + offset: 4 4; + } + rel2 { + relative: 1.0 1.0; + offset: -5 -5; + } + color: 0 0 0 255; + color3: 255 255 255 128; + text { + text: "Check Button"; + font: "Edje-Vera"; + size: 10; + min: 1 1; + align: 0.0 0.5; + } + } + } + part { + name: "event"; + type: RECT; + description { + state: "default" 0.0; + color: 0 0 0 0; + } + } + part { + name: "focus"; + mouse_events: 0; + description { + state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + image { + normal: "focus.png"; + border: 7 7 7 7; + middle: 0; + } + fill { + smooth: 0; + } + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + } + programs { +/* + program { + name: "turn_on1"; + signal: "toggle_on"; + source: ""; + action: STATE_SET "active" 0.0; + target: "item1"; + } + program { + name: "turn_off1"; + signal: "toggle_off"; + source: ""; + action: STATE_SET "default" 0.0; + target: "item1"; + } + program { + name: "click"; + signal: "mouse,down,1"; + source: "event"; + script { + new buf[100]; + new Float:val; + + get_state(PART:"item1", buf, sizeof(buf), val); + if (!strcmp(buf, "default")) { + set_state(PART:"item1", "active", 0.0); + emit("toggled", "on"); + } + else { + set_state(PART:"item1", "default", 0.0); + emit("toggled", "off"); + } + } + } + */ + program { + name: "focus_in"; + signal: "focus_in"; + source: ""; + action: STATE_SET "focused" 0.0; + transition: DECELERATE 0.2; + target: "focus"; + } + program { + name: "focus_out"; + signal: "focus_out"; + source: ""; + action: STATE_SET "default" 0.0; + transition: ACCELERATE 0.5; + target: "focus"; + } + } +} diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 0c4168323..f912f4c89 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -88,7 +88,8 @@ e_widget_check.h \ e_widget_radio.h \ e_widget_framelist.h \ e_widget_list.h \ -e_widget_button.h +e_widget_button.h \ +e_widget_label.h enlightenment_src = \ e_user.c \ @@ -159,6 +160,7 @@ e_widget_radio.c \ e_widget_framelist.c \ e_widget_list.c \ e_widget_button.c \ +e_widget_label.c \ $(ENLIGHTENMENTHEADERS) enlightenment_SOURCES = \ diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c index f63eb219a..8a662fba3 100644 --- a/src/bin/e_fileman_smart.c +++ b/src/bin/e_fileman_smart.c @@ -95,9 +95,7 @@ struct _E_Fileman_File E_Menu *menu; struct { - Evas_Object *table; - E_Win *win; - Evas_Object *bg; + E_Dialog *dia; Evas_List *objects; } prop; @@ -128,7 +126,8 @@ enum _E_Fileman_File_Type E_FILEMAN_FILETYPE_DIRECTORY = 2, E_FILEMAN_FILETYPE_FILE = 3, E_FILEMAN_FILETYPE_HIDDEN = 4, - E_FILEMAN_FILETYPE_UNKNOWN = 5 + E_FILEMAN_FILETYPE_SYMLINK = 5, + E_FILEMAN_FILETYPE_UNKNOWN = 6 }; enum _E_Fileman_Arrange @@ -297,6 +296,10 @@ static char *thumb_path; static double _e_fm_grab_time = 0; static Evas_Smart *e_fm_smart = NULL; + +static int my_val; + + /* externally accessible functions */ Evas_Object * @@ -1631,6 +1634,7 @@ _e_fm_file_delete_no_cb(void *data, E_Dialog *dia) e_object_del(E_OBJECT(dia)); } +/* TODO: This isnt needed any more. Where do we clean the properties dia? */ static void _e_fm_file_menu_properties_del_cb(E_Win *win) { @@ -1638,25 +1642,13 @@ _e_fm_file_menu_properties_del_cb(E_Win *win) Evas_List *l; file = win->data; - evas_object_del(file->prop.table); for (l = file->prop.objects; l; l = l->next) evas_object_del(l->data); - evas_object_del(file->prop.bg); - e_object_del(E_OBJECT(win)); } -static void -_e_fm_file_menu_properties_resize_cb(E_Win *win) -{ - E_Fileman_File *file; - - file = win->data; - evas_object_resize(file->prop.bg, win->w, win->h); -} - static void _e_fm_file_menu_properties(void *data, E_Menu *m, E_Menu_Item *mi) { @@ -1671,9 +1663,15 @@ _e_fm_file_menu_properties(void *data, E_Menu *m, E_Menu_Item *mi) struct tm *t; char *fullname; char *size, *username, *groupname, *lastaccess, *lastmod, *permissions; - + char text[512]; + E_Dialog *dia; + Evas_Object *o, *ol, *hb; + Evas_Coord mw, mh; + E_Radio_Group *rg; + Evas *e; + file = data; - + size = E_NEW(char, 64); snprintf(size, 64, "%ld KB", file->attr->size / 1024); @@ -1697,241 +1695,97 @@ _e_fm_file_menu_properties(void *data, E_Menu *m, E_Menu_Item *mi) permissions = E_NEW(char, 128); // todo snprintf(permissions, 128, "%s", ""); + + dia = e_dialog_new(file->sd->win->container); + e_dialog_title_set(dia, "Properties"); + e = e_win_evas_get(dia->win); + + ol = e_widget_list_add(e, 0, 0); + + hb = e_widget_list_add(e, 1, 1); + + o = e_widget_framelist_add(e, "General", 0); + + snprintf(text, 512, "Name:"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + snprintf(text, 512, "%s", file->attr->name); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + snprintf(text, 512, "Owner:"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + snprintf(text, 512, "%s", username); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + snprintf(text, 512, "Group:"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + snprintf(text, 512, "%s", groupname); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + snprintf(text, 512, "Type:"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + switch(_e_fm_file_type(file)) + { + case E_FILEMAN_FILETYPE_DIRECTORY: + snprintf(text, 512, "Directory"); + break; + case E_FILEMAN_FILETYPE_FILE: + snprintf(text, 512, "File"); + break; + case E_FILEMAN_FILETYPE_SYMLINK: + snprintf(text, 512, "Symlink"); + break; + default: + snprintf(text, 512, "Unknown"); + break; + } + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + snprintf(text, 512, "Last Access:"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + snprintf(text, 512, "%s", lastaccess); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + snprintf(text, 512, "Last Modification"); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + snprintf(text, 512, "%s", lastmod); + e_widget_framelist_object_append(o, e_widget_label_add(e, text, &my_val)); + + e_widget_list_object_append(hb, o, 0, 1, 0.0); + + o = e_widget_framelist_add(e, "Permissions", 0); + + e_widget_framelist_object_append(o, e_widget_label_add(e, "User:", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Read", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Write", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Execute", &my_val)); + + e_widget_framelist_object_append(o, e_widget_label_add(e, "Group:", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Read", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Write", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Execute", &my_val)); + + e_widget_framelist_object_append(o, e_widget_label_add(e, "World:", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Read", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Write", &my_val)); + e_widget_framelist_object_append(o, e_widget_check_add(e, "Execute", &my_val)); - win = e_win_new(file->sd->win->container); - e_win_delete_callback_set(win, _e_fm_file_menu_properties_del_cb); - e_win_resize_callback_set(win, _e_fm_file_menu_properties_resize_cb); - win->data = file; + e_widget_list_object_append(hb, o, 0, 0, 0.0); + + e_widget_list_object_append(ol, hb, 1, 0, 0.0); + + e_widget_min_size_get(ol, &w, &h); + + e_dialog_content_set(dia, ol, w, h); + + e_dialog_button_add(dia, "OK", NULL, NULL, NULL); + e_dialog_button_add(dia, "Apply", "enlightenment/reset", NULL, NULL); + e_dialog_button_add(dia, "Cancel", "enlightenment/exit", NULL, NULL); + e_win_centered_set(dia->win, 1); + e_dialog_show(dia); - bg = edje_object_add(win->evas); - e_theme_edje_object_set(bg, "base/theme/fileman/properties", "fileman/properties"); - edje_object_part_text_set(bg, "title", file->attr->name); - evas_object_move(bg, 0, 0); - evas_object_show(bg); - - table = e_table_add(win->evas); - e_table_homogenous_set(table, 1); - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Name"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 0, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Owner"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 1, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Group"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 2, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Size"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 3, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Last Accessed"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 4, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Last Modified"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 5, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, "Permissions"); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 0, 6, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, file->attr->name); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 0, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, username); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 1, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, groupname); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 2, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, size); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 3, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, lastaccess); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 4, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, lastmod); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 5, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - name = evas_object_text_add(win->evas); - evas_object_text_font_set(name, "Vera", 10); - evas_object_text_text_set(name, permissions); - evas_object_color_set(name, 0, 0, 0, 255); - evas_object_geometry_get(name, NULL, NULL, &w, &h); - evas_object_show(name); - file->prop.objects = evas_list_append(file->prop.objects, name); - e_table_pack(table, name, 1, 6, 1, 1); - e_table_pack_options_set(name, - 1, 1, 1, 1, /* fill */ - 0, 0.5, /* align */ - w, h, /* min w, h */ - w, h); /* max w, h */ - - file->prop.table = table;; - file->prop.win = win; - file->prop.bg = bg; - - edje_object_part_swallow(file->prop.bg, "content_swallow", file->prop.table); - - evas_object_show(table); - - e_box_min_size_get(table, &w, &h); - evas_object_resize(table, w, h); - - // do proper calculation - w += 20; - h += 50; - - if (w < 223) w = 223; - if (h < 209) h = 209; - - e_win_title_set(win, "Properties"); - e_win_resize(win, w, h); - e_win_size_min_set(win, w, h); - e_win_size_base_set(win, w, h); - e_win_size_max_set(win, w, h); - e_win_show(win); + file->prop.dia = dia; + + return; } static void diff --git a/src/bin/e_widget_label.c b/src/bin/e_widget_label.c new file mode 100644 index 000000000..11ed9bb46 --- /dev/null +++ b/src/bin/e_widget_label.c @@ -0,0 +1,119 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#include "e.h" + +typedef struct _E_Widget_Data E_Widget_Data; +struct _E_Widget_Data +{ + Evas_Object *o_label; + int *valptr; +}; + +static void _e_wid_del_hook(Evas_Object *obj); +static void _e_wid_focus_hook(Evas_Object *obj); +static void _e_wid_do(Evas_Object *obj); +static void _e_wid_activate_hook(Evas_Object *obj); +static void _e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info); + +/* local subsystem functions */ + +/* externally accessible functions */ +Evas_Object * +e_widget_label_add(Evas *evas, char *label, int *val) +{ + Evas_Object *obj, *o; + E_Widget_Data *wd; + Evas_Coord mw, mh; + + obj = e_widget_add(evas); + + e_widget_del_hook_set(obj, _e_wid_del_hook); + e_widget_focus_hook_set(obj, _e_wid_focus_hook); + e_widget_activate_hook_set(obj, _e_wid_activate_hook); + wd = calloc(1, sizeof(E_Widget_Data)); + wd->valptr = val; + e_widget_data_set(obj, wd); + + o = edje_object_add(evas); + wd->o_label = o; + e_theme_edje_object_set(o, "base/theme/widgets", + "widgets/label"); + edje_object_signal_callback_add(o, "toggled", "*", _e_wid_signal_cb1, obj); + edje_object_part_text_set(o, "label", label); + evas_object_show(o); + edje_object_size_min_calc(o, &mw, &mh); + e_widget_min_size_set(obj, mw, mh); + + if (wd->valptr) + { + if (*(wd->valptr)) edje_object_signal_emit(o, "toggle_on", ""); + } + + e_widget_sub_object_add(obj, o); + evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN, _e_wid_focus_steal, obj); + e_widget_resize_object_set(obj, o); + + return obj; +} + +static void +_e_wid_del_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + free(wd); +} + +static void +_e_wid_focus_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + if (e_widget_focus_get(obj)) + edje_object_signal_emit(wd->o_label, "focus_in", ""); + else + edje_object_signal_emit(wd->o_label, "focus_out", ""); +} + +static void +_e_wid_do(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + if (wd->valptr) + { + if (*(wd->valptr) == 0) *(wd->valptr) = 1; + else *(wd->valptr) = 0; + } +} + +static void +_e_wid_activate_hook(Evas_Object *obj) +{ + E_Widget_Data *wd; + + wd = e_widget_data_get(obj); + _e_wid_do(obj); + if (wd->valptr) + { + if (*(wd->valptr)) edje_object_signal_emit(wd->o_label, "toggle_on", ""); + else edje_object_signal_emit(wd->o_label, "toggle_off", ""); + } +} + +static void +_e_wid_signal_cb1(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + _e_wid_do(data); +} + +static void +_e_wid_focus_steal(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + e_widget_focus_steal(data); +} diff --git a/src/bin/e_widget_label.h b/src/bin/e_widget_label.h new file mode 100644 index 000000000..2a45b2a37 --- /dev/null +++ b/src/bin/e_widget_label.h @@ -0,0 +1,12 @@ +/* + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 + */ +#ifdef E_TYPEDEFS +#else +#ifndef E_WIDGET_LABEL_H +#define E_WIDGET_LABEL_H + +EAPI Evas_Object *e_widget_label_add(Evas *evas, char *label, int *val); + +#endif +#endif