From c7da1205881caf3e103a2dc65d88d032735ed19b Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Mon, 24 Jun 2013 10:57:01 +0400 Subject: [PATCH] (dlg_replace_widget): rename to widget_replace() ...and move to lib/widget/widget-common.c. Signed-off-by: Andrew Borodin --- lib/widget/dialog.c | 35 ----------------------------------- lib/widget/dialog.h | 1 - lib/widget/widget-common.c | 40 ++++++++++++++++++++++++++++++++++++++++ lib/widget/widget-common.h | 2 ++ src/filemanager/layout.c | 2 +- 5 files changed, 43 insertions(+), 37 deletions(-) diff --git a/lib/widget/dialog.c b/lib/widget/dialog.c index 69fca0720..53496ac22 100644 --- a/lib/widget/dialog.c +++ b/lib/widget/dialog.c @@ -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); -} - -/* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/dialog.h b/lib/widget/dialog.h index 32f7852aa..6595fd61f 100644 --- a/lib/widget/dialog.h +++ b/lib/widget/dialog.h @@ -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); diff --git a/lib/widget/widget-common.c b/lib/widget/widget-common.c index 4449a5834..52711514e 100644 --- a/lib/widget/widget-common.c +++ b/lib/widget/widget-common.c @@ -295,6 +295,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 */ Gpm_Event diff --git a/lib/widget/widget-common.h b/lib/widget/widget-common.h index f9a732660..c36c3cd09 100644 --- a/lib/widget/widget-common.h +++ b/lib/widget/widget-common.h @@ -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); diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index eb7a53b1d..01afca68b 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -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) -- 2.11.4.GIT