static void init_panelize (void) { struct { int ret_cmd; button_flags_t flags; const char *text; } panelize_but[] = { /* *INDENT-OFF* */ { B_ENTER, DEFPUSH_BUTTON, N_("Pane&lize") }, { B_REMOVE, NORMAL_BUTTON, N_("&Remove") }, { B_ADD, NORMAL_BUTTON, N_("&Add new") }, { B_CANCEL, NORMAL_BUTTON, N_("&Cancel") } /* *INDENT-ON* */ }; size_t i; int blen; int panelize_cols; struct panelize *current; int x, y; last_listitem = 0; do_refresh (); i = G_N_ELEMENTS (panelize_but); blen = i - 1; /* gaps between buttons */ while (i-- != 0) { #ifdef ENABLE_NLS panelize_but[i].text = _(panelize_but[i].text); #endif blen += str_term_width1 (panelize_but[i].text) + 3 + 1; if (panelize_but[i].flags == DEFPUSH_BUTTON) blen += 2; } panelize_cols = COLS - 6; panelize_cols = max (panelize_cols, blen + 4); panelize_dlg = dlg_create (TRUE, 0, 0, 20, panelize_cols, dialog_colors, panelize_callback, NULL, "[External panelize]", _("External panelize"), DLG_CENTER); /* add listbox to the dialogs */ y = UY; add_widget (panelize_dlg, groupbox_new (y++, UX, 12, panelize_cols - UX * 2, "")); l_panelize = listbox_new (y, UX + 1, 10, panelize_cols - UX * 2 - 2, FALSE, NULL); for (current = panelize; current != NULL; current = current->next) listbox_add_item (l_panelize, LISTBOX_APPEND_AT_END, 0, current->label, current); listbox_select_entry (l_panelize, listbox_search_text (l_panelize, _("Other command"))); add_widget (panelize_dlg, l_panelize); y += WIDGET (l_panelize)->lines + 1; add_widget (panelize_dlg, label_new (y++, UX, _("Command"))); pname = input_new (y++, UX, input_colors, panelize_cols - UX * 2, "", "in", INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES | INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES | INPUT_COMPLETE_CD | INPUT_COMPLETE_SHELL_ESC); add_widget (panelize_dlg, pname); add_widget (panelize_dlg, hline_new (y++, -1, -1)); x = (panelize_cols - blen) / 2; for (i = 0; i < G_N_ELEMENTS (panelize_but); i++) { WButton *b; b = button_new (y, x, panelize_but[i].ret_cmd, panelize_but[i].flags, panelize_but[i].text, NULL); add_widget (panelize_dlg, b); x += button_get_len (b) + 1; } dlg_select_widget (l_panelize); }
static void init_chown_advanced (void) { int i; int dlg_h = 12; int dlg_w = 74; int y; static gboolean i18n = FALSE; if (!i18n) { for (i = BUTTONS_PERM; i < BUTTONS; i++) { #ifdef ENABLE_NLS chown_advanced_but[i].text = _(chown_advanced_but[i].text); #endif /* ENABLE_NLS */ chown_advanced_but[i].len = str_term_width1 (chown_advanced_but[i].text) + 3; if (chown_advanced_but[i].flags == DEFPUSH_BUTTON) chown_advanced_but[i].len += 2; /* "<>" */ } i18n = TRUE; } do_refresh (); sf_stat = g_new (struct stat, 1); current_file = 0; end_chown = need_update = FALSE; single_set = (current_panel->marked < 2); memset (ch_flags, '=', 11); flag_pos = 0; x_toggle = 070; if (!single_set) dlg_h += 2; ch_dlg = dlg_create (TRUE, 0, 0, dlg_h, dlg_w, dialog_colors, advanced_chown_callback, NULL, "[Advanced Chown]", _("Chown advanced command"), DLG_CENTER); l_filename = label_new (2, 3, ""); add_widget (ch_dlg, l_filename); add_widget (ch_dlg, hline_new (3, -1, -1)); #define XTRACT(i,y) y, BX+chown_advanced_but[i].x, \ chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, \ (chown_advanced_but[i].text), NULL b_att[0] = button_new (XTRACT (0, BY)); chown_advanced_but[0].id = add_widget (ch_dlg, b_att[0]); b_att[1] = button_new (XTRACT (1, BY)); chown_advanced_but[1].id = add_widget (ch_dlg, b_att[1]); b_att[2] = button_new (XTRACT (2, BY)); chown_advanced_but[2].id = add_widget (ch_dlg, b_att[2]); b_user = button_new (XTRACT (3, BY)); chown_advanced_but[3].id = add_widget (ch_dlg, b_user); b_group = button_new (XTRACT (4, BY)); chown_advanced_but[4].id = add_widget (ch_dlg, b_group); #undef XTRACT l_mode = label_new (BY + 2, 3, ""); add_widget (ch_dlg, l_mode); y = BY + 3; if (!single_set) { i = BUTTONS_PERM; add_widget (ch_dlg, hline_new (y++, -1, -1)); chown_advanced_but[i].id = add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 - chown_advanced_but[i].len, chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, chown_advanced_but[i].text, NULL)); i++; chown_advanced_but[i].id = add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, chown_advanced_but[i].text, NULL)); y++; } i = BUTTONS_PERM + 2; add_widget (ch_dlg, hline_new (y++, -1, -1)); chown_advanced_but[i].id = add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 - chown_advanced_but[i].len, chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, chown_advanced_but[i].text, NULL)); i++; chown_advanced_but[i].id = add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chown_advanced_but[i].ret_cmd, chown_advanced_but[i].flags, chown_advanced_but[i].text, NULL)); dlg_select_widget (b_att[0]); }
static gboolean learn_check_key (int c) { int i; for (i = 0; i < learn_total; i++) { if (key_name_conv_tab[i].code != c || learnkeys[i].ok) continue; dlg_select_widget (learnkeys[i].button); /* TRANSLATORS: This label appears near learned keys. Keep it short. */ label_set_text (LABEL (learnkeys[i].label), _("OK")); learnkeys[i].ok = TRUE; learnok++; if (learnok >= learn_total) { learn_dlg->ret_value = B_CANCEL; if (learnchanged) { if (query_dialog (learn_title, _ ("It seems that all your keys already\n" "work fine. That's great."), D_ERROR, 2, _("&Save"), _("&Discard")) == 0) learn_dlg->ret_value = B_ENTER; } else { message (D_ERROR, learn_title, _ ("Great! You have a complete terminal database!\n" "All your keys work well.")); } dlg_stop (learn_dlg); } return TRUE; } switch (c) { case KEY_LEFT: case 'h': return learn_move (FALSE); case KEY_RIGHT: case 'l': return learn_move (TRUE); case 'j': dlg_one_down (learn_dlg); return TRUE; case 'k': dlg_one_up (learn_dlg); return TRUE; default: break; } /* Prevent from disappearing if a non-defined sequence is pressed and contains a button hotkey. Only recognize hotkeys with ALT. */ return (c < 255 && g_ascii_isalnum (c)); }
static cb_ret_t panel_listing_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) { WDialog *h = DIALOG (w); switch (msg) { case MSG_KEY: if (parm == '\n') { Widget *wi; wi = dlg_find_by_id (h, panel_listing_types_id); if (widget_is_active (wi)) { WInput *in; 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; } wi = dlg_find_by_id (h, panel_user_format_id); if (widget_is_active (wi)) { h->ret_value = B_USER + 6; dlg_stop (h); return MSG_HANDLED; } wi = dlg_find_by_id (h, mini_user_format_id); if (widget_is_active (wi)) { h->ret_value = B_USER + 7; dlg_stop (h); return MSG_HANDLED; } } if (g_ascii_tolower (parm) == listing_user_hotkey) { Widget *wi; wi = dlg_find_by_id (h, panel_user_format_id); if (widget_is_active (wi)) { wi = dlg_find_by_id (h, mini_user_format_id); if (widget_is_active (wi)) { WRadio *r; 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); return MSG_HANDLED; } } } return MSG_NOT_HANDLED; case MSG_ACTION: if (sender != NULL && sender->id == panel_listing_types_id) { WCheck *ch; WInput *in1, *in2; 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[RADIO (sender)->sel]); input_update (in2, FALSE); input_update (in1, FALSE); widget_disable (WIDGET (in1), RADIO (sender)->sel != panel_listing_user_idx); return MSG_HANDLED; } if (sender != NULL && sender->id == mini_user_status_id) { WInput *in; in = INPUT (dlg_find_by_id (h, mini_user_format_id)); if (CHECK (sender)->state & C_BOOL) { widget_disable (WIDGET (in), FALSE); input_assign_text (in, status_format[3]); } else { WRadio *r; r = RADIO (dlg_find_by_id (h, panel_listing_types_id)); widget_disable (WIDGET (in), TRUE); input_assign_text (in, status_format[r->sel]); } /* input_update (in, FALSE); */ return MSG_HANDLED; } return MSG_NOT_HANDLED; default: return dlg_default_callback (w, sender, msg, parm, data); } }
static WDialog * init_chown (void) { int lines, cols; int i; int y; struct passwd *l_pass; struct group *l_grp; WDialog *ch_dlg; do_refresh (); end_chown = need_update = current_file = 0; single_set = (current_panel->marked < 2) ? 3 : 0; cols = GW * 3 + 2 + 6; lines = GH + 4 + (single_set ? 2 : 4); ch_dlg = dlg_create (TRUE, 0, 0, lines, cols, dialog_colors, chown_callback, NULL, "[Chown]", _("Chown command"), DLG_CENTER); add_widget (ch_dlg, groupbox_new (2, 3, GH, GW, _("User name"))); l_user = listbox_new (3, 4, GH - 2, GW - 2, FALSE, NULL); add_widget (ch_dlg, l_user); /* add field for unknown names (numbers) */ listbox_add_item (l_user, LISTBOX_APPEND_AT_END, 0, _("<Unknown user>"), NULL); /* get and put user names in the listbox */ setpwent (); while ((l_pass = getpwent ()) != NULL) listbox_add_item (l_user, LISTBOX_APPEND_SORTED, 0, l_pass->pw_name, NULL); endpwent (); add_widget (ch_dlg, groupbox_new (2, 4 + GW, GH, GW, _("Group name"))); l_group = listbox_new (3, 5 + GW, GH - 2, GW - 2, FALSE, NULL); add_widget (ch_dlg, l_group); /* add field for unknown names (numbers) */ listbox_add_item (l_group, LISTBOX_APPEND_AT_END, 0, _("<Unknown group>"), NULL); /* get and put group names in the listbox */ setgrent (); while ((l_grp = getgrent ()) != NULL) listbox_add_item (l_group, LISTBOX_APPEND_SORTED, 0, l_grp->gr_name, NULL); endgrent (); add_widget (ch_dlg, groupbox_new (2, 5 + GW * 2, GH, GW, _("File"))); /* add widgets for the file information */ for (i = 0; i < LABELS; i++) { chown_label[i].l = label_new (chown_label[i].y, 7 + GW * 2, ""); add_widget (ch_dlg, chown_label[i].l); } if (!single_set) { int x; add_widget (ch_dlg, hline_new (lines - chown_but[0].y - 1, -1, -1)); y = lines - chown_but[0].y; x = (cols - blen) / 2; for (i = 0; i < BUTTONS - 2; i++) { add_widget (ch_dlg, button_new (y, x, chown_but[i].ret_cmd, chown_but[i].flags, chown_but[i].text, NULL)); x += chown_but[i].len + 1; } } i = BUTTONS - 2; y = lines - chown_but[i].y; add_widget (ch_dlg, hline_new (y - 1, -1, -1)); add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 - chown_but[i].len, chown_but[i].ret_cmd, chown_but[i].flags, chown_but[i].text, NULL)); i++; add_widget (ch_dlg, button_new (y, WIDGET (ch_dlg)->cols / 2 + 1, chown_but[i].ret_cmd, chown_but[i].flags, chown_but[i].text, NULL)); /* select first listbox */ dlg_select_widget (l_user); return ch_dlg; }
static WDialog * init_layout (void) { WDialog *layout_dlg; int l1 = 0, width; int b1, b2, b; size_t i; const char *title1 = N_("Panel split"); const char *title2 = N_("Console output"); const char *title3 = N_("Other options"); const char *s_split_direction[2] = { N_("&Vertical"), N_("&Horizontal") }; const char *ok_button = N_("&OK"); const char *cancel_button = N_("&Cancel"); output_lines_label = _("Output lines:"); /* save old params */ old_output_lines = -1; _output_lines = output_lines; #ifdef ENABLE_NLS { static gboolean i18n = FALSE; title1 = _(title1); title2 = _(title2); title3 = _(title3); i = G_N_ELEMENTS (s_split_direction); while (i-- != 0) s_split_direction[i] = _(s_split_direction[i]); if (!i18n) { for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++) check_options[i].text = _(check_options[i].text); i18n = TRUE; } ok_button = _(ok_button); cancel_button = _(cancel_button); } #endif /* radiobuttons */ i = G_N_ELEMENTS (s_split_direction); while (i-- != 0) l1 = max (l1, str_term_width1 (s_split_direction[i]) + 7); /* checkboxes */ for (i = 0; i < (size_t) LAYOUT_OPTIONS_COUNT; i++) l1 = max (l1, str_term_width1 (check_options[i].text) + 7); /* groupboxes */ l1 = max (l1, str_term_width1 (title1) + 4); l1 = max (l1, str_term_width1 (title2) + 4); l1 = max (l1, str_term_width1 (title3) + 4); /* label + "+"/"-" buttons */ output_lines_label_len = str_term_width1 (output_lines_label); l1 = max (l1, output_lines_label_len + 12); /* buttons */ b1 = str_term_width1 (ok_button) + 5; /* default button */ b2 = str_term_width1 (cancel_button) + 3; b = b1 + b2 + 1; /* dialog width */ width = max (l1 * 2 + 7, b); layout_dlg = 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 /* "Panel split" groupbox */ add_widget (layout_dlg, groupbox_new (2, 3, 6, l1, title1)); radio_widget = radio_new (3, 5, 2, s_split_direction); radio_widget->sel = panels_layout.horizontal_split; add_widget (layout_dlg, radio_widget); check_options[0].widget = check_new (5, 5, XTRACT (0)); add_widget (layout_dlg, check_options[0].widget); equal_split = panels_layout.horizontal_split ? panels_layout.horizontal_equal : panels_layout.vertical_equal; bleft_widget = button_new (6, 8, B_2LEFT, NARROW_BUTTON, "&<", b_left_right_cback); widget_disable (WIDGET (bleft_widget), equal_split); add_widget (layout_dlg, bleft_widget); bright_widget = button_new (6, 14, B_2RIGHT, NARROW_BUTTON, "&>", b_left_right_cback); widget_disable (WIDGET (bright_widget), equal_split); add_widget (layout_dlg, bright_widget); /* "Console output" groupbox */ { widget_state_t disabled; Widget *w; disabled = mc_global.tty.console_flag != '\0' ? 0 : WST_DISABLED; w = WIDGET (groupbox_new (8, 3, 3, l1, title2)); w->state |= disabled; add_widget (layout_dlg, w); w = WIDGET (button_new (9, output_lines_label_len + 5, B_PLUS, NARROW_BUTTON, "&+", bplus_cback)); w->state |= disabled; add_widget (layout_dlg, w); w = WIDGET (button_new (9, output_lines_label_len + 5 + 5, B_MINUS, NARROW_BUTTON, "&-", bminus_cback)); w->state |= disabled; add_widget (layout_dlg, w); } /* "Other options" groupbox */ add_widget (layout_dlg, groupbox_new (2, 4 + l1, 9, l1, title3)); for (i = 1; i < (size_t) LAYOUT_OPTIONS_COUNT; i++) { check_options[i].widget = check_new (i + 2, 6 + l1, XTRACT (i)); add_widget (layout_dlg, check_options[i].widget); } #undef XTRACT add_widget (layout_dlg, hline_new (11, -1, -1)); /* buttons */ add_widget (layout_dlg, button_new (12, (width - b) / 2, B_ENTER, DEFPUSH_BUTTON, ok_button, 0)); add_widget (layout_dlg, button_new (12, (width - b) / 2 + b1 + 1, B_CANCEL, NORMAL_BUTTON, cancel_button, 0)); dlg_select_widget (radio_widget); return layout_dlg; }
void swap_panels (void) { WPanel *panel1, *panel2; Widget *tmp_widget; panel1 = PANEL (panels[0].widget); panel2 = PANEL (panels[1].widget); if (panels[0].type == view_listing && panels[1].type == view_listing && !mc_config_get_bool (mc_global.main_config, CONFIG_PANELS_SECTION, "simple_swap", FALSE)) { WPanel panel; #define panelswap(x) panel.x = panel1->x; panel1->x = panel2->x; panel2->x = panel.x; #define panelswapstr(e) strcpy (panel.e, panel1->e); \ strcpy (panel1->e, panel2->e); \ strcpy (panel2->e, panel.e); /* Change content and related stuff */ panelswap (dir); panelswap (active); panelswap (cwd_vpath); panelswap (lwd_vpath); panelswap (marked); panelswap (dirs_marked); panelswap (total); panelswap (top_file); panelswap (selected); panelswap (is_panelized); panelswap (dir_stat); #undef panelswapstr #undef panelswap panel1->searching = FALSE; panel2->searching = FALSE; if (current_panel == panel1) current_panel = panel2; else current_panel = panel1; /* if sort options are different -> resort panels */ if (memcmp (&panel1->sort_info, &panel2->sort_info, sizeof (dir_sort_options_t)) != 0) { panel_re_sort (other_panel); panel_re_sort (current_panel); } if (widget_is_active (panels[0].widget)) dlg_select_widget (panels[1].widget); else if (widget_is_active (panels[1].widget)) dlg_select_widget (panels[0].widget); } else { WPanel *tmp_panel; int x, y, cols, lines; int tmp_type; tmp_panel = right_panel; right_panel = left_panel; left_panel = tmp_panel; if (panels[0].type == view_listing) { if (strcmp (panel1->panel_name, get_nth_panel_name (0)) == 0) { g_free (panel1->panel_name); panel1->panel_name = g_strdup (get_nth_panel_name (1)); } } if (panels[1].type == view_listing) { if (strcmp (panel2->panel_name, get_nth_panel_name (1)) == 0) { g_free (panel2->panel_name); panel2->panel_name = g_strdup (get_nth_panel_name (0)); } } x = panels[0].widget->x; y = panels[0].widget->y; cols = panels[0].widget->cols; lines = panels[0].widget->lines; panels[0].widget->x = panels[1].widget->x; panels[0].widget->y = panels[1].widget->y; panels[0].widget->cols = panels[1].widget->cols; panels[0].widget->lines = panels[1].widget->lines; panels[1].widget->x = x; panels[1].widget->y = y; panels[1].widget->cols = cols; panels[1].widget->lines = lines; tmp_widget = panels[0].widget; panels[0].widget = panels[1].widget; panels[1].widget = tmp_widget; tmp_type = panels[0].type; panels[0].type = panels[1].type; panels[1].type = tmp_type; /* force update formats because of possible changed sizes */ if (panels[0].type == view_listing) set_panel_formats (PANEL (panels[0].widget)); if (panels[1].type == view_listing) set_panel_formats (PANEL (panels[1].widget)); } }
static int menubar_event (Gpm_Event * event, void *data) { WMenuBar *menubar = MENUBAR (data); Widget *w = WIDGET (data); gboolean was_active = TRUE; int left_x, right_x, bottom_y; menu_t *menu; Gpm_Event local; if (!mouse_global_in_widget (event, w)) return MOU_UNHANDLED; /* ignore unsupported events */ if ((event->type & (GPM_UP | GPM_DOWN | GPM_DRAG)) == 0) return MOU_NORMAL; /* ignore wheel events if menu is inactive */ if (!menubar->is_active && ((event->buttons & (GPM_B_MIDDLE | GPM_B_UP | GPM_B_DOWN)) != 0)) return MOU_NORMAL; local = mouse_get_local (event, w); if (local.y == 1 && (local.type & GPM_UP) != 0) return MOU_NORMAL; if (!menubar->is_dropped) { if (local.y > 1) { /* mouse click below menubar -- close menu and send focus to widget under mouse */ menubar_finish (menubar); return MOU_UNHANDLED; } menubar->previous_widget = dlg_get_current_widget_id (w->owner); menubar->is_active = TRUE; menubar->is_dropped = TRUE; was_active = FALSE; } /* Mouse operations on the menubar */ if (local.y == 1 || !was_active) { /* wheel events on menubar */ if ((local.buttons & GPM_B_UP) != 0) menubar_left (menubar); else if ((local.buttons & GPM_B_DOWN) != 0) menubar_right (menubar); else { const unsigned int len = g_list_length (menubar->menu); unsigned int new_selection = 0; while ((new_selection < len) && (local.x > MENU (g_list_nth_data (menubar->menu, new_selection))->start_x)) new_selection++; if (new_selection != 0) /* Don't set the invalid value -1 */ new_selection--; if (!was_active) { menubar->selected = new_selection; dlg_select_widget (menubar); } else { menubar_remove (menubar); menubar->selected = new_selection; } menubar_draw (menubar); } return MOU_NORMAL; } if (!menubar->is_dropped || (local.y < 2)) return MOU_NORMAL; /* middle click -- everywhere */ if (((local.buttons & GPM_B_MIDDLE) != 0) && ((local.type & GPM_DOWN) != 0)) { menubar_execute (menubar); return MOU_NORMAL; } /* the mouse operation is on the menus or it is not */ menu = MENU (g_list_nth_data (menubar->menu, menubar->selected)); left_x = menu->start_x; right_x = left_x + menu->max_entry_len + 3; if (right_x > w->cols) { left_x = w->cols - menu->max_entry_len - 3; right_x = w->cols; } bottom_y = g_list_length (menu->entries) + 3; if ((local.x >= left_x) && (local.x <= right_x) && (local.y <= bottom_y)) { int pos = local.y - 3; const menu_entry_t *entry = MENUENTRY (g_list_nth_data (menu->entries, pos)); /* mouse wheel */ if ((local.buttons & GPM_B_UP) != 0 && (local.type & GPM_DOWN) != 0) { menubar_up (menubar); return MOU_NORMAL; } if ((local.buttons & GPM_B_DOWN) != 0 && (local.type & GPM_DOWN) != 0) { menubar_down (menubar); return MOU_NORMAL; } /* ignore events above and below dropped down menu */ if ((pos < 0) || (pos >= bottom_y - 3)) return MOU_NORMAL; if ((entry != NULL) && (entry->command != CK_IgnoreKey)) { menubar_paint_idx (menubar, menu->selected, MENU_ENTRY_COLOR); menu->selected = pos; menubar_paint_idx (menubar, menu->selected, MENU_SELECTED_COLOR); if ((event->type & GPM_UP) != 0) menubar_execute (menubar); } } else if (((local.type & GPM_DOWN) != 0) && ((local.buttons & (GPM_B_UP | GPM_B_DOWN)) == 0)) { /* use click not wheel to close menu */ menubar_finish (menubar); } return MOU_NORMAL; }
void file_op_context_create_ui (file_op_context_t * ctx, gboolean with_eta, filegui_dialog_type_t dialog_type) { file_op_context_ui_t *ui; int buttons_width; int dlg_width = 58, dlg_height = 17; int y = 2, x = 3; if (ctx == NULL || ctx->ui != NULL) return; #ifdef ENABLE_NLS if (progress_buttons[0].len == -1) { size_t i; for (i = 0; i < G_N_ELEMENTS (progress_buttons); i++) progress_buttons[i].text = _(progress_buttons[i].text); } #endif ctx->dialog_type = dialog_type; ctx->recursive_result = RECURSIVE_YES; ctx->ui = g_new0 (file_op_context_ui_t, 1); ui = ctx->ui; ui->replace_result = REPLACE_YES; ui->op_dlg = dlg_create (TRUE, 0, 0, dlg_height, dlg_width, dialog_colors, NULL, NULL, NULL, op_names[ctx->operation], DLG_CENTER); if (dialog_type != FILEGUI_DIALOG_DELETE_ITEM) { ui->showing_eta = with_eta && ctx->progress_totals_computed; ui->showing_bps = with_eta; ui->src_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file_label); ui->src_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file); ui->tgt_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->tgt_file_label); ui->tgt_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->tgt_file); ui->progress_file_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0); if (!classic_progressbar && (current_panel == right_panel)) ui->progress_file_gauge->from_left_to_right = FALSE; add_widget_autopos (ui->op_dlg, ui->progress_file_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL); ui->progress_file_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->progress_file_label); if (verbose && dialog_type == FILEGUI_DIALOG_MULTI_ITEM) { ui->total_bytes_label = hline_new (y++, -1, -1); add_widget (ui->op_dlg, ui->total_bytes_label); if (ctx->progress_totals_computed) { ui->progress_total_gauge = gauge_new (y++, x + 3, dlg_width - (x + 3) * 2, FALSE, 100, 0); if (!classic_progressbar && (current_panel == right_panel)) ui->progress_total_gauge->from_left_to_right = FALSE; add_widget_autopos (ui->op_dlg, ui->progress_total_gauge, WPOS_KEEP_TOP | WPOS_KEEP_HORZ, NULL); } ui->total_files_processed_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->total_files_processed_label); ui->time_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->time_label); } } else { ui->src_file = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->src_file); ui->total_files_processed_label = label_new (y++, x, ""); add_widget (ui->op_dlg, ui->total_files_processed_label); } add_widget (ui->op_dlg, hline_new (y++, -1, -1)); progress_buttons[0].w = WIDGET (button_new (y, 0, progress_buttons[0].action, progress_buttons[0].flags, progress_buttons[0].text, progress_button_callback)); if (progress_buttons[0].len == -1) progress_buttons[0].len = button_get_len (BUTTON (progress_buttons[0].w)); progress_buttons[1].w = WIDGET (button_new (y, 0, progress_buttons[1].action, progress_buttons[1].flags, progress_buttons[1].text, progress_button_callback)); if (progress_buttons[1].len == -1) progress_buttons[1].len = button_get_len (BUTTON (progress_buttons[1].w)); if (progress_buttons[2].len == -1) { /* create and destroy button to get it length */ progress_buttons[2].w = WIDGET (button_new (y, 0, progress_buttons[2].action, progress_buttons[2].flags, progress_buttons[2].text, progress_button_callback)); progress_buttons[2].len = button_get_len (BUTTON (progress_buttons[2].w)); send_message (progress_buttons[2].w, NULL, MSG_DESTROY, 0, NULL); g_free (progress_buttons[2].w); } progress_buttons[2].w = progress_buttons[1].w; progress_buttons[3].w = WIDGET (button_new (y, 0, progress_buttons[3].action, progress_buttons[3].flags, progress_buttons[3].text, NULL)); if (progress_buttons[3].len == -1) progress_buttons[3].len = button_get_len (BUTTON (progress_buttons[3].w)); add_widget (ui->op_dlg, progress_buttons[0].w); add_widget (ui->op_dlg, progress_buttons[1].w); add_widget (ui->op_dlg, progress_buttons[3].w); buttons_width = 2 + progress_buttons[0].len + max (progress_buttons[1].len, progress_buttons[2].len) + progress_buttons[3].len; /* adjust dialog sizes */ dlg_set_size (ui->op_dlg, y + 3, max (COLS * 2 / 3, buttons_width + 6)); place_progress_buttons (ui->op_dlg, FALSE); dlg_select_widget (progress_buttons[0].w); /* We will manage the dialog without any help, that's why we have to call dlg_init */ dlg_init (ui->op_dlg); }
/* Input lines */ static void entry_click (GtkWidget *widget, GdkEvent *event, WInput *in) { dlg_select_widget (in->widget.parent, in); }