summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean@guyomarch.bzh>2018-01-01 13:11:47 +0100
committerJean Guyomarc'h <jean@guyomarch.bzh>2018-01-01 13:11:47 +0100
commit8f265a6107d2a1e644d4e6fbbad4e21d6e17e955 (patch)
tree1536590f84e6151b745c056367571389b9930fa8
parent4dfa1eea7d9c25b3ffd922be505e72ce4233e38f (diff)
gui: properly quit neovim when an eovim window is closed
-rw-r--r--src/gui.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/gui.c b/src/gui.c
index 777de85..39e8d8e 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -125,6 +125,20 @@ gui_size_recalculate(s_gui *gui)
125 termview_refresh(gui->termview); 125 termview_refresh(gui->termview);
126} 126}
127 127
128static void
129_win_close_cb(void *data,
130 Evas_Object *obj EINA_UNUSED,
131 void *info EINA_UNUSED)
132{
133 /* When closing the neovim window, send to neovim the :quitall! command
134 * so it will be naturally terminated.
135 *
136 * TODO: see if they are unsaved files ...
137 */
138 s_nvim *const nvim = data;
139 const char cmd[] = ":quitall!";
140 nvim_api_command(nvim, cmd, sizeof(cmd) - 1);
141}
128 142
129Eina_Bool 143Eina_Bool
130gui_add(s_gui *gui, 144gui_add(s_gui *gui,
@@ -154,6 +168,7 @@ gui_add(s_gui *gui,
154 /* Window setup */ 168 /* Window setup */
155 gui->win = elm_win_util_standard_add("eovim", "Eovim"); 169 gui->win = elm_win_util_standard_add("eovim", "Eovim");
156 elm_win_autodel_set(gui->win, EINA_TRUE); 170 elm_win_autodel_set(gui->win, EINA_TRUE);
171 evas_object_smart_callback_add(gui->win, "delete,request", _win_close_cb, nvim);
157 Evas *const evas = evas_object_evas_get(gui->win); 172 Evas *const evas = evas_object_evas_get(gui->win);
158 173
159 174