2012-06-17 09:32:23 -07:00
|
|
|
#include "private.h"
|
2012-06-17 09:03:46 -07:00
|
|
|
|
|
|
|
#include <Ecore_Getopt.h>
|
2012-06-12 03:10:01 -07:00
|
|
|
#include <Elementary.h>
|
2012-06-13 08:10:18 -07:00
|
|
|
#include "main.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
#include "win.h"
|
|
|
|
#include "termio.h"
|
|
|
|
#include "config.h"
|
2012-06-23 23:39:54 -07:00
|
|
|
#include "controls.h"
|
2012-06-16 21:10:17 -07:00
|
|
|
#include "media.h"
|
2012-06-19 08:59:49 -07:00
|
|
|
#include "utils.h"
|
2012-06-12 03:10:01 -07:00
|
|
|
|
2012-06-17 09:32:23 -07:00
|
|
|
int _log_domain = -1;
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
static Evas_Object *win = NULL, *bg = NULL, *term = NULL, *media = NULL;
|
2012-07-01 19:52:48 -07:00
|
|
|
static Evas_Object *conform = NULL;
|
2012-06-16 19:35:07 -07:00
|
|
|
static Ecore_Timer *flush_timer = NULL;
|
2012-06-23 02:25:01 -07:00
|
|
|
static Eina_Bool focused = EINA_FALSE;
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_focus_in(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-23 02:25:01 -07:00
|
|
|
if (!focused) elm_win_urgent_set(win, EINA_FALSE);
|
|
|
|
focused = EINA_TRUE;
|
2012-06-12 03:10:01 -07:00
|
|
|
edje_object_signal_emit(bg, "focus,in", "terminology");
|
|
|
|
elm_object_focus_set(data, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_focus_out(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-23 02:25:01 -07:00
|
|
|
focused = EINA_FALSE;
|
2012-06-12 03:10:01 -07:00
|
|
|
edje_object_signal_emit(bg, "focus,out", "terminology");
|
|
|
|
elm_object_focus_set(data, EINA_FALSE);
|
2012-06-16 19:35:07 -07:00
|
|
|
elm_cache_all_flush();
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_size_hint(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event __UNUSED__)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
|
|
|
Evas_Coord mw, mh, rw, rh, w = 0, h = 0;
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_size_hint_min_get(obj, &mw, &mh);
|
|
|
|
evas_object_size_hint_request_get(obj, &rw, &rh);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
edje_object_size_min_calc(bg, &w, &h);
|
|
|
|
evas_object_size_hint_min_set(bg, w, h);
|
|
|
|
elm_win_size_base_set(win, w - mw, h - mh);
|
|
|
|
elm_win_size_step_set(win, mw, mh);
|
|
|
|
if (!evas_object_data_get(obj, "sizedone"))
|
|
|
|
{
|
|
|
|
evas_object_resize(win, w - mw + rw, h - mh + rh);
|
|
|
|
evas_object_data_set(obj, "sizedone", obj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-12 06:08:09 -07:00
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_options(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-12 06:08:09 -07:00
|
|
|
{
|
2012-06-23 23:39:54 -07:00
|
|
|
controls_toggle(win, bg, term);
|
2012-06-12 06:08:09 -07:00
|
|
|
}
|
|
|
|
|
2012-06-16 19:35:07 -07:00
|
|
|
static Eina_Bool
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_flush(void *data __UNUSED__)
|
2012-06-16 19:35:07 -07:00
|
|
|
{
|
|
|
|
flush_timer = NULL;
|
|
|
|
elm_cache_all_flush();
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2012-06-17 10:04:17 -07:00
|
|
|
_cb_change(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
2012-06-16 19:35:07 -07:00
|
|
|
{
|
|
|
|
if (!flush_timer) flush_timer = ecore_timer_add(0.25, _cb_flush, NULL);
|
|
|
|
else ecore_timer_delay(flush_timer, 0.25);
|
|
|
|
}
|
|
|
|
|
2012-06-20 07:12:26 -07:00
|
|
|
static void
|
|
|
|
_cb_exited(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|
|
|
{
|
|
|
|
elm_exit();
|
|
|
|
}
|
|
|
|
|
2012-06-23 02:25:01 -07:00
|
|
|
static void
|
|
|
|
_cb_bell(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
|
|
|
{
|
|
|
|
Config *config = termio_config_get(term);
|
|
|
|
|
|
|
|
edje_object_signal_emit(bg, "bell", "terminology");
|
|
|
|
if (!config) return;
|
|
|
|
if (config->urg_bell)
|
|
|
|
{
|
|
|
|
if (!focused) elm_win_urgent_set(win, EINA_TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-16 07:00:00 -07:00
|
|
|
void
|
2012-06-17 13:24:23 -07:00
|
|
|
main_trans_update(const Config *config)
|
2012-06-16 07:00:00 -07:00
|
|
|
{
|
|
|
|
if (config->translucent)
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(bg, "translucent,on", "terminology");
|
|
|
|
elm_win_alpha_set(win, EINA_TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edje_object_signal_emit(bg, "translucent,off", "terminology");
|
|
|
|
elm_win_alpha_set(win, EINA_FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-16 21:10:17 -07:00
|
|
|
void
|
2012-06-17 13:24:23 -07:00
|
|
|
main_media_update(const Config *config)
|
2012-06-16 21:10:17 -07:00
|
|
|
{
|
|
|
|
Evas_Object *o;
|
2012-06-17 00:10:27 -07:00
|
|
|
int type = 0;
|
2012-06-16 21:10:17 -07:00
|
|
|
|
2012-06-16 22:41:02 -07:00
|
|
|
if ((config->background) && (config->background[0]))
|
2012-06-16 21:10:17 -07:00
|
|
|
{
|
|
|
|
if (media) evas_object_del(media);
|
2012-06-17 13:24:23 -07:00
|
|
|
o = media = media_add(win, config->background, config, MEDIA_BG, &type);
|
2012-06-16 21:10:17 -07:00
|
|
|
edje_object_part_swallow(bg, "terminology.background", o);
|
2012-06-17 00:10:27 -07:00
|
|
|
if (type == TYPE_IMG)
|
|
|
|
edje_object_signal_emit(bg, "media,image", "terminology");
|
|
|
|
else if (type == TYPE_SCALE)
|
|
|
|
edje_object_signal_emit(bg, "media,scale", "terminology");
|
|
|
|
else if (type == TYPE_EDJE)
|
|
|
|
edje_object_signal_emit(bg, "media,edje", "terminology");
|
|
|
|
else if (type == TYPE_MOV)
|
|
|
|
edje_object_signal_emit(bg, "media,movie", "terminology");
|
2012-06-16 21:10:17 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (media)
|
|
|
|
{
|
2012-06-17 00:10:27 -07:00
|
|
|
edje_object_signal_emit(bg, "media,off", "terminology");
|
2012-06-16 21:10:17 -07:00
|
|
|
evas_object_del(media);
|
|
|
|
media = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-17 02:26:01 -07:00
|
|
|
void
|
2012-06-17 13:24:23 -07:00
|
|
|
main_media_mute_update(const Config *config)
|
2012-06-17 02:26:01 -07:00
|
|
|
{
|
|
|
|
if (media) media_mute_set(media, config->mute);
|
|
|
|
}
|
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
static const char *emotion_choices[] = {
|
|
|
|
"auto", "gstreamer", "xine", "generic",
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
static const Ecore_Getopt options = {
|
|
|
|
PACKAGE_NAME,
|
|
|
|
"%prog [options]",
|
|
|
|
PACKAGE_VERSION,
|
2012-06-23 18:27:44 -07:00
|
|
|
"(C) 2012 Carsten Haitzler and others",
|
2012-06-18 07:22:15 -07:00
|
|
|
"BSD 2-Clause",
|
2012-06-17 09:03:46 -07:00
|
|
|
"Terminal emulator written with Enlightenment Foundation Libraries.",
|
|
|
|
EINA_TRUE,
|
|
|
|
{
|
|
|
|
ECORE_GETOPT_STORE_STR('e', "exec",
|
|
|
|
"command to execute. "
|
|
|
|
"Defaults to $SHELL (or passwd shel or /bin/sh)"),
|
|
|
|
ECORE_GETOPT_STORE_STR('t', "theme",
|
|
|
|
"Use the named edje theme or path to theme file."),
|
|
|
|
ECORE_GETOPT_STORE_STR('b', "background",
|
|
|
|
"Use the named file as a background wallpaper."),
|
|
|
|
ECORE_GETOPT_CHOICE(0, "video-module",
|
|
|
|
"Set emotion module to use.",
|
|
|
|
emotion_choices),
|
|
|
|
ECORE_GETOPT_STORE_BOOL(0, "video-mute",
|
|
|
|
"Set mute mode for video playback."),
|
|
|
|
ECORE_GETOPT_VERSION('V', "version"),
|
|
|
|
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
|
|
|
|
ECORE_GETOPT_LICENSE('L', "license"),
|
|
|
|
ECORE_GETOPT_HELP('h', "help"),
|
|
|
|
ECORE_GETOPT_SENTINEL
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
EAPI_MAIN int
|
|
|
|
elm_main(int argc, char **argv)
|
|
|
|
{
|
2012-06-17 09:03:46 -07:00
|
|
|
char *cmd = NULL;
|
|
|
|
char *theme = NULL;
|
|
|
|
char *background = NULL;
|
|
|
|
char *video_module = NULL;
|
|
|
|
Eina_Bool video_mute = 0xff; /* unset */
|
|
|
|
Eina_Bool quit_option = EINA_FALSE;
|
|
|
|
Ecore_Getopt_Value values[] = {
|
|
|
|
ECORE_GETOPT_VALUE_STR(cmd),
|
|
|
|
ECORE_GETOPT_VALUE_STR(theme),
|
|
|
|
ECORE_GETOPT_VALUE_STR(background),
|
|
|
|
ECORE_GETOPT_VALUE_STR(video_module),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(video_mute),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_BOOL(quit_option),
|
|
|
|
ECORE_GETOPT_VALUE_NONE
|
|
|
|
};
|
|
|
|
int args, retval = EXIT_SUCCESS;
|
2012-06-17 13:24:23 -07:00
|
|
|
Config *config;
|
2012-06-12 03:10:01 -07:00
|
|
|
Evas_Object *o;
|
|
|
|
|
2012-06-17 09:32:23 -07:00
|
|
|
_log_domain = eina_log_domain_register("terminology", NULL);
|
|
|
|
if (_log_domain < 0)
|
|
|
|
{
|
|
|
|
EINA_LOG_CRIT("could not create log domain 'terminology'.");
|
|
|
|
elm_shutdown();
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
config_init();
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
config = config_load("config");
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
|
|
|
elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
|
|
|
|
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
|
|
|
|
elm_app_info_set(elm_main, "terminology", "themes/default.edj");
|
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
args = ecore_getopt_parse(&options, values, argc, argv);
|
|
|
|
if (args < 0)
|
2012-06-12 03:10:01 -07:00
|
|
|
{
|
2012-06-17 09:32:23 -07:00
|
|
|
ERR("Could not parse command line options.");
|
2012-06-17 09:03:46 -07:00
|
|
|
retval = EXIT_FAILURE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (quit_option) goto end;
|
|
|
|
|
|
|
|
if (theme)
|
|
|
|
{
|
2012-06-17 11:03:33 -07:00
|
|
|
char path[PATH_MAX];
|
|
|
|
char name[PATH_MAX];
|
|
|
|
|
2012-06-17 09:03:46 -07:00
|
|
|
if (eina_str_has_suffix(theme, ".edj"))
|
2012-06-17 11:03:33 -07:00
|
|
|
eina_strlcpy(name, theme, sizeof(name));
|
2012-06-17 09:03:46 -07:00
|
|
|
else
|
2012-06-17 11:03:33 -07:00
|
|
|
snprintf(name, sizeof(name), "%s.edj", theme);
|
|
|
|
|
|
|
|
if (strchr(name, '/'))
|
|
|
|
eina_strlcpy(path, name, sizeof(path));
|
|
|
|
else
|
|
|
|
snprintf(path, sizeof(path), "%s/themes/%s",
|
|
|
|
elm_app_data_dir_get(), name);
|
|
|
|
|
|
|
|
eina_stringshare_replace(&(config->theme), path);
|
2012-06-17 13:24:23 -07:00
|
|
|
config->temporary = EINA_TRUE;
|
2012-06-17 09:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (background)
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&(config->background), background);
|
2012-06-17 13:24:23 -07:00
|
|
|
config->temporary = EINA_TRUE;
|
2012-06-17 09:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (video_module)
|
|
|
|
{
|
|
|
|
int i;
|
2012-06-17 10:04:17 -07:00
|
|
|
for (i = 0; i < (int)EINA_C_ARRAY_LENGTH(emotion_choices); i++)
|
2012-06-17 00:10:27 -07:00
|
|
|
{
|
2012-06-17 09:03:46 -07:00
|
|
|
if (video_module == emotion_choices[i])
|
|
|
|
break;
|
2012-06-17 00:10:27 -07:00
|
|
|
}
|
2012-06-17 09:03:46 -07:00
|
|
|
|
|
|
|
if (i == EINA_C_ARRAY_LENGTH(emotion_choices))
|
|
|
|
i = 0; /* ecore getopt shouldn't let this happen, but... */
|
|
|
|
config->vidmod = i;
|
2012-06-17 13:24:23 -07:00
|
|
|
config->temporary = EINA_TRUE;
|
2012-06-17 09:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (video_mute != 0xff)
|
|
|
|
{
|
|
|
|
config->mute = video_mute;
|
2012-06-17 13:24:23 -07:00
|
|
|
config->temporary = EINA_TRUE;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-23 18:27:44 -07:00
|
|
|
// set an env so terminal apps can detect they are in terminology :)
|
|
|
|
putenv("TERMINOLOGY=1");
|
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
win = tg_win_add();
|
2012-07-01 19:52:48 -07:00
|
|
|
|
|
|
|
conform = o = elm_conformant_add(win);
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
elm_win_resize_object_add(win, o);
|
|
|
|
evas_object_show(o);
|
2012-06-12 03:10:01 -07:00
|
|
|
|
|
|
|
bg = o = edje_object_add(evas_object_evas_get(win));
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
2012-06-19 08:59:49 -07:00
|
|
|
if (!theme_apply(o, config, "terminology/background"))
|
|
|
|
{
|
|
|
|
CRITICAL("Couldn't find terminology theme! Forgot 'make install'?");
|
|
|
|
retval = EXIT_FAILURE;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
theme_auto_reload_enable(o);
|
2012-07-01 19:52:48 -07:00
|
|
|
elm_object_content_set(conform, o);
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_show(o);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
term = o = termio_add(win, config, cmd, 80, 24);
|
2012-06-12 03:10:01 -07:00
|
|
|
termio_win_set(o, win);
|
|
|
|
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
|
|
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
|
|
evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
|
|
|
|
_cb_size_hint, win);
|
|
|
|
edje_object_part_swallow(bg, "terminology.content", o);
|
2012-06-12 06:08:09 -07:00
|
|
|
evas_object_smart_callback_add(o, "options", _cb_options, NULL);
|
2012-06-16 21:10:17 -07:00
|
|
|
evas_object_smart_callback_add(o, "change", _cb_change, NULL);
|
2012-06-20 07:12:26 -07:00
|
|
|
evas_object_smart_callback_add(o, "exited", _cb_exited, NULL);
|
2012-06-23 02:25:01 -07:00
|
|
|
evas_object_smart_callback_add(o, "bell", _cb_bell, NULL);
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_show(o);
|
|
|
|
|
2012-06-17 13:24:23 -07:00
|
|
|
main_trans_update(config);
|
|
|
|
main_media_update(config);
|
2012-06-19 08:59:49 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_smart_callback_add(win, "focus,in", _cb_focus_in, term);
|
|
|
|
evas_object_smart_callback_add(win, "focus,out", _cb_focus_out, term);
|
|
|
|
_cb_size_hint(win, evas_object_evas_get(win), term, NULL);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
evas_object_show(win);
|
2012-06-12 17:26:00 -07:00
|
|
|
|
2012-06-12 03:10:01 -07:00
|
|
|
elm_run();
|
2012-06-17 09:03:46 -07:00
|
|
|
end:
|
2012-06-17 13:24:23 -07:00
|
|
|
|
|
|
|
config_del(config);
|
2012-06-12 03:10:01 -07:00
|
|
|
config_shutdown();
|
2012-06-17 09:32:23 -07:00
|
|
|
|
|
|
|
eina_log_domain_unregister(_log_domain);
|
|
|
|
_log_domain = -1;
|
|
|
|
|
2012-06-15 23:28:39 -07:00
|
|
|
elm_shutdown();
|
2012-06-17 09:03:46 -07:00
|
|
|
return retval;
|
2012-06-12 03:10:01 -07:00
|
|
|
}
|
|
|
|
ELM_MAIN()
|