mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
Widget and WDialog API changes:
* (widget_destroy): new API to destroy widget. * (del_widget): don't destroy widget after remove it from dialog. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
9506db9148
commit
baca4ba045
@ -903,12 +903,9 @@ del_widget (void *w)
|
||||
if (d == h->current)
|
||||
dlg_set_current_widget_next (h);
|
||||
|
||||
h->widgets = g_list_remove_link (h->widgets, d);
|
||||
h->widgets = g_list_delete_link (h->widgets, d);
|
||||
if (h->widgets == NULL)
|
||||
h->current = NULL;
|
||||
send_message (d->data, NULL, MSG_DESTROY, 0, NULL);
|
||||
g_free (d->data);
|
||||
g_list_free_1 (d);
|
||||
|
||||
/* widget has been deleted in runtime */
|
||||
if (widget_get_state (WIDGET (h), WST_ACTIVE))
|
||||
@ -916,6 +913,8 @@ del_widget (void *w)
|
||||
dlg_redraw (h);
|
||||
dlg_select_current_widget (h);
|
||||
}
|
||||
|
||||
WIDGET (w)->owner = NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1177,8 +1176,8 @@ dlg_destroy (WDialog * h)
|
||||
{
|
||||
/* if some widgets have history, save all history at one moment here */
|
||||
dlg_save_history (h);
|
||||
dlg_broadcast_msg (h, MSG_DESTROY);
|
||||
g_list_free_full (h->widgets, g_free);
|
||||
g_list_foreach (h->widgets, (GFunc) widget_destroy, NULL);
|
||||
g_list_free (h->widgets);
|
||||
mc_event_group_del (h->event_group);
|
||||
g_free (h->event_group);
|
||||
g_free (h->title);
|
||||
|
@ -215,6 +215,15 @@ widget_init (Widget * w, int y, int x, int lines, int cols,
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
widget_destroy (Widget * w)
|
||||
{
|
||||
send_message (w, NULL, MSG_DESTROY, 0, NULL);
|
||||
g_free (w);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/* Default callback for widgets */
|
||||
cb_ret_t
|
||||
widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
|
@ -175,6 +175,7 @@ void hotkey_draw (Widget * w, const hotkey_t hotkey, gboolean focused);
|
||||
/* widget initialization */
|
||||
void widget_init (Widget * w, int y, int x, int lines, int cols,
|
||||
widget_cb_fn callback, widget_mouse_cb_fn mouse_callback);
|
||||
void widget_destroy (Widget * w);
|
||||
/* Default callback for widgets */
|
||||
cb_ret_t widget_default_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm,
|
||||
void *data);
|
||||
|
@ -2268,6 +2268,7 @@ edit_close_cmd (WEdit * edit)
|
||||
unlock_file (edit->filename_vpath);
|
||||
|
||||
del_widget (edit);
|
||||
widget_destroy (WIDGET (edit));
|
||||
|
||||
if (edit_widget_is_editor (CONST_WIDGET (h->current->data)))
|
||||
edit = (WEdit *) h->current->data;
|
||||
|
@ -904,8 +904,7 @@ file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta,
|
||||
progress_buttons[2].text,
|
||||
progress_button_callback));
|
||||
progress_buttons[2].len = button_get_len (BUTTON (progress_buttons[2].w));
|
||||
send_message (progress_buttons[2].w, NULL, MSG_DESTROY, 0, NULL);
|
||||
g_free (progress_buttons[2].w);
|
||||
widget_destroy (progress_buttons[2].w);
|
||||
}
|
||||
progress_buttons[2].w = progress_buttons[1].w;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user