summaryrefslogtreecommitdiff
path: root/src/bin/controls.c
blob: 0a08ed0b6cb59f2b7438b535c734542aa75928fd (plain) (blame)
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "private.h"

#include <Elementary.h>
#include "controls.h"
#include "options.h"
#include "about.h"
#include "termio.h"

static Evas_Object *ct_frame, *ct_box = NULL;
static Eina_Bool ct_out = EINA_FALSE;
static Ecore_Timer *ct_del_timer = NULL;

static Evas_Object *ct_win, *ct_bg, *ct_term;

static Eina_Bool
_cb_ct_del_delay(void *data __UNUSED__)
{
   evas_object_del(ct_frame);
   ct_frame = NULL;
   ct_del_timer = NULL;
   elm_cache_all_flush();
   return EINA_FALSE;
}

static void
_cb_ct_copy(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
   controls_toggle(ct_win, ct_bg, ct_term);
   termio_copy_clipboard(data);
}

static void
_cb_ct_paste(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
   controls_toggle(ct_win, ct_bg, ct_term);
   termio_paste_clipboard(data);
}

static void
_cb_ct_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
   controls_toggle(ct_win, ct_bg, ct_term);
   options_toggle(ct_win, ct_bg, ct_term);
}

static void
_cb_ct_about(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
   controls_toggle(ct_win, ct_bg, ct_term);
   about_toggle(ct_win, ct_bg, ct_term);
}

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

   if (!ct_out)
     {
        if (options_active_get())
          {
             options_toggle(win, bg, term);
             return;
          }
     }
   if (!ct_frame)
     {
        ct_frame = o = elm_frame_add(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);
        elm_object_text_set(o, "Controls");

        ct_box = o = elm_box_add(win);
        elm_object_content_set(ct_frame, o);
        evas_object_show(o);
        
        o = elm_button_add(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);
        elm_object_text_set(o, "Copy");
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        evas_object_smart_callback_add(o, "clicked", _cb_ct_copy, term);
        
        o = elm_button_add(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);
        elm_object_text_set(o, "Paste");
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        evas_object_smart_callback_add(o, "clicked", _cb_ct_paste, term);
        
        o = elm_separator_add(win);
        evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
        evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
        elm_separator_horizontal_set(o, EINA_TRUE);
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        
        o = elm_button_add(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);
        elm_object_text_set(o, "Options");
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        evas_object_smart_callback_add(o, "clicked", _cb_ct_options, NULL);
        
        o = elm_separator_add(win);
        evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, 0.0);
        evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.5);
        elm_separator_horizontal_set(o, EINA_TRUE);
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        
        o = elm_button_add(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);
        elm_object_text_set(o, "About");
        elm_box_pack_end(ct_box, o);
        evas_object_show(o);
        evas_object_smart_callback_add(o, "clicked", _cb_ct_about, NULL);
        
        edje_object_part_swallow(bg, "terminology.controls", ct_frame);
        evas_object_show(ct_frame);
     }
   if (!ct_out)
     {
        ct_win = win;
        ct_bg = bg;
        ct_term = term;
        edje_object_signal_emit(bg, "controls,show", "terminology");
        ct_out = EINA_TRUE;
        elm_object_focus_set(ct_frame, EINA_TRUE);
        if (ct_del_timer)
          {
             ecore_timer_del(ct_del_timer);
             ct_del_timer = NULL;
          }
     }
   else
     {
        edje_object_signal_emit(bg, "controls,hide", "terminology");
        ct_out = EINA_FALSE;
        elm_object_focus_set(ct_frame, EINA_FALSE);
        elm_object_focus_set(term, EINA_TRUE);
        if (ct_del_timer) ecore_timer_del(ct_del_timer);
        ct_del_timer = ecore_timer_add(10.0, _cb_ct_del_delay, NULL);
     }
}