Tizen 2.1 release
[platform/core/uifw/e17.git] / src / modules / everything / evry_view_help.c
1 #include "e_mod_main.h"
2
3 static Evry_View *view;
4 static Evas_Object *o_text = NULL;
5
6 static void
7 _view_clear(Evry_View *v)
8 {
9    v->active = 0;
10    evas_object_del(v->o_list);
11    evas_object_del(o_text);
12    o_text = NULL;
13 }
14
15 static int
16 _view_update(Evry_View *v __UNUSED__)
17 {
18    return 1;
19 }
20
21 static int
22 _cb_key_down(Evry_View *v, const Ecore_Event_Key *ev)
23 {
24    Evas_Object *o;
25    double align;
26    int h;
27
28    if (!strcmp(ev->key, "Down"))
29      {
30         o = v->o_list;
31         evas_object_geometry_get(o, NULL, NULL, NULL, &h);
32         if (!h) h = 1;
33         e_box_align_get(o, NULL, &align);
34
35         align = align - 10.0 / (double)h;
36         if (align < 0.0) align = 0.0;
37
38         e_box_align_set(v->o_list, 0.5, align);
39
40         return 1;
41      }
42    else if (!strcmp(ev->key, "Up"))
43      {
44         o = v->o_list;
45         evas_object_geometry_get(o, NULL, NULL, NULL, &h);
46         if (!h) h = 1;
47         e_box_align_get(o, NULL, &align);
48
49         align = align + 10.0 / (double)h;
50         if (align > 1.0) align = 1.0;
51
52         e_box_align_set(v->o_list, 0.5, align);
53         return 1;
54      }
55
56    evry_view_toggle(v->state, NULL);
57    return 1;
58 }
59
60 static Evry_View *
61 _view_create(Evry_View *v, const Evry_State *s __UNUSED__, const Evas_Object *swallow)
62 {
63    Evas_Object *o;
64    int mw, mh;
65
66    char *text =
67      _("  Ok, here comes the explanation of <hilight>everything</hilight>...<br>"
68        "  Just type a few letters of the thing you are looking for. <br>"
69        "  Use cursor <hilight>&lt;up/down&gt;</hilight> to choose from the list of things.<br>"
70        "  Press  <hilight>&lt;tab&gt;</hilight> to select"
71        " an action, then press  <hilight>&lt;return&gt;</hilight>.<br>"
72        " This page will not show up next time you run <hilight>everything</hilight>.<br>"
73        "    <hilight>&lt;Esc&gt;</hilight> close this Dialog<br>"
74        "    <hilight>&lt;?&gt;</hilight> show this page<br>"
75        "    <hilight>&lt;return&gt;</hilight> run action<br>"
76        "    <hilight>&lt;ctrl+return&gt;</hilight> run action and continue<br>"
77        "    <hilight>&lt;tab&gt;</hilight> toggle between selectors<br>"
78        "    <hilight>&lt;ctrl+tab&gt;</hilight> complete input (depends on plugin)<br>"
79        "    <hilight>&lt;ctrl+'x'&gt;</hilight> jump to plugin beginning with 'x'<br>"
80        "    <hilight>&lt;ctrl+left/right&gt;</hilight> cycle through plugins<br>"
81        "    <hilight>&lt;ctrl+up/down&gt;</hilight> go to first/last item<br>"
82        "    <hilight>&lt;ctrl+1&gt;</hilight> toggle view modes (exit this page ;)<br>"
83        "    <hilight>&lt;ctrl+2&gt;</hilight> toggle list view modes<br>"
84        "    <hilight>&lt;ctrl+3&gt;</hilight> toggle thumb view modes"
85        );
86
87    if (v->active) return v;
88
89    o = e_box_add(evas_object_evas_get(swallow));
90    e_box_orientation_set(o, 0);
91    e_box_align_set(o, 0.5, 1.0);
92    v->o_list = o;
93    e_box_freeze(v->o_list);
94    o = edje_object_add(evas_object_evas_get(swallow));
95    e_theme_edje_object_set(o, "base/theme/widgets",
96                            "e/modules/everything/textblock");
97
98    edje_object_part_text_set(o, "e.textblock.text", text);
99    e_box_pack_start(v->o_list, o);
100    edje_object_size_min_calc(o, &mw, &mh);
101    e_box_pack_options_set(o, 1, 0, 1, 0, 0.5, 0.5, mw, mh + 200, 999, 999);
102    e_box_thaw(v->o_list);
103    evas_object_show(o);
104    o_text = o;
105
106    v->active = 1;
107
108    return v;
109 }
110
111 static void
112 _view_destroy(Evry_View *v)
113 {
114    v->active = 0;
115 }
116
117 Eina_Bool
118 evry_view_help_init(void)
119 {
120    if (!evry_api_version_check(EVRY_API_VERSION))
121      return EINA_FALSE;
122
123    view = E_NEW(Evry_View, 1);
124    view->id = view;
125    view->name = "Help";
126    view->create = &_view_create;
127    view->destroy = &_view_destroy;
128    view->update = &_view_update;
129    view->clear = &_view_clear;
130    view->cb_key_down = &_cb_key_down;
131    view->trigger = "?";
132    /* view->types = "NONE"; */
133    evry_view_register(view, 2);
134
135    return EINA_TRUE;
136 }
137
138 void
139 evry_view_help_shutdown(void)
140 {
141    evry_view_unregister(view);
142    E_FREE(view);
143 }
144