summaryrefslogtreecommitdiff
path: root/src/bin/about.c
blob: 0e4f229a5611d47288e910d50c8818ccd88ee9a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "private.h"

#include <Elementary.h>
#include "about.h"

static Evas_Object *ab_layout = NULL, *ab_over;
static Eina_Bool ab_out = EINA_FALSE;
static Ecore_Timer *ab_del_timer = NULL;
static Evas_Object *saved_win = NULL;
static Evas_Object *saved_bg = NULL;

static Eina_Bool
_cb_ab_del_delay(void *data __UNUSED__)
{
   evas_object_del(ab_layout);
   ab_layout = NULL;
   ab_del_timer = NULL;
   elm_cache_all_flush();
   return EINA_FALSE;
}

static void
_cb_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *ev __UNUSED__)
{
   about_toggle(saved_win, saved_bg, data);
}

void
about_toggle(Evas_Object *win, Evas_Object *bg, Evas_Object *term)
{
   Evas_Object *o;

   saved_win = win;
   saved_bg = bg;
   if (!ab_layout)
     {
        char buf[PATH_MAX];
        
        ab_layout = o = elm_layout_add(win);
        snprintf(buf, sizeof(buf), "%s/themes/default.edj",
                 elm_app_data_dir_get());
        elm_layout_file_set(o, buf, "terminology/about");
        elm_object_part_text_set
          (o, "terminology.text",
              "<b>Terminology</b><br>"
              "Why should terminals be boring?<br>"
              "<br>"
              "This terminal was written for Enlightenment, to use EFL "
              "and otherwise push the boundaries of what a modern terminal"
              "emulator should be. We hope you enjoy it.<br"
              "<br>"
              "Copyright © 2012 by:<br>"
              "Carsten Haitzler<br>"
              // add more authors here
              "<br>"
              "<br>"
              "Distrubted under the 2-clause BSD license detailed below:<br>"
              "<br>"
              "All rights reserved.<br>"
              "<br>"
              "Redistribution and use in source and binary forms, with or "
              "without modification, are permitted provided that the "
              "following conditions are met:<br>"
              "<br>"
              "1. Redistributions of source code must retain the above "
              "copyright notice, this list of conditions and the following "
              "disclaimer.<br>"
              "2. Redistributions in binary form must reproduce the above "
              "copyright notice, this list of conditions and the following "
              "disclaimer in the documentation and/or other materials "
              "provided with the distribution.<br>"
              "<br>"
              "<b>THIS SOFTWARE IS PROVIDED \"AS IS\" AND ANY EXPRESS OR "
              "IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED "
              "WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR "
              "PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER "
              "OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, "
              "INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES "
              "(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE "
              "GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS "
              "INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, "
              "WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING "
              "NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF "
              "THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH "
              "DAMAGE.</b>"
          );
        evas_object_show(o);
        edje_object_part_swallow(bg, "terminology.about", ab_layout);
     }
   if (!ab_out)
     {
        ab_over = o = evas_object_rectangle_add(evas_object_evas_get(win));
        evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
        evas_object_size_hint_align_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
        evas_object_color_set(o, 0, 0, 0, 0);
        elm_win_resize_object_add(win, o);
        evas_object_show(o);
        evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
                                       _cb_mouse_down, term);
        
        edje_object_signal_emit(bg, "about,show", "terminology");
        ab_out = EINA_TRUE;
        elm_object_focus_set(ab_layout, EINA_TRUE);
        if (ab_del_timer)
          {
             ecore_timer_del(ab_del_timer);
             ab_del_timer = NULL;
          }
     }
   else
     {
        evas_object_del(ab_over);
        ab_over = NULL;
        edje_object_signal_emit(bg, "about,hide", "terminology");
        ab_out = EINA_FALSE;
        elm_object_focus_set(ab_layout, EINA_FALSE);
        elm_object_focus_set(term, EINA_TRUE);
        if (ab_del_timer) ecore_timer_del(ab_del_timer);
        ab_del_timer = ecore_timer_add(10.0,  _cb_ab_del_delay, NULL);
     }
}