ui: allow loading of a single file

Simple mode just now, see how it works out
This commit is contained in:
Andy Williams 2016-07-03 21:06:22 +01:00
parent 0e9b8a64c6
commit 214792b73e
4 changed files with 34 additions and 9 deletions

View File

@ -1018,7 +1018,7 @@ _edi_open_tabs()
}
}
Evas_Object *
Eina_Bool
edi_open(const char *inputpath)
{
Evas_Object *win, *vbx, *content, *tb;
@ -1028,7 +1028,7 @@ edi_open(const char *inputpath)
if (!edi_project_set(inputpath))
{
fprintf(stderr, "Project path must be a directory\n");
return NULL;
return EINA_FALSE;
}
path = realpath(inputpath, NULL);
_edi_project_config_load();
@ -1039,7 +1039,7 @@ edi_open(const char *inputpath)
winname = _edi_win_title_get(path);
win = elm_win_util_standard_add("main", winname);
free((char*)winname);
if (!win) return NULL;
if (!win) return EINA_FALSE;
_edi_main_win = win;
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
@ -1072,7 +1072,18 @@ edi_open(const char *inputpath)
ecore_event_handler_add(EDI_EVENT_CONFIG_CHANGED, _edi_config_changed, NULL);
free(path);
return win;
return EINA_TRUE;
}
void
edi_open_file(const char *filepath)
{
// TODO we should make this window more functional (i.e. toolbar etc)
edi_project_set(eina_environment_home_get());
_edi_project_config_load();
edi_mainview_open_window_path(filepath);
}
void
@ -1096,6 +1107,12 @@ edi_open_url(const char *url)
free(cmd);
}
Eina_Bool
edi_noproject()
{
return !_edi_main_win;
}
static Eina_Bool
_edi_log_init()
{
@ -1136,7 +1153,6 @@ static const Ecore_Getopt optdesc = {
EAPI_MAIN int
elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
{
Evas_Object *win;
int args;
Eina_Bool quit_option = EINA_FALSE;
const char *project_path = NULL;
@ -1191,7 +1207,11 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
if (!edi_welcome_show())
goto end;
}
else if (!(win = edi_open(project_path)))
else if (!ecore_file_is_dir(project_path))
{
edi_open_file(project_path);
}
else if (!(edi_open(project_path)))
goto end;
elm_run();

View File

@ -1,7 +1,7 @@
#ifndef EDI_PRIVATE_H_
# define EDI_PRIVATE_H_
#include <Evas.h>
#include <Eina.h>
#include <Elementary.h>
extern int _edi_log_dom;
@ -31,12 +31,14 @@ extern int _edi_log_dom;
#define FONT_PREVIEW " Evas *dostuff(void) {...}"
Evas_Object *edi_open(const char *path);
Eina_Bool edi_open(const char *path);
void edi_close();
void edi_open_url();
Eina_Bool edi_noproject();
// TODO remove this once our filepanel is updating gracefully
void _edi_filepanel_reload();

View File

@ -219,6 +219,9 @@ _edi_mainview_win_exit(void *data EINA_UNUSED, Evas_Object *obj, void *event_inf
_edi_project_config_tab_remove(it->path);
eina_stringshare_del(it->path);
if (edi_noproject())
edi_close();
free(it);
}

View File

@ -80,7 +80,7 @@ _edi_welcome_project_open(const char *path, const unsigned int _edi_creating)
{
edi_project_set(path);
if ((edi_open(edi_project_get()) == NULL) && !_edi_creating)
if (!edi_open(edi_project_get()) && !_edi_creating)
{
_edi_message_path = path;
_edi_message_open("Apparently that project directory doesn't exist", EINA_TRUE);