forked from enlightenment/edi
editor: improve goto line dialog
Focus the input when we show and allow enter press to submit. Also refactor it out of the edi_main mess.
This commit is contained in:
parent
f80b901195
commit
1c7e2b3873
|
@ -42,7 +42,7 @@ static Elm_Object_Item *_edi_logpanel_item, *_edi_consolepanel_item, *_edi_testp
|
||||||
static Elm_Object_Item *_edi_selected_bottompanel;
|
static Elm_Object_Item *_edi_selected_bottompanel;
|
||||||
static Evas_Object *_edi_filepanel, *_edi_filepanel_icon;
|
static Evas_Object *_edi_filepanel, *_edi_filepanel_icon;
|
||||||
|
|
||||||
static Evas_Object *_edi_main_win, *_edi_main_box, *_edi_new_popup, *_edi_goto_popup,*_edi_message_popup;
|
static Evas_Object *_edi_main_win, *_edi_main_box, *_edi_new_popup, *_edi_message_popup;
|
||||||
int _edi_log_dom = -1;
|
int _edi_log_dom = -1;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -584,62 +584,12 @@ _tb_search_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UN
|
||||||
edi_mainview_search();
|
edi_mainview_search();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_tb_goto_go_cb(void *data,
|
|
||||||
Evas_Object *obj EINA_UNUSED,
|
|
||||||
void *event_info EINA_UNUSED)
|
|
||||||
{
|
|
||||||
int number;
|
|
||||||
|
|
||||||
number = atoi(elm_entry_entry_get((Evas_Object *) data));
|
|
||||||
edi_mainview_goto(number);
|
|
||||||
|
|
||||||
evas_object_del(_edi_goto_popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_tb_goto_cancel_cb(void *data EINA_UNUSED,
|
|
||||||
Evas_Object *obj EINA_UNUSED,
|
|
||||||
void *event_info EINA_UNUSED)
|
|
||||||
{
|
|
||||||
evas_object_del(_edi_goto_popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_edi_edit_goto()
|
|
||||||
{
|
|
||||||
Evas_Object *popup, *input, *button;
|
|
||||||
|
|
||||||
popup = elm_popup_add(_edi_main_win);
|
|
||||||
_edi_goto_popup = popup;
|
|
||||||
elm_object_part_text_set(popup, "title,text",
|
|
||||||
"Enter line number");
|
|
||||||
|
|
||||||
input = elm_entry_add(popup);
|
|
||||||
elm_entry_single_line_set(input, EINA_TRUE);
|
|
||||||
elm_object_content_set(popup, 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",
|
|
||||||
_tb_goto_cancel_cb, NULL);
|
|
||||||
|
|
||||||
button = elm_button_add(popup);
|
|
||||||
elm_object_text_set(button, "go");
|
|
||||||
elm_object_part_content_set(popup, "button2", button);
|
|
||||||
evas_object_smart_callback_add(button, "clicked",
|
|
||||||
_tb_goto_go_cb, input);
|
|
||||||
|
|
||||||
evas_object_show(popup);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_tb_goto_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
_tb_goto_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
||||||
|
|
||||||
_edi_edit_goto();
|
edi_mainview_goto_popup_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
@ -776,7 +726,7 @@ static void
|
||||||
_edi_menu_goto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
_edi_menu_goto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||||
void *event_info EINA_UNUSED)
|
void *event_info EINA_UNUSED)
|
||||||
{
|
{
|
||||||
_edi_edit_goto();
|
edi_mainview_goto_popup_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -180,6 +180,10 @@ _smart_cb_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
||||||
{
|
{
|
||||||
edi_mainview_search();
|
edi_mainview_search();
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(ev->key, "g"))
|
||||||
|
{
|
||||||
|
edi_mainview_goto_popup_show();
|
||||||
|
}
|
||||||
else if (!strcmp(ev->key, "z"))
|
else if (!strcmp(ev->key, "z"))
|
||||||
{
|
{
|
||||||
_undo_cb(editor, obj, event);
|
_undo_cb(editor, obj, event);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "edi_config.h"
|
#include "edi_config.h"
|
||||||
|
|
||||||
static Evas_Object *nf, *tb, *_main_win;
|
static Evas_Object *nf, *tb, *_main_win;
|
||||||
static Evas_Object *_edi_mainview_choose_popup;
|
static Evas_Object *_edi_mainview_choose_popup, *_edi_mainview_goto_popup;
|
||||||
static Edi_Path_Options *_edi_mainview_choose_options;
|
static Edi_Path_Options *_edi_mainview_choose_options;
|
||||||
|
|
||||||
static Eina_List *_edi_mainview_items = NULL;
|
static Eina_List *_edi_mainview_items = NULL;
|
||||||
|
@ -572,6 +572,71 @@ edi_mainview_goto(int line)
|
||||||
elm_object_focus_set(editor->entry, EINA_TRUE);
|
elm_object_focus_set(editor->entry, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edi_mainview_goto_popup_go_cb(void *data,
|
||||||
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
int number;
|
||||||
|
|
||||||
|
number = atoi(elm_entry_entry_get((Evas_Object *) data));
|
||||||
|
edi_mainview_goto(number);
|
||||||
|
|
||||||
|
evas_object_del(_edi_mainview_goto_popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edi_mainview_goto_popup_cancel_cb(void *data EINA_UNUSED,
|
||||||
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
void *event_info EINA_UNUSED)
|
||||||
|
{
|
||||||
|
evas_object_del(_edi_mainview_goto_popup);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_edi_mainview_goto_popup_key_up_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
||||||
|
Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Evas_Event_Key_Up *ev = (Evas_Event_Key_Up *)event_info;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
str = elm_object_text_get(obj);
|
||||||
|
|
||||||
|
if (strlen(str) && (!strcmp(ev->key, "KP_Enter") || !strcmp(ev->key, "Return")))
|
||||||
|
_edi_mainview_goto_popup_go_cb(obj, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_mainview_goto_popup_show()
|
||||||
|
{
|
||||||
|
Evas_Object *popup, *input, *button;
|
||||||
|
|
||||||
|
popup = elm_popup_add(_main_win);
|
||||||
|
_edi_mainview_goto_popup = popup;
|
||||||
|
elm_object_part_text_set(popup, "title,text",
|
||||||
|
"Enter line number");
|
||||||
|
|
||||||
|
input = elm_entry_add(popup);
|
||||||
|
elm_entry_single_line_set(input, EINA_TRUE);
|
||||||
|
evas_object_event_callback_add(input, EVAS_CALLBACK_KEY_UP, _edi_mainview_goto_popup_key_up_cb, NULL);
|
||||||
|
elm_object_content_set(popup, 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_mainview_goto_popup_cancel_cb, NULL);
|
||||||
|
|
||||||
|
button = elm_button_add(popup);
|
||||||
|
elm_object_text_set(button, "go");
|
||||||
|
elm_object_part_content_set(popup, "button2", button);
|
||||||
|
evas_object_smart_callback_add(button, "clicked",
|
||||||
|
_edi_mainview_goto_popup_go_cb, input);
|
||||||
|
|
||||||
|
evas_object_show(popup);
|
||||||
|
elm_object_focus_set(input, EINA_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edi_mainview_add(Evas_Object *parent, Evas_Object *win)
|
edi_mainview_add(Evas_Object *parent, Evas_Object *win)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,7 +89,6 @@ void edi_mainview_open_window_path(const char *path);
|
||||||
*/
|
*/
|
||||||
void edi_mainview_open_window(Edi_Path_Options *options);
|
void edi_mainview_open_window(Edi_Path_Options *options);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save the current file.
|
* Save the current file.
|
||||||
*
|
*
|
||||||
|
@ -148,6 +147,13 @@ void edi_mainview_search();
|
||||||
*/
|
*/
|
||||||
void edi_mainview_goto(int line);
|
void edi_mainview_goto(int line);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Present a popup that will initiate a goto in the current view.
|
||||||
|
*
|
||||||
|
* @ingroup Content
|
||||||
|
*/
|
||||||
|
void edi_mainview_goto_popup_show();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue