Ticket #4256: wgroup.patch

File wgroup.patch, 30.0 KB (added by psprint, 2 years ago)
  • lib/widget/dialog-switch.c

    diff --git a/lib/widget/dialog-switch.c b/lib/widget/dialog-switch.c
    index 4a753842d..fe0de5873 100644
    a b dialog_switch_list (void) 
    237237        char *title; 
    238238 
    239239        if (dlg->get_title != NULL) 
    240             title = dlg->get_title (dlg, WIDGET (listbox->list)->cols - 2); 
     240            title = dlg->get_title (dlg, WIDGET (LISTBOX_(listbox)->list)->cols - 2); 
    241241        else 
    242242            title = g_strdup (""); 
    243243 
    244         listbox_add_item (listbox->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h, FALSE); 
     244        listbox_add_item (LISTBOX_(listbox)->list, LISTBOX_APPEND_BEFORE, get_hotkey (i++), title, h, FALSE); 
    245245 
    246246        g_free (title); 
    247247    } 
  • lib/widget/history.c

    diff --git a/lib/widget/history.c b/lib/widget/history.c
    index fc3caf3e2..bfeb5bf20 100644
    a b history_create_item (history_descriptor_t * hd, void *data) 
    158158    width = str_term_width1 (text); 
    159159    hd->max_width = MAX (width, hd->max_width); 
    160160 
    161     listbox_add_item (hd->listbox, LISTBOX_APPEND_AT_END, 0, text, NULL, TRUE); 
     161    listbox_add_item (LISTBOX(hd->listbox), LISTBOX_APPEND_AT_END, 0, text, NULL, TRUE); 
    162162} 
    163163 
    164164/* --------------------------------------------------------------------------------------------- */ 
    history_show (history_descriptor_t * hd) 
    217217        hd->create (hd, z->data); 
    218218    /* after this, the order of history items is following: recent at begin, oldest at end */ 
    219219 
    220     count = listbox_get_length (hd->listbox); 
     220    count = listbox_get_length (LISTBOX(hd->listbox)); 
    221221 
    222222    hist_data.y = hd->y; 
    223223    hist_data.x = hd->x; 
    history_show (history_descriptor_t * hd) 
    231231 
    232232    /* this call makes list stick to all sides of dialog, effectively make 
    233233       it be resized with dialog */ 
    234     group_add_widget_autopos (GROUP (query_dlg), hd->listbox, WPOS_KEEP_ALL, NULL); 
     234    group_add_widget_autopos (GROUP (query_dlg), LISTBOX(hd->listbox), WPOS_KEEP_ALL, NULL); 
    235235 
    236236    /* to avoid diplicating of (calculating sizes in two places) 
    237237       code, call history_dlg_callback function here, to set dialog and 
    history_show (history_descriptor_t * hd) 
    244244    { 
    245245        /* history is above base widget -- revert order to place recent item at bottom */ 
    246246        /* revert history direction */ 
    247         g_queue_reverse (hd->listbox->list); 
     247        g_queue_reverse (LISTBOX_(hd->listbox)->list); 
    248248        if (hd->current < 0 || (size_t) hd->current >= count) 
    249             listbox_select_last (hd->listbox); 
     249            listbox_select_last (LISTBOX(hd->listbox)); 
    250250        else 
    251             listbox_select_entry (hd->listbox, count - 1 - (size_t) hd->current); 
     251            listbox_select_entry (LISTBOX(hd->listbox), count - 1 - (size_t) hd->current); 
    252252    } 
    253253    else 
    254254    { 
    255255        /* history is below base widget -- keep order to place recent item on top  */ 
    256256        if (hd->current > 0) 
    257             listbox_select_entry (hd->listbox, hd->current); 
     257            listbox_select_entry (LISTBOX(hd->listbox), hd->current); 
    258258    } 
    259259 
    260260    dlg_ret = dlg_run (query_dlg); 
    history_show (history_descriptor_t * hd) 
    274274            hd->action = CK_Enter; 
    275275        } 
    276276 
    277         listbox_get_current (hd->listbox, &q, NULL); 
     277        listbox_get_current (LISTBOX(hd->listbox), &q, NULL); 
    278278        hd->text = g_strdup (q); 
    279279    } 
    280280 
    281281    /* get modified history from dialog */ 
    282282    z = NULL; 
    283     for (hi = listbox_get_first_link (hd->listbox); hi != NULL; hi = g_list_next (hi)) 
     283    for (hi = listbox_get_first_link (LISTBOX(hd->listbox)); hi != NULL; hi = g_list_next (hi)) 
    284284        /* history is being reverted here again */ 
    285285        z = g_list_prepend (z, hd->release (hd, LENTRY (hi->data))); 
    286286 
  • lib/widget/listbox-window.c

    diff --git a/lib/widget/listbox-window.c b/lib/widget/listbox-window.c
    index d16dca9b0..c353b3d43 100644
    a b run_listbox (Listbox * l) 
    131131    int val = -1; 
    132132 
    133133    if (dlg_run (l->dlg) != B_CANCEL) 
    134         val = l->list->pos; 
     134        val = LISTBOX_(l->list)->pos; 
    135135    widget_destroy (WIDGET (l->dlg)); 
    136136    g_free (l); 
    137137    return val; 
    run_listbox_with_data (Listbox * l, const void *select) 
    152152    void *val = NULL; 
    153153 
    154154    if (select != NULL) 
    155         listbox_select_entry (l->list, listbox_search_data (l->list, select)); 
     155        listbox_select_entry (LISTBOX_(l->list), listbox_search_data (LISTBOX_(l->list), select)); 
    156156 
    157157    if (dlg_run (l->dlg) != B_CANCEL) 
    158158    { 
    159159        WLEntry *e; 
    160         e = listbox_get_nth_item (l->list, l->list->pos); 
     160        e = listbox_get_nth_item (LISTBOX_(l->list), LISTBOX_(l->list)->pos); 
    161161        if (e != NULL) 
    162162        { 
    163163            /* The assert guards against returning a soon-to-be deallocated 
  • lib/widget/listbox.c

    diff --git a/lib/widget/listbox.c b/lib/widget/listbox.c
    index 460dbee66..db6722839 100644
    a b const global_keymap_t *listbox_map = NULL; 
    5151/*** file scope macro definitions ****************************************************************/ 
    5252 
    5353/* Gives the position of the last item. */ 
    54 #define LISTBOX_LAST(l) (listbox_is_empty (l) ? 0 : (int) g_queue_get_length ((l)->list) - 1) 
     54#define LISTBOX_LAST(l) (listbox_is_empty (l) ? 0 : (int) g_queue_get_length (LISTBOX_(l)->list) - 1) 
    5555 
    5656/*** file scope type declarations ****************************************************************/ 
    5757 
    static void 
    7676listbox_entry_free (void *data) 
    7777{ 
    7878    WLEntry *e = data; 
    79  
     79        FILE *f=fopen("mc-.log","a+"); 
     80        fprintf(f,"1.FREE:%p, text:%s\n",data,e->text); 
     81        fclose(f); 
    8082    g_free (e->text); 
    8183    if (e->free_data) 
    8284        g_free (e->data); 
    listbox_entry_free (void *data) 
    8688/* --------------------------------------------------------------------------------------------- */ 
    8789 
    8890static void 
    89 listbox_draw (WListbox * l, gboolean focused) 
     91listbox_draw (WListbox_ * l, gboolean focused) 
    9092{ 
    9193    Widget *w = WIDGET (l); 
    9294    const int *colors; 
    listbox_draw (WListbox * l, gboolean focused) 
    9799    int pos; 
    98100    int i; 
    99101    int sel_line = -1; 
    100  
    101102    colors = widget_get_colors (w); 
    102103 
    103104    disabled = widget_get_state (w, WST_DISABLED); 
    104105    normalc = disabled ? DISABLED_COLOR : colors[DLG_COLOR_NORMAL]; 
    105106    selc = disabled ? DISABLED_COLOR : colors[focused ? DLG_COLOR_HOT_FOCUS : DLG_COLOR_FOCUS]; 
    106107 
     108        FILE *f=fopen("mc-.log","a+"); 
     109        fprintf(f,"ptr:%p, first:%p, ->data--: %p, text:%p\n",l->list, 
     110                g_queue_peek_head_link(l->list), 
     111                LENTRY(g_queue_peek_head(l->list))? 
     112                        LENTRY(g_queue_peek_head(l->list)):0, 
     113                g_queue_peek_head(l->list)); 
     114        fclose(f); 
     115 
    107116    if (l->list != NULL) 
    108117    { 
    109118        length = g_queue_get_length (l->list); 
    listbox_draw (WListbox * l, gboolean focused) 
    142151 
    143152    l->cursor_y = sel_line; 
    144153 
    145     if (l->draw_scrollbar) 
     154    if (LISTBOX(WIDGET(l)->owner)->draw_scrollbar) 
    146155    { 
    147156        tty_setcolor (normalc); 
    148         scrollbar_set_state (l->scrollbar, w->y - 1, w->x + w->cols, w->lines + 2, g_queue_get_length (l->list), w->lines, l->top); 
    149         WIDGET (l->scrollbar)->callback (WIDGET (l->scrollbar), NULL, MSG_DRAW, 0, NULL); 
     157        /*scrollbar_set_state (SCROLLBAR_(l), w->y - 1, w->x + w->cols, w->lines + 2, g_queue_get_length (l->list), w->lines, l->top);*/ 
     158        /*WIDGET (SCROLLBAR_(l))->callback (WIDGET (SCROLLBAR_(l)), NULL, MSG_DRAW, 0, NULL);*/ 
    150159    } 
    151160} 
    152161 
    153162/* --------------------------------------------------------------------------------------------- */ 
    154163 
    155164static int 
    156 listbox_check_hotkey (WListbox * l, int key) 
     165listbox_check_hotkey (WListbox_ * l, int key) 
    157166{ 
    158     if (!listbox_is_empty (l)) 
     167    if (!listbox_is_empty ((LISTBOX(WIDGET(l)->owner)))) 
    159168    { 
    160169        int i; 
    161170        GList *le; 
    listbox_check_hotkey (WListbox * l, int key) 
    176185 
    177186/* Calculates the item displayed at screen row 'y' (y==0 being the widget's 1st row). */ 
    178187static int 
    179 listbox_y_pos (WListbox * l, int y) 
     188listbox_y_pos (WListbox_ * l, int y) 
    180189{ 
    181     return MIN (l->top + y, LISTBOX_LAST (l)); 
     190    return MIN (l->top + y, LISTBOX_LAST (LISTBOX(WIDGET(l)->owner))); 
    182191} 
    183192 
    184193/* --------------------------------------------------------------------------------------------- */ 
    185194 
    186195static void 
    187 listbox_fwd (WListbox * l, gboolean wrap) 
     196listbox_fwd (WListbox_ * l, gboolean wrap) 
    188197{ 
    189     if (!listbox_is_empty (l)) 
     198    if (!listbox_is_empty ((LISTBOX(WIDGET(l)->owner)))) 
    190199    { 
    191200        if ((guint) l->pos + 1 < g_queue_get_length (l->list)) 
    192             listbox_select_entry (l, l->pos + 1); 
     201            listbox_select_entry (LISTBOX(WIDGET(l)->owner), l->pos + 1); 
    193202        else if (wrap) 
    194             listbox_select_first (l); 
     203            listbox_select_first (LISTBOX(WIDGET(l)->owner)); 
    195204    } 
    196205} 
    197206 
    198207/* --------------------------------------------------------------------------------------------- */ 
    199208 
    200209static void 
    201 listbox_fwd_n (WListbox * l, int n) 
     210listbox_fwd_n (WListbox_ * l, int n) 
    202211{ 
    203     listbox_select_entry (l, MIN (l->pos + n, LISTBOX_LAST (l))); 
     212    listbox_select_entry (LISTBOX(WIDGET(l)->owner), MIN (l->pos + n, LISTBOX_LAST (LISTBOX(WIDGET(l)->owner)))); 
    204213} 
    205214 
    206215/* --------------------------------------------------------------------------------------------- */ 
    207216 
    208217static void 
    209 listbox_back (WListbox * l, gboolean wrap) 
     218listbox_back (WListbox_ * l, gboolean wrap) 
    210219{ 
    211     if (!listbox_is_empty (l)) 
     220    if (!listbox_is_empty ((LISTBOX(WIDGET(l)->owner)))) 
    212221    { 
    213222        if (l->pos > 0) 
    214             listbox_select_entry (l, l->pos - 1); 
     223            listbox_select_entry (LISTBOX(WIDGET(l)->owner), l->pos - 1); 
    215224        else if (wrap) 
    216             listbox_select_last (l); 
     225            listbox_select_last (LISTBOX(WIDGET(l)->owner)); 
    217226    } 
    218227} 
    219228 
    220229/* --------------------------------------------------------------------------------------------- */ 
    221230 
    222231static void 
    223 listbox_back_n (WListbox * l, int n) 
     232listbox_back_n (WListbox_ * l, int n) 
    224233{ 
    225     listbox_select_entry (l, MAX (l->pos - n, 0)); 
     234    listbox_select_entry (LISTBOX(WIDGET(l)->owner), MAX (l->pos - n, 0)); 
    226235} 
    227236 
    228237/* --------------------------------------------------------------------------------------------- */ 
    229238 
    230239static cb_ret_t 
    231 listbox_execute_cmd (WListbox * l, long command) 
     240listbox_execute_cmd (WListbox_ * l, long command) 
    232241{ 
    233242    cb_ret_t ret = MSG_HANDLED; 
    234243    Widget *w = WIDGET (l); 
    listbox_execute_cmd (WListbox * l, long command) 
    245254        listbox_fwd (l, TRUE); 
    246255        break; 
    247256    case CK_Top: 
    248         listbox_select_first (l); 
     257        listbox_select_first (LISTBOX(WIDGET(l)->owner)); 
    249258        break; 
    250259    case CK_Bottom: 
    251         listbox_select_last (l); 
     260        listbox_select_last (LISTBOX(WIDGET(l)->owner)); 
    252261        break; 
    253262    case CK_PageUp: 
    254263        listbox_back_n (l, w->lines - 1); 
    listbox_execute_cmd (WListbox * l, long command) 
    267276            is_last = (l->pos + 1 >= length); 
    268277            is_more = (l->top + w->lines >= length); 
    269278 
    270             listbox_remove_current (l); 
     279            listbox_remove_current (LISTBOX(WIDGET(l)->owner)); 
    271280            if ((l->top > 0) && (is_last || is_more)) 
    272281                l->top--; 
    273282        } 
    listbox_execute_cmd (WListbox * l, long command) 
    278287            && (query_dialog (Q_ ("DialogTitle|History cleanup"), 
    279288                              _("Do you want clean this history?"), 
    280289                              D_ERROR, 2, _("&Yes"), _("&No")) == 0)) 
    281             listbox_remove_list (l); 
     290            listbox_remove_list (LISTBOX(WIDGET(l)->owner)); 
    282291        break; 
    283292    case CK_View: 
    284293    case CK_Edit: 
    listbox_execute_cmd (WListbox * l, long command) 
    296305 
    297306/* Return MSG_HANDLED if we want a redraw */ 
    298307static cb_ret_t 
    299 listbox_key (WListbox * l, int key) 
     308listbox_key (WListbox_ * l, int key) 
    300309{ 
    301310    long command; 
    302311 
    listbox_key (WListbox * l, int key) 
    306315    /* focus on listbox item N by '0'..'9' keys */ 
    307316    if (key >= '0' && key <= '9') 
    308317    { 
    309         listbox_select_entry (l, key - '0'); 
     318        listbox_select_entry (LISTBOX(WIDGET(l)->owner), key - '0'); 
    310319        return MSG_HANDLED; 
    311320    } 
    312321 
    listbox_key (WListbox * l, int key) 
    320329 
    321330/* Listbox item adding function */ 
    322331static inline void 
    323 listbox_append_item (WListbox * l, WLEntry * e, listbox_append_t pos) 
     332listbox_append_item (WListbox_ * l, WLEntry * e, listbox_append_t pos) 
    324333{ 
    325334    if (l->list == NULL) 
    326335    { 
    listbox_append_item (WListbox * l, WLEntry * e, listbox_append_t pos) 
    349358    default: 
    350359        break; 
    351360    } 
     361 
     362    FILE *f=fopen("mc-.log","a+"); 
     363    fprintf(f,"Append ptr:%p, first:%p, ->dat: %p, text:%s\n",l->list, 
     364        g_queue_peek_head_link(l->list), 
     365        g_queue_peek_head (l->list), 
     366        LENTRY(g_queue_peek_tail(l->list))->text); 
     367    fclose(f); 
     368 
    352369} 
    353370 
    354371/* --------------------------------------------------------------------------------------------- */ 
    355372 
    356373/* Call this whenever the user changes the selected item. */ 
    357374static void 
    358 listbox_on_change (WListbox * l) 
     375listbox_on_change (WListbox_ * l) 
    359376{ 
    360377    listbox_draw (l, TRUE); 
    361378    send_message (WIDGET (l)->owner, l, MSG_NOTIFY, 0, NULL); 
    listbox_on_change (WListbox * l) 
    364381/* --------------------------------------------------------------------------------------------- */ 
    365382 
    366383static void 
    367 listbox_do_action (WListbox * l) 
     384listbox_do_action (WListbox_ * l) 
    368385{ 
    369386    int action; 
    370387 
    371     if (listbox_is_empty (l)) 
     388    if (listbox_is_empty ((LISTBOX(WIDGET(l)->owner)))) 
    372389        return; 
    373390 
    374391    if (l->callback != NULL) 
    375         action = l->callback (l); 
     392        action = l->callback (LISTBOX(WIDGET(l)->owner)); 
    376393    else 
    377394        action = LISTBOX_DONE; 
    378395 
    listbox_do_action (WListbox * l) 
    388405/* --------------------------------------------------------------------------------------------- */ 
    389406 
    390407static void 
    391 listbox_run_hotkey (WListbox * l, int pos) 
     408listbox_run_hotkey (WListbox_ * l, int pos) 
    392409{ 
    393     listbox_select_entry (l, pos); 
     410    listbox_select_entry (LISTBOX(WIDGET(l)->owner), pos); 
    394411    listbox_on_change (l); 
    395412    listbox_do_action (l); 
    396413} 
    listbox_run_hotkey (WListbox * l, int pos) 
    398415/* --------------------------------------------------------------------------------------------- */ 
    399416 
    400417static inline void 
    401 listbox_destroy (WListbox * l) 
     418listbox_destroy (WListbox_ * l) 
    402419{ 
    403     widget_destroy (WIDGET (l->scrollbar)); 
    404     listbox_remove_list (l); 
     420    widget_destroy (WIDGET (SCROLLBAR_(l))); 
     421    listbox_remove_list (LISTBOX(WIDGET(l)->owner)); 
    405422} 
    406423 
    407424/* --------------------------------------------------------------------------------------------- */ 
    listbox_destroy (WListbox * l) 
    409426static cb_ret_t 
    410427listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) 
    411428{ 
    412     WListbox *l = LISTBOX (w); 
     429    WListbox_ *l = LISTBOX__ (w); 
    413430 
    414431    switch (msg) 
    415432    { 
    listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void 
    440457        return listbox_execute_cmd (l, parm); 
    441458 
    442459    case MSG_CURSOR: 
    443         widget_gotoyx (l, l->cursor_y, 0); 
     460        widget_gotoyx (w, l->cursor_y, 0); 
    444461        return MSG_HANDLED; 
    445462 
    446463    case MSG_DRAW: 
    listbox_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void 
    461478static void 
    462479listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    463480{ 
    464     WListbox *l = LISTBOX (w); 
     481    WListbox_ *l = LISTBOX__ (w); 
    465482    int old_pos; 
    466483 
    467484    old_pos = l->pos; 
    listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    470487    { 
    471488    case MSG_MOUSE_DOWN: 
    472489        widget_select (w); 
    473         listbox_select_entry (l, listbox_y_pos (l, event->y)); 
     490        listbox_select_entry (LISTBOX(WIDGET(l)->owner), listbox_y_pos(l, event->y)); 
    474491        break; 
    475492 
    476493    case MSG_MOUSE_SCROLL_UP: 
    477         listbox_back (l, FALSE); 
     494        listbox_back(l, FALSE); 
    478495        break; 
    479496 
    480497    case MSG_MOUSE_SCROLL_DOWN: 
    listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    483500 
    484501    case MSG_MOUSE_DRAG: 
    485502        event->result.repeat = TRUE;    /* It'd be functional even without this. */ 
    486         listbox_select_entry (l, listbox_y_pos (l, event->y)); 
     503        listbox_select_entry (LISTBOX(WIDGET(l)->owner), listbox_y_pos (l, event->y)); 
    487504        break; 
    488505 
    489506    case MSG_MOUSE_CLICK: 
    listbox_mouse_callback (Widget * w, mouse_msg_t msg, mouse_event_t * event) 
    505522/*** public functions ****************************************************************************/ 
    506523/* --------------------------------------------------------------------------------------------- */ 
    507524 
    508 WListbox * 
    509 listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn callback) 
     525static WListbox_ * 
     526listbox_new_inter (int y, int x, int height, int width, gboolean deletable, gboolean so, lcback_fn callback) 
    510527{ 
    511     WListbox *l; 
     528    WListbox_ *l; 
    512529    Widget *w; 
    513530 
    514531    if (height <= 0) 
    515532        height = 1; 
    516533 
    517     l = g_new (WListbox, 1); 
     534    l = g_new0 (WListbox_, 1); 
    518535    w = WIDGET (l); 
    519536    widget_init (w, y, x, height, width, listbox_callback, listbox_mouse_callback); 
    520537    w->options |= WOP_SELECTABLE | WOP_WANT_HOTKEY; 
    listbox_new (int y, int x, int height, int width, gboolean deletable, lcback_fn 
    525542    l->deletable = deletable; 
    526543    l->callback = callback; 
    527544    l->allow_duplicates = TRUE; 
    528     l->draw_scrollbar = !mc_global.tty.slow_terminal; 
    529     l->scrollbar = scrollbar_new (y, x + width - 1, height, TRUE); 
    530545 
    531546    return l; 
    532547} 
    533548 
     549 
     550WListbox * 
     551listbox_new (int y, int x, int height, int width, gboolean pruneable, lcback_fn callback) 
     552{ 
     553    WGroup *g; 
     554    Widget *w; 
     555    WListbox *l; 
     556    WListbox_ *w1; 
     557    WScrollbar *w2; 
     558 
     559    if (height <= 0) 
     560        height = 1; 
     561 
     562    l = g_new0 (WListbox, 1); 
     563    g = GROUP(l); 
     564    w = WIDGET(l); 
     565    group_init(g,y,x,height,width,NULL,NULL); 
     566 
     567    w->options |= WOP_SELECTABLE | WOP_TOP_SELECT; 
     568    w->state |= WST_FOCUSED; 
     569 
     570    w1 = listbox_new_inter(y,x,height,width,pruneable,TRUE,callback); 
     571    w2 = scrollbar_new (y, x + width - 1, height, TRUE); 
     572    l->draw_scrollbar = !mc_global.tty.slow_terminal; 
     573    group_add_widget_autopos(g,w2,0,0); 
     574    group_add_widget_autopos(g,w1,0,0); 
     575    return l; 
     576} 
     577 
    534578/* --------------------------------------------------------------------------------------------- */ 
    535579 
    536580/** 
    listbox_search_text (WListbox * l, const char *text) 
    544588        int i; 
    545589        GList *le; 
    546590 
    547         for (i = 0, le = g_queue_peek_head_link (l->list); le != NULL; i++, le = g_list_next (le)) 
     591        for (i = 0, le = g_queue_peek_head_link (LISTBOX_(l)->list); le != NULL; i++, le = g_list_next (le)) 
    548592        { 
    549593            WLEntry *e = LENTRY (le->data); 
    550594 
    listbox_search_data (WListbox * l, const void *data) 
    569613        int i; 
    570614        GList *le; 
    571615 
    572         for (i = 0, le = g_queue_peek_head_link (l->list); le != NULL; i++, le = g_list_next (le)) 
     616        for (i = 0, le = g_queue_peek_head_link (LISTBOX_(l)->list); le != NULL; i++, le = g_list_next (le)) 
    573617        { 
    574618            WLEntry *e = LENTRY (le->data); 
    575619 
    listbox_search_data (WListbox * l, const void *data) 
    587631void 
    588632listbox_select_first (WListbox * l) 
    589633{ 
    590     l->pos = l->top = 0; 
     634    LISTBOX_(l)->pos = LISTBOX_(l)->top = 0; 
    591635} 
    592636 
    593637/* --------------------------------------------------------------------------------------------- */ 
    listbox_select_last (WListbox * l) 
    601645 
    602646    length = listbox_get_length (l); 
    603647 
    604     l->pos = DOZ (length, 1); 
    605     l->top = DOZ (length, lines); 
     648    LISTBOX_(l)->pos = DOZ (length, 1); 
     649    LISTBOX_(l)->top = DOZ (length, lines); 
    606650} 
    607651 
    608652/* --------------------------------------------------------------------------------------------- */ 
    listbox_select_entry (WListbox * l, int dest) 
    618662        return; 
    619663 
    620664    /* Special case */ 
    621     for (pos = 0, le = g_queue_peek_head_link (l->list); le != NULL; pos++, le = g_list_next (le)) 
     665    for (pos = 0, le = g_queue_peek_head_link (LISTBOX_(l)->list); le != NULL; pos++, le = g_list_next (le)) 
    622666    { 
    623         if (pos == l->top) 
     667        if (pos == LISTBOX_(l)->top) 
    624668            top_seen = TRUE; 
    625669 
    626670        if (pos == dest) 
    627671        { 
    628             l->pos = dest; 
     672            LISTBOX_(l)->pos = dest; 
    629673            if (!top_seen) 
    630                 l->top = l->pos; 
     674                LISTBOX_(l)->top = LISTBOX_(l)->pos; 
    631675            else 
    632676            { 
    633677                int lines = WIDGET (l)->lines; 
    634678 
    635                 if (l->pos - l->top >= lines) 
    636                     l->top = l->pos - lines + 1; 
     679                if (LISTBOX_(l)->pos - LISTBOX_(l)->top >= lines) 
     680                    LISTBOX_(l)->top = LISTBOX_(l)->pos - lines + 1; 
    637681            } 
    638682            return; 
    639683        } 
    640684    } 
    641685 
    642686    /* If we are unable to find it, set decent values */ 
    643     l->pos = l->top = 0; 
     687    LISTBOX_(l)->pos = LISTBOX_(l)->top = 0; 
    644688} 
    645689 
    646690/* --------------------------------------------------------------------------------------------- */ 
    listbox_select_entry (WListbox * l, int dest) 
    648692int 
    649693listbox_get_length (const WListbox * l) 
    650694{ 
    651     return listbox_is_empty (l) ? 0 : (int) g_queue_get_length (l->list); 
     695    return listbox_is_empty (l) ? 0 : (int) g_queue_get_length (LISTBOX_(l)->list); 
    652696} 
    653697 
    654698/* --------------------------------------------------------------------------------------------- */ 
    listbox_get_current (WListbox * l, char **string, void **extra) 
    661705    gboolean ok; 
    662706 
    663707    if (l != NULL) 
    664         e = listbox_get_nth_item (l, l->pos); 
     708        e = listbox_get_nth_item (l, LISTBOX_(l)->pos); 
    665709 
    666710    ok = (e != NULL); 
    667711 
    listbox_get_nth_item (const WListbox * l, int pos) 
    681725    { 
    682726        GList *item; 
    683727 
    684         item = g_queue_peek_nth_link (l->list, (guint) pos); 
     728        item = g_queue_peek_nth_link (LISTBOX_(l)->list, (guint) pos); 
    685729        if (item != NULL) 
    686730            return LENTRY (item->data); 
    687731    } 
    listbox_get_nth_item (const WListbox * l, int pos) 
    694738GList * 
    695739listbox_get_first_link (const WListbox * l) 
    696740{ 
    697     return (l == NULL || l->list == NULL) ? NULL : g_queue_peek_head_link (l->list); 
     741    return (l == NULL || LISTBOX_(l)->list == NULL) ? NULL : g_queue_peek_head_link (LISTBOX_(l)->list); 
    698742} 
    699743 
    700744/* --------------------------------------------------------------------------------------------- */ 
    listbox_remove_current (WListbox * l) 
    707751        GList *current; 
    708752        int length; 
    709753 
    710         current = g_queue_peek_nth_link (l->list, (guint) l->pos); 
     754        current = g_queue_peek_nth_link (LISTBOX_(l)->list, (guint) LISTBOX_(l)->pos); 
    711755        listbox_entry_free (current->data); 
    712         g_queue_delete_link (l->list, current); 
     756        g_queue_delete_link (LISTBOX_(l)->list, current); 
    713757 
    714         length = g_queue_get_length (l->list); 
     758        length = g_queue_get_length (LISTBOX_(l)->list); 
    715759 
    716760        if (length == 0) 
    717             l->top = l->pos = 0; 
    718         else if (l->pos >= length) 
    719             l->pos = length - 1; 
     761            LISTBOX_(l)->top = LISTBOX_(l)->pos = 0; 
     762        else if (LISTBOX_(l)->pos >= length) 
     763            LISTBOX_(l)->pos = length - 1; 
    720764    } 
    721765} 
    722766 
    listbox_remove_current (WListbox * l) 
    725769gboolean 
    726770listbox_is_empty (const WListbox * l) 
    727771{ 
    728     return (l == NULL || l->list == NULL || g_queue_is_empty (l->list)); 
     772    return (l == NULL || LISTBOX_(l)->list == NULL || g_queue_is_empty (LISTBOX_(l)->list)); 
    729773} 
    730774 
    731775/* --------------------------------------------------------------------------------------------- */ 
    listbox_is_empty (const WListbox * l) 
    733777/** 
    734778 * Set new listbox items list. 
    735779 * 
    736  * @param l WListbox object 
     780 * @param l WListbox_ object 
    737781 * @param list list of WLEntry objects 
    738782 */ 
    739783void 
    listbox_set_list (WListbox * l, GQueue * list) 
    742786    listbox_remove_list (l); 
    743787 
    744788    if (l != NULL) 
    745         l->list = list; 
     789        LISTBOX_(l)->list = list; 
    746790} 
    747791 
    748792/* --------------------------------------------------------------------------------------------- */ 
    listbox_remove_list (WListbox * l) 
    752796{ 
    753797    if (l != NULL) 
    754798    { 
    755         if (l->list != NULL) 
     799        if (LISTBOX_(l)->list != NULL) 
    756800        { 
    757             g_queue_free_full (l->list, (GDestroyNotify) listbox_entry_free); 
    758             l->list = NULL; 
     801        FILE *f=fopen("mc-.log","a+"); 
     802        fprintf(f,"1.release:%p, first:%p, entry: %p\n",LISTBOX_(l)->list, 
     803                g_queue_peek_head(LISTBOX_(l)->list), 
     804                0); 
     805        fclose(f);            g_queue_free_full (LISTBOX_(l)->list, (GDestroyNotify) listbox_entry_free); 
     806            LISTBOX_(l)->list = NULL; 
    759807        } 
    760808 
    761         l->pos = l->top = 0; 
     809        LISTBOX_(l)->pos = LISTBOX_(l)->top = 0; 
    762810    } 
    763811} 
    764812 
    listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *te 
    773821    if (l == NULL) 
    774822        return NULL; 
    775823 
    776     if (!l->allow_duplicates && (listbox_search_text (l, text) >= 0)) 
     824    if (!LISTBOX_(l)->allow_duplicates && (listbox_search_text (l, text) >= 0)) 
    777825        return NULL; 
    778826 
    779827    entry = g_new (WLEntry, 1); 
    listbox_add_item (WListbox * l, listbox_append_t pos, int hotkey, const char *te 
    781829    entry->data = data; 
    782830    entry->free_data = free_data; 
    783831    entry->hotkey = hotkey; 
    784  
    785     listbox_append_item (l, entry, pos); 
     832        FILE *f=fopen("mc-.log","a+"); 
     833        fprintf(f,"1.Add-item ptr:%p, first:%p, entry: %p\n",LISTBOX_(l)->list, 
     834                g_queue_peek_head(LISTBOX_(l)->list), 
     835                entry); 
     836        fclose(f); 
     837    listbox_append_item (LISTBOX_ (l), entry, pos); 
    786838 
    787839    return entry->text; 
    788840} 
  • lib/widget/listbox.h

    diff --git a/lib/widget/listbox.h b/lib/widget/listbox.h
    index 96dd4afc4..23dbb4817 100644
    a b  
    88 
    99/*** typedefs(not structures) and defined constants **********************************************/ 
    1010 
    11 #define LISTBOX(x) ((WListbox *)(x)) 
     11#define SCROLLBAR_(x) ((WScrollbar *)(((GList *)GROUP((WListbox *)(x))->widgets)->data)) 
     12#define LISTBOX(x) ((WListbox *)x) 
     13#define LISTBOX__(x) ((WListbox_ *)x) 
     14#define LISTBOX_(x) ((WListbox_ *)(g_list_next(GROUP((WListbox *)(x))->widgets)->data)) 
    1215#define LENTRY(x) ((WLEntry *)(x)) 
    1316 
    1417/*** enums ***************************************************************************************/ 
    typedef enum 
    3033 
    3134/*** structures declarations (and typedefs of structures)*****************************************/ 
    3235 
    33 struct WListbox; 
    34 typedef lcback_ret_t (*lcback_fn) (struct WListbox * l); 
     36typedef struct WListbox WListbox; 
     37typedef struct WListbox_ WListbox_; 
     38typedef lcback_ret_t (*lcback_fn) (WListbox * l); 
    3539 
    3640typedef struct WLEntry 
    3741{ 
    typedef struct WLEntry 
    4246} WLEntry; 
    4347 
    4448typedef struct WListbox 
     49{ 
     50    WGroup base; 
     51    gboolean draw_scrollbar; 
     52} WListbox; 
     53 
     54typedef struct WListbox_ 
    4555{ 
    4656    Widget widget; 
    4757    GQueue *list;               /* Pointer to the list of WLEntry */ 
    4858    int pos;                    /* The current element displayed */ 
    4959    int top;                    /* The first element displayed */ 
    5060    gboolean allow_duplicates;  /* Do we allow duplicates on the list? */ 
    51     gboolean draw_scrollbar;    /* Draw a scrollbar? */ 
    52     WScrollbar *scrollbar;      /* Scrollbar widget */ 
    5361    gboolean deletable;         /* Can list entries be deleted? */ 
    5462    lcback_fn callback;         /* The callback function */ 
    5563    int cursor_x, cursor_y;     /* Cache the values */ 
    56 } WListbox; 
     64} WListbox_; 
    5765 
    5866/*** global variables defined in .c file *********************************************************/ 
    5967 
  • lib/widget/scrollbar.c

    diff --git a/lib/widget/scrollbar.c b/lib/widget/scrollbar.c
    index 8b68d0893..1599cd4a3 100644
    a b scrollbar_new (int y, int x, int lines, gboolean has_subchars) 
    132132    WScrollbar *scrollbar; 
    133133    Widget *w; 
    134134 
    135     scrollbar = g_new (WScrollbar, 1); 
     135    scrollbar = g_new0 (WScrollbar, 1); 
    136136    w = WIDGET (scrollbar); 
    137137    widget_init (w, y, x, lines, 1, scrollbar_callback, NULL); 
    138138 
  • src/filemanager/achown.c

    diff --git a/po/be.po b/po/be.po
    index 3bb003750..80db90018 100644
    Binary files a/po/be.po and b/po/be.po differ
    diff --git a/po/fr.po b/po/fr.po
    index 2a7636f3f..f86c9ba8e 100644
    Binary files a/po/fr.po and b/po/fr.po differ
    diff --git a/po/hr.po b/po/hr.po
    index 7d3fa992b..cbdf916bc 100644
    Binary files a/po/hr.po and b/po/hr.po differ
    diff --git a/src/filemanager/achown.c b/src/filemanager/achown.c
    index 202d10275..d1151961a 100644
    a b user_group_button_cb (WButton * button, int action) 
    582582 
    583583        listbox_select_entry (chl_list, fe); 
    584584 
    585         b_pos = chl_list->pos; 
     585        b_pos = LISTBOX_(chl_list)->pos; 
    586586        group_add_widget (GROUP (chl_dlg), chl_list); 
    587587 
    588588        result = dlg_run (chl_dlg); 
    589589 
    590590        if (result != B_CANCEL) 
    591591        { 
    592             if (b_pos != chl_list->pos) 
     592            if (b_pos != LISTBOX_(chl_list)->pos) 
    593593            { 
    594594                gboolean ok = FALSE; 
    595595                char *text; 
  • src/filemanager/boxes.c

    diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c
    index ec83e250a..75c36d634 100644
    a b task_cb (WButton * button, int action) 
    488488 
    489489    (void) button; 
    490490 
    491     if (bg_list->list == NULL) 
     491    if (LISTBOX_(bg_list)->list == NULL) 
    492492        return 0; 
    493493 
    494494    /* Get this instance information */ 
  • src/filemanager/hotlist.c

    diff --git a/src/filemanager/hotlist.c b/src/filemanager/hotlist.c
    index 9b66c4555..ad1118906 100644
    a b add2hotlist (char *label, char *directory, enum HotListType type, listbox_append 
    990990        } 
    991991        else 
    992992            listbox_add_item (l_hotlist, pos, 0, new->label, new, FALSE); 
    993         listbox_select_entry (l_hotlist, l_hotlist->pos); 
     993        listbox_select_entry (l_hotlist, LISTBOX_(l_hotlist)->pos); 
    994994    } 
    995995 
    996996    return new; 
  • src/filemanager/panelize.c

    diff --git a/src/filemanager/panelize.c b/src/filemanager/panelize.c
    index 9edaff74c..d0f089f8e 100644
    a b static struct panelize 
    9292static void 
    9393update_command (void) 
    9494{ 
    95     if (l_panelize->pos != last_listitem) 
     95    if (LISTBOX_(l_panelize)->pos != last_listitem) 
    9696    { 
    9797        struct panelize *data = NULL; 
    9898 
    99         last_listitem = l_panelize->pos; 
     99        last_listitem = LISTBOX_(l_panelize)->pos; 
    100100        listbox_get_current (l_panelize, NULL, (void **) &data); 
    101101        input_assign_text (pname, data->command); 
    102102        pname->point = 0;