From: Andrew Borodin Date: Thu, 11 Oct 2012 08:25:07 +0000 (+0400) Subject: Add useful macros for widget type cast. X-Git-Tag: 4.8.7~19^2~2 X-Git-Url: https://repo.or.cz/w/midnight-commander.git/commitdiff_plain/2ec122bc05f54b0d3bb6052bb596231ef4541bc3 Add useful macros for widget type cast. Signed-off-by: Andrew Borodin --- diff --git a/lib/widget/button.c b/lib/widget/button.c index 4d5f7b45f..0c1b5fc90 100644 --- a/lib/widget/button.c +++ b/lib/widget/button.c @@ -57,7 +57,7 @@ static cb_ret_t button_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WButton *b = (WButton *) w; + WButton *b = BUTTON (w); WDialog *h = w->owner; int stop = 0; int off = 0; diff --git a/lib/widget/button.h b/lib/widget/button.h index 39c7bf720..dccb2b26b 100644 --- a/lib/widget/button.h +++ b/lib/widget/button.h @@ -8,6 +8,7 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define BUTTON(x) ((WButton *)(x)) struct WButton; diff --git a/lib/widget/buttonbar.c b/lib/widget/buttonbar.c index 31f5f1257..82acc7eca 100644 --- a/lib/widget/buttonbar.c +++ b/lib/widget/buttonbar.c @@ -160,7 +160,7 @@ buttonbar_call (WButtonBar * bb, int i) static cb_ret_t buttonbar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WButtonBar *bb = (WButtonBar *) w; + WButtonBar *bb = BUTTONBAR (w); int i; const char *text; @@ -224,7 +224,7 @@ buttonbar_event (Gpm_Event * event, void *data) if ((event->type & GPM_UP) != 0) { - WButtonBar *bb = (WButtonBar *) data; + WButtonBar *bb = BUTTONBAR (data); Gpm_Event local; int button; @@ -288,5 +288,5 @@ buttonbar_set_label (WButtonBar * bb, int idx, const char *text, WButtonBar * find_buttonbar (const WDialog * h) { - return (WButtonBar *) find_widget_type (h, buttonbar_callback); + return BUTTONBAR (find_widget_type (h, buttonbar_callback)); } diff --git a/lib/widget/buttonbar.h b/lib/widget/buttonbar.h index 9d18632c8..d6694a11a 100644 --- a/lib/widget/buttonbar.h +++ b/lib/widget/buttonbar.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define BUTTONBAR(x) ((WButtonBar *)(x)) + /* number of bttons in buttonbar */ #define BUTTONBAR_LABELS_NUM 10 diff --git a/lib/widget/check.c b/lib/widget/check.c index cdb9fd166..7e34fdd56 100644 --- a/lib/widget/check.c +++ b/lib/widget/check.c @@ -56,7 +56,7 @@ static cb_ret_t check_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WCheck *c = (WCheck *) w; + WCheck *c = CHECK (w); switch (msg) { diff --git a/lib/widget/check.h b/lib/widget/check.h index 9c823b26b..ed541399d 100644 --- a/lib/widget/check.h +++ b/lib/widget/check.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define CHECK(x) ((WCheck *)(x)) + #define C_BOOL 0x0001 #define C_CHANGE 0x0002 diff --git a/lib/widget/gauge.c b/lib/widget/gauge.c index 04bc29b6a..1c7355c2b 100644 --- a/lib/widget/gauge.c +++ b/lib/widget/gauge.c @@ -61,7 +61,7 @@ static cb_ret_t gauge_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WGauge *g = (WGauge *) w; + WGauge *g = GAUGE (w); WDialog *h = w->owner; if (msg == MSG_INIT) diff --git a/lib/widget/gauge.h b/lib/widget/gauge.h index 52658b411..9b149a763 100644 --- a/lib/widget/gauge.h +++ b/lib/widget/gauge.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define GAUGE(x) ((WGauge *)(x)) + /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/lib/widget/groupbox.c b/lib/widget/groupbox.c index 5fff66809..39aeccd55 100644 --- a/lib/widget/groupbox.c +++ b/lib/widget/groupbox.c @@ -55,7 +55,7 @@ static cb_ret_t groupbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WGroupbox *g = (WGroupbox *) w; + WGroupbox *g = GROUPBOX (w); switch (msg) { diff --git a/lib/widget/groupbox.h b/lib/widget/groupbox.h index e6b792065..1ff6f3b43 100644 --- a/lib/widget/groupbox.h +++ b/lib/widget/groupbox.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define GROUPBOX(x) ((WGroupbox *)(x)) + /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/lib/widget/history.c b/lib/widget/history.c index b482bc5cf..9ccf7b975 100644 --- a/lib/widget/history.c +++ b/lib/widget/history.c @@ -369,9 +369,8 @@ history_show (GList ** history, Widget * widget, int current) z = NULL; for (hi = query_list->list; hi != NULL; hi = g_list_next (hi)) { - WLEntry *entry; + WLEntry *entry = LENTRY (hi->data); - entry = (WLEntry *) hi->data; /* history is being reverted here again */ z = g_list_prepend (z, entry->text); entry->text = NULL; diff --git a/lib/widget/hline.c b/lib/widget/hline.c index 5308d5336..22ea76725 100644 --- a/lib/widget/hline.c +++ b/lib/widget/hline.c @@ -56,7 +56,7 @@ static cb_ret_t hline_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WHLine *l = (WHLine *) w; + WHLine *l = HLINE (w); WDialog *h = w->owner; switch (msg) diff --git a/lib/widget/hline.h b/lib/widget/hline.h index 68f34915c..0f0c1977c 100644 --- a/lib/widget/hline.h +++ b/lib/widget/hline.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define HLINE(x) ((WHLine *)(x)) + /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/lib/widget/input.c b/lib/widget/input.c index 52bb520d4..b65aa7a42 100644 --- a/lib/widget/input.c +++ b/lib/widget/input.c @@ -831,7 +831,7 @@ static gboolean input_load_history (const gchar * event_group_name, const gchar * event_name, gpointer init_data, gpointer data) { - WInput *in = (WInput *) init_data; + WInput *in = INPUT (init_data); ev_history_load_save_t *ev = (ev_history_load_save_t *) data; const char *def_text; size_t buffer_len; @@ -874,7 +874,7 @@ static gboolean input_save_history (const gchar * event_group_name, const gchar * event_name, gpointer init_data, gpointer data) { - WInput *in = (WInput *) init_data; + WInput *in = INPUT (init_data); (void) event_group_name; (void) event_name; @@ -928,7 +928,7 @@ input_destroy (WInput * in) static int input_event (Gpm_Event * event, void *data) { - WInput *in = (WInput *) data; + WInput *in = INPUT (data); Widget *w = WIDGET (data); if (!mouse_global_in_widget (event, w)) @@ -983,7 +983,7 @@ input_event (Gpm_Event * event, void *data) static void input_set_options_callback (Widget * w, widget_options_t options, gboolean enable) { - WInput *in = (WInput *) w; + WInput *in = INPUT (w); widget_default_set_options_callback (w, options, enable); if (in->label != NULL) @@ -1059,7 +1059,7 @@ input_new (int y, int x, const int *input_colors, int width, const char *def_tex cb_ret_t input_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WInput *in = (WInput *) w; + WInput *in = INPUT (w); cb_ret_t v; switch (msg) diff --git a/lib/widget/input.h b/lib/widget/input.h index 42dc5bf1e..e82ecd4d3 100644 --- a/lib/widget/input.h +++ b/lib/widget/input.h @@ -10,6 +10,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define INPUT(x) ((WInput *)(x)) + /* For history load-save functions */ #define INPUT_LAST_TEXT ((char *) 2) diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c index dba925f85..b47a506a4 100644 --- a/lib/widget/input_complete.c +++ b/lib/widget/input_complete.c @@ -1092,14 +1092,14 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d new_end = str_get_prev_char (&input->buffer[end]) - input->buffer; - for (i = 0, e = ((WListbox *) h->current->data)->list; + for (i = 0, e = LISTBOX (h->current->data)->list; e != NULL; i++, e = g_list_next (e)) { - WLEntry *le = (WLEntry *) e->data; + WLEntry *le = LENTRY (e->data); if (strncmp (input->buffer + start, le->text, new_end - start) == 0) { - listbox_select_entry ((WListbox *) h->current->data, i); + listbox_select_entry (LISTBOX (h->current->data), i); end = new_end; input_handle_char (input, parm); send_message (h->current->data, NULL, MSG_DRAW, 0, NULL); @@ -1143,10 +1143,10 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d return MSG_HANDLED; } - for (i = 0, e = ((WListbox *) h->current->data)->list; + for (i = 0, e = LISTBOX (h->current->data)->list; e != NULL; i++, e = g_list_next (e)) { - WLEntry *le = (WLEntry *) e->data; + WLEntry *le = LENTRY (e->data); if (strncmp (input->buffer + start, le->text, end - start) == 0 && strncmp (&le->text[end - start], buff, bl) == 0) @@ -1154,7 +1154,7 @@ query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d if (need_redraw == 0) { need_redraw = 1; - listbox_select_entry ((WListbox *) h->current->data, i); + listbox_select_entry (LISTBOX (h->current->data), i); last_text = le->text; } else diff --git a/lib/widget/label.c b/lib/widget/label.c index 8ecbd7a8b..ec31c3226 100644 --- a/lib/widget/label.c +++ b/lib/widget/label.c @@ -59,7 +59,7 @@ static cb_ret_t label_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WLabel *l = (WLabel *) w; + WLabel *l = LABEL (w); WDialog *h = w->owner; switch (msg) diff --git a/lib/widget/label.h b/lib/widget/label.h index bcee62920..9b7573f89 100644 --- a/lib/widget/label.h +++ b/lib/widget/label.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define LABEL(x) ((WLabel *)(x)) + /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c index ade0f4450..1bcda01bb 100644 --- a/lib/widget/listbox.c +++ b/lib/widget/listbox.c @@ -161,7 +161,8 @@ listbox_draw (WListbox * l, gboolean focused) text = ""; else { - WLEntry *e = (WLEntry *) le->data; + WLEntry *e = LENTRY (le->data); + text = e->text; le = g_list_next (le); pos++; @@ -189,7 +190,7 @@ listbox_check_hotkey (WListbox * l, int key) for (i = 0, le = l->list; le != NULL; i++, le = g_list_next (le)) { - WLEntry *e = (WLEntry *) le->data; + WLEntry *e = LENTRY (le->data); if (e->hotkey == key) return i; @@ -367,7 +368,7 @@ listbox_destroy (WListbox * l) static cb_ret_t listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WListbox *l = (WListbox *) w; + WListbox *l = LISTBOX (w); WDialog *h = w->owner; cb_ret_t ret_code; @@ -441,7 +442,7 @@ listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void static int listbox_event (Gpm_Event * event, void *data) { - WListbox *l = (WListbox *) data; + WListbox *l = LISTBOX (data); Widget *w = WIDGET (data); if (!mouse_global_in_widget (event, w)) @@ -553,7 +554,7 @@ listbox_search_text (WListbox * l, const char *text) for (i = 0, le = l->list; le != NULL; i++, le = g_list_next (le)) { - WLEntry *e = (WLEntry *) le->data; + WLEntry *e = LENTRY (le->data); if (strcmp (e->text, text) == 0) return i; @@ -632,7 +633,7 @@ listbox_get_current (WListbox * l, char **string, void **extra) gboolean ok; if (l != NULL) - e = (WLEntry *) g_list_nth_data (l->list, l->pos); + e = LENTRY (g_list_nth_data (l->list, l->pos)); ok = (e != NULL); @@ -654,7 +655,7 @@ listbox_remove_current (WListbox * l) current = g_list_nth (l->list, l->pos); l->list = g_list_remove_link (l->list, current); - listbox_entry_free ((WLEntry *) current->data); + listbox_entry_free (LENTRY (current->data)); g_list_free_1 (current); l->count--; diff --git a/lib/widget/listbox.h b/lib/widget/listbox.h index 88424848b..eee50b7c9 100644 --- a/lib/widget/listbox.h +++ b/lib/widget/listbox.h @@ -10,6 +10,9 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define LISTBOX(x) ((WListbox *)(x)) +#define LENTRY(x) ((WLEntry *)(x)) + /*** enums ***************************************************************************************/ /* callback should return one of the following values */ diff --git a/lib/widget/menu.c b/lib/widget/menu.c index 29de4d7ab..54f4251f0 100644 --- a/lib/widget/menu.c +++ b/lib/widget/menu.c @@ -544,7 +544,7 @@ menubar_handle_key (WMenuBar * menubar, int key) static cb_ret_t menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WMenuBar *menubar = (WMenuBar *) w; + WMenuBar *menubar = MENUBAR (w); switch (msg) { @@ -606,7 +606,7 @@ menubar_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void static int menubar_event (Gpm_Event * event, void *data) { - WMenuBar *menubar = (WMenuBar *) data; + WMenuBar *menubar = MENUBAR (data); Widget *w = WIDGET (data); gboolean was_active = TRUE; int left_x, right_x, bottom_y; @@ -915,7 +915,7 @@ menubar_arrange (WMenuBar * menubar) WMenuBar * find_menubar (const WDialog * h) { - return (WMenuBar *) find_widget_type (h, menubar_callback); + return MENUBAR (find_widget_type (h, menubar_callback)); } /* --------------------------------------------------------------------------------------------- */ diff --git a/lib/widget/menu.h b/lib/widget/menu.h index d6cb0f04e..93511abaf 100644 --- a/lib/widget/menu.h +++ b/lib/widget/menu.h @@ -11,6 +11,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define MENUBAR(x) ((WMenuBar *)(x)) + #define menu_separator_create() NULL /*** enums ***************************************************************************************/ diff --git a/lib/widget/quick.c b/lib/widget/quick.c index 2cb9aafe4..ce0f9ca0d 100644 --- a/lib/widget/quick.c +++ b/lib/widget/quick.c @@ -150,7 +150,7 @@ quick_create_labeled_input (GArray * widgets, int *y, int x, quick_widget_t * qu return; } - ((WInput *) in.widget)->label = (WLabel *) label.widget; + INPUT (in.widget)->label = LABEL (label.widget); /* cross references */ label.quick_widget->u.label.input = in.quick_widget; in.quick_widget->u.input.label = label.quick_widget; @@ -465,7 +465,7 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip) case quick_input: { - Widget *label = WIDGET (((WInput *) item->widget)->label); + Widget *label = WIDGET (INPUT (item->widget)->label); int width = column_width; if (g != NULL) @@ -495,12 +495,12 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip) } /* forced update internal variables of inpuit line */ - input_set_origin ((WInput *) (item->widget), item->widget->x, item->widget->cols); + input_set_origin (INPUT (item->widget), item->widget->x, item->widget->cols); } break; case quick_start_groupbox: - g = (WGroupbox *) item->widget; + g = GROUPBOX (item->widget); if (item->widget->x != x1) item->widget->x = x2; item->widget->cols = column_width; @@ -517,20 +517,20 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip) { Widget *wg = WIDGET (g); - ((WHLine *) item->widget)->auto_adjust_cols = FALSE; + HLINE (item->widget)->auto_adjust_cols = FALSE; item->widget->x = wg->x + 1 - WIDGET (wg->owner)->x; item->widget->cols = wg->cols; } else if (two_columns) { - ((WHLine *) item->widget)->auto_adjust_cols = FALSE; + HLINE (item->widget)->auto_adjust_cols = FALSE; if (item->widget->x != x1) item->widget->x = x2; item->widget->x--; item->widget->cols = column_width + 2; } else - ((WHLine *) item->widget)->auto_adjust_cols = TRUE; + HLINE (item->widget)->auto_adjust_cols = TRUE; } break; @@ -583,20 +583,19 @@ quick_dialog_skip (quick_dialog_t * quick_dlg, int nskip) switch (item->quick_widget->widget_type) { case quick_checkbox: - *item->quick_widget->u.checkbox.state = ((WCheck *) item->widget)->state & C_BOOL; + *item->quick_widget->u.checkbox.state = CHECK (item->widget)->state & C_BOOL; break; case quick_input: if ((quick_widget->u.input.flags & 2) != 0) *item->quick_widget->u.input.result = - tilde_expand (((WInput *) item->widget)->buffer); + tilde_expand (INPUT (item->widget)->buffer); else - *item->quick_widget->u.input.result = - g_strdup (((WInput *) item->widget)->buffer); + *item->quick_widget->u.input.result = g_strdup (INPUT (item->widget)->buffer); break; case quick_radio: - *item->quick_widget->u.radio.value = ((WRadio *) item->widget)->sel; + *item->quick_widget->u.radio.value = RADIO (item->widget)->sel; break; default: diff --git a/lib/widget/radio.c b/lib/widget/radio.c index 92b3dd088..a3eedef96 100644 --- a/lib/widget/radio.c +++ b/lib/widget/radio.c @@ -56,7 +56,7 @@ static cb_ret_t radio_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WRadio *r = (WRadio *) w; + WRadio *r = RADIO (w); int i; switch (msg) @@ -153,7 +153,7 @@ radio_event (Gpm_Event * event, void *data) if ((event->type & (GPM_DOWN | GPM_UP)) != 0) { - WRadio *r = (WRadio *) data; + WRadio *r = RADIO (data); Gpm_Event local; local = mouse_get_local (event, w); diff --git a/lib/widget/radio.h b/lib/widget/radio.h index 87a88d82e..c6addf821 100644 --- a/lib/widget/radio.h +++ b/lib/widget/radio.h @@ -8,6 +8,8 @@ /*** typedefs(not structures) and defined constants **********************************************/ +#define RADIO(x) ((WRadio *)(x)) + /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c index d3adfb944..620264503 100644 --- a/src/editor/editcmd.c +++ b/src/editor/editcmd.c @@ -128,7 +128,7 @@ edit_save_mode_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm Widget *ww; ww = dlg_find_by_id (DIALOG (w), edit_save_mode_input_id); - widget_disable (ww, ((WRadio *) sender)->sel != 2); + widget_disable (ww, RADIO (sender)->sel != 2); return MSG_HANDLED; } diff --git a/src/editor/editwidget.c b/src/editor/editwidget.c index d1101fc08..af8a26c6a 100644 --- a/src/editor/editwidget.c +++ b/src/editor/editwidget.c @@ -661,7 +661,7 @@ edit_dialog_event (Gpm_Event * event, void *data) w = WIDGET (find_menubar (h)); - if (event->y == wh->y + 1 && (event->type & GPM_DOWN) != 0 && !((WMenuBar *) w)->is_active) + if (event->y == wh->y + 1 && (event->type & GPM_DOWN) != 0 && !MENUBAR (w)->is_active) { /* menubar */ diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c index 092439c08..53fa3a64f 100644 --- a/src/filemanager/achown.c +++ b/src/filemanager/achown.c @@ -570,7 +570,7 @@ advanced_chown_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm if (f_pos > 2) break; flag_pos = f_pos * 3 + i; /* (strchr(ch_perm,parm)-ch_perm); */ - if (((WButton *) h->current->data)->text.start[(flag_pos % 3)] == '-') + if (BUTTON (h->current->data)->text.start[(flag_pos % 3)] == '-') ch_flags[flag_pos] = '+'; else ch_flags[flag_pos] = '-'; diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index 46d82fe47..290fde515 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -134,8 +134,8 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, { WInput *in; - in = (WInput *) dlg_find_by_id (h, mini_user_format_id); - input_assign_text (in, status_format[((WRadio *) wi)->sel]); + in = INPUT (dlg_find_by_id (h, mini_user_format_id)); + input_assign_text (in, status_format[RADIO (wi)->sel]); dlg_stop (h); return MSG_HANDLED; } @@ -169,7 +169,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, { WRadio *r; - r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id); + r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); r->pos = r->sel = panel_listing_user_idx; dlg_select_widget (WIDGET (r)); /* force redraw */ send_message (h, r, MSG_ACTION, 0, NULL); @@ -185,15 +185,15 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, WCheck *ch; WInput *in1, *in2; - in1 = (WInput *) dlg_find_by_id (h, panel_user_format_id); - ch = (WCheck *) dlg_find_by_id (h, mini_user_status_id); - in2 = (WInput *) dlg_find_by_id (h, mini_user_format_id); + in1 = INPUT (dlg_find_by_id (h, panel_user_format_id)); + ch = CHECK (dlg_find_by_id (h, mini_user_status_id)); + in2 = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (!(ch->state & C_BOOL)) - input_assign_text (in2, status_format[((WRadio *) sender)->sel]); + input_assign_text (in2, status_format[RADIO (sender)->sel]); input_update (in2, FALSE); input_update (in1, FALSE); - widget_disable (WIDGET (in1), ((WRadio *) sender)->sel != panel_listing_user_idx); + widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx); return MSG_HANDLED; } @@ -201,9 +201,9 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, { WInput *in; - in = (WInput *) dlg_find_by_id (h, mini_user_format_id); + in = INPUT (dlg_find_by_id (h, mini_user_format_id)); - if (((WCheck *) sender)->state & C_BOOL) + if (CHECK (sender)->state & C_BOOL) { widget_disable (WIDGET (in), FALSE); input_assign_text (in, status_format[3]); @@ -212,7 +212,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, { WRadio *r; - r = (WRadio *) dlg_find_by_id (h, panel_listing_types_id); + r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); widget_disable (WIDGET (in), TRUE); input_assign_text (in, status_format[r->sel]); } @@ -254,7 +254,7 @@ sel_charset_button (WButton * button, int action) /* avoid strange bug with label repainting */ g_snprintf (buf, sizeof (buf), "%-27s", cpname); w = dlg_find_by_id (WIDGET (button)->owner, disp_bits_name_id); - label_set_text ((WLabel *) w, buf); + label_set_text (LABEL (w), buf); } return 0; @@ -311,7 +311,7 @@ confvfs_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void /* message from "Always use ftp proxy" checkbutton */ if (sender != NULL && sender->id == ftpfs_always_use_proxy_id) { - const gboolean not_use = !(((WCheck *) sender)->state & C_BOOL); + const gboolean not_use = !(CHECK (sender)->state & C_BOOL); Widget *wi; /* input */ diff --git a/src/filemanager/command.c b/src/filemanager/command.c index 6fd049f20..4cb197319 100644 --- a/src/filemanager/command.c +++ b/src/filemanager/command.c @@ -337,8 +337,6 @@ enter (WInput * lc_cmdline) static cb_ret_t command_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { - WInput *cmd = (WInput *) w; - switch (msg) { case MSG_FOCUS: @@ -348,7 +346,7 @@ command_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void case MSG_KEY: /* Special case: we handle the enter key */ if (parm == '\n') - return enter (cmd); + return enter (INPUT (w)); /* fall through */ default: diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 1c2190af2..90b31d592 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -1714,7 +1714,7 @@ do_find (const char *start_dir, ssize_t start_dir_len, const char *ignore_dirs, for (i = 0, entry = find_list->list; entry != NULL; i++, entry = g_list_next (entry)) { const char *lc_filename = NULL; - WLEntry *le = (WLEntry *) entry->data; + WLEntry *le = LENTRY (entry->data); char *p; if ((le->text == NULL) || (le->data == NULL)) diff --git a/src/filemanager/option.c b/src/filemanager/option.c index 7da0f1cad..1894858d2 100644 --- a/src/filemanager/option.c +++ b/src/filemanager/option.c @@ -70,7 +70,7 @@ configure_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi /* message from "Single press" checkbutton */ if (sender != NULL && sender->id == configure_old_esc_mode_id) { - const gboolean not_single = !(((WCheck *) sender)->state & C_BOOL); + const gboolean not_single = !(CHECK (sender)->state & C_BOOL); Widget *ww; /* input line */ diff --git a/src/learn.c b/src/learn.c index b3ba36b8a..57d2ed698 100644 --- a/src/learn.c +++ b/src/learn.c @@ -181,7 +181,7 @@ learn_check_key (int c) dlg_select_widget (learnkeys[i].button); /* TRANSLATORS: This label appears near learned keys. Keep it short. */ - label_set_text ((WLabel *) learnkeys[i].label, _("OK")); + label_set_text (LABEL (learnkeys[i].label), _("OK")); learnkeys[i].ok = TRUE; learnok++; if (learnok >= learn_total)