(dlg_find_by_id): use the GLib way to find widget.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2011-08-07 18:36:28 +04:00 committed by Slava Zanko
parent 829f79c7e7
commit bb8babce1e

View File

@ -558,6 +558,17 @@ frontend_run_dlg (Dlg_head * h)
} }
} }
/* --------------------------------------------------------------------------------------------- */
static int
dlg_find_widget_by_id (gconstpointer a, gconstpointer b)
{
Widget *w = (Widget *) a;
unsigned long id = GPOINTER_TO_UINT (b);
return w->id == id ? 0 : 1;
}
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
/*** public functions ****************************************************************************/ /*** public functions ****************************************************************************/
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
@ -942,16 +953,10 @@ find_widget_type (const Dlg_head * h, callback_fn callback)
Widget * Widget *
dlg_find_by_id (const Dlg_head * h, unsigned int id) dlg_find_by_id (const Dlg_head * h, unsigned int id)
{ {
if (h->widgets != NULL)
{
GList *w; GList *w;
for (w = h->widgets; w != NULL; w = g_list_next (w)) w = g_list_find_custom (h->widgets, GUINT_TO_POINTER (id), dlg_find_widget_by_id);
if (((Widget *) w->data)->id == id) return w != NULL ? (Widget *) w->data : NULL;
return (Widget *) w->data;
}
return NULL;
} }
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */