editor: Changes in Editor Mode.
This commit is contained in:
parent
1ae1048960
commit
c9500ca7e5
|
@ -250,7 +250,7 @@ _item_menu_open_window_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
if (sd->isdir)
|
if (sd->isdir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_open_cb(sd->path, NULL, EINA_TRUE);
|
edi_open_new(sd->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -2,10 +2,6 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* NOTE: Respecting header order is important for portability.
|
|
||||||
* Always put system first, then EFL, then your public header,
|
|
||||||
* and finally your private one. */
|
|
||||||
|
|
||||||
#include <Ecore_Getopt.h>
|
#include <Ecore_Getopt.h>
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
#include <Eio.h>
|
#include <Eio.h>
|
||||||
|
@ -1559,6 +1555,8 @@ _edi_win_title_get()
|
||||||
provider = edi_build_provider_for_project_get();
|
provider = edi_build_provider_for_project_get();
|
||||||
if (provider)
|
if (provider)
|
||||||
type = provider->id;
|
type = provider->id;
|
||||||
|
else if (!edi_project_mode_get())
|
||||||
|
type = _("editor");
|
||||||
else
|
else
|
||||||
type = _("unknown");
|
type = _("unknown");
|
||||||
|
|
||||||
|
@ -1570,6 +1568,31 @@ _edi_win_title_get()
|
||||||
return winname;
|
return winname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_main_win_title_set(const char *path)
|
||||||
|
{
|
||||||
|
char *title;
|
||||||
|
|
||||||
|
if (edi_project_mode_get() || !path)
|
||||||
|
{
|
||||||
|
title = _edi_win_title_get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
title = strdup(eina_slstr_printf(_("%s - Edi"), path));
|
||||||
|
}
|
||||||
|
|
||||||
|
elm_win_title_set(edi_main_win_get(), title);
|
||||||
|
|
||||||
|
free(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_main_win_title_reset(void)
|
||||||
|
{
|
||||||
|
edi_main_win_title_set(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
_edi_exit(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
|
@ -1845,6 +1868,12 @@ edi_close()
|
||||||
elm_exit();
|
elm_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_open_new(const char *path)
|
||||||
|
{
|
||||||
|
ecore_exe_run(eina_slstr_printf("edi %s", path), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edi_open_url(const char *url)
|
edi_open_url(const char *url)
|
||||||
{
|
{
|
||||||
|
@ -1860,12 +1889,6 @@ edi_open_url(const char *url)
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
Eina_Bool
|
|
||||||
edi_noproject()
|
|
||||||
{
|
|
||||||
return !_edi_main_win;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_edi_log_init()
|
_edi_log_init()
|
||||||
{
|
{
|
||||||
|
@ -1970,12 +1993,27 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
|
||||||
}
|
}
|
||||||
else if (!ecore_file_is_dir(project_path))
|
else if (!ecore_file_is_dir(project_path))
|
||||||
{
|
{
|
||||||
|
FILE *f;
|
||||||
const char *mime;
|
const char *mime;
|
||||||
|
|
||||||
|
/* Here we attempt to open a file that exists or create one if it does not. */
|
||||||
|
|
||||||
if (!ecore_file_exists(project_path))
|
if (!ecore_file_exists(project_path))
|
||||||
{
|
{
|
||||||
fprintf(stderr, _("Could not open file (%s)\n"), project_path);
|
f = fopen(project_path, "w");
|
||||||
goto end;
|
if (f)
|
||||||
|
{
|
||||||
|
if (fclose(f))
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("Could not create file (%s) (%s)\n"), project_path, strerror(errno));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, _("Could not open file (%s) (%s)\n"), project_path, strerror(errno));
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mime = edi_mime_type_get(project_path);
|
mime = edi_mime_type_get(project_path);
|
||||||
|
|
|
@ -47,19 +47,18 @@ extern int EDI_EVENT_FILE_SAVED;
|
||||||
#define FONT_PREVIEW " Evas *dostuff(void) {...}"
|
#define FONT_PREVIEW " Evas *dostuff(void) {...}"
|
||||||
|
|
||||||
Eina_Bool edi_open(const char *path);
|
Eina_Bool edi_open(const char *path);
|
||||||
|
void edi_open_new(const char *path);
|
||||||
Evas_Object *edi_main_win_get(void);
|
Evas_Object *edi_main_win_get(void);
|
||||||
|
void edi_main_win_title_set(const char *path);
|
||||||
|
void edi_main_win_title_reset(void);
|
||||||
|
|
||||||
void edi_close();
|
void edi_close();
|
||||||
|
|
||||||
void edi_open_url();
|
void edi_open_url();
|
||||||
|
|
||||||
Eina_Bool edi_noproject();
|
|
||||||
|
|
||||||
void edi_launcher_config_missing();
|
void edi_launcher_config_missing();
|
||||||
void edi_debug_exe_missing(void);
|
void edi_debug_exe_missing(void);
|
||||||
|
|
||||||
|
|
||||||
Eina_Bool _edi_project_config_save_no_notify(void);
|
Eina_Bool _edi_project_config_save_no_notify(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -63,6 +63,64 @@ _edi_editor_file_change_ignore_cb(void *data, Evas_Object *obj EINA_UNUSED, void
|
||||||
editor->popup = NULL;
|
editor->popup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edi_editor_file_save_fail_popup(Evas_Object *parent, Edi_Editor *editor)
|
||||||
|
{
|
||||||
|
Evas_Object *table, *frame, *box, *label, *sep, *icon, *button;
|
||||||
|
|
||||||
|
if (editor->popup)
|
||||||
|
return;
|
||||||
|
|
||||||
|
editor->popup = elm_popup_add(parent);
|
||||||
|
elm_popup_orient_set(editor->popup, ELM_POPUP_ORIENT_CENTER);
|
||||||
|
elm_popup_scrollable_set(editor->popup, EINA_TRUE);
|
||||||
|
elm_object_part_text_set(editor->popup, "title,text", _("Permission Denied"));
|
||||||
|
evas_object_size_hint_align_set(editor->popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
evas_object_size_hint_weight_set(editor->popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
|
||||||
|
table = elm_table_add(editor->popup);
|
||||||
|
icon = elm_icon_add(table);
|
||||||
|
elm_icon_standard_set(icon, "dialog-warning");
|
||||||
|
evas_object_size_hint_min_set(icon, 48 * elm_config_scale_get(), 48 * elm_config_scale_get());
|
||||||
|
evas_object_size_hint_weight_set(icon, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
|
evas_object_size_hint_align_set(icon, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
|
evas_object_show(icon);
|
||||||
|
elm_table_pack(table, icon, 0, 0, 1, 1);
|
||||||
|
|
||||||
|
frame = elm_frame_add(editor->popup);
|
||||||
|
elm_object_content_set(frame, table);
|
||||||
|
evas_object_show(frame);
|
||||||
|
|
||||||
|
box = elm_box_add(editor->popup);
|
||||||
|
label = elm_label_add(editor->popup);
|
||||||
|
elm_object_text_set(label, _("Unable to save file. Would you like to reload <br> the contents of this file?"));
|
||||||
|
evas_object_show(label);
|
||||||
|
elm_box_pack_end(box, label);
|
||||||
|
|
||||||
|
sep = elm_separator_add(box);
|
||||||
|
elm_separator_horizontal_set(sep, EINA_TRUE);
|
||||||
|
evas_object_show(sep);
|
||||||
|
elm_box_pack_end(box, sep);
|
||||||
|
evas_object_show(box);
|
||||||
|
elm_table_pack(table, box, 1, 0, 1, 1);
|
||||||
|
|
||||||
|
elm_object_content_set(editor->popup, frame);
|
||||||
|
evas_object_show(table);
|
||||||
|
|
||||||
|
button = elm_button_add(editor->popup);
|
||||||
|
elm_object_text_set(button, _("Reload"));
|
||||||
|
elm_object_part_content_set(editor->popup, "button1", button);
|
||||||
|
evas_object_smart_callback_add(button, "clicked", _edi_editor_file_change_reload_cb, editor);
|
||||||
|
|
||||||
|
button = elm_button_add(editor->popup);
|
||||||
|
elm_object_text_set(button, _("No, continue editing"));
|
||||||
|
elm_object_part_content_set(editor->popup, "button2", button);
|
||||||
|
evas_object_smart_callback_add(button, "clicked", _edi_editor_file_change_ignore_cb, editor);
|
||||||
|
|
||||||
|
evas_object_show(editor->popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edi_editor_file_change_popup(Evas_Object *parent, Edi_Editor *editor)
|
_edi_editor_file_change_popup(Evas_Object *parent, Edi_Editor *editor)
|
||||||
{
|
{
|
||||||
|
@ -133,6 +191,13 @@ edi_editor_save(Edi_Editor *editor)
|
||||||
|
|
||||||
filename = elm_code_file_path_get(code->file);
|
filename = elm_code_file_path_get(code->file);
|
||||||
|
|
||||||
|
// TODO: elm_code_file_save() should handle this.
|
||||||
|
if (!ecore_file_can_write(filename))
|
||||||
|
{
|
||||||
|
_edi_editor_file_save_fail_popup(editor->entry, editor);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
elm_code_file_save(code->file);
|
elm_code_file_save(code->file);
|
||||||
|
|
||||||
editor->save_time = ecore_file_mod_time(filename);
|
editor->save_time = ecore_file_mod_time(filename);
|
||||||
|
@ -1108,6 +1173,8 @@ _focused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
||||||
filename = elm_code_file_path_get(code->file);
|
filename = elm_code_file_path_get(code->file);
|
||||||
mtime = ecore_file_mod_time(filename);
|
mtime = ecore_file_mod_time(filename);
|
||||||
|
|
||||||
|
edi_main_win_title_set(filename);
|
||||||
|
|
||||||
if ((editor->save_time) && (editor->save_time < mtime))
|
if ((editor->save_time) && (editor->save_time < mtime))
|
||||||
{
|
{
|
||||||
ecore_timer_del(editor->save_timer);
|
ecore_timer_del(editor->save_timer);
|
||||||
|
|
|
@ -25,11 +25,7 @@ static Evas_Object *_main_win, *_mainview_panel;
|
||||||
static Evas_Object *_edi_mainview_search_project_popup;
|
static Evas_Object *_edi_mainview_search_project_popup;
|
||||||
|
|
||||||
static Edi_Mainview_Panel *_current_panel;
|
static Edi_Mainview_Panel *_current_panel;
|
||||||
static Eina_List *_edi_mainview_panels = NULL, *_edi_mainview_wins = NULL;
|
static Eina_List *_edi_mainview_panels = NULL;
|
||||||
|
|
||||||
static void
|
|
||||||
dummy()
|
|
||||||
{}
|
|
||||||
|
|
||||||
Eina_Bool
|
Eina_Bool
|
||||||
edi_mainview_is_empty(void)
|
edi_mainview_is_empty(void)
|
||||||
|
@ -158,117 +154,6 @@ edi_mainview_tab_select(unsigned int id)
|
||||||
edi_mainview_panel_tab_select(_current_panel, id);
|
edi_mainview_panel_tab_select(_current_panel, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_edi_mainview_win_exit(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|
||||||
{
|
|
||||||
Edi_Mainview_Item *it;
|
|
||||||
|
|
||||||
evas_object_hide(obj);
|
|
||||||
|
|
||||||
it = evas_object_data_get(obj, "edi_mainview_item");
|
|
||||||
_edi_mainview_wins = eina_list_remove(_edi_mainview_wins, it);
|
|
||||||
|
|
||||||
_edi_project_config_tab_remove(it->path, EINA_TRUE, 0);
|
|
||||||
eina_stringshare_del(it->path);
|
|
||||||
|
|
||||||
if (edi_noproject())
|
|
||||||
edi_close();
|
|
||||||
free(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
|
||||||
_edi_mainview_win_title_get(const char *path)
|
|
||||||
{
|
|
||||||
return eina_slstr_printf(_("Edi :: %s"), ecore_file_file_get(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
static Evas_Object *
|
|
||||||
_edi_mainview_content_create(Edi_Mainview_Item *item, Evas_Object *parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
Evas_Object *container;
|
|
||||||
|
|
||||||
container = elm_box_add(parent);
|
|
||||||
evas_object_size_hint_weight_set(container, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(container, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
evas_object_show(container);
|
|
||||||
|
|
||||||
item->loaded = EINA_FALSE;
|
|
||||||
item->container = container;
|
|
||||||
// TODO not in 2 halfs
|
|
||||||
Edi_Content_Provider *provider;
|
|
||||||
Evas_Object *child;
|
|
||||||
|
|
||||||
provider = edi_content_provider_for_id_get(item->editortype);
|
|
||||||
if (!provider)
|
|
||||||
{
|
|
||||||
ERR("No content provider found for type %s", item->editortype);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
child = provider->content_ui_add(item->container, item);
|
|
||||||
|
|
||||||
evas_object_size_hint_weight_set(child, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
|
||||||
evas_object_size_hint_align_set(child, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
|
||||||
elm_box_pack_end(item->container, child);
|
|
||||||
evas_object_show(child);
|
|
||||||
|
|
||||||
item->loaded = EINA_TRUE;
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_edi_mainview_item_win_add(Edi_Path_Options *options, const char *mime)
|
|
||||||
{
|
|
||||||
Evas_Object *win, *content;
|
|
||||||
Edi_Mainview_Item *item;
|
|
||||||
Edi_Editor *editor;
|
|
||||||
|
|
||||||
win = elm_win_util_standard_add("mainview", _edi_mainview_win_title_get(options->path));
|
|
||||||
if (!win) return;
|
|
||||||
|
|
||||||
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
|
||||||
evas_object_smart_callback_add(win, "delete,request", _edi_mainview_win_exit, NULL);
|
|
||||||
item = edi_mainview_item_add(options, mime, NULL, win);
|
|
||||||
_edi_mainview_wins = eina_list_append(_edi_mainview_wins, item);
|
|
||||||
evas_object_data_set(win, "edi_mainview_item", item);
|
|
||||||
|
|
||||||
content = _edi_mainview_content_create(item, win);
|
|
||||||
elm_win_resize_object_add(win, content);
|
|
||||||
|
|
||||||
// Set focus on the newly opening window so that one can just start typing
|
|
||||||
editor = (Edi_Editor *)evas_object_data_get(content, "editor");
|
|
||||||
if (editor)
|
|
||||||
elm_object_focus_set(editor->entry, EINA_TRUE);
|
|
||||||
|
|
||||||
evas_object_resize(win, 380 * elm_config_scale_get(), 260 * elm_config_scale_get());
|
|
||||||
evas_object_show(win);
|
|
||||||
|
|
||||||
_edi_project_config_tab_add(options->path, mime?mime:options->type, EINA_TRUE, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_edi_mainview_win_stat_done(void *data, Eio_File *handler EINA_UNUSED, const Eina_Stat *stat)
|
|
||||||
{
|
|
||||||
Edi_Path_Options *options;
|
|
||||||
Edi_Content_Provider *provider;
|
|
||||||
const char *mime;
|
|
||||||
|
|
||||||
options = data;
|
|
||||||
if (!S_ISREG(stat->mode))
|
|
||||||
return;
|
|
||||||
|
|
||||||
mime = edi_mime_type_get(options->path);
|
|
||||||
provider = edi_content_provider_for_mime_get(mime);
|
|
||||||
if (!provider)
|
|
||||||
{
|
|
||||||
//TODO _edi_mainview_mime_content_safe_popup();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
options->type = provider->id;
|
|
||||||
_edi_mainview_item_win_add(options, mime);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
edi_mainview_open_path(const char *path)
|
edi_mainview_open_path(const char *path)
|
||||||
{
|
{
|
||||||
|
@ -358,26 +243,7 @@ edi_mainview_open_window(Edi_Path_Options *options)
|
||||||
{
|
{
|
||||||
edi_mainview_item_close_path(options->path);
|
edi_mainview_item_close_path(options->path);
|
||||||
|
|
||||||
if (options->type == NULL)
|
edi_open_new(options->path);
|
||||||
{
|
|
||||||
eio_file_direct_stat(options->path, _edi_mainview_win_stat_done, dummy, options);
|
|
||||||
}
|
|
||||||
else if (!edi_content_provider_for_id_get(options->type))
|
|
||||||
{
|
|
||||||
const char *mime = options->type;
|
|
||||||
Edi_Content_Provider *provider = edi_content_provider_for_mime_get(mime);
|
|
||||||
|
|
||||||
if (provider)
|
|
||||||
options->type = provider->id;
|
|
||||||
else
|
|
||||||
options->type = NULL;
|
|
||||||
|
|
||||||
_edi_mainview_item_win_add(options, mime);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_edi_mainview_item_win_add(options, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -435,8 +301,8 @@ edi_mainview_new_window()
|
||||||
item = edi_mainview_item_current_get();
|
item = edi_mainview_item_current_get();
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
// TODO OPTIONS!
|
|
||||||
edi_mainview_open_window_path(item->path);
|
edi_open_new(item->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -449,6 +449,11 @@ _closetab(void *data, Evas_Object *obj EINA_UNUSED,
|
||||||
|
|
||||||
if (eina_list_count(panel->items))
|
if (eina_list_count(panel->items))
|
||||||
_edi_mainview_panel_current_tab_show(panel);
|
_edi_mainview_panel_current_tab_show(panel);
|
||||||
|
|
||||||
|
if (eina_list_count(panel->items) == 0 && edi_mainview_panel_count() == 1)
|
||||||
|
{
|
||||||
|
edi_main_win_title_reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
|
|
|
@ -109,7 +109,7 @@ _edi_welcome_project_open(const char *path, const unsigned int _edi_creating)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ecore_exe_run(eina_slstr_printf("edi %s", path), NULL);
|
edi_open_new(path);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue