From 5e2f4a80696586c5a3965c7925a9c2790b7dbc6e Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Fri, 25 Nov 2016 09:32:04 +0300 Subject: [PATCH] WCheck: change type of 'state' from int to gboolean. Signed-off-by: Andrew Borodin --- lib/widget/check.c | 8 ++++---- lib/widget/check.h | 6 ++---- lib/widget/quick.c | 2 +- lib/widget/quick.h | 2 +- src/filemanager/boxes.c | 12 ++++++------ src/filemanager/chmod.c | 2 +- src/filemanager/find.c | 30 +++++++++++++++--------------- src/filemanager/layout.c | 18 +++++++++--------- 8 files changed, 39 insertions(+), 41 deletions(-) diff --git a/lib/widget/check.c b/lib/widget/check.c index 08d749e63..1fdcf8791 100644 --- a/lib/widget/check.c +++ b/lib/widget/check.c @@ -73,7 +73,7 @@ check_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d case MSG_KEY: if (parm != ' ') return MSG_NOT_HANDLED; - c->state ^= C_BOOL; + c->state = !c->state; widget_redraw (w); send_message (w->owner, w, MSG_NOTIFY, (int) MSG_KEY, NULL); return MSG_HANDLED; @@ -89,7 +89,7 @@ check_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *d focused = widget_get_state (w, WST_FOCUSED); widget_selectcolor (w, focused, FALSE); widget_move (w, 0, 0); - tty_print_string ((c->state & C_BOOL) ? "[x] " : "[ ] "); + tty_print_string (c->state ? "[x] " : "[ ] "); hotkey_draw (w, c->text, focused); return MSG_HANDLED; } @@ -131,7 +131,7 @@ check_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) /* --------------------------------------------------------------------------------------------- */ WCheck * -check_new (int y, int x, int state, const char *text) +check_new (int y, int x, gboolean state, const char *text) { WCheck *c; Widget *w; @@ -142,7 +142,7 @@ check_new (int y, int x, int state, const char *text) /* 4 is width of "[X] " */ widget_init (w, y, x, 1, 4 + hotkey_width (c->text), check_callback, check_mouse_callback); w->options |= WOP_SELECTABLE | WOP_WANT_CURSOR | WOP_WANT_HOTKEY; - c->state = state ? C_BOOL : 0; + c->state = state; return c; } diff --git a/lib/widget/check.h b/lib/widget/check.h index 1ddfa3093..3f23e0216 100644 --- a/lib/widget/check.h +++ b/lib/widget/check.h @@ -10,8 +10,6 @@ #define CHECK(x) ((WCheck *)(x)) -#define C_BOOL 0x0001 - /*** enums ***************************************************************************************/ /*** structures declarations (and typedefs of structures)*****************************************/ @@ -19,7 +17,7 @@ typedef struct WCheck { Widget widget; - unsigned int state; /* check button state */ + gboolean state; /* check button state */ hotkey_t text; /* text of check button */ } WCheck; @@ -27,7 +25,7 @@ typedef struct WCheck /*** declarations of public functions ************************************************************/ -WCheck *check_new (int y, int x, int state, const char *text); +WCheck *check_new (int y, int x, gboolean state, const char *text); /*** inline functions ****************************************************************************/ diff --git a/lib/widget/quick.c b/lib/widget/quick.c index ea088d403..5ccad4dbe 100644 --- a/lib/widget/quick.c +++ b/lib/widget/quick.c @@ -586,7 +586,7 @@ 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 = CHECK (item->widget)->state & C_BOOL; + *item->quick_widget->u.checkbox.state = CHECK (item->widget)->state; break; case quick_input: diff --git a/lib/widget/quick.h b/lib/widget/quick.h index 267be27d4..86c027c88 100644 --- a/lib/widget/quick.h +++ b/lib/widget/quick.h @@ -279,7 +279,7 @@ struct quick_widget_t struct { const char *text; - int *state; /* in/out */ + gboolean *state; /* in/out */ } checkbox; struct diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index 07648772a..8d16d6964 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -132,7 +132,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 && parm == (int) MSG_KEY) { - const gboolean not_single = !(CHECK (sender)->state & C_BOOL); + const gboolean not_single = !CHECK (sender)->state; Widget *ww; /* input line */ @@ -289,7 +289,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, ch = CHECK (dlg_find_by_id (h, mini_user_status_id)); in3 = INPUT (dlg_find_by_id (h, mini_user_format_id)); - if (!(ch->state & C_BOOL)) + if (!ch->state) input_assign_text (in3, status_format[RADIO (sender)->sel]); input_update (in1, FALSE); input_update (in2, FALSE); @@ -305,7 +305,7 @@ panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, in = INPUT (dlg_find_by_id (h, mini_user_format_id)); - if (CHECK (sender)->state & C_BOOL) + if (CHECK (sender)->state) { widget_disable (WIDGET (in), FALSE); input_assign_text (in, status_format[3]); @@ -403,7 +403,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 && parm == (int) MSG_KEY) { - const gboolean not_use = !(CHECK (sender)->state & C_BOOL); + const gboolean not_use = !CHECK (sender)->state; Widget *wi; /* input */ @@ -693,8 +693,8 @@ panel_options_box (void) return; } - mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION, - "simple_swap", (gboolean) (simple_swap & C_BOOL)); + mc_config_set_bool (mc_global.main_config, CONFIG_PANELS_SECTION, "simple_swap", + (gboolean) simple_swap); if (!panels_options.fast_reload_msg_shown && panels_options.fast_reload) { diff --git a/src/filemanager/chmod.c b/src/filemanager/chmod.c index 573d0f0df..9265e6e37 100644 --- a/src/filemanager/chmod.c +++ b/src/filemanager/chmod.c @@ -504,7 +504,7 @@ chmod_cmd (void) for (i = 0; i < check_perm_num; i++) if (check_perm[i].selected || result == B_ALL) { - if (check_perm[i].check->state & C_BOOL) + if (check_perm[i].check->state) or_mask |= check_perm[i].mode; else and_mask &= ~check_perm[i].mode; diff --git a/src/filemanager/find.c b/src/filemanager/find.c index da495726f..a6548479a 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -425,7 +425,7 @@ find_check_regexp (const char *r) static void find_toggle_enable_ignore_dirs (void) { - widget_disable (WIDGET (in_ignore), !(ignore_dirs_cbox->state & C_BOOL)); + widget_disable (WIDGET (in_ignore), !ignore_dirs_cbox->state); } /* --------------------------------------------------------------------------------------------- */ @@ -501,8 +501,8 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi return MSG_HANDLED; /* check filename regexp */ - if (!(file_pattern_cbox->state & C_BOOL) - && (in_name->buffer[0] != '\0') && !find_check_regexp (in_name->buffer)) + if (!file_pattern_cbox->state && (in_name->buffer[0] != '\0') + && !find_check_regexp (in_name->buffer)) { /* Don't stop the dialog */ widget_set_state (WIDGET (h), WST_ACTIVE, TRUE); @@ -512,7 +512,7 @@ find_parm_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, voi } /* check content regexp */ - if ((content_regexp_cbox->state & C_BOOL) && (in_with->buffer[0] != '\0') + if (content_regexp_cbox->state && (in_with->buffer[0] != '\0') && !find_check_regexp (in_with->buffer)) { /* Don't stop the dialog */ @@ -799,18 +799,18 @@ find_parameters (char **start_dir, ssize_t * start_dir_len, char *s; #ifdef HAVE_CHARSET - options.file_all_charsets = file_all_charsets_cbox->state & C_BOOL; - options.content_all_charsets = content_all_charsets_cbox->state & C_BOOL; + options.file_all_charsets = file_all_charsets_cbox->state; + options.content_all_charsets = content_all_charsets_cbox->state; #endif - options.content_case_sens = content_case_sens_cbox->state & C_BOOL; - options.content_regexp = content_regexp_cbox->state & C_BOOL; - options.content_first_hit = content_first_hit_cbox->state & C_BOOL; - options.content_whole_words = content_whole_words_cbox->state & C_BOOL; - options.find_recurs = recursively_cbox->state & C_BOOL; - options.file_pattern = file_pattern_cbox->state & C_BOOL; - options.file_case_sens = file_case_sens_cbox->state & C_BOOL; - options.skip_hidden = skip_hidden_cbox->state & C_BOOL; - options.ignore_dirs_enable = ignore_dirs_cbox->state & C_BOOL; + options.content_case_sens = content_case_sens_cbox->state; + options.content_regexp = content_regexp_cbox->state; + options.content_first_hit = content_first_hit_cbox->state; + options.content_whole_words = content_whole_words_cbox->state; + options.find_recurs = recursively_cbox->state; + options.file_pattern = file_pattern_cbox->state; + options.file_case_sens = file_case_sens_cbox->state; + options.skip_hidden = skip_hidden_cbox->state; + options.ignore_dirs_enable = ignore_dirs_cbox->state; g_free (options.ignore_dirs); options.ignore_dirs = g_strdup (in_ignore->buffer); diff --git a/src/filemanager/layout.c b/src/filemanager/layout.c index c70cb0bd5..f2e94ddfb 100644 --- a/src/filemanager/layout.c +++ b/src/filemanager/layout.c @@ -228,7 +228,7 @@ update_split (const WDialog * h) check_options[0].widget->state = panels_layout.vertical_equal ? 1 : 0; widget_redraw (WIDGET (check_options[0].widget)); - tty_setcolor ((check_options[0].widget->state & C_BOOL) ? DISABLED_COLOR : COLOR_NORMAL); + tty_setcolor (check_options[0].widget->state ? DISABLED_COLOR : COLOR_NORMAL); widget_move (h, 6, 5); if (panels_layout.horizontal_split) @@ -333,10 +333,10 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * { int _menubar_visible, _command_prompt, _keybar_visible, _message_visible; - _menubar_visible = check_options[1].widget->state & C_BOOL; - _command_prompt = check_options[2].widget->state & C_BOOL; - _keybar_visible = check_options[3].widget->state & C_BOOL; - _message_visible = check_options[4].widget->state & C_BOOL; + _menubar_visible = check_options[1].widget->state; + _command_prompt = check_options[2].widget->state; + _keybar_visible = check_options[3].widget->state; + _message_visible = check_options[4].widget->state; if (mc_global.tty.console_flag != '\0') { @@ -410,12 +410,12 @@ layout_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void * if (panels_layout.horizontal_split) { - panels_layout.horizontal_equal = check_options[0].widget->state & C_BOOL; + panels_layout.horizontal_equal = check_options[0].widget->state; eq = panels_layout.horizontal_equal; } else { - panels_layout.vertical_equal = check_options[0].widget->state & C_BOOL; + panels_layout.vertical_equal = check_options[0].widget->state; eq = panels_layout.vertical_equal; } @@ -513,7 +513,7 @@ init_layout (void) dlg_create (TRUE, 0, 0, 15, width, WPOS_CENTER, FALSE, dialog_colors, layout_callback, NULL, "[Layout]", _("Layout")); -#define XTRACT(i) *check_options[i].variable, check_options[i].text +#define XTRACT(i) (*check_options[i].variable != 0), check_options[i].text /* "Panel split" groupbox */ add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1)); @@ -650,7 +650,7 @@ layout_box (void) for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++) if (check_options[i].widget != NULL) - *check_options[i].variable = check_options[i].widget->state & C_BOOL; + *check_options[i].variable = check_options[i].widget->state; output_lines = _output_lines; }