From 10b20c24e5757517fa13063188c461df9cb9d8aa Mon Sep 17 00:00:00 2001 From: Hannes Janetzek Date: Mon, 10 Aug 2009 11:36:37 +0000 Subject: [PATCH] 'everything' module: - restructured and rewrote most parts of core - new gui SVN revision: 41655 --- data/themes/default.edc | 1216 ++++++-- src/modules/everything/Makefile.am | 7 + src/modules/everything/e_mod_main.c | 85 +- src/modules/everything/e_mod_main.h | 40 +- src/modules/everything/evry.c | 2753 +++++++++++------ src/modules/everything/evry_config.c | 141 +- src/modules/everything/evry_plug_apps.c | 449 +-- src/modules/everything/evry_plug_aspell.c | 124 +- src/modules/everything/evry_plug_border.c | 49 +- src/modules/everything/evry_plug_border_act.c | 285 +- src/modules/everything/evry_plug_calc.c | 124 +- src/modules/everything/evry_plug_config.c | 195 +- src/modules/everything/evry_plug_dir_browse.c | 294 +- src/modules/everything/evry_plug_tracker.c | 214 +- 14 files changed, 3797 insertions(+), 2179 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 2c90c14d9..44591a92f 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -26582,408 +26582,938 @@ MIMEBASE("application/x-font-bdf","icon_mime_font_generic.png", ".BDF", 128); ///////////////////////////////////////////////////////////////////////////// /*** MOD: EVERYTHING ***/ + ICON("everything-launch","icon_advanced.png",64) + group { name: "e/widgets/everything/main"; - images { - image: "base_bg.png" COMP; - image: "inset_sunk.png" COMP; - image: "menu_sel_bg.png" COMP; - image: "menu_sel_fg.png" COMP; - } - parts { - part { name: "base"; - mouse_events: 0; - description { state: "default" 0.0; - image { - normal: "base_bg.png"; - border: 2 2 2 2; + min: 620 118; + images { + image: "base_bg.png" COMP; + image: "inset_sunk.png" COMP; + image: "menu_sel_bg.png" COMP; + image: "menu_sel_fg.png" COMP; + } + data.item: "shaped" "1"; + parts { + part { name: "bg"; + description { state: "default" 0; + min: 420 118; + rel1.relative: 0.5 0.0; + rel2.relative: 0.5 1.0; + image { + normal: "menu_sel_bg.png"; + border: 8 8 5 9; + } + } + description { state: "wide" 0; + inherit: "default" 0.0; + min: 620 118; + } + } + + part { name: "selector_frame"; + type: RECT; + description { state: "default" 0; + color: 255 255 255 255; + rel1 { + offset: 5 5; + to: "bg"; + } + rel2 { + offset: -6 -6; + to: "bg"; + } + } + } + part { name: "e.swallow.subject_selector"; + type: SWALLOW; + clip_to: "selector_frame"; + description { state: "default" 0; + min: 200 100; + max: 200 100; + rel1 { + offset: 5 5; + to: "selector_frame"; + } + rel2 { + relative: 0 0; + offset: 205 100; + to: "selector_frame"; + } + } + } + part { name: "e.swallow.action_selector"; + type: SWALLOW; + clip_to: "selector_frame"; + description { state: "default" 0; + min: 200 100; + max: 200 100; + rel1 { + relative: 0 0; + offset: 205 5; + to: "selector_frame"; + } + rel2 { + relative: 0 0; + offset: 405 100; + to: "selector_frame"; + } + } + } + part { name: "e.swallow.object_selector"; + type: SWALLOW; + clip_to: "selector_frame"; + description { state: "default" 0; + max: 200 100; + visible: 0; + rel1 { + relative: 0 0; + offset: 405 5; + to: "selector_frame"; + } + rel2 { + relative: 0 0; + offset: 605 100; + to: "selector_frame"; + } + } + description { state: "wide" 0; + inherit: "default" 0.0; + visible: 1; + } + } + + part { name: "fg"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + image { + normal: "menu_sel_fg.png"; + border: 8 8 11 4; + } + } + } + } + programs { + program { name: "object_selector_hide"; + signal: "e,state,object_selector_hide"; + source: "e"; + action: STATE_SET "default" 0.00; + transition: SINUSOIDAL 0.20000; + target: "bg"; + target: "e.swallow.object_selector"; + } + program { name: "object_selector_show"; + signal: "e,state,object_selector_show"; + source: "e"; + action: STATE_SET "wide" 0.00; + transition: SINUSOIDAL 0.40000; + target: "bg"; + target: "e.swallow.object_selector"; + } + } + } + + group { name: "e/widgets/everything/selector_item"; + images { + image: "gadman_border.png" COMP; + } + parts { + part { name: "clip"; + type: RECT; + mouse_events: 0; + description { + state: "default" 0.0; + } + } + + part { name: "border"; + clip_to: "clip"; + mouse_events: 0; + description { state: "default" 0.0; + color: 255 255 255 32; + image { + normal: "gadman_border.png"; + border: 10 10 10 10; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 128; + } + } + + part { name: "inner_clip"; + type: RECT; + clip_to: "clip"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1.offset: 10 10; + rel2.offset: -11 -11; + } + } + + part { + name: "e.swallow.icons"; + type: SWALLOW; + clip_to: "inner_clip"; + description { + state: "default" 0.0; + max: 64 64; + aspect: 1.0 1.0; + align: 0.0 0.5; + aspect_preference: VERTICAL; + rel1 { + relative: 0.0 0.0; + offset: 10 10; + } + rel2 { + relative: 0.0 1.0; + offset: -11 -11; + } + } + } + part { name: "e.text.label"; + type: TEXT; + clip_to: "inner_clip"; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + offset: 6 1; + relative: 1.0 0.5; + to_x: "e.swallow.icons"; + } + rel2.offset: -3 -2; + color: 240 240 240 255; + color3: 0 0 0 0; + color_class: "menu_item"; + text { + font: "Sans:style=Bold"; + size: 10; + min: 0 1; + align: 0.0 0.5; + /* text_class: "menu_item"; */ + } + } + } + part { name: "e.text.plugin"; + type: TEXT; + clip_to: "inner_clip"; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + offset: 6 12; + relative: 1.0 0.0; + to_x: "e.swallow.icons"; + } + rel2.offset: -13 -2; + color: 210 210 210 255; + color3: 0 0 0 0; + color_class: "menu_item"; + text { + font: "Sans"; + size: 10; + min: 0 1; + align: 1.0 0.0; + /* text_class: "menu_item"; */ + } + } + } + } + programs { + program { name: "sel"; + signal: "e,state,selected"; + source: "e"; + action: STATE_SET "selected" 0.0; + transition: SINUSOIDAL 0.2; + target: "border"; + } + program { name: "unsel"; + signal: "e,state,unselected"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.3; + target: "border"; + } + } + } + + group { name: "e/widgets/everything/list"; + images { + image: "base_bg.png" COMP; + image: "inset_sunk.png" COMP; + image: "menu_sel_bg.png" COMP; + image: "menu_sel_fg.png" COMP; + } + data.item: "shaped" "1"; + parts { + part { name: "base"; + mouse_events: 0; + type: RECT; + description { state: "default" 0.0; + rel1 { + relative: 0.0 1.0; + to_y: "input_base"; + } + rel2 { + relative: 1.0 1.0; + to_y: "input_base"; + } + } + description { state: "visible" 0.0; + rel1 { + relative: 0.0 1.0; + to_y: "input_base"; + } + rel2 { + relative: 1.0 1.0; + } + } + } + + part { name: "bg"; + description { state: "default" 0.0; + rel2 { + to: "base"; + } + image { + normal: "base_bg.png"; + border: 2 2 2 2; + } + fill.smooth: 0; + color: 235 235 235 255; + } + } + + part { name: "list_bg"; + type: RECT; + clip_to: "base"; + description { state: "default" 0.0; + rel1 { + to: "list_clip"; + offset: 0 0; + } + rel2 { + to: "list_clip"; + offset: 0 0; + } + color: 255 255 255 255; + } + } + + part { name: "input_base"; + mouse_events: 1; + type: RECT; + description { state: "default" 0.0; + rel1 { + relative: 0.0 0.0; + } + rel2 { + relative: 1.0 0.0; + offset: -1 4; + } + } + description { state: "visible" 0.0; + rel1 { + relative: 0.0 0.0; + } + rel2 { + relative: 1.0 0.0; + offset: -1 30; + } + } + } + + part { name: "input_bg"; + mouse_events: 1; + clip_to: "input_base"; + description { state: "default" 0.0; + min: 32 28; + max: 9999 28; + visible: 0; + rel1 { + relative: 0.0 0.0; + offset: 1 2; + to: "input_base"; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + to: "input_base"; + } + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; + } + color: 235 235 235 255; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + part { name: "e.text.label"; + type: TEXT; + effect: SHADOW; + scale: 1; + clip_to: "input_base"; + description { state: "default" 0.0; + fixed: 0 1; + align: 0.0 0.5; + rel1 { + relative: 0.0 0.0; + offset: 10 7; + to: "input_bg"; + } + rel2 { + relative: 0.0 1.0; + offset: 10 -5; + to: "input_bg"; + } + color: 10 10 10 255; + color3: 255 255 255 128; + text { + font: "Sans:style=Bold"; + size: 14; + align: 0.0 0.5; + min: 1 1; + /* text_class: "exebuf_command"; */ + } + } + } + + /* part { name: "cursor"; + * type: RECT; + * mouse_events: 0; + * description { state: "default" 0.0; + * min: 1 18; + * max: 1 18; + * align: 0.0 0.5; + * fixed: 1 1; + * rel1 { + * relative: 1.0 0.0; + * offset: 1 0; + * to: "e.text.label"; + * } + * rel2 { + * relative: 1.0 1.0; + * offset: 1 -1; + * to: "e.text.label"; + * } + * color: 10 10 10 220; + * } + * description { state: "faded" 0.0; + * inherit: "default" 0.0; + * color: 10 10 10 0; + * } + * } */ + + part { name: "input_over2"; + mouse_events: 0; + clip_to: "input_base"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "input_bg"; + rel2.to: "input_bg"; + image { + normal: "bt_dis_shine.png"; + border: 4 4 4 4; + } + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; } - fill.smooth: 0; - color: 245 245 245 255; - } - } + } + part { name: "input_over1"; + mouse_events: 0; + clip_to: "input_base"; + description { state: "default" 0.0; + visible: 0; + rel1.to: "input_bg"; + rel2.to: "input_bg"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + color: 255 255 255 128; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + } + } + + part { name: "selector_base"; + mouse_events: 1; + clip_to: "base"; + description { state: "default" 0.0; + min: 32 28; + max: 9999 28; - part { name: "bg"; - mouse_events: 0; - description { state: "default" 0.0; - min: 0 42; - max: 99999 42; - - rel1 { - relative: 0.0 0.0; - offset: 4 8; - } - rel2 { - relative: 1.0 0.0; - offset: -6 50; - } - - image { - normal: "menu_sel_bg.png"; - border: 8 8 5 9; - } - } - } - - part { name: "list_bg"; - type: RECT; - description { state: "default" 0.0; - rel1 { - relative: 0.0 1.0; - to: "selector_base"; - offset: 3 6; - } - rel2 { - to: "e.swallow.list"; - offset: 0 0; - } - color: 255 255 255 255; - } - } - - part { name: "selector_base"; - mouse_events: 1; - description { state: "default" 0.0; - min: 32 32; - max: 9999 32; - - rel1 { - relative: 0.0 1.0; - offset: 8 6; - to_y: "bg"; - } - rel2 { - relative: 1.0 1.0; - offset: -9 38; - to_y: "bg"; - } + rel1 { + relative: 0.0 1.0; + offset: 1 -30; + to: "base"; + } + rel2 { + relative: 1.0 1.0; + offset: -2 -1; + to: "base"; + } - image { - normal: "bt_dis_base.png"; - border: 4 4 4 4; - } - } - } - part { name: "clipper"; - type: RECT; - mouse_events: 0; - description { - state: "default" 0.0; - rel1 { - to: "selector_base"; - offset: 2 2; - } - rel2 { - to: "selector_base"; - offset: -3 -3; - } - } - } - part { name: "e.swallow.bar"; - clip_to: "clipper"; - type: SWALLOW; - description { - state: "default" 0.0; - rel1.to: "clipper"; - rel2.to: "clipper"; - } - } - part { name: "over2"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "selector_base"; - rel2.to: "selector_base"; - image { - normal: "bt_dis_shine.png"; - border: 4 4 4 4; - } - } - } - part { name: "over1"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "selector_base"; - rel2.to: "selector_base"; - rel2.relative: 1.0 0.5; - image { - normal: "bt_dis_hilight.png"; - border: 4 4 4 0; - } - color: 255 255 255 128; - } - } + image { + normal: "bt_dis_base.png"; + border: 4 4 4 4; - part { name: "e.swallow.list"; - type: SWALLOW; - clip_to: "list_clip"; - description { state: "default" 0.0; - min: 32 64; - align: 0.5 0.0; - rel1 { - relative: 0.0 1.0; - offset: 12 7; - to_y: "selector_base"; + } + color: 235 234 234 255; } - rel2.offset: -13 -13; - } - } - part { name: "list_clip"; - type: RECT; - description { state: "default" 0.0; - color: 255 255 255 255; - rel1.to_y: "e.swallow.list"; - rel2.to_y: "e.swallow.list"; - } - } - part { name: "list_over"; - mouse_events: 0; - description { state: "default" 0.0; - rel1 { - offset: -1 -1; - to: "list_bg"; + } + part { name: "bar_clip"; + type: RECT; + clip_to: "base"; + mouse_events: 0; + description { + state: "default" 0.0; + rel1 { + to: "e.swallow.bar"; + offset: 2 0; + } + rel2 { + to: "e.swallow.bar"; + offset: -5 -1; + } } - rel2 { - offset: 0 0; - to: "list_bg"; + } + part { name: "e.swallow.bar"; + clip_to: "bar_clip"; + type: SWALLOW; + description { + state: "default" 0.0; + rel1 { + to: "selector_base"; + offset: 0 2; + } + rel2 { + to: "selector_base"; + offset: -2 -3; + } } - image { - normal: "inset_sunk.png"; - border: 7 7 7 7; - middle: 0; + } + part { name: "over2"; + mouse_events: 0; + clip_to: "base"; + description { state: "default" 0.0; + rel1.to: "selector_base"; + rel2.to: "selector_base"; + image { + normal: "bt_dis_shine.png"; + border: 4 4 4 4; + } } - fill.smooth : 0; - } - } + } + part { name: "over1"; + mouse_events: 0; + clip_to: "base"; + description { state: "default" 0.0; + rel1.to: "selector_base"; + rel2.to: "selector_base"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_dis_hilight.png"; + border: 4 4 4 0; + } + color: 255 255 255 128; + } + } - part { name: "e.text.label"; - type: TEXT; - effect: SHADOW; - scale: 1; - description { state: "default" 0.0; - fixed: 0 1; - align: 0.0 0.5; - rel1 { - relative: 1.0 0.0; - offset: 4 8; - to_x: "e.swallow.icons"; + part { name: "e.swallow.list"; + type: SWALLOW; + clip_to: "list_clip"; + description { state: "default" 0.0; + min: 32 150; + rel1 { + relative: 0.0 0.0; + offset: 4 5; + to: "list_clip"; + } + rel2 { + relative: 1.0 1.0; + offset: -4 -4; + to: "list_clip"; + } } - rel2 { - relative: 1.0 0.0; - offset: -10 50; - to_x: "e.swallow.icons"; + } + part { name: "list_clip"; + type: RECT; + clip_to: "base"; + description { state: "default" 0.0; + color: 255 255 255 255; + rel1 { + relative: 0.0 0.0; + offset: 3 0; + to: "base"; + } + rel2 { + relative: 1.0 0.0; + offset: -4 -4; + to_y: "selector_base"; + to_x: "base"; + } } - color: 255 255 255 255; - color3: 0 0 0 64; - text { - font: "Sans:style=Bold"; - size: 14; - align: 0.0 0.5; - min: 1 1; - text_class: "exebuf_command"; + } + part { name: "list_over"; + mouse_events: 0; + clip_to: "base"; + description { state: "default" 0.0; + rel1 { + offset: -1 -1; + to: "list_bg"; + } + rel2 { + offset: 0 0; + to: "list_bg"; + } + image { + normal: "inset_sunk.png"; + border: 7 7 7 7; + middle: 0; + } + fill.smooth : 0; } - } - } - part { name: "cursor"; - type: RECT; - mouse_events: 0; - description { state: "default" 0.0; - min: 1 18; - max: 1 18; - align: 0.0 0.5; - fixed: 1 1; - rel1 { - relative: 1.0 0.0; - offset: 1 0; - to: "e.text.label"; - } - rel2 { - relative: 1.0 1.0; - offset: 1 -1; - to: "e.text.label"; - } - color: 255 255 255 220; - } - description { state: "faded" 0.0; - inherit: "default" 0.0; - color: 255 255 255 0; - } - } - part { name: "e.swallow.icons"; - type: SWALLOW; - description { state: "default" 0.0; - min: 32 32; - max: 32 32; - align: 0.0 0.0; - rel1 { - offset: 6 4; - to: "bg"; - } - rel2 { - offset: -7 -5; - to: "bg"; - } - } - } - part { name: "fg"; - mouse_events: 0; - description { state: "default" 0.0; - rel1.to: "bg"; - rel2.to: "bg"; - image { - normal: "menu_sel_fg.png"; - border: 8 8 5 9; - } - } - } - } - programs { - program { name: "blink_off"; - signal: "show"; - source: ""; - action: STATE_SET "faded" 0.0; - transition: SINUSOIDAL 0.5; - target: "cursor"; - after: "blink_on"; - } - program { name: "blink_on"; - action: STATE_SET "default" 0.0; - transition: SINUSOIDAL 0.25; - target: "cursor"; - after: "blink_off"; - } - } + } + } + programs { + program { name: "show_list"; + signal: "e,state,list_show"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: ACCELERATE 0.2; + target: "base"; + /* after: "show_list_end"; */ + } + program { name: "hide_list"; + signal: "e,state,list_hide"; + source: "e"; + action: STATE_SET "default" 0.0; + /* transition: SINUSOIDAL 0.1; */ + target: "base"; + } + program { name: "show_entry"; + signal: "e,state,entry_show"; + source: "e"; + action: STATE_SET "visible" 0.0; + transition: SINUSOIDAL 0.08; + target: "input_over1"; + target: "input_over2"; + target: "input_base"; + target: "input_bg"; + } + program { name: "hide_entry"; + signal: "e,state,entry_hide"; + source: "e"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 0.08; + target: "input_over1"; + target: "input_over2"; + target: "input_base"; + target: "input_bg"; + } + /* program { name: "blink_off"; + * signal: "show"; + * source: ""; + * action: STATE_SET "faded" 0.0; + * transition: SINUSOIDAL 0.5; + * target: "cursor"; + * after: "blink_on"; + * } + * program { name: "blink_on"; + * action: STATE_SET "default" 0.0; + * transition: SINUSOIDAL 0.25; + * target: "cursor"; + * after: "blink_off"; + * } */ + + /* program { name: "show_list_end"; + * action: SIGNAL_EMIT "e,state,list_shown" "e"; + * } */ + } } group { name: "e/widgets/everything/item"; + parts { + part { name: "bg"; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + rel1.offset: -5 -3; + rel2.offset: 4 5; + image { + normal: "menu_sel_bg.png"; + border: 8 8 5 9; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + rel1.offset: -2 0; + rel2.offset: 1 2; + } + } + part { name: "e.text.title"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + offset: 5 3; + relative: 1.0 0.0; + to_x: "e.swallow.icons"; + } + rel2.offset: -3 -2; + color: 60 60 60 255; + color3: 255 255 255 64; + color_class: "menu_item"; + text { + font: "Sans:style=Bold"; + size: 10; + min: 0 1; + align: 0.0 0.5; + text_class: "menu_item"; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + color3: 0 0 0 64; + color_class: "menu_item"; + } + } + part { + name: "e.swallow.icons"; + type: SWALLOW; + description { + state: "default" 0.0; + max: 20 20; + aspect: 1.0 1.0; + align: 0.0 0.5; + aspect_preference: VERTICAL; + rel1 { + relative: 0.0 0.0; + offset: 3 1; + } + rel2 { + relative: 0.0 1.0; + offset: -3 -2; + } + } + } + part { name: "fg"; + mouse_events: 0; + description { state: "default" 0.0; + visible: 0; + color: 255 255 255 0; + rel1.to: "bg"; + rel2.to: "bg"; + image { + normal: "menu_sel_fg.png"; + border: 8 8 5 9; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + color: 255 255 255 255; + } + } + part { + name: "e.event.exebuf.item"; + type: RECT; + mouse_events: 1; + description { + state: "default" 0.0; + min: 14 14; + visible: 1; + color: 0 0 0 0; + rel1 { + relative: 1.0 0.0; + offset: 1 -1; + to_x: "e.swallow.icons"; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + } + } + } + programs { + program { name: "sel"; + signal: "e,state,selected"; + source: "e"; + action: STATE_SET "selected" 0.0; + /* transition: LINEAR 0.2; */ + target: "bg"; + target: "fg"; + target: "e.text.title"; + } + program { name: "unsel"; + signal: "e,state,unselected"; + source: "e"; + action: STATE_SET "default" 0.0; + /* transition: LINEAR 0.1; */ + target: "bg"; + target: "fg"; + target: "e.text.title"; + } + } + } + + group { name: "e/widgets/everything/tab_item"; + images { + image: "toolbar_sel.png" COMP; + } parts { + part { name: "label2"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 1.0; + fixed: 0 1; + rel1.to: "e.text.label"; + rel2.to: "e.text.label"; + color: 0 0 0 255; + text { + font: "Sans"; + text_source: "e.text.label"; + size: 10; + min: 1 1; + align: 0.5 0.5; + text_class: "fileman_icon"; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } part { name: "bg"; mouse_events: 0; description { state: "default" 0.0; visible: 0; color: 255 255 255 0; - rel1.offset: -5 -3; - rel2.offset: 4 5; image { - normal: "menu_sel_bg.png"; - border: 8 8 5 9; + normal: "toolbar_sel.png"; + border: 3 3 0 0; } + fill.smooth: 0; } description { state: "selected" 0.0; inherit: "default" 0.0; visible: 1; color: 255 255 255 255; - rel1.offset: -2 0; - rel2.offset: 1 2; } } - part { name: "e.text.title"; - type: TEXT; - effect: SOFT_SHADOW; - mouse_events: 0; - scale: 1; - description { - state: "default" 0.0; - rel1 { - offset: 2 1; - relative: 1.0 0.0; - to_x: "e.swallow.icons"; - } - rel2.offset: -3 -2; - color: 0 0 0 255; - color3: 0 0 0 0; - color_class: "menu_item"; - text { - font: "Sans"; - size: 10; - min: 0 1; - align: 0.0 0.5; - text_class: "menu_item"; - } - } - description { state: "selected" 0.0; - inherit: "default" 0.0; - color: 255 255 255 255; - color3: 0 0 0 64; - color_class: "menu_item"; - } - } - part { - name: "e.swallow.icons"; + part { name: "e.swallow.icon"; type: SWALLOW; - description { - state: "default" 0.0; - max: 18 18; + description { state: "default" 0.0; + align: 0.5 0.5; aspect: 1.0 1.0; - align: 0.0 0.5; aspect_preference: VERTICAL; rel1 { relative: 0.0 0.0; - offset: 3 1; + offset: 2 2; } rel2 { - relative: 0.0 1.0; - offset: -3 -2; + to_y: "e.text.label"; + relative: 1.0 0.0; + offset: -3 -1; } + color: 0 0 0 0; } } - part { name: "fg"; - mouse_events: 0; + part { name: "e.text.label"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events: 0; + scale: 1; description { state: "default" 0.0; + align: 0.5 1.0; + fixed: 0 1; + rel1 { + relative: 0.0 1.0; + offset: 4 -1; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } visible: 0; - color: 255 255 255 0; - rel1.to: "bg"; - rel2.to: "bg"; - image { - normal: "menu_sel_fg.png"; - border: 8 8 5 9; + color: 224 224 224 255; + color3: 0 0 0 32; + text { + font: "Sans:style=Bold"; + size: 10; + min: 1 1; + align: 0.5 0.5; + text_class: "fileman_icon"; } } description { state: "selected" 0.0; inherit: "default" 0.0; visible: 1; - color: 255 255 255 255; } } - part { - name: "e.event.exebuf.item"; - type: RECT; - mouse_events: 1; - description { - state: "default" 0.0; - min: 14 14; - visible: 1; + part { name: "event"; + type: RECT; + mouse_events: 1; + ignore_flags: ON_HOLD; + description { state: "default" 0.0; color: 0 0 0 0; - rel1 { - relative: 1.0 0.0; - offset: 1 -1; - to_x: "e.swallow.icons"; - } - rel2 { - relative: 1.0 1.0; - offset: -1 -1; - } } } } programs { - program { name: "sel"; - signal: "e,state,selected"; - source: "e"; - action: STATE_SET "selected" 0.0; + program { name: "go_active"; + signal: "e,state,selected"; + source: "e"; + action: STATE_SET "selected" 0.0; + target: "bg"; + target: "e.text.label"; + target: "label2"; transition: LINEAR 0.2; - target: "bg"; - target: "fg"; - target: "e.text.title"; } - program { name: "unsel"; - signal: "e,state,unselected"; - source: "e"; - action: STATE_SET "default" 0.0; + program { name: "go_passive"; + signal: "e,state,unselected"; + source: "e"; + action: STATE_SET "default" 0.0; + target: "bg"; + target: "e.text.label"; + target: "label2"; transition: LINEAR 0.1; - target: "bg"; - target: "fg"; - target: "e.text.title"; } + /* program { name: "go"; + * signal: "mouse,up,1"; + * source: "event"; + * action: SIGNAL_EMIT "e,action,click" "e"; + * } */ } } -} + + + diff --git a/src/modules/everything/Makefile.am b/src/modules/everything/Makefile.am index c45650d1c..778f2512d 100644 --- a/src/modules/everything/Makefile.am +++ b/src/modules/everything/Makefile.am @@ -85,6 +85,13 @@ evry_plug_aspell_la_LIBADD = @e_libs@ evry_plug_aspell_la_LDFLAGS = -no-undefined -module -avoid-version evry_plug_aspell_la_LIBTOOLFLAGS = --tag=disable-static +evry_plug_clipboarddir = $(pkgdir) +evry_plug_clipboard_LTLIBRARIES = evry_plug_clipboard.la +evry_plug_clipboard_la_SOURCES = evry_plug_clipboard.c +evry_plug_clipboard_la_LIBADD = @e_libs@ +evry_plug_clipboard_la_LDFLAGS = -no-undefined -module -avoid-version +evry_plug_clipboard_la_LIBTOOLFLAGS = --tag=disable-static + uninstall: rm -rf $(DESTDIR)$(libdir)/enlightenment/modules/$(MODULE) diff --git a/src/modules/everything/e_mod_main.c b/src/modules/everything/e_mod_main.c index 251f75309..45f11be93 100644 --- a/src/modules/everything/e_mod_main.c +++ b/src/modules/everything/e_mod_main.c @@ -85,7 +85,10 @@ e_modapi_init(E_Module *m) } /* evry_conf->history = eina_hash_string_superfast_new(NULL); */ - + + evry_conf->width = 380; + evry_conf->height = 235; + evry_conf->scroll_animate = 0; /* conf_module = m; */ evry_init(); @@ -107,8 +110,8 @@ e_modapi_init(E_Module *m) maug = e_int_menus_menu_augmentation_add("main/1", _e_mod_menu_add, NULL, NULL, NULL); - e_configure_registry_category_add("advanced", 80, _("Advanced"), NULL, "preferences-advanced"); - e_configure_registry_item_add("advanced/run_everything", 40, _("Run Everything"), NULL, "system-run", evry_config_dialog); + e_configure_registry_category_add("extensions", 80, _("Extensions"), NULL, "preferences-extensions"); + e_configure_registry_item_add("extensions/run_everything", 40, _("Run Everything"), NULL, "system-run", evry_config_dialog); e_module_delayed_set(m, 1); @@ -136,6 +139,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__) evry_shutdown(); /* conf_module = NULL; */ + eina_list_free(evry_conf->plugins); + eina_list_free(evry_conf->actions); eina_module_list_unload(plugins); eina_module_list_flush(plugins); @@ -144,8 +149,8 @@ e_modapi_shutdown(E_Module *m __UNUSED__) eina_module_shutdown(); while ((cfd = e_config_dialog_get("E", "_config_everything_dialog"))) e_object_del(E_OBJECT(cfd)); - e_configure_registry_item_del("advanced/run_everything"); - e_configure_registry_category_del("advanced"); + e_configure_registry_item_del("extensions/run_everything"); + e_configure_registry_category_del("extensions"); /* Clean EET */ E_CONFIG_DD_FREE(conf_item_edd); @@ -212,3 +217,73 @@ _e_mod_menu_add(void *data __UNUSED__, E_Menu *m) e_util_menu_item_theme_icon_set(mi, "system-run"); e_menu_item_callback_set(mi, _e_mod_run_cb, NULL); } + + +static int +_evry_cb_plugin_sort(const void *data1, const void *data2) +{ + const Evry_Plugin *p1 = data1; + const Evry_Plugin *p2 = data2; + return p1->config->priority - p2->config->priority; +} + +EAPI void +evry_plugin_register(Evry_Plugin *plugin) +{ + Eina_List *l; + Plugin_Config *pc; + Eina_Bool found = 0; + + evry_conf->plugins = eina_list_append(evry_conf->plugins, plugin); + + EINA_LIST_FOREACH(evry_conf->plugins_conf, l, pc) + { + if (pc->name && plugin->name && !strcmp(pc->name, plugin->name)) + { + found = 1; + break; + } + } + + if (!found) + { + pc = E_NEW(Plugin_Config, 1); + pc->name = eina_stringshare_add(plugin->name); + pc->enabled = 1; + pc->priority = eina_list_count(evry_conf->plugins); + + evry_conf->plugins_conf = eina_list_append(evry_conf->plugins_conf, pc); + } + + /* if (plugin->trigger && !pc->trigger) + * pc->trigger = eina_stringshare_add(plugin->trigger); */ + + plugin->config = pc; + + evry_conf->plugins = eina_list_sort(evry_conf->plugins, + eina_list_count(evry_conf->plugins), + _evry_cb_plugin_sort); + + /* TODO sorting, initialization, etc */ +} + +EAPI void +evry_plugin_unregister(Evry_Plugin *plugin) +{ + evry_conf->plugins = eina_list_remove(evry_conf->plugins, plugin); + /* cleanup */ +} + +EAPI void +evry_action_register(Evry_Action *action) +{ + evry_conf->actions = eina_list_append(evry_conf->actions, action); + /* TODO sorting, initialization, etc */ +} + +EAPI void +evry_action_unregister(Evry_Action *action) +{ + evry_conf->actions = eina_list_remove(evry_conf->actions, action); + /* cleanup */ +} diff --git a/src/modules/everything/e_mod_main.h b/src/modules/everything/e_mod_main.h index 218db3114..6fb0239ca 100644 --- a/src/modules/everything/e_mod_main.h +++ b/src/modules/everything/e_mod_main.h @@ -45,6 +45,7 @@ struct _Config /**/ Eina_List *plugins; + Eina_List *actions; Eina_Hash *history; }; @@ -67,10 +68,14 @@ struct _Plugin_Config struct _Evry_Item { + Evry_Plugin *plugin; + const char *label; const char *uri; const char *mime; + + Eina_Bool browseable; /* these are only for internally use by plugins */ /* used e.g. as pointer for item data (Efreet_Desktop) or */ @@ -80,13 +85,16 @@ struct _Evry_Item /* not to be set by plugin! */ Evas_Object *o_icon; - Evas_Object *o_bg; + Evas_Object *o_bg; }; struct _Evry_Plugin { const char *name; + const char *icon; + enum {type_subject, type_action, type_object } type; + const char *type_in; const char *type_out; @@ -99,6 +107,8 @@ struct _Evry_Plugin * e.g. borders, app history */ Eina_Bool need_query; + Eina_Bool browseable; + /* run when plugin is activated. */ int (*begin) (Evry_Plugin *p, Evry_Item *item); @@ -108,14 +118,14 @@ struct _Evry_Plugin /* run before new query and when hiding 'everything' */ void (*cleanup) (Evry_Plugin *p); - /* TODO return icon */ - void (*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e); + Evas_Object *(*icon_get) (Evry_Plugin *p, Evry_Item *it, Evas *e); /* provide more information for a candidate */ /* int (*candidate_info) (Evas *evas, Evry_Item *item); */ /* optional: default action for this plugins items */ int (*action) (Evry_Plugin *p, Evry_Item *item, const char *input); - + Evry_Action *act; + /* optional: create list of items when shown (e.g. for sorting) */ void (*realize_items) (Evry_Plugin *p, Evas *e); @@ -124,6 +134,9 @@ struct _Evry_Plugin Evas_Object *(*config_page) (void); void (*config_apply) (void); + /* only for internal use by plugin */ + void *private; + /* not to be set by plugin! */ Evas_Object *tab; Plugin_Config *config; @@ -136,17 +149,20 @@ struct _Evry_Action const char *type_in1; const char *type_in2; const char *type_out; - - Evry_Item *thing1; - Evry_Item *thing2; - int (*action) (Evry_Action *act); + int (*action) (Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input); int (*check_item) (Evry_Action *act, Evry_Item *it); - void (*icon_get) (Evry_Action *act, Evry_Item *it, Evas *e); + Evas_Object *(*icon_get) (Evry_Action *act, Evas *e); + + /* use icon name from theme */ + const char *icon; - void *priv; + Eina_Bool is_default; + + /* only for internal use by plugin */ + void *private; /* not to be set by plugin! */ Evas_Object *o_icon; @@ -175,6 +191,10 @@ EAPI void evry_action_register(Evry_Action *act); EAPI void evry_action_unregister(Evry_Action *act); EAPI void evry_plugin_async_update(Evry_Plugin *plugin, int state); EAPI void evry_clear_input(void); +EAPI Evry_Item *evry_item_new(Evry_Plugin *p, const char *label); +EAPI void evry_item_free(Evry_Item *it); + +EAPI int evry_icon_theme_set(Evas_Object *obj, const char *icon); extern Config *evry_conf; diff --git a/src/modules/everything/evry.c b/src/modules/everything/evry.c index e63744b73..cda2b6bed 100644 --- a/src/modules/everything/evry.c +++ b/src/modules/everything/evry.c @@ -1,820 +1,1075 @@ #include "e.h" #include "e_mod_main.h" +/* TODO */ +/* - animations + * - mouse handlers + * - show item descriptions + * - keybinding configuration + * - shortcuts for plugins + */ #define INPUTLEN 40 #define MATCH_LAG 0.33 typedef struct _Evry_State Evry_State; +typedef struct _Evry_Window Evry_Window; +typedef struct _Evry_List_Window Evry_List_Window; +typedef struct _Evry_Selector Evry_Selector; struct _Evry_State { - Eina_List *cur_items; - Eina_List *cur_plugins; - Eina_List *plugins; - Evry_Plugin *cur_plugin; - Evry_Item *sel_item; + char *input; + /* all available plugins for current state */ + Eina_List *plugins; - Eina_List *cur_actions; - Evry_Action *cur_action; + /* currently active plugins, i.e. those that provide items */ + Eina_List *cur_plugins; + + /* active plugin */ + Evry_Plugin *plugin; + + /* selected item */ + Evry_Item *sel_item; /* Eina_List *sel_items; */ - char *input; - const char *request_type; - - Eina_Bool initial; - + /* this is for the case when the current plugin was not selected manually and a higher priority (async) plugin retrieves candidates, the higher priority plugin is made current */ Eina_Bool plugin_auto_selected; - + Eina_Bool item_auto_selected; }; +/* */ +struct _Evry_Selector +{ + Evas_Object *o_main; + Evas_Object *o_icon; + + /* current state */ + Evry_State *state; + + /* stack of states (for browseable plugins) */ + Eina_List *states; + + /* provides collection of items from other plugins */ + Evry_Plugin *aggregator; + + /* */ + Eina_List *actions; + + /* all plugins that belong to this selector*/ + Eina_List *plugins; +}; + +struct _Evry_Window +{ + E_Popup *popup; + Evas_Object *o_main; + + /* E_Popup *input_win; */ +}; + +struct _Evry_List_Window +{ + E_Popup *popup; + Evas_Object *o_main; + Evas_Object *o_list; + Evas_Object *o_tabs; + Eina_List *items; + + int ev_last_is_mouse; + Evry_Item *item_mouseover; + Ecore_Animator *scroll_animator; + Ecore_Timer *scroll_timer; + double scroll_align_to; + double scroll_align; + Ecore_Idler *item_idler; + + Eina_Bool visible; +}; + +/* struct _Evry_List_Item + * { + * Evry_Item *item; + * + * Evas_Object *o_icon; + * Evas_Object *o_bg; + * + * const char *label; + * }; */ + + static int _evry_cb_key_down(void *data, int type, void *event); -static int _evry_cb_key_down(void *data, int type, void *event); -static int _evry_cb_mouse_down(void *data, int type, void *event); -static int _evry_cb_mouse_up(void *data, int type, void *event); -static int _evry_cb_mouse_move(void *data, int type, void *event); -static int _evry_cb_mouse_wheel(void *data, int type, void *event); -static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info); -static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); -static void _evry_backspace(void); -static void _evry_update(void); -static void _evry_list_clear(void); -static void _evry_show_items(Evry_Plugin *plugin); +/* static int _evry_cb_mouse_down(void *data, int type, void *event); + * static int _evry_cb_mouse_up(void *data, int type, void *event); + * static int _evry_cb_mouse_move(void *data, int type, void *event); + * static int _evry_cb_mouse_wheel(void *data, int type, void *event); + * static void _evry_cb_item_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event_info); + * static void _evry_cb_item_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event_info); */ + +static void _evry_matches_update(Evry_Selector *sel, Evry_Plugin *plugin); +static void _evry_plugin_action(Evry_Selector *sel, int finished); +static void _evry_backspace(Evry_State *s); +static void _evry_update(Evry_State *s); +static void _evry_clear(Evry_State *s); static int _evry_update_timer(void *data); -static void _evry_matches_update(Evry_Plugin *cur_plugin); -static void _evry_clear(void); -static void _evry_item_next(void); -static void _evry_item_prev(void); -static void _evry_plugin_next(void); -static void _evry_plugin_prev(void); -static void _evry_scroll_to(int i); -static void _evry_tab_scroll_to(Evry_Plugin *p); -static void _evry_item_desel(Evry_Item *it); -static void _evry_item_sel(Evry_Item *it); -static void _evry_plugin_action(int finished); -static int _evry_animator(void *data); -static int _evry_scroll_timer(void *data); -static int _evry_push_state(void); -static int _evry_pop_state(void); -static void _evry_plugin_selector_show(Evry_Plugin *p); -static int _evry_cb_plugin_sort(const void *data1, const void *data2); +static Evry_State *_evry_state_new(Evry_Selector *sel, Eina_List *plugins); +static void _evry_state_pop(Evry_Selector *sel); +static void _evry_select_plugin(Evry_State *s, Evry_Plugin *p); +static void _evry_update_text_label(Evry_State *s); +static void _evry_browse_item(Evry_Selector *sel); +static void _evry_browse_back(Evry_Selector *sel); +static void _evry_selectors_switch(void); + +static Evry_Window *_evry_window_new(E_Zone *zone); +static void _evry_window_free(Evry_Window *win); +static Evry_Selector *_evry_selector_new(int type); +static void _evry_selector_free(Evry_Selector *sel); +static void _evry_selector_activate(Evry_Selector *sel); +static void _evry_selector_update(Evry_Selector *sel); +static void _evry_selector_icon_set(Evry_Selector *sel); +static int _evry_selector_subjects_get(void); +static int _evry_selector_actions_get(Evry_Item *it); +static int _evry_selector_objects_get(const char *type); + +static Evry_List_Window *_evry_list_win_new(E_Zone *zone); +static void _evry_list_win_free(Evry_List_Window *win); +static void _evry_list_win_show(void); +static void _evry_list_win_hide(void); +static void _evry_list_clear_list(Evry_State *s); +static void _evry_list_update(Evry_State *s); +static void _evry_list_show_items(Evry_State *s, Evry_Plugin *plugin); +static void _evry_list_item_next(Evry_State *s); +static void _evry_list_item_prev(Evry_State *s); +static void _evry_list_plugin_next(Evry_State *s); +static void _evry_list_plugin_prev(Evry_State *s); +static void _evry_list_scroll_to(Evry_State *s, Evry_Item *it); +static void _evry_list_item_desel(Evry_State *s, Evry_Item *it); +static void _evry_list_item_sel(Evry_State *s, Evry_Item *it); +static void _evry_list_tab_scroll_to(Evry_State *s, Evry_Plugin *p); +static void _evry_list_tab_show(Evry_State *s, Evry_Plugin *p); +static void _evry_list_tabs_update(Evry_State *s); +static int _evry_list_animator(void *data); +static int _evry_list_scroll_timer(void *data); +static int _evry_list_item_idler(void *data); + +static int _evry_plug_actions_init(void); +static int _evry_plug_actions_begin(Evry_Plugin *p, Evry_Item *it); +static int _evry_plug_actions_fetch(Evry_Plugin *p, const char *input); +static void _evry_plug_actions_cleanup(Evry_Plugin *p); +static Evas_Object *_evry_plug_actions_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); + +static Evry_Plugin *_evry_plug_aggregator_new(void); +static void _evry_plug_aggregator_free(Evry_Plugin *p); +static int _evry_plug_aggregator_begin(Evry_Plugin *p, Evry_Item *it); +static int _evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input); +static int _evry_plug_aggregator_action(Evry_Plugin *p, Evry_Item *item, const char *input); +static void _evry_plug_aggregator_cleanup(Evry_Plugin *p); +static Evas_Object *_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); /* static int _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2); */ -static int _evry_plug_act_select_init(void); -static int _evry_plug_act_select_begin(Evry_Plugin *p, Evry_Item *it); -static int _evry_plug_act_select_fetch(Evry_Plugin *p, const char *input); -static int _evry_plug_act_select_action(Evry_Plugin *p, Evry_Item *item, const char *input); -static void _evry_plug_act_select_cleanup(Evry_Plugin *p); -static void _evry_plug_act_select_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); - /* local subsystem globals */ -static E_Popup *popup = NULL; + +static Evry_Window *win = NULL; +static Evry_List_Window *list = NULL; static Ecore_X_Window input_window = 0; static Eina_List *handlers = NULL; static Ecore_Timer *update_timer = NULL; -static Evas_Object *o_list = NULL; -static Evas_Object *o_main = NULL; -static Evas_Object *o_selector = NULL; -static int ev_last_is_mouse; -static Evry_Item *item_mouseover = NULL; -static Ecore_Animator *scroll_animator = NULL; -static Ecore_Timer *scroll_timer = NULL; -static double scroll_align_to; -static double scroll_align; -/* static Eina_List *plugins = NULL; */ -static Eina_List *actions = NULL; -static Evry_State *cur_state = NULL; -static Eina_List *stack = NULL; +static Evry_Selector *selectors[3]; +static Evry_Selector *selector = NULL; + static Evry_Plugin *action_selector = NULL; /* externally accessible functions */ EAPI int evry_init(void) { - _evry_plug_act_select_init(); - + _evry_plug_actions_init(); + return 1; } EAPI int evry_shutdown(void) { + // TODO free action_selector evry_hide(); return 1; } -EAPI void -evry_plugin_register(Evry_Plugin *plugin) -{ - Eina_List *l; - Plugin_Config *pc; - Eina_Bool found = 0; - - evry_conf->plugins = eina_list_append(evry_conf->plugins, plugin); - - EINA_LIST_FOREACH(evry_conf->plugins_conf, l, pc) - { - if (pc->name && plugin->name && !strcmp(pc->name, plugin->name)) - { - found = 1; - break; - } - } - - if (!found) - { - pc = E_NEW(Plugin_Config, 1); - pc->name = eina_stringshare_add(plugin->name); - pc->enabled = 1; - pc->priority = eina_list_count(evry_conf->plugins); - - evry_conf->plugins_conf = eina_list_append(evry_conf->plugins_conf, pc); - } - - /* if (plugin->trigger && !pc->trigger) - * pc->trigger = eina_stringshare_add(plugin->trigger); */ - - plugin->config = pc; - - evry_conf->plugins = eina_list_sort(evry_conf->plugins, - eina_list_count(evry_conf->plugins), - _evry_cb_plugin_sort); - - /* TODO sorting, initialization, etc */ -} - -EAPI void -evry_plugin_unregister(Evry_Plugin *plugin) -{ - evry_conf->plugins = eina_list_remove(evry_conf->plugins, plugin); - /* cleanup */ -} - -EAPI void -evry_action_register(Evry_Action *action) -{ - actions = eina_list_append(actions, action); - /* TODO sorting, initialization, etc */ -} - -EAPI void -evry_action_unregister(Evry_Action *action) -{ - actions = eina_list_remove(actions, action); - /* cleanup */ -} - EAPI int evry_show(E_Zone *zone) { - Evas_Object *o; - int x, y; - + if (win) return 0; + E_OBJECT_CHECK_RETURN(zone, 0); E_OBJECT_TYPE_CHECK_RETURN(zone, E_ZONE_TYPE, 0); - - if (popup) return 0; - + input_window = ecore_x_window_input_new(zone->container->win, zone->x, zone->y, zone->w, zone->h); ecore_x_window_show(input_window); if (!e_grabinput_get(input_window, 1, input_window)) + goto error; + + win = _evry_window_new(zone); + if (!win) goto error; + + list = _evry_list_win_new(zone); + if (!list) goto error; + + list->visible = EINA_FALSE; + + /* TODO check NULL */ + selectors[0] = _evry_selector_new(type_subject); + selectors[1] = _evry_selector_new(type_action); + selectors[2] = _evry_selector_new(type_object); + + _evry_selector_subjects_get(); + _evry_selector_activate(selectors[0]); + _evry_selector_update(selector); + + e_popup_layer_set(list->popup, 255); + e_popup_layer_set(win->popup, 255); + e_popup_show(win->popup); + e_popup_show(list->popup); + + if (list->visible) { - ecore_x_window_free(input_window); - input_window = 0; - return 0; + e_popup_show(list->popup); + _evry_list_update(selector->state); } - - x = (zone->w / 2) - (evry_conf->width / 2); - y = (zone->h / 2) - (evry_conf->height / 2); - - popup = e_popup_new(zone, x, y, evry_conf->width, evry_conf->height); - if (!popup) return 0; - - ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY); - - e_popup_layer_set(popup, 255); - evas_event_freeze(popup->evas); - evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL); - evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, ecore_x_current_time_get(), NULL); - o = edje_object_add(popup->evas); - o_main = o; - e_theme_edje_object_set(o, "base/theme/everything", - "e/widgets/everything/main"); - - o = e_box_add(popup->evas); - o_list = o; - e_box_orientation_set(o, 0); - e_box_homogenous_set(o, 1); - edje_object_part_swallow(o_main, "e.swallow.list", o); - evas_object_show(o); - - o = o_main; - evas_object_move(o, 0, 0); - evas_object_resize(o, evry_conf->width, evry_conf->height); - evas_object_show(o); - e_popup_edje_bg_object_set(popup, o); - - o = e_box_add(popup->evas); - e_box_orientation_set(o, 1); - e_box_homogenous_set(o, 1); - edje_object_part_swallow(o_main, "e.swallow.bar", o); - evas_object_show(o); - o_selector = o; - - evas_event_thaw(popup->evas); - + e_box_align_set(list->o_tabs, 0.0, 0.5); + handlers = eina_list_append (handlers, ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _evry_cb_key_down, NULL)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_BUTTON_DOWN, _evry_cb_mouse_down, NULL)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_BUTTON_UP, _evry_cb_mouse_up, NULL)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_MOVE, _evry_cb_mouse_move, NULL)); - handlers = eina_list_append - (handlers, ecore_event_handler_add - (ECORE_EVENT_MOUSE_WHEEL, _evry_cb_mouse_wheel, NULL)); + /* handlers = eina_list_append + * (handlers, ecore_event_handler_add + * (ECORE_EVENT_MOUSE_BUTTON_DOWN, _evry_cb_mouse_down, NULL)); + * handlers = eina_list_append + * (handlers, ecore_event_handler_add + * (ECORE_EVENT_MOUSE_BUTTON_UP, _evry_cb_mouse_up, NULL)); + * handlers = eina_list_append + * (handlers, ecore_event_handler_add + * (ECORE_EVENT_MOUSE_MOVE, _evry_cb_mouse_move, NULL)); + * handlers = eina_list_append + * (handlers, ecore_event_handler_add + * (ECORE_EVENT_MOUSE_WHEEL, _evry_cb_mouse_wheel, NULL)); */ - _evry_push_state(); - - e_popup_show(popup); - - e_box_align_set(o_selector, 0.0, 0.5); return 1; + + error: + if (win && selectors[0]) + _evry_selector_free(selectors[0]); + if (win && selectors[1]) + _evry_selector_free(selectors[1]); + if (win && selectors[2]) + _evry_selector_free(selectors[2]); + + if (win) + _evry_window_free(win); + if (list) + _evry_list_win_free(list); + win = NULL; + list = NULL; + ecore_x_window_free(input_window); + input_window = 0; + + return 0; } EAPI void evry_hide(void) { Ecore_Event *ev; - Evry_State *s; + + if (!win) return; - if (!popup) return; - - evas_event_freeze(popup->evas); - - _evry_list_clear(); - - EINA_LIST_FREE(stack, s) - { - Evry_Plugin *p; - - free(s->input); - - EINA_LIST_FREE(s->plugins, p) - { - p->cleanup(p); - - if (p->tab) - { - evas_object_del(p->tab); - p->tab = NULL; - } - } - } - stack = NULL; - cur_state = NULL; + _evry_list_clear_list(selector->state); if (update_timer) ecore_timer_del(update_timer); update_timer = NULL; - if (scroll_timer) - ecore_timer_del(scroll_timer); - scroll_timer = NULL; - - if (scroll_animator) - ecore_animator_del(scroll_animator); - scroll_animator = NULL; - - e_popup_hide(popup); - - evas_object_del(o_list); - o_list = NULL; - - evas_object_del(o_selector); - o_selector = NULL; - - evas_object_del(o_main); - o_main = NULL; - - evas_event_thaw(popup->evas); - e_object_del(E_OBJECT(popup)); - popup = NULL; + _evry_selector_free(selectors[0]); + _evry_selector_free(selectors[1]); + _evry_selector_free(selectors[2]); + selectors[0] = NULL; + selectors[1] = NULL; + selectors[2] = NULL; + selector = NULL; + + _evry_list_win_free(list); + list = NULL; + + _evry_window_free(win); + win = NULL; EINA_LIST_FREE(handlers, ev) ecore_event_handler_del(ev); - + handlers = NULL; + ecore_x_window_free(input_window); e_grabinput_release(input_window, input_window); input_window = 0; } -EAPI void -evry_plugin_async_update(Evry_Plugin *p, int action) -{ - Evry_State *s; - - if (!popup) return; - - s = cur_state; - - if (action == EVRY_ASYNC_UPDATE_ADD) - { - if (!p->items) return; - - if (!eina_list_data_find(s->cur_plugins, p)) - { - s->cur_plugins = eina_list_prepend(s->cur_plugins, p); - - /* s->cur_plugins = eina_list_sort(s->cur_plugins, - * eina_list_count(s->cur_plugins), - * _evry_cb_plugin_sort_by_trigger); */ - - _evry_plugin_selector_show(p); - } - else - { - char buf[64]; - snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items)); - edje_object_part_text_set(p->tab, "e.text.label", buf); - } - - if ((!s->cur_plugin && s->cur_plugins) || (s->cur_plugin == p)) - /* || (s->plugin_auto_selected && (s->cur_plugin->config->priority > p->config->priority))) */ - { - if (!s->cur_plugin) - s->plugin_auto_selected = 1; - - _evry_list_clear(); - _evry_show_items(s->cur_plugins->data); - } - else if (/*s->plugin_auto_selected &&*/ p->trigger && - (!strncmp(s->input, p->trigger, strlen(p->trigger)))) - { - _evry_list_clear(); - _evry_show_items(p); - /* s->plugin_auto_selected = 0; */ - } - else if (s->cur_plugin) - _evry_tab_scroll_to(s->cur_plugin); - } - else if ((action == EVRY_ASYNC_UPDATE_CLEAR) && (s->cur_plugin == p)) - { - _evry_list_clear(); - /*XXX move this into list clear?*/ - s->cur_items = NULL; - } -} EAPI void evry_clear_input(void) { - if (cur_state->input[0] != 0) + Evry_State *s = selector->state; + + if (s->input[0] != 0) { - cur_state->input[0] = 0; + s->input[0] = 0; } } - -/* local subsystem functions */ -static int -_evry_cb_plugin_sort(const void *data1, const void *data2) +EAPI Evry_Item * +evry_item_new(Evry_Plugin *p, const char *label) { - const Evry_Plugin *p1 = data1; - const Evry_Plugin *p2 = data2; - return p1->config->priority - p2->config->priority; + Evry_Item *it; + + it = E_NEW(Evry_Item, 1); + if (!it) return NULL; + + it->plugin = p; + if (label) it->label = eina_stringshare_add(label); + + return it; } -/* static int - * _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2) +EAPI void +evry_item_free(Evry_Item *it) +{ + if (it->label) eina_stringshare_del(it->label); + E_FREE(it); +} + +/* static void + * _evry_list_cb_list_shown(void *data, Evas_Object *obj, const char *emission, const char *source) * { - * const Evry_Plugin *p1 = data1; - * const Evry_Plugin *p2 = data2; - * if (p1->trigger) - * { - * if (!strncmp(cur_state->input, p1->trigger, strlen(p1->trigger))) - * return 1; - * } - * - * return p1->config->priority - p2->config->priority; + * _evry_list_scroll_to(selector->state, selector->state->sel_item); * } */ -static int -_evry_push_state(void) +static Evry_List_Window * +_evry_list_win_new(E_Zone *zone) { - Evry_State *s; - Eina_List *l, *list = NULL; - const char *cur_type = "NONE"; - Evry_Plugin *p; + int x, y; + Evry_List_Window *list_win; + E_Popup *popup; + Evas_Object *o; + + x = (zone->w / 2) - (win->popup->w / 3); + y = (zone->h / 2); + + popup = e_popup_new(zone, x + 50, y - 4, /*XXX get from theme ?*/ + win->popup->w * 2/3 - 100, + evry_conf->height); + if (!popup) return NULL; - s = cur_state; - - if (update_timer) + list_win = E_NEW(Evry_List_Window, 1); + if (!list_win) { - _evry_matches_update(s->cur_plugin); - ecore_timer_del(update_timer); - update_timer = NULL; + e_object_del(E_OBJECT(popup)); + return NULL; + } + + list_win->popup = popup; + + evas_event_freeze(popup->evas); + evas_event_feed_mouse_in(popup->evas, ecore_x_current_time_get(), NULL); + evas_event_feed_mouse_move(popup->evas, -1000000, -1000000, ecore_x_current_time_get(), NULL); + o = edje_object_add(popup->evas); + list_win->o_main = o; + e_theme_edje_object_set(o, "base/theme/everything", + "e/widgets/everything/list"); + + o = e_box_add(popup->evas); + list_win->o_list = o; + e_box_orientation_set(o, 0); + e_box_homogenous_set(o, 1); + edje_object_part_swallow(list_win->o_main, "e.swallow.list", o); + evas_object_show(o); + + o = list_win->o_main; + evas_object_move(o, 0, 0); + evas_object_resize(o, list_win->popup->w, list_win->popup->h); + evas_object_show(o); + e_popup_edje_bg_object_set(popup, o); + + o = e_box_add(popup->evas); + e_box_orientation_set(o, 1); + /* e_box_homogenous_set(o, 1); */ + edje_object_part_swallow(list_win->o_main, "e.swallow.bar", o); + evas_object_show(o); + list_win->o_tabs = o; + + /* edje_object_signal_callback_add(list_win->o_main, "e,state,list_shown", "e", + * _evry_list_cb_list_shown, NULL); */ + + evas_event_thaw(popup->evas); + + return list_win; +} + +static void +_evry_list_win_free(Evry_List_Window *list_win) +{ + if (list_win->scroll_timer) + ecore_timer_del(list_win->scroll_timer); + if (list_win->scroll_animator) + ecore_animator_del(list_win->scroll_animator); + if (list_win->item_idler) + ecore_idler_del(list_win->item_idler); + + e_popup_hide(list_win->popup); + evas_event_freeze(list_win->popup->evas); + evas_object_del(list_win->o_list); + evas_object_del(list_win->o_tabs); + evas_object_del(list_win->o_main); + /* evas_event_thaw(list_win->popup->evas); */ + e_object_del(E_OBJECT(list_win->popup)); + + E_FREE(list_win); +} + +static void +_evry_list_win_show(void) +{ + if (list->visible) return; + + list->visible = EINA_TRUE; + + _evry_list_update(selector->state); + + edje_object_signal_emit(list->o_main, "e,state,list_show", "e"); +} + +static void +_evry_list_win_hide(void) +{ + Eina_List *l; + Evry_Plugin *p; + + if (!list->visible) return; + + list->visible = EINA_FALSE; + + EINA_LIST_FOREACH(selector->plugins, l, p) + { + e_box_unpack(p->tab); + evas_object_del(p->tab); + p->tab = NULL; + } + _evry_list_clear_list(selector->state); + + edje_object_signal_emit(list->o_main, "e,state,list_hide", "e"); + /* e_popup_hide(list->popup); */ +} + + +static Evry_Window * +_evry_window_new(E_Zone *zone) +{ + int x, y, mw, mh; + Evry_Window *win; + E_Popup *popup; + Evas_Object *o; + + popup = e_popup_new(zone, 100, 100, 1, 1); + if (!popup) return NULL; + + win = E_NEW(Evry_Window, 1); + if (!win) + { + e_object_del(E_OBJECT(popup)); + return NULL; } - if (s) - { - if (!s->cur_plugin || !s->sel_item) - return 0; + win->popup = popup; - cur_type = s->cur_plugin->type_out; - /* current plugin provides no candidates to act on by others */ - if (!s->cur_action && !strcmp(cur_type, "NONE")) - return 0; + o = edje_object_add(popup->evas); + win->o_main = o; + e_theme_edje_object_set(o, "base/theme/everything", + "e/widgets/everything/main"); - EINA_LIST_FOREACH(s->plugins, l, p) - { - if (p != s->cur_plugin) - p->cleanup(p); + edje_object_size_min_get(o, &mw, &mh); - if (p->tab) - { - evas_object_del(p->tab); - p->tab = NULL; - } - } - } + x = (zone->w / 2) - (mw / 2); + y = (zone->h / 2) - mh; + + e_popup_move_resize(popup, x, y, mw, mh); + + o = win->o_main; + e_popup_edje_bg_object_set(win->popup, o); + evas_object_move(o, 0, 0); + evas_object_resize(o, mw, mh); + evas_object_show(o); + + ecore_x_netwm_window_type_set(popup->evas_win, ECORE_X_WINDOW_TYPE_UTILITY); + + return win; +} + +static void +_evry_window_free(Evry_Window *win) +{ + e_popup_hide(win->popup); + evas_event_freeze(win->popup->evas); + evas_object_del(win->o_main); + /* evas_event_thaw(win->popup->evas); */ + e_object_del(E_OBJECT(win->popup)); + E_FREE(win); +} +static Evry_Selector * +_evry_selector_new(int type) +{ + Evry_Plugin *p; + Eina_List *l; + Evry_Selector *sel = E_NEW(Evry_Selector, 1); + Evas_Object *o = edje_object_add(win->popup->evas); + sel->o_main = o; + e_theme_edje_object_set(o, "base/theme/everything", + "e/widgets/everything/selector_item"); + evas_object_show(o); + + if (type == type_subject) + edje_object_part_swallow(win->o_main, "e.swallow.subject_selector", o); + else if (type == type_action) + edje_object_part_swallow(win->o_main, "e.swallow.action_selector", o); + else if (type == type_object) + edje_object_part_swallow(win->o_main, "e.swallow.object_selector", o); + + p = _evry_plug_aggregator_new(); + p->private = sel; + sel->plugins = eina_list_append(sel->plugins, p); + sel->aggregator = p; EINA_LIST_FOREACH(evry_conf->plugins, l, p) { if (!p->config->enabled) continue; - - if (strstr(p->type_in, cur_type) || p == action_selector) + if (p->type != type) continue; + sel->plugins = eina_list_append(sel->plugins, p); + } + if (type == type_action) + sel->plugins = eina_list_append(sel->plugins, action_selector); + + return sel; +} + +static void +_evry_selector_free(Evry_Selector *sel) +{ + Evry_State *s; + Evry_Plugin *p; + + if (sel->o_icon) + evas_object_del(sel->o_icon); + evas_object_del(sel->o_main); + + if (list->visible && (sel == selector)) + { + _evry_list_clear_list(sel->state); + } + + EINA_LIST_FREE(sel->states, s) + { + free(s->input); + + EINA_LIST_FREE(s->plugins, p) + { + p->cleanup(p); + if (p->tab) evas_object_del(p->tab); + p->tab = NULL; + } + } + + _evry_plug_aggregator_free(sel->aggregator); + + eina_list_free(sel->plugins); + E_FREE(sel); +} + +static void +_evry_selector_activate(Evry_Selector *sel) +{ + if (selector) + { + edje_object_signal_emit(selector->o_main, "e,state,unselected", "e"); + + edje_object_part_text_set(selector->o_main, "e.text.plugin", ""); + + if (update_timer) { - /* printf("%s- in:%s out:%s\n", p->name, p->type_in, p->type_out); */ - - if (s && s->cur_action) + Evry_State *s = selector->state; + + /* XXX what if an async plugin is selected */ + if (s && s->plugin && !s->plugin->async_query) { - /* filter out plugins that dont provide the type - requested by current action */ - if (strcmp(p->type_out, s->request_type)) - continue; + _evry_list_clear_list(s); + _evry_matches_update(selector, s->plugin); + _evry_selector_update(selector); } + ecore_timer_del(update_timer); + update_timer = NULL; + } + + _evry_list_win_hide(); + } + + selector = sel; - if (p->begin) - { - Evry_Item *it = NULL; + edje_object_signal_emit(sel->o_main, "e,state,selected", "e"); + + if (sel->state) + { + _evry_update_text_label(sel->state); - if (s && (s->cur_plugin != action_selector)) - it = s->sel_item; - - if (p->begin(p, it)) - list = eina_list_append(list, p); - } - else - list = eina_list_append(list, p); + if (sel->state->sel_item) + edje_object_part_text_set(sel->o_main, "e.text.plugin", + sel->state->sel_item->plugin->name); + + if (list->visible && sel->state->plugin) + { + _evry_list_tabs_update(sel->state); + _evry_list_show_items(sel->state, sel->state->plugin); } } +} - if (!list) return 0; +static void +_evry_selector_icon_set(Evry_Selector *sel) +{ + Evry_State *s = sel->state; + Evry_Item *it; + Evas_Object *o; + + if (!edje_object_part_exists(sel->o_main, "e.swallow.icons")) return; + + if (sel->o_icon) + { + evas_object_del(sel->o_icon); + sel->o_icon = NULL; + } - _evry_list_clear(); + if (!s) return; - s = E_NEW(Evry_State, 1); + it = s->sel_item; + + if (it && it->plugin && it->plugin->icon_get) + { + o = it->plugin->icon_get(it->plugin, it, win->popup->evas); + if (o) + { + edje_object_part_swallow(sel->o_main, "e.swallow.icons", o); + evas_object_show(o); + sel->o_icon = o; + } + } + else if (s->plugin && s->plugin->icon) + { + o = e_icon_add(win->popup->evas); + evry_icon_theme_set(o, s->plugin->icon); + edje_object_part_swallow(sel->o_main, "e.swallow.icons", o); + evas_object_show(o); + sel->o_icon = o; + } +} + +static void +_evry_selector_update(Evry_Selector *sel) +{ + Evry_State *s = sel->state; + Evry_Item *it = NULL; + + if (s && !s->sel_item && s->cur_plugins) + { + /* get first item */ + Evry_Plugin *p = s->plugin; + + if (!p) + { + _evry_select_plugin(s, s->cur_plugins->data); + p = s->plugin; + } + + if (p->items) + { + it = p->items->data; + s->item_auto_selected = EINA_TRUE; + _evry_list_item_sel(s, it); + } + } + else if (s && s->sel_item) + { + it = s->sel_item; + } + + _evry_selector_icon_set(sel); + + if (it) + { + edje_object_part_text_set(sel->o_main, "e.text.label", it->label); + + if (sel == selector) + edje_object_part_text_set(sel->o_main, "e.text.plugin", it->plugin->name); + else + edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); + } + else + { + /* no items for this state - clear selector */ + edje_object_part_text_set(sel->o_main, "e.text.label", ""); + if (sel == selector && s->plugin) + edje_object_part_text_set(sel->o_main, "e.text.plugin", s->plugin->name); + else + edje_object_part_text_set(sel->o_main, "e.text.plugin", ""); + } + + if (sel == selectors[0]) + { + _evry_selector_actions_get(it); + _evry_selector_update(selectors[1]); + } +} + +static void +_evry_list_update(Evry_State *s) +{ + if (!list->visible) return; + if (!s->plugin) return; + + _evry_list_clear_list(s); + _evry_list_tabs_update(s); + _evry_list_show_items(s, s->plugin); + _evry_list_scroll_to(s, s->sel_item); +} + +static int +_evry_selector_subjects_get(void) +{ + Eina_List *l, *plugins = NULL; + Evry_Plugin *p; + Evry_Selector *sel = selectors[0]; + + EINA_LIST_FOREACH(sel->plugins, l, p) + { + if (p->begin) + { + if (p->begin(p, NULL)) + plugins = eina_list_append(plugins, p); + } + else + plugins = eina_list_append(plugins, p); + } + + if (!plugins) return 0; + + _evry_state_new(sel, plugins); + + _evry_matches_update(sel, NULL); + + return 1; +} + +static int +_evry_selector_actions_get(Evry_Item *it) +{ + Eina_List *l, *plugins = NULL; + Evry_Plugin *p; + Evry_Selector *sel = selectors[1]; + + while (sel->state) + _evry_state_pop(sel); + + if (!it) + { + _evry_state_new(sel, plugins); + return 1; + } + + EINA_LIST_FOREACH(sel->plugins, l, p) + { + if (strcmp(p->type_in, it->plugin->type_out) && + (p != action_selector) && + (p != sel->aggregator)) continue; + + if (p->begin) + { + if (p->begin(p, it)) + plugins = eina_list_append(plugins, p); + } + else + plugins = eina_list_append(plugins, p); + } + + if (!plugins) return 0; + + _evry_state_new(sel, plugins); + + _evry_matches_update(sel, NULL); + + return 1; +} + +static int +_evry_selector_objects_get(const char *type) +{ + Eina_List *l, *plugins = NULL; + Evry_Plugin *p; + Evry_Selector *sel = selectors[2]; + Evry_Item *it; + + while (sel->state) + _evry_state_pop(sel); + + it = NULL; // TODO let 'object' plugins take subject and action + // into account. selectors[0]->state->sel_item; + + EINA_LIST_FOREACH(sel->plugins, l, p) + { + if (strcmp(p->type_out, type) && + (p != sel->aggregator)) continue; + + if (p->begin) + { + if (p->begin(p, it)) + plugins = eina_list_append(plugins, p); + } + else + plugins = eina_list_append(plugins, p); + } + + if (!plugins) return 0; + + _evry_state_new(sel, plugins); + + _evry_matches_update(sel, NULL); + + return 1; +} + + +static Evry_State * +_evry_state_new(Evry_Selector *sel, Eina_List *plugins) +{ + Evry_State *s = E_NEW(Evry_State, 1); s->input = malloc(INPUTLEN); s->input[0] = 0; - s->plugins = list; + s->plugins = plugins; s->cur_plugins = NULL; s->sel_item = NULL; s->plugin_auto_selected = 1; - if (cur_state) - { - s->request_type = cur_state->request_type; - s->cur_action = cur_state->cur_action; - s->cur_actions = cur_state->cur_actions; - s->initial = 0; - } - else s->initial = 1; - - cur_state = s; - stack = eina_list_prepend(stack, s); - - edje_object_part_text_set(o_main, "e.text.label", s->input); - - ev_last_is_mouse = 0; - item_mouseover = NULL; - - _evry_matches_update(s->cur_plugin); - - return 1; + sel->states = eina_list_prepend(sel->states, s); + sel->state = s; + + return s; } -static int -_evry_pop_state(void) +static void +_evry_state_pop(Evry_Selector *sel) { - Evry_State *s, *last_state; Evry_Plugin *p; - Eina_List *l; - if (!stack || !stack->next) return 0; - - s = cur_state; - - stack = eina_list_remove_list(stack, stack); - last_state = stack->data; - - _evry_list_clear(); - - free(s->input); - - EINA_LIST_FOREACH(s->plugins, l, p) + free(sel->state->input); + EINA_LIST_FREE(sel->state->plugins, p) p->cleanup(p); - E_FREE(s); - - if (stack) - { - Evry_Item *it = NULL; - int i = 0; - - s = last_state; - cur_state = s; - - edje_object_part_text_set(o_main, "e.text.label", s->input); - - if (s->sel_item) - { - Evry_Item *it; - EINA_LIST_FOREACH(s->cur_plugin->items, l, it) - if (it == s->sel_item) - break; - else i++; - } - - if (stack->next) - { - Evry_State *prev = stack->next->data; - it = prev->sel_item; - } - - EINA_LIST_FOREACH(s->plugins, l, p) - if (p != s->cur_plugin && p->begin) - p->begin(p, it); - - p = s->cur_plugin; - s->cur_plugin = NULL; - _evry_matches_update(p); - - /* FIXME better solution: handle the case that previous plugin fetches async */ - s->cur_plugin = p; - - it = eina_list_nth(s->cur_plugin->items, i); - - if (it) - { - if (s->sel_item) _evry_item_desel(s->sel_item); - s->sel_item = it; - _evry_item_sel(s->sel_item); - _evry_scroll_to(i); - } - } - - /* else - * { - * cur_state = NULL; - * evry_hide(); - * } */ - - ev_last_is_mouse = 0; - item_mouseover = NULL; - - return 1; + E_FREE(sel->state); + + sel->states = eina_list_remove_list(sel->states, sel->states); + + if (sel->states) + sel->state = sel->states->data; + else + sel->state = NULL; } -/* TODO config options for users preferred keys */ -static int +static void +_evry_browse_item(Evry_Selector *sel) +{ + Evry_State *s = sel->state; + Evry_Item *it; + Eina_List *l, *plugins = NULL; + Evry_Plugin *p; + + it = s->sel_item; + + if (!it || !it->browseable) return; + + _evry_list_clear_list(sel->state); + + EINA_LIST_FOREACH(sel->plugins, l, p) + { + if (!strstr(p->type_in, it->plugin->type_out)) continue; + + if (p->begin) + { + if (p->begin(p, it)) + plugins = eina_list_append(plugins, p); + } + else + plugins = eina_list_append(plugins, p); + } + if (plugins) + { + _evry_state_new(sel, plugins); + _evry_matches_update(sel, NULL); + _evry_selector_update(sel); + } + + _evry_list_update(sel->state); + _evry_update_text_label(sel->state); +} + + +static void +_evry_browse_back(Evry_Selector *sel) +{ + Evry_State *s = sel->state; + + if (!s || !sel->states->next) return; + + _evry_list_clear_list(s); + _evry_state_pop(sel); + _evry_selector_update(sel); + _evry_list_update(sel->state); + _evry_update_text_label(sel->state); +} + +static void +_evry_selectors_switch(void) +{ + Evry_State *s = selector->state; + + if (selector == selectors[0]) + { + if (s->sel_item) + _evry_selector_activate(selectors[1]); + } + else if (selector == selectors[1]) + { + int next_selector = 0; + + if (s->plugin == action_selector) + { + Evry_Action *act; + Evry_Selector *sel; + int w; + + if (update_timer) + { + /* XXX redundant > selector_activate, + plugin_action, update_timer !!! */ + if (!s->plugin->async_query) + { + _evry_list_clear_list(s); + _evry_matches_update(selector, s->plugin); + _evry_selector_update(selector); + } + ecore_timer_del(update_timer); + update_timer = NULL; + } + + act = s->sel_item->data[0]; + + if (act && act->type_in2) + { + + sel = selectors[2]; + _evry_selector_objects_get(act->type_in2); + _evry_selector_update(sel); + + edje_object_signal_emit(win->o_main, + "e,state,object_selector_show", "e"); + + next_selector = 2; + } + } + _evry_selector_activate(selectors[next_selector]); + } + else if (selector == selectors[2]) + { + edje_object_signal_emit(win->o_main, + "e,state,object_selector_hide", "e"); + + _evry_list_clear_list(s); + + while (selector->states) + _evry_state_pop(selector); + + _evry_selector_activate(selectors[0]); + } +} + + static int _evry_cb_key_down(void *data __UNUSED__, int type __UNUSED__, void *event) { Ecore_Event_Key *ev; - Evry_State *s = cur_state; - ev_last_is_mouse = 0; - item_mouseover = NULL; + Evry_State *s = selector->state; + /* ev_last_is_mouse = 0; + * item_mouseover = NULL; */ ev = event; if (ev->event_window != input_window) return 1; - if (!strcmp(ev->key, "Up")) - _evry_item_prev(); + if (!strcmp(ev->key, "Up")) + _evry_list_item_prev(s); else if (!strcmp(ev->key, "Down")) - _evry_item_next(); + _evry_list_item_next(s); else if (!strcmp(ev->key, "Right") && - ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || - (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))) - { - if (s->sel_item) - { - if (!_evry_push_state()) - _evry_plugin_action(0); - } - } - /* _evry_plugin_next(); */ + (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)) + _evry_list_plugin_next(s); else if (!strcmp(ev->key, "Left") && - ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || - (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))) - _evry_pop_state(); - /* _evry_plugin_prev(); */ + (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT)) + _evry_list_plugin_prev(s); else if (!strcmp(ev->key, "Right")) - _evry_plugin_next(); - /* { - * if (s->sel_item) - * { - * if (!_evry_push_state()) - * _evry_plugin_action(0); - * } - * } */ + _evry_browse_item(selector); else if (!strcmp(ev->key, "Left")) - _evry_plugin_prev(); - /* _evry_pop_state(); */ - else if (!strcmp(ev->key, "Return") && - (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)) - _evry_plugin_action(0); + _evry_browse_back(selector); + else if ((!strcmp(ev->key, "Return")) && + ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || + (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))) + _evry_plugin_action(selector, 0); else if (!strcmp(ev->key, "Return")) - _evry_plugin_action(1); + _evry_plugin_action(selector, 1); else if (!strcmp(ev->key, "Tab") && - ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || - (ev->modifiers & ECORE_EVENT_MODIFIER_SHIFT))) - _evry_plugin_prev(); + ((ev->modifiers & ECORE_EVENT_MODIFIER_ALT) || + (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))) + _evry_list_plugin_next(s); else if (!strcmp(ev->key, "Tab")) - { - if (s->sel_item) - { - if (!_evry_push_state()) - _evry_plugin_action(0); - } - } - /* _evry_plugin_next(); */ + _evry_selectors_switch(); else if (!strcmp(ev->key, "u") && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL)) - _evry_clear(); + _evry_clear(s); else if ((!strcmp(ev->key, "Escape")) || (!strcmp(ev->key, "e") && (ev->modifiers & ECORE_EVENT_MODIFIER_CTRL))) + evry_hide(); + else if ((!strcmp(ev->key, "BackSpace")) || + (!strcmp(ev->key, "Delete"))) + _evry_backspace(s); + else if ((ev->compose) && + (!(ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) || + (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) || + (ev->modifiers & ECORE_EVENT_MODIFIER_WIN)) && + ((strlen(s->input) < (INPUTLEN - strlen(ev->compose))))) { - if (!_evry_pop_state()) - evry_hide(); - } - - else if (!strcmp(ev->key, "BackSpace")) - _evry_backspace(); - else if (!strcmp(ev->key, "Delete")) - _evry_backspace(); - else - { - if (ev->compose) - { - if ((strlen(s->input) < (INPUTLEN - strlen(ev->compose)))) - { - strcat(s->input, ev->compose); - _evry_update(); - } - } - } - return 1; -} - -static int -_evry_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Event_Mouse_Button *ev; - Evry_State *s =cur_state; - - ev = event; - if (ev->event_window != input_window) return 1; - - if (item_mouseover) - { - if (s->sel_item != item_mouseover) - { - if (s->sel_item) _evry_item_desel(s->sel_item); - s->sel_item = item_mouseover; - _evry_item_sel(s->sel_item); - } - } - else - { - evas_event_feed_mouse_up(popup->evas, ev->buttons, 0, ev->timestamp, NULL); - } - - return 1; -} - -static int -_evry_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Event_Mouse_Button *ev; - - ev = event; - if (ev->event_window != input_window) return 1; - - if (item_mouseover) - { - if (ev->buttons == 1) - _evry_plugin_action(1); - else if (ev->buttons == 3) - _evry_plugin_action(0); - } - else - { - evas_event_feed_mouse_up(popup->evas, ev->buttons, 0, ev->timestamp, NULL); - } - - return 1; -} - -static int -_evry_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Event_Mouse_Move *ev; - Evry_State *s =cur_state; - - ev = event; - if (ev->event_window != input_window) return 1; - - if (!ev_last_is_mouse) - { - ev_last_is_mouse = 1; - if (item_mouseover) - { - if (s->sel_item && (s->sel_item != item_mouseover)) - _evry_item_desel(s->sel_item); - if (!s->sel_item || (s->sel_item != item_mouseover)) - { - s->sel_item = item_mouseover; - _evry_item_sel(s->sel_item); - } - } - } - - evas_event_feed_mouse_move(popup->evas, ev->x - popup->x, - ev->y - popup->y, ev->timestamp, NULL); - - return 1; -} - -static int -_evry_cb_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event) -{ - Ecore_Event_Mouse_Wheel *ev; - - ev = event; - if (ev->event_window != input_window) return 1; - - ev_last_is_mouse = 0; - - if (ev->z < 0) /* up */ - { - int i; - - for (i = ev->z; i < 0; i++) _evry_item_prev(); - } - else if (ev->z > 0) /* down */ - { - int i; - - for (i = ev->z; i > 0; i--) _evry_item_next(); + strcat(s->input, ev->compose); + _evry_update(s); } return 1; } static void -_evry_cb_item_mouse_in(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - Evry_State *s =cur_state; - - if (!ev_last_is_mouse) return; - - item_mouseover = data; - - if (s->sel_item) _evry_item_desel(s->sel_item); - if (!(s->sel_item = data)) return; - _evry_item_sel(s->sel_item); -} - -static void -_evry_cb_item_mouse_out(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) -{ - item_mouseover = NULL; -} - -static void -_evry_backspace(void) +_evry_backspace(Evry_State *s) { int len, val, pos; - Evry_State *s = cur_state; len = strlen(s->input); if (len > 0) @@ -823,195 +1078,247 @@ _evry_backspace(void) if ((pos < len) && (pos >= 0)) { s->input[pos] = 0; - _evry_update(); + _evry_update(s); } } } static void -_evry_update(void) +_evry_update_text_label(Evry_State *s) { - edje_object_part_text_set(o_main, "e.text.label", cur_state->input); + if (strlen(s->input) > 0) + edje_object_signal_emit(list->o_main, "e,state,entry_show", "e"); + else + edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e"); + + edje_object_part_text_set(win->o_main, "e.text.label", s->input); + edje_object_part_text_set(list->o_main, "e.text.label", s->input); +} + +static void +_evry_update(Evry_State *s) +{ + _evry_update_text_label(s); + if (update_timer) ecore_timer_del(update_timer); - update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, NULL); + update_timer = ecore_timer_add(MATCH_LAG, _evry_update_timer, s); } static int -_evry_update_timer(void *data __UNUSED__) +_evry_update_timer(void *data) { - _evry_matches_update(cur_state->cur_plugin); + Evry_State *s = data; + /* XXX pass selector as data? */ + _evry_list_clear_list(s); + _evry_matches_update(selector, s->plugin); + _evry_selector_update(selector); + _evry_list_update(selector->state); update_timer = NULL; + return 0; } static void -_evry_clear(void) +_evry_clear(Evry_State *s) { - if (cur_state->input[0] != 0) + if (s->input[0] != 0) { - cur_state->input[0] = 0; - _evry_update(); + s->input[0] = 0; + _evry_update(s); + edje_object_signal_emit(list->o_main, "e,state,entry_hide", "e"); } } static void -_evry_plugin_action(int finished) -{ - Evry_State *s = cur_state; +_evry_plugin_action(Evry_Selector *sel, int finished) +{ + Evry_State *s_subject, *s_action, *s_object; + + s_subject = selectors[0]->state; + s_action = selectors[1]->state; + s_object = NULL; + + if (!s_subject || !s_action) return; if (update_timer) { - _evry_matches_update(s->cur_plugin); + /* XXX what if an async plugin is selected */ + if (!selector->state->plugin->async_query) + { + _evry_matches_update(selector, selector->state->plugin); + _evry_selector_update(selector); + } + ecore_timer_del(update_timer); update_timer = NULL; } - - if (s->cur_plugin == action_selector) - { - /* set cur_action and start plugins for second parameter if required */ - if (s->sel_item) - finished = _evry_plug_act_select_action(s->cur_plugin, s->sel_item, s->input); - } - else if (s->cur_action) - { - /* */ - if (s->sel_item && (!strcmp(s->cur_plugin->type_out, s->request_type))) - { - s->cur_action->thing2 = s->sel_item; - s->cur_action->action(s->cur_action); - } - } - else if (s->cur_plugin && (s->sel_item || s->input)) - { - int ret = EVRY_ACTION_OTHER; - if (s->cur_plugin->action) - ret = s->cur_plugin->action(s->cur_plugin, s->sel_item, s->input); - - if (ret == EVRY_ACTION_OTHER) - { - _evry_push_state(); - finished = 0; - } - else if (ret == EVRY_ACTION_CONTINUE) - finished = 0; - } - else if (s->initial) - e_exec(popup->zone, NULL, s->input, NULL, NULL); + if (!s_subject->sel_item || !s_action->sel_item) return; + if (s_action->plugin == action_selector) + { + Evry_Action *act = s_action->sel_item->data[0]; + Evry_Item *it_object = NULL; + + if (selectors[2] == selector) /* && selector->state ? */ + it_object = selector->state->sel_item; + + if (act->type_in2 && !it_object) return; + + act->action(act, s_subject->sel_item, it_object, NULL); + } + else + { + Evry_Item *it = s_action->sel_item; + s_action->plugin->action(s_action->plugin, it, selector->state->input); + } + + if (s_subject->plugin->action) + s_subject->plugin->action(s_subject->plugin, + s_subject->sel_item, + s_subject->input); + + if (s_object && s_object->plugin->action) + s_object->plugin->action(s_object->plugin, + s_object->sel_item, + s_object->input); if (finished) evry_hide(); } static void -_evry_show_items(Evry_Plugin *p) +_evry_list_show_items(Evry_State *s, Evry_Plugin *p) { Evry_Item *it; Eina_List *l; int mw, mh, h; Evas_Object *o; - Evry_State *s = cur_state; - if (s->cur_plugin) - { - if (s->cur_plugin != p) - { - edje_object_signal_emit(s->cur_plugin->tab, "e,state,unselected", "e"); - edje_object_signal_emit(p->tab, "e,state,selected", "e"); - } - } - else - edje_object_signal_emit(p->tab, "e,state,selected", "e"); - - /* XXX move this to push/pop as plugin could be the same for - different states!*/ - if (s->cur_plugin != p) - s->sel_item = NULL; - - if (p->realize_items) p->realize_items(p, popup->evas); + if (p->realize_items) p->realize_items(p, list->popup->evas); - s->cur_plugin = p; - s->cur_items = p->items; - - if (scroll_timer) + if (list->scroll_timer) { - ecore_timer_del(scroll_timer); - scroll_timer = NULL; + ecore_timer_del(list->scroll_timer); + list->scroll_timer = NULL; } - if (scroll_animator) + if (list->scroll_animator) { - ecore_animator_del(scroll_animator); - scroll_animator = NULL; + ecore_animator_del(list->scroll_animator); + list->scroll_animator = NULL; } - scroll_align = 0; + if (!list->visible) return; + + list->scroll_align = 0; - evas_event_freeze(popup->evas); - e_box_freeze(o_list); + evas_event_freeze(list->popup->evas); + e_box_freeze(list->o_list); EINA_LIST_FOREACH(p->items, l, it) { - o = edje_object_add(popup->evas); - it->o_bg = o; - e_theme_edje_object_set(o, "base/theme/everything", - "e/widgets/everything/item"); + if (!it->o_bg) + { + o = edje_object_add(list->popup->evas); + it->o_bg = o; + e_theme_edje_object_set(o, "base/theme/everything", + "e/widgets/everything/item"); - edje_object_part_text_set(o, "e.text.title", it->label); + edje_object_part_text_set(o, "e.text.title", it->label); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, - _evry_cb_item_mouse_in, it); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, - _evry_cb_item_mouse_out, it); - evas_object_show(o); + /* evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_IN, + * _evry_cb_item_mouse_in, it); + * evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_OUT, + * _evry_cb_item_mouse_out, it); */ + evas_object_show(o); + } + else + { + o = it->o_bg; + } + + /* if (!it->o_icon && p->icon_get) p->icon_get(p, it, popup_list->evas); */ - if (!it->o_icon) p->icon_get(p, it, popup->evas); - - if (edje_object_part_exists(o, "e.swallow.icons") && it->o_icon) + if (it->o_icon && edje_object_part_exists(o, "e.swallow.icons")) { edje_object_part_swallow(o, "e.swallow.icons", it->o_icon); evas_object_show(it->o_icon); } + edje_object_size_min_calc(o, &mw, &mh); - e_box_pack_end(o_list, o); + e_box_pack_end(list->o_list, o); e_box_pack_options_set(o, 1, 1, 1, 0, 0.5, 0.5, mw, mh, 9999, mh); - } - e_box_thaw(o_list); - e_box_min_size_get(o_list, NULL, &mh); - evas_object_geometry_get(o_list, NULL, NULL, NULL, &h); - if (mh <= h) - e_box_align_set(o_list, 0.5, 0.0); - else - e_box_align_set(o_list, 0.5, 1.0); - - /* TODO add option */ - - if (/*!s->initial &&*/!s->sel_item && p->items) - { - s->sel_item = p->items->data; - _evry_item_sel(s->sel_item); - _evry_scroll_to(0); - } - else if (!p->items) - { - s->sel_item = NULL; + if (it == s->sel_item) + { + edje_object_signal_emit(it->o_bg, "e,state,selected", "e"); + if (it->o_icon) + edje_object_signal_emit(it->o_icon, "e,state,selected", "e"); + } } + e_box_thaw(list->o_list); + + if (edje_object_part_exists(o, "e.swallow.icons")) + list->item_idler = ecore_idler_add(_evry_list_item_idler, p); - evas_event_thaw(popup->evas); + e_box_min_size_get(list->o_list, NULL, &mh); + evas_object_geometry_get(list->o_list, NULL, NULL, NULL, &h); + if (mh <= h) + e_box_align_set(list->o_list, 0.5, 0.0); + else + e_box_align_set(list->o_list, 0.5, 1.0); - _evry_tab_scroll_to(p); + evas_event_thaw(list->popup->evas); + + _evry_list_tab_scroll_to(s, p); } -static void -_evry_matches_update(Evry_Plugin *cur_plugin) + +static int +_evry_list_item_idler(void *data) { + Evry_Plugin *p = data; + int cnt = 5; + Eina_List *l; + Evry_Item *it; + + if (!list->item_idler) return 0; + + if (!p->icon_get) goto end; + e_box_freeze(list->o_list); + + EINA_LIST_FOREACH(p->items, l, it) + { + if (!it->o_icon) + { + it->o_icon = p->icon_get(p, it, list->popup->evas); + + if (it->o_icon) + { + edje_object_part_swallow(it->o_bg, "e.swallow.icons", it->o_icon); + evas_object_show(it->o_icon); + cnt--; + } + } + if (cnt == 0) break; + } + e_box_thaw(list->o_list); + + if (cnt == 0) return 1; + end: + list->item_idler = NULL; + return 0; +} + + +static void +_evry_matches_update(Evry_Selector *sel, Evry_Plugin *plugin) +{ + Evry_State *s = sel->state; Evry_Plugin *p; Eina_List *l; Eina_Bool has_items = EINA_FALSE; - Evry_State *s = cur_state; - _evry_list_clear(); eina_list_free(s->cur_plugins); s->cur_plugins = NULL; s->sel_item = NULL; @@ -1033,14 +1340,14 @@ _evry_matches_update(Evry_Plugin *cur_plugin) } } } - if (!s->cur_plugins) { EINA_LIST_FOREACH(s->plugins, l, p) { if (p->trigger) continue; - + if (p == sel->aggregator) continue; + if (strlen(s->input) == 0) { if (!p->need_query) @@ -1050,119 +1357,126 @@ _evry_matches_update(Evry_Plugin *cur_plugin) { has_items = p->fetch(p, s->input); } - - if ((!s->initial) || - (has_items && eina_list_count(p->items) > 0) || - (p->async_query)) - s->cur_plugins = eina_list_append(s->cur_plugins, p); + + if ((has_items && eina_list_count(p->items) > 0) || + (p->async_query)) /* XXX append in async_update instead?*/ + { + s->cur_plugins = eina_list_append(s->cur_plugins, p); + } } - } - - /* remove tabs for not active plugins */ - EINA_LIST_FOREACH(evry_conf->plugins, l, p) - { - if (p->tab && !eina_list_data_find(s->cur_plugins, p)) + + if (eina_list_count(s->cur_plugins) > 1) { - evas_object_del(p->tab); - p->tab = NULL; + sel->aggregator->fetch(sel->aggregator, NULL); + s->cur_plugins = eina_list_prepend(s->cur_plugins, sel->aggregator); } } - /* show/update tabs of active plugins */ - EINA_LIST_FOREACH(s->cur_plugins, l, p) - _evry_plugin_selector_show(p); - + /* TODO do this in separate function ? */ if (s->cur_plugins) { - /* s->cur_plugins = eina_list_sort(s->cur_plugins, - * eina_list_count(s->cur_plugins), - * _evry_cb_plugin_sort_by_trigger); */ - - if (cur_plugin && eina_list_data_find(s->cur_plugins, cur_plugin)) - _evry_show_items(cur_plugin); - else - _evry_show_items(s->cur_plugins->data); + if (plugin && !eina_list_data_find(s->cur_plugins, plugin)) + s->plugin = s->cur_plugins->data; } else { - s->cur_plugin = NULL; - s->cur_items = NULL; + s->plugin = NULL; } } static void -_evry_list_clear(void) +_evry_list_clear_list(Evry_State *s) { - Evry_State *s = cur_state; Evry_Item *it; Eina_List *l; - if (s && s->cur_items) + if (list->item_idler) { - evas_event_freeze(popup->evas); - e_box_freeze(o_list); - EINA_LIST_FOREACH(s->cur_items, l, it) + ecore_idler_del(list->item_idler); + list->item_idler = NULL; + } + + if (s && s->plugin && s->plugin->items) + { + evas_event_freeze(list->popup->evas); + e_box_freeze(list->o_list); + EINA_LIST_FOREACH(s->plugin->items, l, it) { - evas_object_del(it->o_bg); + if (it->o_bg) evas_object_del(it->o_bg); + it->o_bg = NULL; if (it->o_icon) evas_object_del(it->o_icon); it->o_icon = NULL; } - e_box_thaw(o_list); - evas_event_thaw(popup->evas); + e_box_thaw(list->o_list); + evas_event_thaw(list->popup->evas); } } static void -_evry_scroll_to(int i) +_evry_list_scroll_to(Evry_State *s, Evry_Item *it) { - int n, h, mh; + int n, h, mh, i = 0, max_w, max_h; + Eina_List *l; - n = eina_list_count(cur_state->cur_plugin->items); - - e_box_min_size_get(o_list, NULL, &mh); - evas_object_geometry_get(o_list, NULL, NULL, NULL, &h); - - if (mh <= h) return; + if (!it) return; + + for(l = s->plugin->items; l; l = l->next, i++) + if (l->data == it) break; + n = eina_list_count(s->plugin->items); + + e_box_min_size_get(list->o_list, NULL, &mh); + evas_object_geometry_get(list->o_list, NULL, NULL, NULL, &h); + /* edje_object_part_geometry_get(list->o_main, "e.swallow.list", NULL, NULL, &max_w, &max_h); */ + /* printf("MAX %d %d %d\n", max_h, h, mh); + * if (max_h != h) + * evas_object_resize(list->o_list, max_w, max_h); */ + + if (i >= n || mh <= h) + { + e_box_align_set(list->o_list, 0.5, 0.0); + return; + } + if (n > 1) { - scroll_align_to = (double)i / (double)(n - 1); + list->scroll_align_to = (double)i / (double)(n - 1); if (evry_conf->scroll_animate) { - if (!scroll_timer) - scroll_timer = ecore_timer_add(0.01, _evry_scroll_timer, NULL); - if (!scroll_animator) - scroll_animator = ecore_animator_add(_evry_animator, NULL); + if (!list->scroll_timer) + list->scroll_timer = ecore_timer_add(0.01, _evry_list_scroll_timer, NULL); + if (!list->scroll_animator) + list->scroll_animator = ecore_animator_add(_evry_list_animator, NULL); } else { - scroll_align = scroll_align_to; - e_box_align_set(o_list, 0.5, 1.0 - scroll_align); + list->scroll_align = list->scroll_align_to; + e_box_align_set(list->o_list, 0.5, 1.0 - list->scroll_align); } } else - e_box_align_set(o_list, 0.5, 1.0); + e_box_align_set(list->o_list, 0.5, 1.0); } static void -_evry_tab_scroll_to(Evry_Plugin *p) +_evry_list_tab_scroll_to(Evry_State *s, Evry_Plugin *p) { int n, w, mw, i; double align; Eina_List *l; - for(i = 0, l = cur_state->cur_plugins; l; l = l->next, i++) + for(i = 0, l = s->cur_plugins; l; l = l->next, i++) if (l->data == p) break; - n = eina_list_count(cur_state->cur_plugins); + n = eina_list_count(s->cur_plugins); - e_box_min_size_get(o_selector, &mw, NULL); - evas_object_geometry_get(o_selector, NULL, NULL, &w, NULL); + e_box_min_size_get(list->o_tabs, &mw, NULL); + evas_object_geometry_get(list->o_tabs, NULL, NULL, &w, NULL); if (mw <= w) { - e_box_align_set(o_selector, 0.0, 0.5); + e_box_align_set(list->o_tabs, 0.0, 0.5); return; } @@ -1172,21 +1486,21 @@ _evry_tab_scroll_to(Evry_Plugin *p) /* if (evry_conf->scroll_animate) * { * if (!scroll_timer) - * scroll_timer = ecore_timer_add(0.01, _evry_scroll_timer, NULL); + * scroll_timer = ecore_timer_add(0.01, _evry_list_scroll_timer, NULL); * if (!scroll_animator) - * scroll_animator = ecore_animator_add(_evry_animator, NULL); + * scroll_animator = ecore_animator_add(_evry_list_animator, NULL); * } * else */ { - e_box_align_set(o_selector, 1.0 - align, 0.5); + e_box_align_set(list->o_tabs, 1.0 - align, 0.5); } } else - e_box_align_set(o_selector, 1.0, 0.5); + e_box_align_set(list->o_tabs, 1.0, 0.5); } static void -_evry_item_desel(Evry_Item *it) +_evry_list_item_desel(Evry_State *s, Evry_Item *it) { edje_object_signal_emit(it->o_bg, "e,state,unselected", "e"); if (it->o_icon) @@ -1194,181 +1508,245 @@ _evry_item_desel(Evry_Item *it) } static void -_evry_item_sel(Evry_Item *it) +_evry_list_item_sel(Evry_State *s, Evry_Item *it) { - edje_object_signal_emit(it->o_bg, "e,state,selected", "e"); - if (it->o_icon) - edje_object_signal_emit(it->o_icon, "e,state,selected", "e"); + if (list->visible && selector->state == s) + { + if (s->sel_item) + _evry_list_item_desel(s, s->sel_item); + + edje_object_signal_emit(it->o_bg, "e,state,selected", "e"); + if (it->o_icon) + edje_object_signal_emit(it->o_icon, "e,state,selected", "e"); + + _evry_list_scroll_to(s, it); + } + + s->sel_item = it; } + static void -_evry_item_next(void) +_evry_list_item_next(Evry_State *s) { Eina_List *l; - int i; - Evry_State *s = cur_state; + Evry_Item *it; - s->plugin_auto_selected = 0; + if (!s->plugin || !s->plugin->items) return; - if (s->sel_item) + if (!list->visible) { - for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++) + _evry_list_win_show(); + return; + } + + s->plugin_auto_selected = EINA_FALSE; + s->item_auto_selected = EINA_FALSE; + + if (!s->sel_item) + { + _evry_list_item_sel(s, s->plugin->items->data); + _evry_selector_update(selector); + return; + } + + EINA_LIST_FOREACH (s->plugin->items, l, it) + { + if (it == s->sel_item) { - if (l->data == s->sel_item) + if (l->next) { - if (l->next) - { - _evry_item_desel(s->sel_item); - s->sel_item = l->next->data; - _evry_item_sel(s->sel_item); - _evry_scroll_to(i + 1); - } - break; + _evry_list_item_sel(s, l->next->data); + _evry_selector_update(selector); } + break; } } - else if (s->cur_plugin && s->cur_plugin->items) - { - s->sel_item = s->cur_plugin->items->data; - _evry_item_sel(s->sel_item); - _evry_scroll_to(0); - } - - /* if (s->sel_item) - * edje_object_part_text_set(o_main, "e.text.label", s->sel_item->label); */ } static void -_evry_item_prev(void) +_evry_list_item_prev(Evry_State *s) { Eina_List *l; - int i; - Evry_State *s = cur_state; + Evry_Item *it; - s->plugin_auto_selected = 0; - - if (s->sel_item) + if (!s->plugin || !s->plugin->items) return; + + s->plugin_auto_selected = EINA_FALSE; + s->item_auto_selected = EINA_FALSE; + + if (!s->sel_item) return; + + EINA_LIST_FOREACH (s->plugin->items, l, it) { - _evry_item_desel(s->sel_item); - - for (i = 0, l = s->cur_plugin->items; l; l = l->next, i++) + if (it == s->sel_item) { - if (l->data == s->sel_item) + if (l->prev) { - if (l->prev) - { - s->sel_item = l->prev->data; - _evry_item_sel(s->sel_item); - _evry_scroll_to(i - 1); - } - else - s->sel_item = NULL; - break; + _evry_list_item_sel(s, l->prev->data); + _evry_selector_update(selector); + return; } + break; } } - /* if (s->sel_item) - * edje_object_part_text_set(o_main, "e.text.label", s->sel_item->label); - * else - * edje_object_part_text_set(o_main, "e.text.label", input); */ + _evry_list_win_hide(); } static void -_evry_plugin_next(void) +_evry_select_plugin(Evry_State *s, Evry_Plugin *p) +{ + if (!p) p = s->plugin; + if (!p) return; + + if (list->visible) + { + if (s->plugin != p) + { + if (s->plugin) + edje_object_signal_emit(s->plugin->tab, "e,state,unselected", "e"); + + /* XXX tab_show ? -> see evry_plugin_async_update*/ + edje_object_signal_emit(p->tab, "e,state,selected", "e"); + } + } + + if (s->plugin != p) + { + s->sel_item = NULL; + s->plugin = p; + } +} + +static void +_evry_list_plugin_next(Evry_State *s) { Eina_List *l; - Evry_State *s = cur_state; + Evry_Plugin *p = NULL; + + if (!s->plugin) return; - if (!s->cur_plugin) return; - - l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin); + /* _evry_list_win_show(); */ + + l = eina_list_data_find_list(s->cur_plugins, s->plugin); if (l && l->next) + p = l->next->data; + else if (s->plugin != s->cur_plugins->data) + p = s->cur_plugins->data; + + if (p) { s->plugin_auto_selected = 0; - _evry_list_clear(); - _evry_show_items(l->next->data); - } - else if (s->cur_plugin != s->cur_plugins->data) - { - s->plugin_auto_selected = 0; - _evry_list_clear(); - _evry_show_items(s->cur_plugins->data); + _evry_list_clear_list(s); + _evry_select_plugin(s, p); + _evry_list_show_items(s, p); + _evry_selector_update(selector); } } static void -_evry_plugin_prev(void) +_evry_list_plugin_prev(Evry_State *s) { Eina_List *l; - Evry_State *s = cur_state; + Evry_Plugin *p = NULL; + + if (!s->plugin) return; - if (!s->cur_plugin) return; - - l = eina_list_data_find_list(s->cur_plugins, s->cur_plugin); + /* _evry_list_win_show(); */ + + l = eina_list_data_find_list(s->cur_plugins, s->plugin); if (l && l->prev) - { - s->plugin_auto_selected = 0; - _evry_list_clear(); - _evry_show_items(l->prev->data); - } + p = l->prev->data; else { l = eina_list_last(s->cur_plugins); - - if (s->cur_plugin != l->data) - { - s->plugin_auto_selected = 0; - _evry_list_clear(); - _evry_show_items(l->data); - } + if (s->plugin != l->data) + p = l->data; + } + + if (p) + { + s->plugin_auto_selected = 0; + _evry_list_clear_list(s); + _evry_select_plugin(s, p); + _evry_list_show_items(s, p); + _evry_selector_update(selector); } } static int -_evry_scroll_timer(void *data __UNUSED__) +_evry_list_scroll_timer(void *data __UNUSED__) { - if (scroll_animator) + if (list->scroll_animator) { double spd; spd = evry_conf->scroll_speed; - scroll_align = (scroll_align * (1.0 - spd)) + (scroll_align_to * spd); + list->scroll_align = (list->scroll_align * (1.0 - spd)) + + (list->scroll_align_to * spd); return 1; } - scroll_timer = NULL; + list->scroll_timer = NULL; return 0; } static int -_evry_animator(void *data __UNUSED__) +_evry_list_animator(void *data __UNUSED__) { double da; Eina_Bool scroll_to = 1; - da = scroll_align - scroll_align_to; + da = list->scroll_align - list->scroll_align_to; if (da < 0.0) da = -da; if (da < 0.01) { - scroll_align = scroll_align_to; + list->scroll_align = list->scroll_align_to; scroll_to = 0; } - e_box_align_set(o_list, 0.5, 1.0 - scroll_align); + e_box_align_set(list->o_list, 0.5, 1.0 - list->scroll_align); if (scroll_to) return 1; - scroll_animator = NULL; + list->scroll_animator = NULL; return 0; } static void -_evry_plugin_selector_show(Evry_Plugin *p) +_evry_list_tabs_update(Evry_State *s) +{ + Eina_List *l; + Evry_Plugin *p; + + /* remove tabs for not active plugins */ + EINA_LIST_FOREACH(selector->plugins, l, p) + { + if (p->tab && !eina_list_data_find(s->cur_plugins, p)) + { + e_box_unpack(p->tab); + evas_object_del(p->tab); + p->tab = NULL; + } + } + + /* show/update tabs of active plugins */ + EINA_LIST_FOREACH(s->cur_plugins, l, p) + { + _evry_list_tab_show(s, p); + if (s->plugin == p) + edje_object_signal_emit(p->tab, "e,state,selected", "e"); + else + edje_object_signal_emit(p->tab, "e,state,unselected", "e"); + } +} + +static void +_evry_list_tab_show(Evry_State *s, Evry_Plugin *p) { Evas_Object *o; Evas_Coord mw = 0, mh = 0; char buf[64]; Eina_List *l; - Evry_State *s = cur_state; - e_box_freeze(o_selector); + e_box_freeze(list->o_tabs); if (p->tab) { @@ -1377,10 +1755,10 @@ _evry_plugin_selector_show(Evry_Plugin *p) } else { - o = edje_object_add(popup->evas); - /* TODO move this to everything theme group !*/ - e_theme_edje_object_set(o, "base/theme/widgets", - "e/widgets/toolbar/item"); + o = edje_object_add(list->popup->evas); + + e_theme_edje_object_set(o, "base/theme/everything", + "e/widgets/everything/tab_item"); } snprintf(buf, 64, "%s (%d)", p->name, eina_list_count(p->items)); @@ -1393,14 +1771,15 @@ _evry_plugin_selector_show(Evry_Plugin *p) if (l && l->prev) { Evry_Plugin *p2 = l->prev->data; - e_box_pack_after(o_selector, o, p2->tab); + e_box_pack_after(list->o_tabs, o, p2->tab); } else - e_box_pack_end(o_selector, o); + e_box_pack_end(list->o_tabs, o); evas_object_show(o); e_box_pack_options_set(o, 1, 1, 0, 0, 0.5, 0.5, mw, mh, 9999, 9999); - e_box_thaw(o_selector); + e_box_thaw(list->o_tabs); + p->tab = o; } @@ -1408,18 +1787,18 @@ _evry_plugin_selector_show(Evry_Plugin *p) /* action selector plugin: provides list of actions registered for candidate types provided by current plugin */ static int -_evry_plug_act_select_init(void) +_evry_plug_actions_init(void) { Plugin_Config *pc; Evry_Plugin *p = E_NEW(Evry_Plugin, 1); p->name = "Select Action"; + p->type = type_action; p->type_in = "ANY"; p->type_out = "NONE"; - p->begin = &_evry_plug_act_select_begin; - p->cleanup = &_evry_plug_act_select_cleanup; - p->fetch = &_evry_plug_act_select_fetch; - p->action = &_evry_plug_act_select_action; - p->icon_get = &_evry_plug_act_select_item_icon_get; + p->begin = &_evry_plug_actions_begin; + p->cleanup = &_evry_plug_actions_cleanup; + p->fetch = &_evry_plug_actions_fetch; + p->icon_get = &_evry_plug_actions_item_icon_get; pc = E_NEW(Plugin_Config, 1); pc->name = eina_stringshare_add(p->name); @@ -1427,110 +1806,486 @@ _evry_plug_act_select_init(void) pc->priority = 100; p->config = pc; - evry_conf->plugins = eina_list_append(evry_conf->plugins, p); action_selector = p; return 1; } static int -_evry_plug_act_select_begin(Evry_Plugin *p, Evry_Item *it __UNUSED__) +_evry_plug_actions_begin(Evry_Plugin *p, Evry_Item *it) { Evry_Action *act; Eina_List *l; - Evry_State *s = cur_state; - - _evry_plug_act_select_cleanup(p); - - if (!s || !s->cur_plugin || s->cur_action) return 0; + Evry_Selector *sel = selectors[1]; - const char *type = s->cur_plugin->type_out; + _evry_plug_actions_cleanup(p); - EINA_LIST_FOREACH(actions, l, act) + if (!it) return 0; + + const char *type = it->plugin->type_out; + + EINA_LIST_FOREACH(evry_conf->actions, l, act) { if ((strstr(act->type_in1, type)) && - (!act->check_item || act->check_item(act, s->sel_item))) + (!act->check_item || act->check_item(act, it))) { - act->thing1 = s->sel_item; - s->cur_actions = eina_list_append(s->cur_actions, act); + sel->actions = eina_list_append(sel->actions, act); } } - if (s->cur_actions) return 1; + if (sel->actions) return 1; return 0; } static int -_evry_plug_act_select_fetch(Evry_Plugin *p, const char *input __UNUSED__) +_evry_plug_actions_fetch(Evry_Plugin *p, const char *input) { Evry_Action *act; Eina_List *l; - Evry_State *s = cur_state; + Evry_Item *it; + Evry_Selector *sel = selectors[1]; + char match1[128]; + char match2[128]; + int prio; - if (p->items) return 1; - - EINA_LIST_FOREACH(s->cur_actions, l, act) + if (p->items) { - Evry_Item *it; - - it = E_NEW(Evry_Item, 1); - it->label = eina_stringshare_add(act->name); - it->data[0] = act; - - p->items = eina_list_append(p->items, it); + EINA_LIST_FREE(p->items, it) + evry_item_free(it); + p->items = NULL; } + snprintf(match1, sizeof(match1), "%s*", input); + snprintf(match2, sizeof(match2), "*%s*", input); + + EINA_LIST_FOREACH(sel->actions, l, act) + { + if (input) + { + if (e_util_glob_case_match(act->name, match1)) + prio = 1; + else if (e_util_glob_case_match(act->name, match2)) + prio = 2; + else prio = 0; + } + + if (!input || prio) + { + it = evry_item_new(p, act->name); + it->priority = prio; + it->data[0] = act; + + p->items = eina_list_append(p->items, it); + } + } + + /* if (input) TODO sort */ if (p->items) return 1; return 0; } -static int -_evry_plug_act_select_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input __UNUSED__) +static void +_evry_plug_actions_cleanup(Evry_Plugin *p) { + Evry_Item *it; + Evry_Selector *sel = selectors[1]; + + EINA_LIST_FREE(p->items, it) + evry_item_free(it); + p->items = NULL; + + eina_list_free(sel->actions); + sel->actions = NULL; +} + +static Evas_Object * +_evry_plug_actions_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) +{ + Evas_Object *o; Evry_Action *act = it->data[0]; - cur_state->cur_action = act; - if (strcmp(act->type_in2, "NONE")) + + if (!act) return NULL; + + if (act->icon_get) + o = act->icon_get(act, e); + else if (act->icon) { - /* XXX hackish - param for push? */ - cur_state->request_type = act->type_in2; - _evry_push_state(); - - return 0; - } - else - { - act->action(act); - return 1; + o = e_icon_add(e); + evry_icon_theme_set(o, act->icon); } + + return o; +} + +static Evry_Plugin * +_evry_plug_aggregator_new(void) +{ + Plugin_Config *pc; + Evry_Plugin *p = E_NEW(Evry_Plugin, 1); + p->name = "All"; + p->type_in = "NONE"; + p->type_out = "NONE"; + p->cleanup = &_evry_plug_aggregator_cleanup; + p->fetch = &_evry_plug_aggregator_fetch; + p->action = &_evry_plug_aggregator_action; + p->icon_get = &_evry_plug_aggregator_item_icon_get; + + pc = E_NEW(Plugin_Config, 1); + pc->name = eina_stringshare_add(p->name); + pc->enabled = 1; + pc->priority = 100; + p->config = pc; + + return p; } static void -_evry_plug_act_select_cleanup(Evry_Plugin *p) +_evry_plug_aggregator_free(Evry_Plugin *p) { - Evry_Item *it; + if (p->config->name) eina_stringshare_del(p->config->name); + E_FREE(p->config); + E_FREE(p); +} - if (!cur_state) return; - - EINA_LIST_FREE(p->items, it) +static int +_evry_plug_aggregator_fetch(Evry_Plugin *p, const char *input __UNUSED__) +{ + Evry_Selector *selector = p->private; + Evry_State *s = selector->state; + Eina_List *l, *ll; + Evry_Plugin *plugin; + Evry_Item *it; + int cnt; + + if (p->items) { - eina_stringshare_del(it->label); - E_FREE(it); + eina_list_free(p->items); + p->items = NULL; + } + + EINA_LIST_FOREACH(s->cur_plugins, l, plugin) + { + for (cnt = 0, ll = plugin->items; ll && cnt < 15; ll = ll->next, cnt++) + { + it = ll->data; + p->items = eina_list_append(p->items, it); + } } - eina_list_free(cur_state->cur_actions); - cur_state->cur_actions = NULL; + return 1; +} +static int +_evry_plug_aggregator_action(Evry_Plugin *p, Evry_Item *it, const char *input) +{ + if (it->plugin && it->plugin->action) + return it->plugin->action(it->plugin, it, input); + + return 0; +} + +static void +_evry_plug_aggregator_cleanup(Evry_Plugin *p) +{ + eina_list_free(p->items); p->items = NULL; } -static void -_evry_plug_act_select_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it __UNUSED__, Evas *e __UNUSED__) +static Evas_Object * +_evry_plug_aggregator_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e) { - /* Evry_Action *act = it->data[0]; */ + if (it->plugin && it->plugin->icon_get) + return it->plugin->icon_get(it->plugin, it, e); - /* if (act->icon_get) - * it->o_icon = act->icon_get(act, e); */ + return NULL; } +EAPI void +evry_plugin_async_update(Evry_Plugin *p, int action) +{ + Evry_State *s; + + if (!win) return; + + s = selector->state; + + if (!s || !eina_list_data_find(s->plugins, p)) return; + + if (action == EVRY_ASYNC_UPDATE_ADD) + { + if (!p->items) return; + + if (!eina_list_data_find(s->cur_plugins, p)) + { + s->cur_plugins = eina_list_append(s->cur_plugins, p); + if (!s->plugin) _evry_select_plugin(s, p); + } + + /* */ + if (eina_list_count(s->cur_plugins) > 1) + { + if (s->plugin == selector->aggregator) + _evry_list_clear_list(s); + + selector->aggregator->fetch(selector->aggregator, NULL); + + if(!eina_list_data_find(s->cur_plugins, selector->aggregator)) + s->cur_plugins = eina_list_prepend(s->cur_plugins, + selector->aggregator); + } + + if (list->visible) + _evry_list_tabs_update(s); + + if ((s->plugin == p) || (s->plugin == selector->aggregator)) + { + p = s->plugin; + + if ((s->item_auto_selected) && + (s->plugin->items->data != s->sel_item)) + { + s->sel_item = NULL; + _evry_selector_update(selector); + } + + /* if (s->plugin == selector->aggregator) + * _evry_list_clear_list(s); + * else */ + { + Eina_List *l; + Evry_Item *it; + evas_event_freeze(list->popup->evas); + e_box_freeze(list->o_list); + EINA_LIST_FOREACH(p->items, l, it) + if (it->o_bg) e_box_unpack(it->o_bg); + + e_box_thaw(list->o_list); + evas_event_thaw(list->popup->evas); + } + + _evry_list_show_items(s, p); + + if (list->visible && s->sel_item) + { + /* TODO check this again!*/ + if (s->item_auto_selected || + !eina_list_data_find(p->items, s->sel_item)) + { + _evry_list_item_desel(s, s->sel_item); + s->sel_item = p->items->data; + } + _evry_list_item_sel(s, s->sel_item); + _evry_list_scroll_to(s, s->sel_item); + } + } + /* else if (/\*s->plugin_auto_selected &&*\/ p->trigger && + * (!strncmp(s->input, p->trigger, strlen(p->trigger)))) + * { + * _evry_list_clear_list(s); + * _evry_list_show_items(s, p); + * } */ + else if (s->plugin) + _evry_list_tab_scroll_to(s, s->plugin); + + _evry_selector_update(selector); + } + else if ((action == EVRY_ASYNC_UPDATE_CLEAR) && (s->plugin == p)) + { + _evry_list_clear_list(s); + } +} + + +/* static int + * _evry_cb_mouse_down(void *data __UNUSED__, int type __UNUSED__, void *event) + * { + * Ecore_Event_Mouse_Button *ev; + * Evry_State *s =state; + * + * ev = event; + * if (ev->event_window != input_window) return 1; + * + * if (item_mouseover) + * { + * if (s->sel_item != item_mouseover) + * { + * if (s->sel_item) _evry_list_item_desel(s->sel_item); + * s->sel_item = item_mouseover; + * _evry_list_item_sel(s->sel_item); + * } + * } + * else + * { + * evas_event_feed_mouse_up(popup_list->evas, ev->buttons, 0, ev->timestamp, NULL); + * } + * + * return 1; + * } + * + * static int + * _evry_cb_mouse_up(void *data __UNUSED__, int type __UNUSED__, void *event) + * { + * Ecore_Event_Mouse_Button *ev; + * + * ev = event; + * if (ev->event_window != input_window) return 1; + * + * if (item_mouseover) + * { + * if (ev->buttons == 1) + * _evry_plugin_action(1); + * else if (ev->buttons == 3) + * _evry_plugin_action(0); + * } + * else + * { + * evas_event_feed_mouse_up(popup_list->evas, ev->buttons, 0, ev->timestamp, NULL); + * } + * + * return 1; + * } + * + * static int + * _evry_cb_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event) + * { + * Ecore_Event_Mouse_Move *ev; + * Evry_State *s =state; + * + * ev = event; + * if (ev->event_window != input_window) return 1; + * + * if (!ev_last_is_mouse) + * { + * ev_last_is_mouse = 1; + * if (item_mouseover) + * { + * if (s->sel_item && (s->sel_item != item_mouseover)) + * _evry_list_item_desel(s->sel_item); + * if (!s->sel_item || (s->sel_item != item_mouseover)) + * { + * s->sel_item = item_mouseover; + * _evry_list_item_sel(s->sel_item); + * } + * } + * } + * + * evas_event_feed_mouse_move(popup_list->evas, ev->x - popup_list->x, + * ev->y - popup_list->y, ev->timestamp, NULL); + * + * return 1; + * } + * + * static int + * _evry_cb_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event) + * { + * Ecore_Event_Mouse_Wheel *ev; + * + * ev = event; + * if (ev->event_window != input_window) return 1; + * + * ev_last_is_mouse = 0; + * + * if (ev->z < 0) /\* up *\/ + * { + * int i; + * + * for (i = ev->z; i < 0; i++) _evry_list_item_prev(); + * } + * else if (ev->z > 0) /\* down *\/ + * { + * int i; + * + * for (i = ev->z; i > 0; i--) _evry_list_item_next(); + * } + * return 1; + * } + * + * static void + * _evry_cb_item_mouse_in(void *data, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) + * { + * Evry_State *s =state; + * + * if (!ev_last_is_mouse) return; + * + * item_mouseover = data; + * + * if (s->sel_item) _evry_list_item_desel(s->sel_item); + * if (!(s->sel_item = data)) return; + * _evry_list_item_sel(s->sel_item); + * } + * + * static void + * _evry_cb_item_mouse_out(void *data __UNUSED__, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) + * { + * item_mouseover = NULL; + * } */ + + +/* static int + * _evry_cb_plugin_sort_by_trigger(const void *data1, const void *data2) + * { + * const Evry_Plugin *p1 = data1; + * const Evry_Plugin *p2 = data2; + * if (p1->trigger) + * { + * if (!strncmp(state->input, p1->trigger, strlen(p1->trigger))) + * return 1; + * } + * + * return p1->config->priority - p2->config->priority; + * } */ + + +/* taken from e_utils. just changed 48 to 72.. we need + evry_icon_theme_set(Evas_Object *obj, const char *icon, + size:small, mid, large) imo */ +static int +_evry_icon_theme_set(Evas_Object *obj, const char *icon) +{ + const char *file; + char buf[4096]; + + if ((!icon) || (!icon[0])) return 0; + snprintf(buf, sizeof(buf), "e/icons/%s", icon); + file = e_theme_edje_file_get("base/theme/icons", buf); + if (file[0]) + { + e_icon_file_edje_set(obj, file, buf); + return 1; + } + return 0; +} + +static int +_evry_icon_fdo_set(Evas_Object *obj, const char *icon) +{ + char *path = NULL; + unsigned int size; + + if ((!icon) || (!icon[0])) return 0; + size = e_util_icon_size_normalize(72 * e_scale); + path = efreet_icon_path_find(e_config->icon_theme, icon, size); + if (!path) return 0; + e_icon_file_set(obj, path); + E_FREE(path); + return 1; +} + +EAPI int +evry_icon_theme_set(Evas_Object *obj, const char *icon) +{ + if (e_config->icon_theme_overrides) + { + if (_evry_icon_fdo_set(obj, icon)) + return 1; + return _evry_icon_theme_set(obj, icon); + } + else + { + if (_evry_icon_theme_set(obj, icon)) + return 1; + return _evry_icon_fdo_set(obj, icon); + } +} diff --git a/src/modules/everything/evry_config.c b/src/modules/everything/evry_config.c index b492a91ff..4e29574e2 100644 --- a/src/modules/everything/evry_config.c +++ b/src/modules/everything/evry_config.c @@ -7,6 +7,9 @@ static void *_create_data (E_Config_Dialog *cfd); static void _free_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static int _basic_apply_data (E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata); static Evas_Object *_basic_create_widgets (E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata); +/* static int _subject = type_subject; + * static int _action = type_action; + * static int _object = type_object; */ struct _E_Config_Dialog_Data @@ -15,8 +18,13 @@ struct _E_Config_Dialog_Data int scroll_animate; - Evas_Object *l_avail; - + Evas_Object *l_subject; + Evas_Object *l_action; + Evas_Object *l_object; + + Eina_List *p_subject; + Eina_List *p_action; + Eina_List *p_object; }; @@ -45,9 +53,20 @@ evry_config_dialog(E_Container *con, const char *params __UNUSED__) static void _fill_data(E_Config_Dialog_Data *cfdata) { + Eina_List *l; + Evry_Plugin *p; + cfdata->scroll_animate = evry_conf->scroll_animate; cfdata->height = evry_conf->height; cfdata->width = evry_conf->width; + + EINA_LIST_FOREACH(evry_conf->plugins, l, p) + if (p->type == type_subject) + cfdata->p_subject = eina_list_append(cfdata->p_subject, p); + else if (p->type == type_action) + cfdata->p_action = eina_list_append(cfdata->p_action, p); + else if (p->type == type_object) + cfdata->p_object = eina_list_append(cfdata->p_object, p); } static void * @@ -63,9 +82,21 @@ _create_data(E_Config_Dialog *cfd __UNUSED__) static void _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { + eina_list_free(cfdata->p_subject); + eina_list_free(cfdata->p_action); + eina_list_free(cfdata->p_object); + E_FREE(cfdata); } +static int +_evry_cb_plugin_sort(const void *data1, const void *data2) +{ + const Evry_Plugin *p1 = data1; + const Evry_Plugin *p2 = data2; + return p1->config->priority - p2->config->priority; +} + static int _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) { @@ -73,12 +104,16 @@ _basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata) evry_conf->height = cfdata->height; evry_conf->scroll_animate = cfdata->scroll_animate; + evry_conf->plugins = eina_list_sort(evry_conf->plugins, + eina_list_count(evry_conf->plugins), + _evry_cb_plugin_sort); + e_config_save_queue(); return 1; } static void -_fill_list(Evas_Object *obj, int enabled __UNUSED__) +_fill_list(Eina_List *plugins, Evas_Object *obj, int enabled __UNUSED__) { Evas *evas; Evas_Coord w; @@ -92,7 +127,7 @@ _fill_list(Evas_Object *obj, int enabled __UNUSED__) e_widget_ilist_freeze(obj); e_widget_ilist_clear(obj); - EINA_LIST_FOREACH(evry_conf->plugins, l, p) + EINA_LIST_FOREACH(plugins, l, p) e_widget_ilist_append(obj, NULL, p->name, NULL, p, NULL); e_widget_ilist_go(obj); @@ -104,7 +139,7 @@ _fill_list(Evas_Object *obj, int enabled __UNUSED__) } static void -_plugin_move(Evas_Object *list, int dir) +_plugin_move(Eina_List *plugins, Evas_Object *list, int dir) { int sel; Eina_List *l1, *l2; @@ -116,40 +151,32 @@ _plugin_move(Evas_Object *list, int dir) Evry_Plugin *p; int prio = 0; - l1 = eina_list_nth_list(evry_conf->plugins, sel); - l2 = eina_list_nth_list(evry_conf->plugins, sel + dir); + l1 = eina_list_nth_list(plugins, sel); + l2 = eina_list_nth_list(plugins, sel + dir); if (!l1 || !l2) return; p = l1->data; l1->data = l2->data; l2->data = p; - _fill_list(list, 0); + _fill_list(plugins, list, 0); e_widget_ilist_selected_set(list, sel + dir); - EINA_LIST_FOREACH(evry_conf->plugins, l1, p) + EINA_LIST_FOREACH(plugins, l1, p) p->config->priority = prio++; } } static void -_plugin_move_up_cb(void *data, void *data2 __UNUSED__) +_plugin_move_up_cb(void *data, void *data2) { - E_Config_Dialog_Data *cfdata; - - cfdata = data; - - _plugin_move(cfdata->l_avail, -1); + _plugin_move(data2, data, -1); } static void -_plugin_move_down_cb(void *data, void *data2 __UNUSED__) +_plugin_move_down_cb(void *data, void *data2) { - E_Config_Dialog_Data *cfdata; - - cfdata = data; - - _plugin_move(cfdata->l_avail, 1); + _plugin_move(data2, data, 1); } static Evas_Object * @@ -164,36 +191,84 @@ _basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dial of = e_widget_framelist_add(evas, _("General Settings"), 0); ob = e_widget_label_add(evas, _("Popup Width")); e_widget_framelist_object_append(of, ob); - ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 300, 800, 5, 0, NULL, &(cfdata->width), 200); + ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), + 300, 800, 5, 0, NULL, + &(cfdata->width), 200); e_widget_framelist_object_append(of, ob); ob = e_widget_label_add(evas, _("Popup Height")); e_widget_framelist_object_append(of, ob); - ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), 200, 800, 5, 0, NULL, &(cfdata->height), 200); + ob = e_widget_slider_add(evas, 1, 0, _("%1.0f"), + 200, 800, 5, 0, NULL, + &(cfdata->height), 200); e_widget_framelist_object_append(of, ob); e_widget_list_object_append(o, of, 1, 1, 0.5); of = e_widget_framelist_add(evas, _("Scroll Settings"), 0); - ob = e_widget_check_add(evas, _("Scroll Animate"), &(cfdata->scroll_animate)); + ob = e_widget_check_add(evas, _("Scroll Animate"), + &(cfdata->scroll_animate)); e_widget_framelist_object_append(of, ob); e_widget_list_object_append(o, of, 1, 1, 0.5); - e_widget_toolbook_page_append(otb, NULL, _("General Settings"), o, 0, 0, 0, 0, 0.5, 0.0); - e_widget_toolbook_page_show(otb, 0); + e_widget_toolbook_page_append(otb, NULL, _("General Settings"), + o, 0, 0, 0, 0, 0.5, 0.0); - of = e_widget_framelist_add(evas, _("Available Plugins"), 0); + ob = e_widget_list_add(evas, 1, 1); + of = e_widget_framelist_add(evas, _("Subject Plugins"), 0); o = e_widget_ilist_add(evas, 24, 24, NULL); - cfdata->l_avail = o; - /* e_widget_ilist_multi_select_set(ol, 1); */ + cfdata->l_subject = o; /* e_widget_on_change_hook_set(ol, _avail_list_cb_change, cfdata); */ - _fill_list(o, 0); + _fill_list(cfdata->p_subject, o, 0); e_widget_framelist_object_append(of, o); - o = e_widget_button_add(evas, _("Move Up"), NULL, _plugin_move_up_cb, cfdata, NULL); + o = e_widget_button_add(evas, _("Move Up"), NULL, + _plugin_move_up_cb, + cfdata->l_subject, + cfdata->p_subject); e_widget_framelist_object_append(of, o); - o = e_widget_button_add(evas, _("Move Down"), NULL, _plugin_move_down_cb, cfdata, NULL); + o = e_widget_button_add(evas, _("Move Down"), NULL, + _plugin_move_down_cb, + cfdata->l_subject, + cfdata->p_subject); e_widget_framelist_object_append(of, o); + e_widget_list_object_append(ob, of, 1, 1, 0.5); - e_widget_toolbook_page_append(otb, NULL, _("Plugins"), of, 0, 0, 0, 0, 0.5, 0.0); + of = e_widget_framelist_add(evas, _("Action Plugins"), 0); + o = e_widget_ilist_add(evas, 24, 24, NULL); + cfdata->l_action = o; + _fill_list(cfdata->p_action, o, 0); + e_widget_framelist_object_append(of, o); + o = e_widget_button_add(evas, _("Move Up"), NULL, + _plugin_move_up_cb, + cfdata->l_action, + cfdata->p_action); + e_widget_framelist_object_append(of, o); + o = e_widget_button_add(evas, _("Move Down"), NULL, + _plugin_move_down_cb, + cfdata->l_action, + cfdata->p_action); + e_widget_framelist_object_append(of, o); + e_widget_list_object_append(ob, of, 1, 1, 0.5); + + of = e_widget_framelist_add(evas, _("Object Plugins"), 0); + o = e_widget_ilist_add(evas, 24, 24, NULL); + cfdata->l_object = o; + _fill_list(cfdata->p_object, o, 0); + e_widget_framelist_object_append(of, o); + o = e_widget_button_add(evas, _("Move Up"), NULL, + _plugin_move_up_cb, + cfdata->l_object, + cfdata->p_object); + e_widget_framelist_object_append(of, o); + o = e_widget_button_add(evas, _("Move Down"), NULL, + _plugin_move_down_cb, + cfdata->l_object, + cfdata->p_object); + e_widget_framelist_object_append(of, o); + e_widget_list_object_append(ob, of, 1, 1, 0.5); + + e_widget_toolbook_page_append(otb, NULL, _("Plugins"), + ob, 0, 0, 0, 0, 0.5, 0.0); + e_widget_toolbook_page_show(otb, 1); return otb; } diff --git a/src/modules/everything/evry_plug_apps.c b/src/modules/everything/evry_plug_apps.c index a660eb082..1851a411f 100644 --- a/src/modules/everything/evry_plug_apps.c +++ b/src/modules/everything/evry_plug_apps.c @@ -16,44 +16,44 @@ static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); static void _cleanup(Evry_Plugin *p); static void _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio); static int _cb_sort(const void *data1, const void *data2); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); -static int _exec_app_action(Evry_Action *act); +static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); +static int _exec_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input); static int _exec_app_check_item(Evry_Action *act, Evry_Item *it); -static int _edit_app_action(Evry_Action *act); +static int _edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input); static int _edit_app_check_item(Evry_Action *act, Evry_Item *it); -static int _new_app_action(Evry_Action *act); +static int _new_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input); static int _new_app_check_item(Evry_Action *act, Evry_Item *it); -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - static Evry_Plugin *p1; static Evry_Plugin *p2; static Evry_Action *act; +static Evry_Action *act1; static Evry_Action *act2; static Evry_Action *act3; -static Inst *inst; - +/* static Inst *inst = NULL; */ +static Eina_List *exe_path = NULL; static Eina_Bool _init(void) { + char *path, *p, *last; + p1 = E_NEW(Evry_Plugin, 1); p1->name = "Applications"; + p1->type = type_subject; p1->type_in = "NONE"; p1->type_out = "APPLICATION"; p1->need_query = 0; p1->begin = &_begin; p1->fetch = &_fetch; - p1->action = &_action; + /* p1->action = &_action; */ p1->cleanup = &_cleanup; p1->icon_get = &_item_icon_get; evry_plugin_register(p1); p2 = E_NEW(Evry_Plugin, 1); p2->name = "Open With..."; + p2->type = type_action; p2->type_in = "FILE"; p2->type_out = "NONE"; p2->need_query = 0; @@ -65,54 +65,91 @@ _init(void) evry_plugin_register(p2); act = E_NEW(Evry_Action, 1); - act->name = "Open File..."; + act->name = "Launch"; + act->is_default = EINA_TRUE; act->type_in1 = "APPLICATION"; - act->type_in2 = "FILE"; - act->type_out = "NONE"; act->action = &_exec_app_action; act->check_item = &_exec_app_check_item; + act->icon = "everything-launch"; evry_action_register(act); + + act1 = E_NEW(Evry_Action, 1); + act1->name = "Open File..."; + act1->type_in1 = "APPLICATION"; + act1->type_in2 = "FILE"; + act1->action = &_exec_app_action; + act1->check_item = &_exec_app_check_item; + act1->icon = "everything-launch"; + evry_action_register(act1); act2 = E_NEW(Evry_Action, 1); act2->name = "Edit Application Entry"; act2->type_in1 = "APPLICATION"; - act2->type_in2 = "NONE"; - act2->type_out = "NONE"; act2->action = &_edit_app_action; act2->check_item = &_edit_app_check_item; + act2->icon = "everything-launch"; evry_action_register(act2); act3 = E_NEW(Evry_Action, 1); act3->name = "New Application Entry"; act3->type_in1 = "APPLICATION"; - act3->type_in2 = "NONE"; - act3->type_out = "NONE"; act3->action = &_new_app_action; act3->check_item = &_new_app_check_item; + act3->icon = "everything-launch"; evry_action_register(act3); - inst = NULL; - + /* taken from e_exebuf.c */ + path = getenv("PATH"); + if (path) + { + path = strdup(path); + last = path; + for (p = path; p[0]; p++) + { + if (p[0] == ':') p[0] = '\0'; + if (p[0] == 0) + { + exe_path = eina_list_append(exe_path, strdup(last)); + last = p + 1; + } + } + if (p > last) + exe_path = eina_list_append(exe_path, strdup(last)); + free(path); + } + return 1; } static void _shutdown(void) { + char *str; + evry_plugin_unregister(p1); evry_plugin_unregister(p2); evry_action_unregister(act); + evry_action_unregister(act1); evry_action_unregister(act2); evry_action_unregister(act3); + E_FREE(p1); + E_FREE(p2); + E_FREE(act); + E_FREE(act1); + E_FREE(act2); + E_FREE(act3); + + EINA_LIST_FREE(exe_path, str) + free(str); + } static int -_begin(Evry_Plugin *p __UNUSED__, Evry_Item *it) +_begin(Evry_Plugin *p, Evry_Item *it) { const char *mime; - - if (inst) return 0; - + Inst *inst = NULL; + if (it) { if (!it->uri) return 0; @@ -127,8 +164,8 @@ _begin(Evry_Plugin *p __UNUSED__, Evry_Item *it) inst = E_NEW(Inst, 1); inst->candidate = it; - inst->apps = efreet_util_desktop_mime_list(mime); - + if (strcmp(mime, "Folder")) + inst->apps = efreet_util_desktop_mime_list(mime); if (!inst->apps) { Efreet_Desktop *desktop; @@ -137,22 +174,21 @@ _begin(Evry_Plugin *p __UNUSED__, Evry_Item *it) inst->apps = eina_list_append(inst->apps, desktop); } } - else - { - inst = E_NEW(Inst, 1); - } + p->private = inst; + return 1; } static int -_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input) +_action(Evry_Plugin *p, Evry_Item *it, const char *input) { E_Zone *zone; Evry_App *app = NULL; Efreet_Desktop *desktop = NULL; Eina_List *files = NULL; - + Inst *inst = p->private; + if (it) app = it->data[0]; if (app && app->desktop) @@ -187,10 +223,16 @@ _action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input) zone = e_util_zone_current_get(e_manager_current_get()); - e_exec(zone, desktop, NULL, files, "everything"); - - if (inst && inst->candidate && inst->candidate->mime) - e_exehist_mime_desktop_add(inst->candidate->mime, desktop); + if (app->desktop) + { + e_exec(zone, desktop, NULL, files, "everything"); + + if (inst && inst->candidate && inst->candidate->mime) + e_exehist_mime_desktop_add(inst->candidate->mime, desktop); + } + else + /* dont put custom commands in exec history.. */ + e_exec(zone, desktop, NULL, files, NULL); if (!it) efreet_desktop_free(desktop); @@ -211,16 +253,18 @@ _list_free(Evry_Plugin *p) EINA_LIST_FREE(p->items, it) { - if (it->label) eina_stringshare_del(it->label); app = it->data[0]; + if (app->file) eina_stringshare_del(app->file); E_FREE(app); - E_FREE(it); + evry_item_free(it); } } static void _cleanup(Evry_Plugin *p) { + Inst *inst = p->private; + _list_free(p); if (inst) @@ -229,7 +273,7 @@ _cleanup(Evry_Plugin *p) E_FREE(inst); } - inst = NULL; + p->private = NULL; } static int @@ -242,9 +286,19 @@ _fetch(Evry_Plugin *p, const char *input) char match2[4096]; Evry_Item *it; Evry_App *app; + Inst *inst = p->private; + + if (!inst) + { + inst = E_NEW(Inst, 1); + p->private = inst; + } _list_free(p); + snprintf(match1, sizeof(match1), "%s*", input); + snprintf(match2, sizeof(match2), "*%s*", input); + if (inst && inst->apps) { if (!input) @@ -254,9 +308,6 @@ _fetch(Evry_Plugin *p, const char *input) } else { - snprintf(match1, sizeof(match1), "%s*", input); - snprintf(match2, sizeof(match2), "*%s*", input); - EINA_LIST_FOREACH(inst->apps, l, desktop) { if (e_util_glob_case_match(desktop->exec, match1)) @@ -284,29 +335,31 @@ _fetch(Evry_Plugin *p, const char *input) snprintf(match1, sizeof(match1), "%s*", input); l = efreet_util_desktop_exec_glob_list(match1); EINA_LIST_FREE(l, desktop) - _item_add(p, desktop, NULL, 1); + if (e_util_glob_match(ecore_file_file_get(desktop->exec), match2)) + _item_add(p, desktop, NULL, 1); l = efreet_util_desktop_name_glob_list(match1); EINA_LIST_FREE(l, desktop) - _item_add(p, desktop, NULL, 3); + _item_add(p, desktop, NULL, 3); snprintf(match1, sizeof(match1), "*%s*", input); l = efreet_util_desktop_exec_glob_list(match1); EINA_LIST_FREE(l, desktop) - _item_add(p, desktop, NULL, 2); + if (e_util_glob_match(ecore_file_file_get(desktop->exec), match1)) + _item_add(p, desktop, NULL, 2); l = efreet_util_desktop_name_glob_list(match1); EINA_LIST_FREE(l, desktop) _item_add(p, desktop, NULL, 4); // TODO make these optional/configurable - l = efreet_util_desktop_generic_name_glob_list(match1); - EINA_LIST_FREE(l, desktop) - _item_add(p, desktop, NULL, 5); + /* l = efreet_util_desktop_generic_name_glob_list(match1); + * EINA_LIST_FREE(l, desktop) + * _item_add(p, desktop, NULL, 5); */ - l = efreet_util_desktop_comment_glob_list(match1); - EINA_LIST_FREE(l, desktop) - _item_add(p, desktop, NULL, 5); + /* l = efreet_util_desktop_comment_glob_list(match1); + * EINA_LIST_FREE(l, desktop) + * _item_add(p, desktop, NULL, 5); */ } else if (!p->items) { @@ -322,15 +375,32 @@ _fetch(Evry_Plugin *p, const char *input) inst->added = NULL; } - it = E_NEW(Evry_Item, 1); - app = E_NEW(Evry_App, 1); - app->file = eina_stringshare_add(input); - app->desktop = NULL; - it->data[0] = app; - it->priority = 100; - it->label = eina_stringshare_add("Run Command"); - p->items = eina_list_append(p->items, it); - + if (input || p == p2) /* FIXME plugins is 'Open with'.. hackish */ + { + int found = 0; + char *path; + EINA_LIST_FOREACH(exe_path, l, path) + { + snprintf(match1, 4096, "%s/%s", path, input); + if (ecore_file_exists(match1)) + { + found = 1; + break; + } + } + if (found || p == p2) + { + snprintf(match1, 4096, "xterm -hold -e %s", input); + it = evry_item_new(p, "Run Command"); + app = E_NEW(Evry_App, 1); + app->file = eina_stringshare_add(match1); + app->desktop = NULL; + it->data[0] = app; + it->priority = 100; + p->items = eina_list_append(p->items, it); + } + } + if (p->items) { p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort); @@ -346,7 +416,8 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio) Evry_Item *it; Evry_App *app; Efreet_Desktop *desktop2; - + Inst *inst = p->private; + if (desktop) { Eina_List *l; @@ -410,35 +481,38 @@ _item_add(Evry_Plugin *p, Efreet_Desktop *desktop, char *file, int prio) file = NULL; } - it = E_NEW(Evry_Item, 1); + if (desktop) + it = evry_item_new(p, desktop->name); + else + it = evry_item_new(p, file); + app = E_NEW(Evry_App, 1); app->desktop = desktop; app->file = file; it->data[0] = app; it->priority = prio; - if (desktop) - it->label = eina_stringshare_add(desktop->name); - else - it->label = eina_stringshare_add(file); - it->o_icon = NULL; p->items = eina_list_append(p->items, it); } -static void +static Evas_Object * _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) { + Evas_Object *o = NULL; Evry_App *app = it->data[0]; if (app->desktop) - it->o_icon = e_util_desktop_icon_add(app->desktop, 24, e); + o = e_util_desktop_icon_add(app->desktop, 64, e); - if (!it->o_icon) + if (!o) { - it->o_icon = edje_object_add(e); - /* e_util_icon_theme_set(it->o_icon, "system-run") */ - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/system-run"); + /* o = edje_object_add(e); */ + /* e_theme_edje_object_set(o, "base/theme/fileman", "e/icons/system-run"); */ + o = e_icon_add(e); + evry_icon_theme_set(o, "system-run"); + } + return o; } static int @@ -494,53 +568,58 @@ _exec_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it) static int -_exec_app_action(Evry_Action *act) +_exec_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input) { - if (act->thing1 && act->thing2) + E_Zone *zone; + Evry_App *app = NULL; + Efreet_Desktop *desktop = NULL; + Eina_List *files = NULL; + + if (!it1 || !it1->data[0]) return 0; + + + app = it1->data[0]; + + if (app->desktop) + desktop = app->desktop; + else { - E_Zone *zone; - Evry_App *app = NULL; - Efreet_Desktop *desktop = NULL; - Eina_List *files = NULL; - - app = act->thing1->data[0]; - - if (app->desktop) - desktop = app->desktop; + desktop = efreet_desktop_empty_new(""); + if (strchr(app->file, '%')) + desktop->exec = strdup(app->file); else { - desktop = efreet_desktop_empty_new(""); - if (strchr(app->file, '%')) - desktop->exec = strdup(app->file); - else - { - int len = strlen(app->file) + 4; - desktop->exec = malloc(len); - if (desktop->exec) - snprintf(desktop->exec, len, "%s %%U", app->file); - } + int len = strlen(app->file) + 4; + desktop->exec = malloc(len); + if (desktop->exec) + snprintf(desktop->exec, len, "%s %%U", app->file); } + } - if (desktop) + if (desktop) + { + if (it2 && it2->uri) + files = eina_list_append(files, it2->uri); + + zone = e_util_zone_current_get(e_manager_current_get()); + + if (app->desktop) { - files = eina_list_append(files, act->thing2->uri); - - zone = e_util_zone_current_get(e_manager_current_get()); - e_exec(zone, desktop, NULL, files, "everything"); - - if (act->thing2->mime) - e_exehist_mime_desktop_add(act->thing2->mime, desktop); - - if (!app->desktop) - efreet_desktop_free(desktop); - - eina_list_free(files); - - return EVRY_ACTION_FINISHED; + if (it2 && it2->mime) + e_exehist_mime_desktop_add(it2->mime, desktop); } + else + /* dont put custom commands in exec history.. */ + e_exec(zone, desktop, NULL, files, NULL); + + if (!app->desktop) + efreet_desktop_free(desktop); - return EVRY_ACTION_CONTINUE; + if (files) + eina_list_free(files); + + return 1; } return 0; @@ -558,33 +637,29 @@ _edit_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it) static int -_edit_app_action(Evry_Action *act) +_edit_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input) { - if (act->thing1) - { - Evry_Item *it = act->thing1; - Evry_App *app = it->data[0]; - - Efreet_Desktop *desktop; - - if (app->desktop) - desktop = app->desktop; - else - { - char buf[128]; - snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file); - - desktop = efreet_desktop_empty_new(eina_stringshare_add(buf)); - /* XXX check if this gets freed by efreet*/ - desktop->exec = strdup(app->file); - } + Evry_App *app; + Efreet_Desktop *desktop; - e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); - - return 1; + if (!it1) return 0; + + app = it1->data[0]; + if (app->desktop) + desktop = app->desktop; + else + { + char buf[128]; + snprintf(buf, 128, "%s/.local/share/applications/%s.desktop", e_user_homedir_get(), app->file); + + desktop = efreet_desktop_empty_new(eina_stringshare_add(buf)); + /* XXX check if this gets freed by efreet*/ + desktop->exec = strdup(app->file); } - - return 0; + + e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); + + return 1; } @@ -603,62 +678,62 @@ _new_app_check_item(Evry_Action *act __UNUSED__, Evry_Item *it) static int -_new_app_action(Evry_Action *act) +_new_app_action(Evry_Action *act, Evry_Item *it1, Evry_Item *it2, const char *input) { - if (act->thing1) + Evry_App *app; + char *name; + char buf[4096]; + char *end; + Efreet_Desktop *desktop; + int i; + + if (!it1) return 0; + + app = it1->data[0]; + + if (app->desktop) + name = strdup(app->desktop->name); + else + /* TODO replace '/' and remove other special characters */ + name = strdup(app->file); + + if ((end = strchr(name, ' '))) + name[end - name] = '\0'; + + for (i = 0; i < 10; i++) { - Evry_Item *it = act->thing1; - Evry_App *app = it->data[0]; - char *name; - char buf[4096]; - char *end; - Efreet_Desktop *desktop; - int i; - - if (app->desktop) - name = strdup(app->desktop->name); - else - /* TODO replace '/' and remove other special characters */ - name = strdup(app->file); - - if ((end = strchr(name, ' '))) - name[end - name] = '\0'; - - for (i = 0; i < 10; i++) + snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop", e_user_homedir_get(), name, i); + if (ecore_file_exists(buf)) { - snprintf(buf, 4096, "%s/.local/share/applications/%s-%d.desktop", e_user_homedir_get(), name, i); - if (ecore_file_exists(buf)) - { - buf[0] = '\0'; - continue; - } - else break; + buf[0] = '\0'; + continue; } - - free(name); - - if (strlen(buf) == 0) - return 0; - - if (!app->desktop) - { - desktop = efreet_desktop_empty_new(buf); - desktop->exec = strdup(app->file); - } - else - { - efreet_desktop_save_as(app->desktop, buf); - /*XXX hackish - desktop is removed on save_as..*/ - efreet_desktop_new(app->desktop->orig_path); - - desktop = efreet_desktop_new(buf); - } - - e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); - - return 1; + else break; } - - return 0; + + free(name); + + if (strlen(buf) == 0) + return 0; + + if (!app->desktop) + { + desktop = efreet_desktop_empty_new(buf); + desktop->exec = strdup(app->file); + } + else + { + efreet_desktop_save_as(app->desktop, buf); + /*XXX hackish - desktop is removed on save_as..*/ + efreet_desktop_new(app->desktop->orig_path); + + desktop = efreet_desktop_new(buf); + } + + e_desktop_edit(e_container_current_get(e_manager_current_get()), desktop); + + return 1; } +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_aspell.c b/src/modules/everything/evry_plug_aspell.c index d0373a567..4e5d70529 100644 --- a/src/modules/everything/evry_plug_aspell.c +++ b/src/modules/everything/evry_plug_aspell.c @@ -2,15 +2,8 @@ #include "e_mod_main.h" #include - -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - static const char TRIGGER[] = "aspell "; static const char LANG_MODIFIER[] = "lang="; -static Ecore_X_Window clipboard_win = 0; typedef struct _Plugin Plugin; @@ -89,20 +82,13 @@ _item_add(Evry_Plugin *p, const char *word, int word_size, int prio) { Evry_Item *it; - it = E_NEW(Evry_Item, 1); + it = evry_item_new(p, NULL); if (!it) return; it->priority = prio; it->label = eina_stringshare_add_length(word, word_size); p->items = eina_list_append(p->items, it); } -static void -_item_del(Evry_Item *it) -{ - eina_stringshare_del(it->label); - E_FREE(it); -} - static void _suggestions_add(Evry_Plugin *p, const char *line) { @@ -143,7 +129,7 @@ _clear_list(Evry_Plugin *plugin) Evry_Item *it; evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR); EINA_LIST_FREE(plugin->items, it) - _item_del(it); + evry_item_free(it); } static int @@ -263,7 +249,7 @@ _fetch(Evry_Plugin *plugin, const char *input) else lang = NULL; - eina_stringshare_del(p->lang); + if (p->lang) eina_stringshare_del(p->lang); if (p->lang != lang) { p->lang = lang; @@ -288,7 +274,7 @@ _fetch(Evry_Plugin *plugin, const char *input) if (len < 1) return 1; input = eina_stringshare_add_length(input, len); - eina_stringshare_del(p->input); + if (p->input) eina_stringshare_del(p->input); if (p->input == input) return 1; @@ -302,44 +288,44 @@ _fetch(Evry_Plugin *plugin, const char *input) return 1; } -static int -_action(Evry_Plugin *plugin, Evry_Item *it, const char *input __UNUSED__) -{ - const char *label; - int len; - - if (!it) return EVRY_ACTION_CONTINUE; - - label = it->label; - len = eina_stringshare_strlen(label); - - if (!ecore_x_selection_primary_set(clipboard_win, label, len)) - fprintf(stderr, "ASPELL cannot set primary selection to %#x '%s'\n", - clipboard_win, label); - if (!ecore_x_selection_clipboard_set(clipboard_win, label, len)) - fprintf(stderr, "ASPELL cannot set clipboard selection to %#x '%s'\n", - clipboard_win, label); - - if (plugin->items) - { - Eina_List *l, *l_next; - Evry_Item *it2; - - evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR); - - EINA_LIST_FOREACH_SAFE(plugin->items, l, l_next, it2) - { - if (it == it2) continue; - plugin->items = eina_list_remove_list(plugin->items, l); - eina_stringshare_del(it2->label); - E_FREE(it2); - } - } - - evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_ADD); - - return EVRY_ACTION_FINISHED; -} +/* static int + * _action(Evry_Plugin *plugin, Evry_Item *it, const char *input __UNUSED__) + * { + * const char *label; + * int len; + * + * if (!it) return EVRY_ACTION_CONTINUE; + * + * label = it->label; + * len = eina_stringshare_strlen(label); + * + * if (!ecore_x_selection_primary_set(clipboard_win, label, len)) + * fprintf(stderr, "ASPELL cannot set primary selection to %#x '%s'\n", + * clipboard_win, label); + * if (!ecore_x_selection_clipboard_set(clipboard_win, label, len)) + * fprintf(stderr, "ASPELL cannot set clipboard selection to %#x '%s'\n", + * clipboard_win, label); + * + * if (plugin->items) + * { + * Eina_List *l, *l_next; + * Evry_Item *it2; + * + * evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_CLEAR); + * + * EINA_LIST_FOREACH_SAFE(plugin->items, l, l_next, it2) + * { + * if (it == it2) continue; + * plugin->items = eina_list_remove_list(plugin->items, l); + * eina_stringshare_del(it2->label); + * E_FREE(it2); + * } + * } + * + * evry_plugin_async_update(plugin, EVRY_ASYNC_UPDATE_ADD); + * + * return EVRY_ACTION_FINISHED; + * } */ static void _cleanup(Evry_Plugin *plugin) @@ -348,7 +334,7 @@ _cleanup(Evry_Plugin *plugin) Evry_Item *it; EINA_LIST_FREE(p->base.items, it) - _item_del(it); + evry_item_free(it); if (p->handler.data) { @@ -377,12 +363,6 @@ _cleanup(Evry_Plugin *plugin) } } -static void -_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e __UNUSED__) -{ - it->o_icon = NULL; -} - static Eina_Bool _init(void) { @@ -393,22 +373,17 @@ _init(void) p = E_NEW(Plugin, 1); p->base.name = "Spell Checker"; + p->base.type = type_subject; p->base.type_in = "NONE"; - p->base.type_out = "NONE"; + p->base.type_out = "TEXT"; + p->base.icon = "accessories-dictionary"; p->base.trigger = TRIGGER; p->base.need_query = 0; p->base.async_query = 1; p->base.begin = _begin; p->base.fetch = _fetch; - p->base.action = _action; + /* p->base.action = _action; */ p->base.cleanup = _cleanup; - p->base.icon_get = _item_icon_get; - - if (clipboard_win == 0) - { - clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1); - fprintf(stderr, "ASPELL clipboard_win=%#x\n", clipboard_win); - } evry_plugin_register(&p->base); @@ -429,8 +404,11 @@ _shutdown(void) _singleton = NULL; EINA_LIST_FREE(p->base.items, it) - _item_del(it); + evry_item_free(it); evry_plugin_unregister(&p->base); E_FREE(p); } + +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_border.c b/src/modules/everything/evry_plug_border.c index 639296e28..200998a01 100644 --- a/src/modules/everything/evry_plug_border.c +++ b/src/modules/everything/evry_plug_border.c @@ -2,11 +2,11 @@ #include "e_mod_main.h" static int _fetch(Evry_Plugin *p, const char *input); -static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); +/* static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); */ static void _cleanup(Evry_Plugin *p); static void _item_add(Evry_Plugin *p, E_Border *bd, int prio); static int _cb_sort(const void *data1, const void *data2); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); +static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); static Eina_Bool _init(void); static void _shutdown(void); @@ -21,11 +21,12 @@ _init(void) { p = E_NEW(Evry_Plugin, 1); p->name = "Windows"; + p->type = type_subject; p->type_in = "NONE"; p->type_out = "BORDER"; p->need_query = 0; p->fetch = &_fetch; - p->action = &_action; + /* p->action = &_action; */ p->cleanup = &_cleanup; p->icon_get = &_item_icon_get; evry_plugin_register(p); @@ -40,33 +41,6 @@ _shutdown(void) E_FREE(p); } -static int -_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input __UNUSED__) -{ - E_Border *bd; - E_Zone *zone; - - if (!it) return EVRY_ACTION_CONTINUE; - - bd = (E_Border *)it->data[0]; - zone = e_util_zone_current_get(e_manager_current_get()); - - if (bd->desk != (e_desk_current_get(zone))) - e_desk_show(bd->desk); - - if (bd->shaded) - e_border_unshade(bd, E_DIRECTION_UP); - - if (bd->iconic) - e_border_uniconify(bd); - else - e_border_raise(bd); - - /* e_border_focus_set(bd, 1, 1); */ - e_border_focus_set_with_pointer(bd); - - return EVRY_ACTION_FINISHED; -} static void _cleanup(Evry_Plugin *p) @@ -76,8 +50,7 @@ _cleanup(Evry_Plugin *p) EINA_LIST_FREE(p->items, it) { /* if (it->data[0]) e_object_unref(E_OBJECT(it->data[0])); */ - if (it->label) eina_stringshare_del(it->label); - E_FREE(it); + evry_item_free(it); } } @@ -133,10 +106,14 @@ _fetch(Evry_Plugin *p, const char *input) return 0; } -static void +static Evas_Object * _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) { - it->o_icon = e_border_icon_add(((E_Border *)it->data[0]), e); + Evas_Object *icon; + + icon = e_border_icon_add(((E_Border *)it->data[0]), e); + + return icon; } static void @@ -144,11 +121,11 @@ _item_add(Evry_Plugin *p, E_Border *bd, int prio) { Evry_Item *it; - it = E_NEW(Evry_Item, 1); + it = evry_item_new(p, e_border_name_get(bd)); + /* e_object_ref(E_OBJECT(bd)); */ it->data[0] = bd; it->priority = prio; - it->label = eina_stringshare_add(e_border_name_get(bd)); p->items = eina_list_append(p->items, it); } diff --git a/src/modules/everything/evry_plug_border_act.c b/src/modules/everything/evry_plug_border_act.c index f775816e8..282035a28 100644 --- a/src/modules/everything/evry_plug_border_act.c +++ b/src/modules/everything/evry_plug_border_act.c @@ -8,26 +8,192 @@ struct _Inst E_Border *border; }; -static int _begin(Evry_Plugin *p, Evry_Item *item); -static int _fetch(Evry_Plugin *p, const char *input); -static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); -static void _cleanup(Evry_Plugin *p); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); -static void _item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon); - -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - static Evry_Plugin *p; static Inst *inst; + +static void +_act_cb_border_switch_to(E_Border *bd) +{ + E_Zone *zone; + + zone = e_util_zone_current_get(e_manager_current_get()); + + if (bd->desk != (e_desk_current_get(zone))) + e_desk_show(bd->desk); + + if (bd->shaded) + e_border_unshade(bd, E_DIRECTION_UP); + + if (bd->iconic) + e_border_uniconify(bd); + else + e_border_raise(bd); + + /* e_border_focus_set(bd, 1, 1); */ + e_border_focus_set_with_pointer(bd); +} + +static void +_act_cb_border_fullscreen(E_Border *bd) +{ + if (!bd->fullscreen) + e_border_fullscreen(bd, E_FULLSCREEN_RESIZE); + else + e_border_unfullscreen(bd); +} + +static void +_act_cb_border_close(E_Border *bd) +{ + if (!bd->lock_close) e_border_act_close_begin(bd); +} + +static void +_act_cb_border_minimize(E_Border *bd) +{ + if (!bd->lock_user_iconify) e_border_iconify(bd); +} + +static void +_act_cb_border_unminimize(E_Border *bd) +{ + if (!bd->lock_user_iconify) e_border_uniconify(bd); +} + +static int +_begin(Evry_Plugin *p __UNUSED__, Evry_Item *item) +{ + E_Border *bd; + + bd = item->data[0]; + /* e_object_ref(E_OBJECT(bd)); */ + inst->border = bd; + + return 1; +} + +static int +_cb_sort(const void *data1, const void *data2) +{ + const Evry_Item *it1, *it2; + + it1 = data1; + it2 = data2; + + return (it1->priority - it2->priority); +} + +static void +_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon, char *m1, char *m2) +{ + Evry_Item *it; + int prio = 1; + + if (m1[0] && m2[0]) + { + if (e_util_glob_case_match(label, m1)) + prio = 1; + else if (e_util_glob_case_match(label, m2)) + prio = 2; + else + prio = 0; + } + + if (!prio) return; + + it = evry_item_new(p, label); + it->data[0] = action_cb; + it->data[1] = (void *) eina_stringshare_add(icon); + it->priority = prio; + + p->items = eina_list_prepend(p->items, it); +} + +static void +_cleanup(Evry_Plugin *p) +{ + Evry_Item *it; + + EINA_LIST_FREE(p->items, it) + { + if (it->data[1]) eina_stringshare_del((const char *)it->data[1]); + evry_item_free(it); + } +} + +static int +_fetch(Evry_Plugin *p, const char *input __UNUSED__) +{ + char m1[128]; + char m2[128]; + + _cleanup(p); + + if (input) + { + snprintf(m1, sizeof(m1), "%s*", input); + snprintf(m2, sizeof(m2), "*%s*", input); + } + else + { + m1[0] = 0; + m2[0] = 0; + } + + _item_add(p, _("Switch To"), _act_cb_border_switch_to, "go-next", m1, m2); + + if (inst->border->iconic) + _item_add(p, _("Uniconify"), _act_cb_border_unminimize, "window-minimize", m1, m2); + else + _item_add(p, _("Iconify"), _act_cb_border_minimize, "window-minimize", m1, m2); + + if (!inst->border->fullscreen) + _item_add(p, _("Fullscreen"), _act_cb_border_fullscreen, "view-fullscreen", m1, m2); + else + _item_add(p, _("Unfullscreen"), _act_cb_border_fullscreen, "view-restore", m1, m2); + + _item_add(p, _("Close"), _act_cb_border_close, "window-close", m1, m2); + + if (eina_list_count(p->items) > 0) + { + p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort); + return 1; + } + + return 0; +} + +static int +_action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__) +{ + void (*border_action) (E_Border *bd); + border_action = item->data[0]; + border_action(inst->border); + + return EVRY_ACTION_FINISHED; +} + +static Evas_Object * +_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) +{ + Evas_Object *o; + + o = e_icon_add(e); + evry_icon_theme_set(o, (const char *)it->data[1]); + + /* icon = edje_object_add(e); + * e_theme_edje_object_set(icon, "base/theme/borders", (const char *)it->data[1]); */ + + return o; +} + static Eina_Bool _init(void) { p = E_NEW(Evry_Plugin, 1); p->name = "Window Action"; + p->type = type_action; p->type_in = "BORDER"; p->type_out = "NONE"; p->need_query = 0; @@ -52,97 +218,6 @@ _shutdown(void) E_FREE(inst); } -static void -_act_cb_border_fullscreen(E_Border *bd) -{ - if (!bd->fullscreen) - e_border_fullscreen(bd, E_FULLSCREEN_RESIZE); - else - e_border_unfullscreen(bd); -} -static void -_act_cb_border_close(E_Border *bd) -{ - if (!bd->lock_close) e_border_act_close_begin(bd); -} - -static void -_act_cb_border_minimize(E_Border *bd) -{ - if (!bd->lock_user_iconify) e_border_iconify(bd); -} - -static int -_begin(Evry_Plugin *p __UNUSED__, Evry_Item *item) -{ - E_Border *bd; - - bd = item->data[0]; - /* e_object_ref(E_OBJECT(bd)); */ - inst->border = bd; - - return 1; -} - -static int -_fetch(Evry_Plugin *p, const char *input __UNUSED__) -{ - _cleanup(p); - - _item_add(p, _("Iconify"), _act_cb_border_minimize, - "e/widgets/border/default/minimize"); - - if (!inst->border->fullscreen) - _item_add(p, _("Fullscreen"), _act_cb_border_fullscreen, - "e/widgets/border/default/fullscreen"); - else - _item_add(p, _("Unfullscreen"), _act_cb_border_fullscreen, - "e/widgets/border/default/fullscreen"); - - _item_add(p, _("Close"), _act_cb_border_close, - "e/widgets/border/default/close"); - return 1; -} - -static int -_action(Evry_Plugin *p __UNUSED__, Evry_Item *item, const char *input __UNUSED__) -{ - void (*border_action) (E_Border *bd); - border_action = item->data[0]; - border_action(inst->border); - - return EVRY_ACTION_FINISHED; -} - -static void -_cleanup(Evry_Plugin *p) -{ - Evry_Item *it; - - EINA_LIST_FREE(p->items, it) - { - if (it->data[1]) eina_stringshare_del(it->data[1]); - if (it->label) eina_stringshare_del(it->label); - E_FREE(it); - } -} - -static void -_item_add(Evry_Plugin *p, const char *label, void (*action_cb) (E_Border *bd), const char *icon) -{ - Evry_Item *it; - - it = E_NEW(Evry_Item, 1); - it->data[0] = action_cb; - it->data[1] = (void *) eina_stringshare_add(icon); - it->label = eina_stringshare_add(label); - p->items = eina_list_append(p->items, it); -} - -static void -_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) -{ - it->o_icon = edje_object_add(e); - e_theme_edje_object_set(it->o_icon, "base/theme/borders", (const char *)it->data[1]); -} +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_calc.c b/src/modules/everything/evry_plug_calc.c index be96c0439..bbf0babda 100644 --- a/src/modules/everything/evry_plug_calc.c +++ b/src/modules/everything/evry_plug_calc.c @@ -10,63 +10,19 @@ static int _fetch(Evry_Plugin *p, const char *input); static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); static void _cleanup(Evry_Plugin *p); static void _item_add(Evry_Plugin *p, char *output, int prio); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); static int _cb_data(void *data, int type, void *event); static int _cb_error(void *data, int type, void *event); static int _cb_del(void *data, int type, void *event); -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - - static Evry_Plugin *p; static Ecore_Exe *exe = NULL; static Eina_List *history = NULL; static Ecore_Event_Handler *data_handler = NULL; static Ecore_Event_Handler *error_handler = NULL; static Ecore_Event_Handler *del_handler = NULL; -static Ecore_X_Window clipboard_win = 0; + static int error = 0; -static Eina_Bool -_init(void) -{ - p = E_NEW(Evry_Plugin, 1); - p->name = "Calculator"; - p->type_in = "NONE"; - p->type_out = "NONE"; - p->trigger = "="; - p->need_query = 0; - p->async_query = 1; - p->begin = &_begin; - p->fetch = &_fetch; - p->action = &_action; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; - evry_plugin_register(p); - - clipboard_win = ecore_x_window_new(0, 0, 0, 1, 1); - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - Evry_Item *it; - - EINA_LIST_FREE(p->items, it) - { - if (it->label) eina_stringshare_del(it->label); - free(it); - } - - evry_plugin_unregister(p); - E_FREE(p); - - ecore_x_window_free(clipboard_win); -} static int _begin(Evry_Plugin *p, Evry_Item *it __UNUSED__) @@ -89,20 +45,12 @@ static void _cleanup(Evry_Plugin *p) { Evry_Item *it; - int i = 0; + int items = 10; EINA_LIST_FREE(p->items, it) - { - if (i < 10) - { - history = eina_list_append(history, it); - } - else - { - if (it->label) eina_stringshare_del(it->label); - free(it); - } - } + if (items-- > 0) + history = eina_list_append(history, it); + else evry_item_free(it); ecore_event_handler_del(data_handler); ecore_event_handler_del(error_handler); @@ -116,8 +64,7 @@ _cleanup(Evry_Plugin *p) static int _action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__) { - if (!it) return EVRY_ACTION_CONTINUE; - + /* if (!it) return EVRY_ACTION_CONTINUE; */ if (p->items) { Eina_List *l; @@ -140,7 +87,7 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__) if (it2) { p->items = eina_list_remove(p->items, it2); - eina_stringshare_del(it2->label); + if (it2->label) eina_stringshare_del(it2->label); E_FREE(it2); } } @@ -150,10 +97,7 @@ _action(Evry_Plugin *p, Evry_Item *it, const char *input __UNUSED__) _item_add(p, (char *) it->label, 1); } - /* evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); */ - - ecore_x_selection_primary_set(clipboard_win, it->label, strlen(it->label)); - ecore_x_selection_clipboard_set(clipboard_win, it->label, strlen(it->label)); + evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); return EVRY_ACTION_FINISHED; } @@ -189,21 +133,13 @@ _fetch(Evry_Plugin *p, const char *input) } static void -_item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e __UNUSED__) -{ - it->o_icon = NULL; -} - -static void -_item_add(Evry_Plugin *p, char *output, int prio) +_item_add(Evry_Plugin *p, char *result, int prio) { Evry_Item *it; - it = E_NEW(Evry_Item, 1); - - it->priority = prio; - it->label = eina_stringshare_add(output); - + it = evry_item_new(p, result); + if (!it) return; + p->items = eina_list_prepend(p->items, it); } @@ -260,3 +196,39 @@ _cb_del(void *data __UNUSED__, int type __UNUSED__, void *event) return 1; } +static Eina_Bool +_init(void) +{ + p = E_NEW(Evry_Plugin, 1); + p->name = "Calculator"; + p->type = type_subject; + p->type_in = "NONE"; + p->type_out = "TEXT"; + p->trigger = "="; + p->icon = "accessories-calculator"; + p->need_query = 0; + p->async_query = 1; + p->begin = &_begin; + p->fetch = &_fetch; + p->action = &_action; + p->cleanup = &_cleanup; + evry_plugin_register(p); + + return EINA_TRUE; +} + +static void +_shutdown(void) +{ + Evry_Item *it; + + EINA_LIST_FREE(p->items, it) + evry_item_free(it); + + evry_plugin_unregister(p); + E_FREE(p); +} + + +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_config.c b/src/modules/everything/evry_plug_config.c index ddbc94c45..46cce1797 100644 --- a/src/modules/everything/evry_plug_config.c +++ b/src/modules/everything/evry_plug_config.c @@ -1,91 +1,41 @@ #include "e.h" #include "e_mod_main.h" -static int _fetch(Evry_Plugin *p, const char *input); -static int _action(Evry_Plugin *p, Evry_Item *item, const char *input); -static void _cleanup(Evry_Plugin *p); -static void _item_add(Evry_Plugin *p, E_Configure_It *eci, int prio); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); -static int _cb_sort(const void *data1, const void *data2); - -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - static Evry_Plugin *p; +static Evry_Action *act; -static Eina_Bool -_init(void) -{ - p = E_NEW(Evry_Plugin, 1); - p->name = "Settings"; - p->type_in = "NONE"; - p->type_out = "NONE"; - p->fetch = &_fetch; - p->action = &_action; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; - - evry_plugin_register(p); - return EINA_TRUE; -} - -static void -_shutdown(void) -{ - evry_plugin_unregister(p); - E_FREE(p); -} - -static int -_action(Evry_Plugin *p __UNUSED__, Evry_Item *it, const char *input __UNUSED__) -{ - E_Configure_It *eci, *eci2; - E_Container *con; - E_Configure_Cat *ecat; - Eina_List *l, *ll; - char buf[1024]; - int found = 0; - - if (!it) return EVRY_ACTION_CONTINUE; - - eci = it->data[0]; - con = e_container_current_get(e_manager_current_get()); - - for (l = e_configure_registry; l && !found; l = l->next) - { - ecat = l->data; - for (ll = ecat->items; ll && !found; ll = ll->next) - { - eci2 = ll->data; - if (eci == eci2) - { - found = 1; - snprintf(buf, sizeof(buf), "%s/%s", - ecat->cat, - eci->item); - } - } - } - - if (found) - e_configure_registry_call(buf, con, NULL); - - return EVRY_ACTION_FINISHED; -} - static void _cleanup(Evry_Plugin *p) { Evry_Item *it; EINA_LIST_FREE(p->items, it) - { - if (it->label) eina_stringshare_del(it->label); - E_FREE(it); - } + evry_item_free(it); +} + +static void +_item_add(Evry_Plugin *p, E_Configure_It *eci, int prio) +{ + Evry_Item *it; + + it = evry_item_new(p, eci->label); + it->data[0] = eci; + it->priority = prio; + + p->items = eina_list_append(p->items, it); +} + +static int +_cb_sort(const void *data1, const void *data2) +{ + const Evry_Item *it1, *it2; + + it1 = data1; + it2 = data2; + + /* TODO sort by name? */ + return (it1->priority - it2->priority); } static int @@ -134,48 +84,93 @@ _fetch(Evry_Plugin *p, const char *input) return 0; } -static void +static Evas_Object * _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) { - E_Configure_It *eci = it->data[0]; Evas_Object *o = NULL; + E_Configure_It *eci = it->data[0]; if (eci->icon) { o = e_icon_add(e); - if (!e_util_icon_theme_set(o, eci->icon)) + if (!evry_icon_theme_set(o, eci->icon)) { evas_object_del(o); o = e_util_icon_add(eci->icon, e); } } - it->o_icon = o; -} - -static void -_item_add(Evry_Plugin *p, E_Configure_It *eci, int prio) -{ - Evry_Item *it; - - it = E_NEW(Evry_Item, 1); - it->data[0] = eci; - it->priority = prio; - it->label = eina_stringshare_add(eci->label); - it->o_icon = NULL; - - p->items = eina_list_append(p->items, it); + return o; } static int -_cb_sort(const void *data1, const void *data2) +_action(Evry_Action *act, Evry_Item *it, Evry_Item *it2 __UNUSED__, const char *input __UNUSED__) { - const Evry_Item *it1, *it2; + E_Configure_It *eci, *eci2; + E_Container *con; + E_Configure_Cat *ecat; + Eina_List *l, *ll; + char buf[1024]; + int found = 0; - it1 = data1; - it2 = data2; + eci = it->data[0]; + con = e_container_current_get(e_manager_current_get()); - /* TODO sort by name? */ + for (l = e_configure_registry; l && !found; l = l->next) + { + ecat = l->data; + for (ll = ecat->items; ll && !found; ll = ll->next) + { + eci2 = ll->data; + if (eci == eci2) + { + found = 1; + snprintf(buf, sizeof(buf), "%s/%s", + ecat->cat, + eci->item); + } + } + } - return (it1->priority - it2->priority); + if (found) + e_configure_registry_call(buf, con, NULL); + + return EVRY_ACTION_FINISHED; } + +static Eina_Bool +_init(void) +{ + p = E_NEW(Evry_Plugin, 1); + p->name = "Settings"; + p->type = type_subject; + p->type_in = "NONE"; + p->type_out = "E_SETTINGS"; + p->fetch = &_fetch; + p->cleanup = &_cleanup; + p->icon_get = &_item_icon_get; + + evry_plugin_register(p); + + act = E_NEW(Evry_Action, 1); + act->name = "Show Dialog"; + act->is_default = EINA_TRUE; + act->type_in1 = "E_SETTINGS"; + act->action = &_action; + act->icon = "preferences-advanced"; + evry_action_register(act); + + return EINA_TRUE; +} + +static void +_shutdown(void) +{ + evry_plugin_unregister(p); + evry_action_unregister(act); + E_FREE(p); + E_FREE(act); +} + +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown); diff --git a/src/modules/everything/evry_plug_dir_browse.c b/src/modules/everything/evry_plug_dir_browse.c index cb113d39a..bea267dbc 100644 --- a/src/modules/everything/evry_plug_dir_browse.c +++ b/src/modules/everything/evry_plug_dir_browse.c @@ -1,25 +1,29 @@ #include "e.h" #include "e_mod_main.h" +#define MAX_ITEMS 100 + typedef struct _State State; struct _State { const char *directory; + /* all files of directory */ Eina_List *items; + /* current list of files */ + Eina_List *cur; int command; }; static int _begin(Evry_Plugin *p, Evry_Item *it); static int _fetch(Evry_Plugin *p, const char *input); -static int _action(Evry_Plugin *p, Evry_Item *it, const char *input); static void _cleanup(Evry_Plugin *p); static int _cb_sort(const void *data1, const void *data2); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); -static void _list_free(Evry_Plugin *p); -static void _item_fill(Evry_Item *it, Evas *evas); +static Evas_Object *_item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); +static void _item_fill(Evry_Item *it); static Evry_Item *_item_add(const char *directory, const char *file); static void _realize(Evry_Plugin *p, Evas *e); +static int _dirbrowse_idler(void *data); static Eina_Bool _init(void); static void _shutdown(void); @@ -27,26 +31,40 @@ EINA_MODULE_INIT(_init); EINA_MODULE_SHUTDOWN(_shutdown); static Evry_Plugin *p; -static Eina_List *stack = NULL; - +static Evry_Plugin *p2; +static Ecore_Idler *idler = NULL; static Eina_Bool _init(void) { p = E_NEW(Evry_Plugin, 1); - p->name = "Browse Files"; + p->name = "Files"; + p->type = type_subject; p->type_in = "NONE|FILE"; p->type_out = "FILE"; - /* p->trigger = "/"; */ + p->browseable = EINA_TRUE; p->begin = &_begin; p->fetch = &_fetch; - p->action = &_action; p->cleanup = &_cleanup; p->realize_items = &_realize; p->icon_get = &_item_icon_get; evry_plugin_register(p); + p2 = E_NEW(Evry_Plugin, 1); + p2->name = "Files"; + p2->type = type_object; + p2->type_in = "NONE|FILE"; + p2->type_out = "FILE"; + p2->browseable = EINA_TRUE; + p2->begin = &_begin; + p2->fetch = &_fetch; + p2->cleanup = &_cleanup; + p2->realize_items = &_realize; + p2->icon_get = &_item_icon_get; + + evry_plugin_register(p2); + return EINA_TRUE; } @@ -54,13 +72,18 @@ static void _shutdown(void) { evry_plugin_unregister(p); + evry_plugin_unregister(p2); E_FREE(p); + E_FREE(p2); } static int _begin(Evry_Plugin *p, Evry_Item *it) { State *s; + char *file; + Eina_List *files; + Eina_List *stack = p->private; if (stack) { @@ -75,60 +98,85 @@ _begin(Evry_Plugin *p, Evry_Item *it) s = E_NEW(State, 1); s->directory = eina_stringshare_add(it->uri); + p->items = NULL; } else { s = E_NEW(State, 1); s->directory = eina_stringshare_add(e_user_homedir_get()); + p->items = NULL; } + + files = ecore_file_ls(s->directory); - stack = eina_list_prepend(stack, s); - p->items = NULL; - - return 1; -} - -static int -_action(Evry_Plugin *p __UNUSED__, Evry_Item *it __UNUSED__, const char *input __UNUSED__) -{ - return EVRY_ACTION_OTHER; -} - -static void -_list_free(Evry_Plugin *p) -{ - Evry_Item *it; - - EINA_LIST_FREE(p->items, it) + EINA_LIST_FREE(files, file) { - if (it->label) eina_stringshare_del(it->label); - if (it->uri) eina_stringshare_del(it->uri); - if (it->mime) eina_stringshare_del(it->mime); - free(it); + it = NULL; + + if (file[0] == '.') + { + free(file); + continue; + } + + it = _item_add(s->directory, file); + + if (it) + s->items = eina_list_append(s->items, it); + + free(file); } + + if (idler) + ecore_idler_del(idler); + + idler = ecore_idler_add(_dirbrowse_idler, p); + + stack = eina_list_prepend(stack, s); + + p->private = stack; + + return 1; } static void _cleanup(Evry_Plugin *p) { State *s; - + Evry_Item *it; + Eina_List *stack = p->private; + if (!stack) return; - + s = stack->data; - _list_free(p); - - eina_stringshare_del(s->directory); + if (s->directory) eina_stringshare_del(s->directory); + EINA_LIST_FREE(s->items, it) + { + if (it->uri) eina_stringshare_del(it->uri); + if (it->mime) eina_stringshare_del(it->mime); + evry_item_free(it); + } + + if (idler) + { + ecore_idler_del(idler); + idler = NULL; + } + E_FREE(s); + eina_list_free(p->items); + p->items = NULL; + stack = eina_list_remove_list(stack, stack); - + p->private = stack; if (stack) { s = stack->data; - p->items = s->items; + + p->items = s->cur; } } @@ -136,24 +184,27 @@ _cleanup(Evry_Plugin *p) static int _fetch(Evry_Plugin *p, const char *input) { - Eina_List *files; - char *file; const char *directory = NULL; Evry_Item *it; + Eina_List *l; char match1[4096]; char match2[4096]; + int cnt = 0; + Eina_List *stack = p->private; State *s = stack->data; - _list_free(p); - + if (p->items) eina_list_free(p->items); + p->items = NULL; + /* input is command ? */ if (input) { + /* XXX free s->items? */ if (!strncmp(input, "/", 1)) { - it = E_NEW(Evry_Item, 1); + it = evry_item_new(p, "/"); + if (!it) return 0; it->uri = eina_stringshare_add("/"); - it->label = eina_stringshare_add("/"); p->items = eina_list_append(p->items, it); s->command = 1; return 1; @@ -175,9 +226,9 @@ _fetch(Evry_Plugin *p, const char *input) { tmp = strdup(dir); snprintf(dir, (end - dir) + 1, "%s", tmp); - it = E_NEW(Evry_Item, 1); + it = evry_item_new(p, dir); + if (!it) return 0; it->uri = eina_stringshare_add(dir); - it->label = eina_stringshare_add(dir); it->priority = prio; p->items = eina_list_append(p->items, it); end = strrchr(dir, '/'); @@ -185,12 +236,11 @@ _fetch(Evry_Plugin *p, const char *input) prio--; } - it = E_NEW(Evry_Item, 1); + it = evry_item_new(p, "/"); + if (!it) return 0; it->uri = eina_stringshare_add("/"); - it->label = eina_stringshare_add("/"); it->priority = prio; p->items = eina_list_append(p->items, it); - s->command = 1; return 1; @@ -200,51 +250,37 @@ _fetch(Evry_Plugin *p, const char *input) if (!directory) directory = s->directory; - files = ecore_file_ls(directory); - if (input) { snprintf(match1, sizeof(match1), "%s*", input); snprintf(match2, sizeof(match2), "*%s*", input); } - EINA_LIST_FREE(files, file) + EINA_LIST_FOREACH(s->items, l, it) { - it = NULL; - - if (file[0] == '.') - { - free(file); - continue; - } - if (input) { - if (e_util_glob_case_match(file, match1)) - { - it = _item_add(directory, file); - it->priority = 1; - } - else if (e_util_glob_case_match(file, match2)) - { - it = _item_add(directory, file); - it->priority = 0; - } + /* TODO fix sort priority */ + if (e_util_glob_case_match(it->label, match1)) + it->priority += 2; + else if (e_util_glob_case_match(it->label, match2)) + it->priority += 1; + else it = NULL; } - else - { - it = _item_add(directory, file); - } - - if (it) - p->items = eina_list_append(p->items, it); - free(file); + if (it) + { + p->items = eina_list_append(p->items, it); + cnt++; + if (cnt >= MAX_ITEMS) break; + } } - s->items = p->items; - - if (p->items) return 1; + if (p->items) + { + s->cur = p->items; + return 1; + } return 0; } @@ -255,11 +291,11 @@ _item_add(const char *directory, const char *file) Evry_Item *it = NULL; char buf[4096]; - it = E_NEW(Evry_Item, 1); - + it = evry_item_new(p, file); + if (!it) return NULL; + snprintf(buf, sizeof(buf), "%s/%s", directory, file); it->uri = eina_stringshare_add(buf); - it->label = eina_stringshare_add(file); return it; } @@ -269,22 +305,23 @@ _realize(Evry_Plugin *p, Evas *e) { Eina_List *l; Evry_Item *it; + Eina_List *stack = p->private; State *s = stack->data; - EINA_LIST_FOREACH(p->items, l, it) - _item_fill(it, e); + /* EINA_LIST_FOREACH(p->items, l, it) + * _item_fill(it, e); */ if (eina_list_count(p->items) > 0) { p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort); - s->items = p->items; + s->cur = p->items; } } /* based on directory-watcher from drawer module */ static void -_item_fill(Evry_Item *it, Evas *e) +_item_fill(Evry_Item *it) { const char *mime; @@ -309,9 +346,8 @@ _item_fill(Evry_Item *it, Evas *e) else if (ecore_file_is_dir(it->uri)) { it->mime = eina_stringshare_add("Folder"); + it->browseable = EINA_TRUE; it->priority += 1; - it->o_icon = edje_object_add(e); - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder"); } else if ((mime = efreet_mime_type_get(it->uri))) { @@ -321,45 +357,37 @@ _item_fill(Evry_Item *it, Evas *e) { it->mime = eina_stringshare_add("None"); } - - if (strcmp(it->mime, "Folder")) - { - char *item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32); - - if (item_path) - it->o_icon = e_util_icon_add(item_path, e); - else - { - it->o_icon = edje_object_add(e); - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file"); - } - } } -static void +static Evas_Object * _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) { + Evas_Object *o = NULL; char *item_path; - if (!it->mime) return; + if (!it->mime) + _item_fill(it); + + if (!it->mime) return NULL; if (!strcmp(it->mime, "Folder")) { - it->o_icon = edje_object_add(e); - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder"); + o = e_icon_add(e); + evry_icon_theme_set(o, "folder"); } else { - item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32); + item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64); if (item_path) - it->o_icon = e_util_icon_add(item_path, e); - else + o = e_util_icon_add(item_path, e); + if (!o) { - it->o_icon = edje_object_add(e); - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file"); + o = e_icon_add(e); + evry_icon_theme_set(o, "none"); } } + return o; } static int @@ -375,3 +403,45 @@ _cb_sort(const void *data1, const void *data2) else return strcasecmp(it1->label, it2->label); } + +static int +_dirbrowse_idler(void *data) +{ + Evry_Plugin *p = data; + State *s = ((Eina_List *)p->private)->data; + int cnt = 10; + Eina_List *l; + Evry_Item *it; + + /* printf("dirbrowse idler\n"); */ + + if (!idler) return 0; + + EINA_LIST_FOREACH(s->items, l, it) + { + if (!it->mime) + { + _item_fill(it); + cnt--; + } + if (cnt == 0) break; + } + + evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_CLEAR); + + if (eina_list_count(p->items) > 0) + { + p->items = eina_list_sort(p->items, eina_list_count(p->items), _cb_sort); + s->cur = p->items; + } + + evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); + + if (cnt > 0) + { + idler = NULL; + return 0; + } + + return 1; +} diff --git a/src/modules/everything/evry_plug_tracker.c b/src/modules/everything/evry_plug_tracker.c index 4b90cac34..a79faef0a 100644 --- a/src/modules/everything/evry_plug_tracker.c +++ b/src/modules/everything/evry_plug_tracker.c @@ -10,57 +10,73 @@ struct _Inst E_DBus_Connection *conn; }; -static int _fetch(Evry_Plugin *p, const char *input); -static void _cleanup(Evry_Plugin *p); -static void _item_add(Evry_Plugin *p, char *file, char *mime, int prio); -static void _item_icon_get(Evry_Plugin *p, Evry_Item *it, Evas *e); -static void _dbus_cb_reply(void *data, DBusMessage *msg, DBusError *error); - -static Eina_Bool _init(void); -static void _shutdown(void); -EINA_MODULE_INIT(_init); -EINA_MODULE_SHUTDOWN(_shutdown); - static Evry_Plugin *p; +static Evry_Plugin *p2; static Inst *inst; +static Eina_Bool active = EINA_FALSE; -static Eina_Bool -_init(void) +static void +_item_add(Evry_Plugin *p, char *file, char *mime, int prio) { - E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION); + Evry_Item *it; + const char *filename; - if (!conn) return 0; + filename = ecore_file_file_get(file); - p = E_NEW(Evry_Plugin, 1); - p->name = "Search Files"; - p->type_in = "NONE"; - p->type_out = "FILE"; - p->need_query = 1; - p->fetch = &_fetch; - p->cleanup = &_cleanup; - p->icon_get = &_item_icon_get; + if (!filename) return; - inst = E_NEW(Inst, 1); - inst->conn = conn; - - evry_plugin_register(p); + it = evry_item_new(p, filename); + it->priority = prio; + it->uri = eina_stringshare_add(file); + it->mime = eina_stringshare_add(mime); - return EINA_TRUE; + if (!strcmp(it->mime, "Folder")) + it->browseable = EINA_TRUE; + + p->items = eina_list_append(p->items, it); } static void -_shutdown(void) +_dbus_cb_reply(void *data __UNUSED__, DBusMessage *msg, DBusError *error) { - evry_plugin_unregister(p); + DBusMessageIter array, iter, item; - if (inst) + if (!active) return; + + if (dbus_error_is_set(error)) { - if (inst->conn) - e_dbus_connection_close(inst->conn); - E_FREE(inst); + printf("Error: %s - %s\n", error->name, error->message); + return; + } + + dbus_message_iter_init(msg, &array); + if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY) + { + dbus_message_iter_recurse(&array, &item); + while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY) + { + char *uri, *mime; + + dbus_message_iter_recurse(&item, &iter); + + if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) + { + dbus_message_iter_get_basic(&iter, &uri); + dbus_message_iter_next(&iter); + /* dbus_message_iter_get_basic(&iter, &service); */ + dbus_message_iter_next(&iter); + dbus_message_iter_get_basic(&iter, &mime); + + if (uri && mime) + { + _item_add(p, uri, mime, 1); + } + } + dbus_message_iter_next(&item); + } } - if (p) E_FREE(p); + if (p->items) evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); } static void @@ -72,9 +88,9 @@ _cleanup(Evry_Plugin *p) { if (it->mime) eina_stringshare_del(it->mime); if (it->uri) eina_stringshare_del(it->uri); - if (it->label) eina_stringshare_del(it->label); - free(it); + evry_item_free(it); } + active = EINA_FALSE; } static int @@ -90,6 +106,8 @@ _fetch(Evry_Plugin *p, const char *input) _cleanup(p); + active = EINA_TRUE; + match = malloc(sizeof(char) * strlen(input) + 2); sprintf(match, "%s*", input); @@ -112,87 +130,83 @@ _fetch(Evry_Plugin *p, const char *input) return 0; } -static void +static Evas_Object * _item_icon_get(Evry_Plugin *p __UNUSED__, Evry_Item *it, Evas *e) { char *item_path; - + Evas_Object *o = NULL; + if (!strcmp(it->mime, "Folder")) { - it->o_icon = edje_object_add(e); - /* e_util_icon_theme_set(it->o_icon, "folder"); */ - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/folder"); + o = e_icon_add(e); + evry_icon_theme_set(o, "folder"); } else { - item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 32); + item_path = efreet_mime_type_icon_get(it->mime, e_config->icon_theme, 64); if (item_path) - it->o_icon = e_util_icon_add(item_path, e); + o = e_util_icon_add(item_path, e); else { - it->o_icon = edje_object_add(e); - /* e_util_icon_theme_set(it->o_icon, "file"); */ - e_theme_edje_object_set(it->o_icon, "base/theme/fileman", "e/icons/fileman/file"); + o = e_icon_add(e); + evry_icon_theme_set(o, "none"); } } + return o; +} + +static Eina_Bool +_init(void) +{ + E_DBus_Connection *conn = e_dbus_bus_get(DBUS_BUS_SESSION); + + if (!conn) return 0; + + p = E_NEW(Evry_Plugin, 1); + p->name = "Find Files"; + p->type = type_subject; + p->type_in = "NONE"; + p->type_out = "FILE"; + p->need_query = 1; + p->fetch = &_fetch; + p->cleanup = &_cleanup; + p->icon_get = &_item_icon_get; + evry_plugin_register(p); + + p2 = E_NEW(Evry_Plugin, 1); + p2->name = "Find Files"; + p2->type = type_object; + p2->type_in = "NONE"; + p2->type_out = "FILE"; + p2->need_query = 1; + p2->fetch = &_fetch; + p2->cleanup = &_cleanup; + p2->icon_get = &_item_icon_get; + evry_plugin_register(p2); + + inst = E_NEW(Inst, 1); + inst->conn = conn; + + return EINA_TRUE; } static void -_item_add(Evry_Plugin *p, char *file, char *mime, int prio) +_shutdown(void) { - Evry_Item *it; - - it = E_NEW(Evry_Item, 1); - it->priority = prio; - it->label = eina_stringshare_add(ecore_file_file_get(file)); - it->uri = eina_stringshare_add(file); - it->mime = eina_stringshare_add(mime); - it->o_icon = NULL; + evry_plugin_unregister(p); + evry_plugin_unregister(p2); - p->items = eina_list_append(p->items, it); -} - -static void -_dbus_cb_reply(void *data __UNUSED__, DBusMessage *msg, DBusError *error) -{ - DBusMessageIter array, iter, item; - - if (dbus_error_is_set(error)) - { - printf("Error: %s - %s\n", error->name, error->message); - return; - } - - dbus_message_iter_init(msg, &array); - if(dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY) - { - dbus_message_iter_recurse(&array, &item); - while(dbus_message_iter_get_arg_type(&item) == DBUS_TYPE_ARRAY) - { - char *uri; - char *mime; - - dbus_message_iter_recurse(&item, &iter); - - if (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_STRING) - { - dbus_message_iter_get_basic(&iter, &uri); - dbus_message_iter_next(&iter); - /* dbus_message_iter_get_basic(&iter, &service); */ - dbus_message_iter_next(&iter); - dbus_message_iter_get_basic(&iter, &mime); - - if (uri && mime) - { - _item_add(p, uri, mime, 1); - } - } - - dbus_message_iter_next(&item); - } - } - - if (p->items) evry_plugin_async_update(p, EVRY_ASYNC_UPDATE_ADD); + if (p) E_FREE(p); + if (p2) E_FREE(p2); + + if (inst) + { + if (inst->conn) + e_dbus_connection_close(inst->conn); + E_FREE(inst); + } } +EINA_MODULE_INIT(_init); +EINA_MODULE_SHUTDOWN(_shutdown);