forked from enlightenment/edi
edi_file_screens: refactor UI create/rm/rdir and add directory and file renaming method.
Summary: Add this to the filepanel menus also. Reviewers: ajwillia.ms Differential Revision: https://phab.enlightenment.org/D4920
This commit is contained in:
parent
4614a105aa
commit
37759291c5
|
@ -26,6 +26,7 @@ language/edi_language_provider.h \
|
|||
editor/edi_editor.h \
|
||||
edi_content_provider.h \
|
||||
screens/edi_screens.h \
|
||||
screens/edi_file_screens.h \
|
||||
edi_filepanel.h \
|
||||
edi_file.h \
|
||||
edi_logpanel.h \
|
||||
|
@ -46,6 +47,7 @@ screens/edi_welcome.c \
|
|||
screens/edi_about.c \
|
||||
screens/edi_settings_font.c \
|
||||
screens/edi_settings.c \
|
||||
screens/edi_file_screens.c \
|
||||
edi_filepanel.c \
|
||||
edi_file.c \
|
||||
edi_logpanel.c \
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
#include "Edi.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
#include "edi_file.h"
|
||||
#include "edi_private.h"
|
||||
|
||||
static Evas_Object *_parent_obj, *_popup, *_popup_dir, *_edi_file_message_popup;
|
||||
static const char *_directory_path;
|
||||
|
||||
Eina_Bool
|
||||
edi_file_path_hidden(const char *path)
|
||||
{
|
||||
|
@ -21,186 +17,3 @@ edi_file_path_hidden(const char *path)
|
|||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_message_close_cb(void *data EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_message_open(const char *message)
|
||||
{
|
||||
Evas_Object *popup, *button;
|
||||
|
||||
_edi_file_message_popup = popup = elm_popup_add(_parent_obj);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
message);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "Ok");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_message_close_cb, popup);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del((Evas_Object *)data);
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_create_file_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *name;
|
||||
char *path;
|
||||
const char *directory = _directory_path;
|
||||
FILE *f;
|
||||
|
||||
if (!ecore_file_is_dir(directory))
|
||||
return;
|
||||
|
||||
name = elm_entry_entry_get((Evas_Object *) data);
|
||||
if (!name || strlen(name) == 0)
|
||||
{
|
||||
_edi_file_message_open("Please enter a file name.");
|
||||
return;
|
||||
}
|
||||
|
||||
path = edi_path_append(directory, name);
|
||||
if ((ecore_file_exists(path) && ecore_file_is_dir(path)) ||
|
||||
!ecore_file_exists(path))
|
||||
{
|
||||
f = fopen(path, "w");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
edi_mainview_open_path(path);
|
||||
}
|
||||
else
|
||||
_edi_file_message_open("Unable to write file.");
|
||||
}
|
||||
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
|
||||
evas_object_del(_popup);
|
||||
free(path);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_create_dir_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *name;
|
||||
char *path;
|
||||
const char *directory = _directory_path;
|
||||
|
||||
if (!ecore_file_is_dir(directory)) return;
|
||||
|
||||
name = elm_entry_entry_get((Evas_Object *) data);
|
||||
if (!name || strlen(name) == 0)
|
||||
{
|
||||
_edi_file_message_open("Please enter a directory name.");
|
||||
return;
|
||||
}
|
||||
|
||||
path = edi_path_append(directory, name);
|
||||
|
||||
mkdir(path, 0755);
|
||||
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
|
||||
evas_object_del(_popup_dir);
|
||||
free(path);
|
||||
}
|
||||
|
||||
void
|
||||
edi_file_create_file(Evas_Object *parent, const char *directory)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
|
||||
_parent_obj = parent;
|
||||
_popup = popup = elm_popup_add(parent);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter new file name");
|
||||
_directory_path = eina_stringshare_add(directory);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_popup_cancel_cb, popup);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "create");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_create_file_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
edi_file_create_dir(Evas_Object *parent, const char *directory)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
|
||||
_parent_obj = parent;
|
||||
_directory_path = eina_stringshare_add(directory);
|
||||
|
||||
_popup_dir = popup = elm_popup_add(parent);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter new directory name");
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_popup_cancel_cb, popup);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "create");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_create_dir_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ extern "C" {
|
|||
*
|
||||
* @{
|
||||
*
|
||||
* Management of file/dir creation with the UI
|
||||
* Management of file/dir actions.
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -31,25 +31,6 @@ extern "C" {
|
|||
|
||||
Eina_Bool edi_file_path_hidden(const char *path);
|
||||
|
||||
/**
|
||||
* Create a file add dialogue and add it to the parent obj.
|
||||
*
|
||||
* @param parent The object into which the UI will load.
|
||||
* @param directory The directory root of which file is created.
|
||||
* @ingroup UI
|
||||
*/
|
||||
|
||||
void edi_file_create_file(Evas_Object *parent, const char *directory);
|
||||
|
||||
/**
|
||||
* Create a directory add dialogue and add it to the parent obj.
|
||||
*
|
||||
* @param parent The object into which the UI will load.
|
||||
* @param directory The directory root of which directory is created.
|
||||
* @ingroup UI
|
||||
*/
|
||||
|
||||
void edi_file_create_dir(Evas_Object *parent, const char *directory);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include "edi_file.h"
|
||||
#include "edi_content_provider.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
|
||||
#include "screens/edi_file_screens.h"
|
||||
#include "edi_private.h"
|
||||
|
||||
typedef struct _Edi_Dir_Data
|
||||
|
@ -133,6 +133,15 @@ _item_menu_open_as_image_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
_open_cb(sd->path, "image", EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Edi_Dir_Data *sd = data;
|
||||
|
||||
edi_file_screens_rename(_main_win, sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -182,6 +191,7 @@ _item_menu_create(Evas_Object *win, Edi_Dir_Data *sd)
|
|||
_item_menu_filetype_create(menu, menu_it, "text", _item_menu_open_as_text_cb, sd);
|
||||
_item_menu_filetype_create(menu, menu_it, "code", _item_menu_open_as_code_cb, sd);
|
||||
_item_menu_filetype_create(menu, menu_it, "image", _item_menu_open_as_image_cb, sd);
|
||||
menu_it = elm_menu_item_add(menu, NULL, "document-save-as", "rename", _item_menu_rename_cb, sd);
|
||||
menu_it = elm_menu_item_add(menu, NULL, "edit-delete", "delete", _item_menu_del_cb, sd);
|
||||
}
|
||||
|
||||
|
@ -231,7 +241,7 @@ _item_menu_create_file_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
if (!sd->isdir)
|
||||
return;
|
||||
|
||||
edi_file_create_file(_main_win, sd->path);
|
||||
edi_file_screens_create_file(_main_win, sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -244,7 +254,7 @@ _item_menu_create_dir_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
if (!sd->isdir)
|
||||
return;
|
||||
|
||||
edi_file_create_dir(_main_win, sd->path);
|
||||
edi_file_screens_create_dir(_main_win, sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -257,8 +267,13 @@ _item_menu_dir_create(Evas_Object *win, Edi_Dir_Data *sd)
|
|||
elm_menu_item_add(menu, NULL, "folder-new", "create directory here", _item_menu_create_dir_cb, sd);
|
||||
if (ecore_file_app_installed("terminology"))
|
||||
elm_menu_item_add(menu, NULL, "terminal", "open terminal here", _item_menu_open_terminal_cb, sd);
|
||||
if (ecore_file_dir_is_empty(sd->path))
|
||||
elm_menu_item_add(menu, NULL, "edit-delete", "remove directory", _item_menu_rmdir_cb, sd);
|
||||
|
||||
if (strcmp(sd->path, edi_project_get()))
|
||||
{
|
||||
elm_menu_item_add(menu, NULL, "document-save-as", "rename", _item_menu_rename_cb, sd);
|
||||
if (ecore_file_dir_is_empty(sd->path))
|
||||
elm_menu_item_add(menu, NULL, "edit-delete", "remove directory", _item_menu_rmdir_cb, sd);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "edi_content_provider.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
#include "screens/edi_screens.h"
|
||||
#include "screens/edi_file_screens.h"
|
||||
|
||||
#include "edi_private.h"
|
||||
|
||||
|
@ -582,7 +583,7 @@ _tb_new_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSE
|
|||
|
||||
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
||||
|
||||
edi_file_create_file(_edi_main_win, path);
|
||||
edi_file_screens_create_file(_edi_main_win, path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -728,7 +729,7 @@ _edi_menu_new_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
else
|
||||
path = edi_project_get();
|
||||
|
||||
edi_file_create_file(_edi_main_win, path);
|
||||
edi_file_screens_create_file(_edi_main_win, path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -742,7 +743,7 @@ _edi_menu_new_dir_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
else
|
||||
path = edi_project_get();
|
||||
|
||||
edi_file_create_dir(_edi_main_win, path);
|
||||
edi_file_screens_create_dir(_edi_main_win, path);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -0,0 +1,285 @@
|
|||
#include "Edi.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
#include "edi_file_screens.h"
|
||||
#include "edi_private.h"
|
||||
|
||||
static Evas_Object *_parent_obj, *_popup, *_popup_dir, *_edi_file_screens_message_popup;
|
||||
static const char *_directory_path;
|
||||
|
||||
static void
|
||||
_edi_file_screens_message_close_cb(void *data EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_screens_message_open(const char *message)
|
||||
{
|
||||
Evas_Object *popup, *button;
|
||||
|
||||
_edi_file_screens_message_popup = popup = elm_popup_add(_parent_obj);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
message);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "Ok");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_message_close_cb, popup);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_screens_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del((Evas_Object *)data);
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_screens_create_file_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *name;
|
||||
char *path;
|
||||
const char *directory = _directory_path;
|
||||
FILE *f;
|
||||
|
||||
if (!ecore_file_is_dir(directory))
|
||||
return;
|
||||
|
||||
name = elm_entry_entry_get((Evas_Object *) data);
|
||||
if (!name || strlen(name) == 0)
|
||||
{
|
||||
_edi_file_screens_message_open("Please enter a file name.");
|
||||
return;
|
||||
}
|
||||
|
||||
path = edi_path_append(directory, name);
|
||||
if ((ecore_file_exists(path) && ecore_file_is_dir(path)) ||
|
||||
!ecore_file_exists(path))
|
||||
{
|
||||
f = fopen(path, "w");
|
||||
if (f)
|
||||
{
|
||||
fclose(f);
|
||||
edi_mainview_open_path(path);
|
||||
}
|
||||
else
|
||||
_edi_file_screens_message_open("Unable to write file.");
|
||||
}
|
||||
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
|
||||
evas_object_del(_popup);
|
||||
free(path);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_screens_create_dir_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *name;
|
||||
char *path;
|
||||
const char *directory = _directory_path;
|
||||
|
||||
if (!ecore_file_is_dir(directory)) return;
|
||||
|
||||
name = elm_entry_entry_get((Evas_Object *) data);
|
||||
if (!name || strlen(name) == 0)
|
||||
{
|
||||
_edi_file_screens_message_open("Please enter a directory name.");
|
||||
return;
|
||||
}
|
||||
|
||||
path = edi_path_append(directory, name);
|
||||
|
||||
mkdir(path, 0755);
|
||||
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
|
||||
evas_object_del(_popup_dir);
|
||||
free(path);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_file_screens_rename_cb(void *data,
|
||||
Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *entry;
|
||||
const char *name, *existing_path, *directory;
|
||||
char *path;
|
||||
|
||||
directory = _directory_path;
|
||||
existing_path = (char *) data;
|
||||
|
||||
entry = evas_object_data_get(obj, "input");
|
||||
|
||||
name = elm_entry_entry_get(entry);
|
||||
if (!name || strlen(name) == 0)
|
||||
{
|
||||
_edi_file_screens_message_open("Please enter a valid name.");
|
||||
return;
|
||||
}
|
||||
|
||||
path = edi_path_append(directory, name);
|
||||
|
||||
if (ecore_file_exists(path))
|
||||
{
|
||||
if (ecore_file_is_dir(path))
|
||||
_edi_file_screens_message_open("Directory with that name already exists.");
|
||||
else
|
||||
_edi_file_screens_message_open("File with that name already exists.");
|
||||
return;
|
||||
}
|
||||
|
||||
eina_stringshare_del(_directory_path);
|
||||
_directory_path = NULL;
|
||||
|
||||
if (strcmp(existing_path, path))
|
||||
{
|
||||
if (!ecore_file_is_dir(existing_path))
|
||||
edi_mainview_item_close_path(existing_path);
|
||||
ecore_file_mv(existing_path, path);
|
||||
}
|
||||
|
||||
evas_object_del(_popup);
|
||||
free(path);
|
||||
}
|
||||
|
||||
void
|
||||
edi_file_screens_rename(Evas_Object *parent, const char *path)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
const char *leaf;
|
||||
|
||||
_parent_obj = parent;
|
||||
_popup = popup = elm_popup_add(parent);
|
||||
|
||||
if (ecore_file_is_dir(path))
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Rename directory");
|
||||
else
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Rename file");
|
||||
leaf = ecore_file_file_get(path);
|
||||
_directory_path = eina_stringshare_add(ecore_file_dir_get(path));
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
elm_entry_editable_set(input, EINA_TRUE);
|
||||
elm_object_text_set(input, leaf);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_popup_cancel_cb, popup);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
evas_object_data_set(button, "input", input);
|
||||
elm_object_text_set(button, "rename");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_rename_cb, path);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
edi_file_screens_create_file(Evas_Object *parent, const char *directory)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
|
||||
_parent_obj = parent;
|
||||
_popup = popup = elm_popup_add(parent);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter new file name");
|
||||
_directory_path = eina_stringshare_add(directory);
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_popup_cancel_cb, popup);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "create");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_create_file_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
edi_file_screens_create_dir(Evas_Object *parent, const char *directory)
|
||||
{
|
||||
Evas_Object *popup, *box, *input, *button;
|
||||
|
||||
_parent_obj = parent;
|
||||
_directory_path = eina_stringshare_add(directory);
|
||||
|
||||
_popup_dir = popup = elm_popup_add(parent);
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter new directory name");
|
||||
|
||||
box = elm_box_add(popup);
|
||||
elm_box_horizontal_set(box, EINA_FALSE);
|
||||
elm_object_content_set(popup, box);
|
||||
|
||||
input = elm_entry_add(box);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_align_set(input, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(input);
|
||||
elm_box_pack_end(box, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_popup_cancel_cb, popup);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "create");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_edi_file_screens_create_dir_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
elm_object_focus_set(input, EINA_TRUE);
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
#ifndef __EDI_FILE_SCREENS_H__
|
||||
#define __EDI_FILE_SCREENS_H__
|
||||
|
||||
#include <Elementary.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief These routines used for managing Edi file actions from UI.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief UI management functions.
|
||||
* @defgroup UI
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* Management of file/dir creation with the UI
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Create a file add dialogue and add it to the parent obj.
|
||||
*
|
||||
* @param parent The object into which the UI will load.
|
||||
* @param directory The directory root of which file is created.
|
||||
* @ingroup UI
|
||||
*/
|
||||
|
||||
void edi_file_screens_create_file(Evas_Object *parent, const char *directory);
|
||||
|
||||
/**
|
||||
* Create a directory add dialogue and add it to the parent obj.
|
||||
*
|
||||
* @param parent The object into which the UI will load.
|
||||
* @param directory The directory root of which directory is created.
|
||||
* @ingroup UI
|
||||
*/
|
||||
|
||||
void edi_file_screens_create_dir(Evas_Object *parent, const char *directory);
|
||||
|
||||
/**
|
||||
* Create a dialogue for renaming item and add it to the parent obj
|
||||
*
|
||||
* @param parent The object into which the UI will load
|
||||
* @param path The path of the file or directory to rename
|
||||
* @ingroup UI
|
||||
*/
|
||||
|
||||
void edi_file_screens_rename(Evas_Object *parent, const char *path);
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue