(dlg_replace_widget): rename to widget_replace()

...and move to lib/widget/widget-common.c.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-06-24 10:57:01 +04:00
parent 1672fa44dd
commit c7da120588
5 changed files with 43 additions and 37 deletions

View File

@ -1339,38 +1339,3 @@ dlg_get_title (const WDialog * h, size_t len)
}
/* --------------------------------------------------------------------------------------------- */
/** Replace widget old_w for widget new_w in the dialog */
void
dlg_replace_widget (Widget * old_w, Widget * new_w)
{
WDialog *h = old_w->owner;
gboolean should_focus = FALSE;
if (h->widgets == NULL)
return;
if (h->current == NULL)
h->current = h->widgets;
if (old_w == h->current->data)
should_focus = TRUE;
new_w->owner = h;
new_w->id = old_w->id;
if (should_focus)
h->current->data = new_w;
else
g_list_find (h->widgets, old_w)->data = new_w;
send_message (old_w, NULL, MSG_DESTROY, 0, NULL);
send_message (new_w, NULL, MSG_INIT, 0, NULL);
if (should_focus)
dlg_select_widget (new_w);
widget_redraw (new_w);
}
/* --------------------------------------------------------------------------------------------- */

View File

@ -163,7 +163,6 @@ cb_ret_t dlg_default_callback (Widget * w, Widget * sender, widget_msg_t msg, in
/* Default paint routine for dialogs */
void dlg_default_repaint (WDialog * h);
void dlg_replace_widget (Widget * old, Widget * new);
int dlg_overlap (Widget * a, Widget * b);
void dlg_erase (WDialog * h);
void dlg_stop (WDialog * h);

View File

@ -294,6 +294,46 @@ widget_redraw (Widget * w)
}
}
/* --------------------------------------------------------------------------------------------- */
/**
* Replace widget in the dialog.
*
* @param old_w old widget that need to be replaced
* @param new_w new widget that will replace @old_w
*/
void
widget_replace (Widget * old_w, Widget * new_w)
{
WDialog *h = old_w->owner;
gboolean should_focus = FALSE;
if (h->widgets == NULL)
return;
if (h->current == NULL)
h->current = h->widgets;
if (old_w == h->current->data)
should_focus = TRUE;
new_w->owner = h;
new_w->id = old_w->id;
if (should_focus)
h->current->data = new_w;
else
g_list_find (h->widgets, old_w)->data = new_w;
send_message (old_w, NULL, MSG_DESTROY, 0, NULL);
send_message (new_w, NULL, MSG_INIT, 0, NULL);
if (should_focus)
dlg_select_widget (new_w);
widget_redraw (new_w);
}
/* --------------------------------------------------------------------------------------------- */
/* get mouse pointer location within widget */

View File

@ -146,6 +146,8 @@ void widget_redraw (Widget * w);
void widget_erase (Widget * w);
gboolean widget_is_active (const void *w);
void widget_replace (Widget * old, Widget * new);
/* get mouse pointer location within widget */
Gpm_Event mouse_get_local (const Gpm_Event * global, const Widget * w);
gboolean mouse_global_in_widget (const Gpm_Event * event, const Widget * w);

View File

@ -1038,7 +1038,7 @@ set_display_type (int num, panel_view_mode_t type)
dlg_save_history (midnight_dlg);
}
dlg_replace_widget (old_widget, new_widget);
widget_replace (old_widget, new_widget);
}
if (type == view_listing)