Skip to content

Commit b933303

Browse files
zyvgithub-actions[bot]
authored andcommitted
Ticket #4704: add about box for mc and move display info there
Signed-off-by: Yury V. Zaytsev <yury@shurup.com>
1 parent d6d0426 commit b933303

File tree

3 files changed

+64
-19
lines changed

3 files changed

+64
-19
lines changed

src/filemanager/boxes.c

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,64 @@ task_cb (WButton *button, int action)
487487
/*** public functions ****************************************************************************/
488488
/* --------------------------------------------------------------------------------------------- */
489489

490+
void
491+
about_box (void)
492+
{
493+
char *label_cp_display;
494+
char *label_cp_source;
495+
496+
char *version = g_strdup_printf ("Midnight Commander %s", mc_global.mc_version);
497+
498+
const char *name_cp_display =
499+
((codepage_desc *) g_ptr_array_index (codepages, mc_global.display_codepage))->name;
500+
501+
const char *name_cp_source = mc_global.source_codepage >= 0
502+
? ((codepage_desc *) g_ptr_array_index (codepages, mc_global.source_codepage))->name
503+
: N_ ("No translation");
504+
505+
label_cp_display =
506+
g_strdup_printf ("%s: %s", N_ ("Detected display codepage"), name_cp_display);
507+
label_cp_source =
508+
g_strdup_printf ("%s: %s", N_ ("Selected source (file I/O) codepage"), name_cp_source);
509+
510+
quick_widget_t quick_widgets[] = {
511+
QUICK_LABEL (version, NULL),
512+
QUICK_SEPARATOR (TRUE),
513+
QUICK_LABEL (N_ ("Classic terminal file manager inspired by Norton Commander."), NULL),
514+
QUICK_SEPARATOR (FALSE),
515+
QUICK_LABEL (N_ ("Copyright (C) 1996-2025 the Free Software Foundation"), NULL),
516+
QUICK_SEPARATOR (TRUE),
517+
QUICK_LABEL (label_cp_display, NULL),
518+
QUICK_LABEL (label_cp_source, NULL),
519+
QUICK_START_BUTTONS (TRUE, TRUE),
520+
QUICK_BUTTON (N_ ("&OK"), B_ENTER, NULL, NULL),
521+
QUICK_END,
522+
};
523+
524+
WRect r = { -1, -1, 0, 40 };
525+
526+
quick_dialog_t qdlg = {
527+
.rect = r,
528+
.title = N_ ("About"),
529+
.help = "[Overview]",
530+
.widgets = quick_widgets,
531+
.callback = NULL,
532+
.mouse_callback = NULL,
533+
};
534+
535+
quick_widgets[0].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ;
536+
quick_widgets[2].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ;
537+
quick_widgets[4].pos_flags = WPOS_KEEP_TOP | WPOS_CENTER_HORZ;
538+
539+
(void) quick_dialog (&qdlg);
540+
541+
g_free (version);
542+
g_free (label_cp_display);
543+
g_free (label_cp_source);
544+
}
545+
546+
/* --------------------------------------------------------------------------------------------- */
547+
490548
void
491549
configure_box (void)
492550
{
@@ -590,24 +648,10 @@ void
590648
appearance_box (void)
591649
{
592650
const gboolean shadows = mc_global.tty.shadows;
593-
char *label_cp_display;
594-
char *label_cp_source;
595651

596652
current_skin_name = g_strdup (mc_skin__default.name);
597653
skin_names = mc_skin_list ();
598654

599-
const char *name_cp_display =
600-
((codepage_desc *) g_ptr_array_index (codepages, mc_global.display_codepage))->name;
601-
602-
const char *name_cp_source = mc_global.source_codepage >= 0
603-
? ((codepage_desc *) g_ptr_array_index (codepages, mc_global.source_codepage))->name
604-
: N_ ("No translation");
605-
606-
label_cp_display =
607-
g_strdup_printf ("%s: %s", N_ ("Detected display codepage"), name_cp_display);
608-
label_cp_source =
609-
g_strdup_printf ("%s: %s", N_ ("Selected source (file I/O) codepage"), name_cp_source);
610-
611655
{
612656
quick_widget_t quick_widgets[] = {
613657
// clang-format off
@@ -619,9 +663,6 @@ appearance_box (void)
619663
QUICK_STOP_COLUMNS,
620664
QUICK_SEPARATOR (TRUE),
621665
QUICK_CHECKBOX (N_ ("&Shadows"), &mc_global.tty.shadows, &shadows_id),
622-
QUICK_SEPARATOR (TRUE),
623-
QUICK_LABEL (label_cp_display, NULL),
624-
QUICK_LABEL (label_cp_source, NULL),
625666
QUICK_BUTTONS_OK_CANCEL,
626667
QUICK_END,
627668
// clang-format on
@@ -648,8 +689,6 @@ appearance_box (void)
648689
}
649690
}
650691

651-
g_free (label_cp_display);
652-
g_free (label_cp_source);
653692
g_free (current_skin_name);
654693
g_ptr_array_free (skin_names, TRUE);
655694
}

src/filemanager/boxes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
/*** declarations of public functions ************************************************************/
2020

21+
void about_box (void);
2122
void configure_box (void);
2223
void appearance_box (void);
2324
void panel_options_box (void);

src/filemanager/filemanager.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ create_options_menu (void)
329329
#endif
330330
entries = g_list_prepend (entries, menu_separator_new ());
331331
entries = g_list_prepend (entries, menu_entry_new (_ ("&Save setup"), CK_SaveSetup));
332+
entries = g_list_prepend (entries, menu_separator_new ());
333+
entries = g_list_prepend (entries, menu_entry_new (_ ("A&bout..."), CK_About));
332334

333335
return g_list_reverse (entries);
334336
}
@@ -1107,6 +1109,9 @@ midnight_execute_cmd (Widget *sender, long command)
11071109

11081110
switch (command)
11091111
{
1112+
case CK_About:
1113+
about_box ();
1114+
break;
11101115
case CK_ChangePanel:
11111116
(void) change_panel ();
11121117
break;

0 commit comments

Comments
 (0)