forked from enlightenment/edi
screens: add confirmation dialogue to screens.
Summary: Also add some uses of this method on scm stash and file deletion. Reviewers: ajwillia.ms Reviewed By: ajwillia.ms Differential Revision: https://phab.enlightenment.org/D5028
This commit is contained in:
parent
be2e8af7b4
commit
e4aaffb9d4
|
@ -50,6 +50,7 @@ screens/edi_settings_font.c \
|
|||
screens/edi_settings.c \
|
||||
screens/edi_file_screens.c \
|
||||
screens/edi_scm_screens.c \
|
||||
screens/edi_screens.c \
|
||||
edi_filepanel.c \
|
||||
edi_file.c \
|
||||
edi_logpanel.c \
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "edi_content_provider.h"
|
||||
#include "mainview/edi_mainview.h"
|
||||
#include "screens/edi_file_screens.h"
|
||||
#include "screens/edi_screens.h"
|
||||
#include "edi_private.h"
|
||||
|
||||
typedef struct _Edi_Dir_Data
|
||||
|
@ -143,17 +144,23 @@ _item_menu_rename_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_item_menu_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
_item_menu_del_do_cb(void *data)
|
||||
{
|
||||
Edi_Dir_Data *sd;
|
||||
Edi_Dir_Data *sd = data;
|
||||
|
||||
sd = data;
|
||||
edi_mainview_item_close_path(sd->path);
|
||||
|
||||
ecore_file_unlink(sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_screens_message_confirm(_main_win, "Are you sure you want to delete this file?",
|
||||
_item_menu_del_do_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_scm_add_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
@ -166,8 +173,7 @@ _item_menu_scm_add_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_item_menu_scm_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
_item_menu_scm_del_do_cb(void *data)
|
||||
{
|
||||
Edi_Dir_Data *sd;
|
||||
|
||||
|
@ -177,6 +183,14 @@ _item_menu_scm_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
edi_scm_del(sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_scm_del_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_screens_message_confirm(_main_win, "Are you sure you want to delete this file?",
|
||||
_item_menu_scm_del_do_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_dismissed_cb(void *data EINA_UNUSED, Evas_Object *obj,
|
||||
void *ev EINA_UNUSED)
|
||||
|
@ -253,8 +267,7 @@ _item_menu_open_terminal_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_item_menu_rmdir_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
_item_menu_rmdir_do_cb(void *data)
|
||||
{
|
||||
Edi_Dir_Data *sd;
|
||||
|
||||
|
@ -265,6 +278,14 @@ _item_menu_rmdir_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
|||
ecore_file_recursive_rm(sd->path);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_rmdir_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_screens_message_confirm(_main_win, "Are you sure you want to delete this directory?",
|
||||
_item_menu_rmdir_do_cb, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_menu_create_file_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "screens/edi_screens.h"
|
||||
#include "screens/edi_file_screens.h"
|
||||
#include "screens/edi_scm_screens.h"
|
||||
#include "screens/edi_screens.h"
|
||||
|
||||
#include "edi_private.h"
|
||||
|
||||
|
@ -1008,13 +1009,20 @@ _edi_menu_scm_commit_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
|||
}
|
||||
|
||||
static void
|
||||
_edi_menu_scm_stash_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
_edi_scm_stash_do_cb(void *data EINA_UNUSED)
|
||||
{
|
||||
edi_scm_stash();
|
||||
edi_mainview_refresh_all();
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_scm_stash_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
edi_screens_message_confirm(_edi_main_win, "Are you sure you wish to stash these changes?",
|
||||
_edi_scm_stash_do_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_menu_scm_status_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <Elementary.h>
|
||||
#include <Ecore.h>
|
||||
|
||||
#include "edi_private.h"
|
||||
#include "edi_screens.h"
|
||||
|
||||
static Evas_Object *_edi_screens_popup = NULL;
|
||||
|
||||
static void
|
||||
_edi_screens_popup_cancel_cb(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del((Evas_Object *) data);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_screens_message_confirm_cb(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
void ((*confirm_fn)(void *)) = evas_object_data_get(obj, "callback");
|
||||
|
||||
confirm_fn(data);
|
||||
|
||||
if (_edi_screens_popup)
|
||||
{
|
||||
evas_object_del(_edi_screens_popup);
|
||||
_edi_screens_popup = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void edi_screens_message_confirm(Evas_Object *parent, const char *message, void ((*confirm_cb)(void *)), void *data)
|
||||
{
|
||||
Evas_Object *popup, *table, *label, *button, *icon;
|
||||
|
||||
_edi_screens_popup = popup = elm_popup_add(parent);
|
||||
elm_object_part_text_set(popup, "title,text", "Confirmation required");
|
||||
|
||||
table = elm_table_add(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);
|
||||
|
||||
label = elm_label_add(table);
|
||||
elm_object_text_set(label, message);
|
||||
evas_object_show(label);
|
||||
elm_table_pack(table, label, 1, 0, 1, 1);
|
||||
elm_object_content_set(popup, table);
|
||||
|
||||
evas_object_show(table);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "Yes");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_data_set(button, "callback", confirm_cb);
|
||||
evas_object_smart_callback_add(button, "clicked", _edi_screens_message_confirm_cb, data);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "No");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked", _edi_screens_popup_cancel_cb, popup);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
|
@ -60,6 +60,17 @@ Evas_Object *edi_settings_show(Evas_Object *mainwin);
|
|||
|
||||
void edi_settings_font_add(Evas_Object *parent);
|
||||
|
||||
/**
|
||||
* Create a a confirmation dialogue and add it to the parent obj.
|
||||
*
|
||||
* @param parent The parent object to display the dialogue in.
|
||||
* @param message The generic message to display in the dialogue.
|
||||
* @param confirm_cb Function to execute upon confirmation.
|
||||
* @param data Data to pass to the confirm_cb callback.
|
||||
* @ingroup UI
|
||||
*/
|
||||
void edi_screens_message_confirm(Evas_Object *parent, const char *message, void ((*confirm_cb)(void *)), void *data);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -68,4 +79,4 @@ void edi_settings_font_add(Evas_Object *parent);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif /* EDI_CONSOLEPANEL_H_ */
|
||||
#endif /* EDI_SCREENS_H_ */
|
||||
|
|
Loading…
Reference in New Issue