@@ -103,15 +103,14 @@ static struct
103
103
int ret_cmd ;
104
104
button_flags_t flags ;
105
105
int y ; // vertical position relatively to dialog bottom boundary
106
- int len ;
107
106
const char * text ;
108
107
} chmod_but [BUTTONS ] = {
109
- { B_SETALL , NORMAL_BUTTON , 6 , 0 , N_ ("Set &all" ) },
110
- { B_MARKED , NORMAL_BUTTON , 6 , 0 , N_ ("&Marked all" ) },
111
- { B_SETMRK , NORMAL_BUTTON , 5 , 0 , N_ ("S&et marked" ) },
112
- { B_CLRMRK , NORMAL_BUTTON , 5 , 0 , N_ ("C&lear marked" ) },
113
- { B_ENTER , DEFPUSH_BUTTON , 3 , 0 , N_ ("&Set" ) },
114
- { B_CANCEL , NORMAL_BUTTON , 3 , 0 , N_ ("&Cancel" ) },
108
+ { B_SETALL , NORMAL_BUTTON , 6 , N_ ("Set &all" ) },
109
+ { B_MARKED , NORMAL_BUTTON , 6 , N_ ("&Marked all" ) },
110
+ { B_SETMRK , NORMAL_BUTTON , 5 , N_ ("S&et marked" ) },
111
+ { B_CLRMRK , NORMAL_BUTTON , 5 , N_ ("C&lear marked" ) },
112
+ { B_ENTER , DEFPUSH_BUTTON , 3 , N_ ("&Set" ) },
113
+ { B_CANCEL , NORMAL_BUTTON , 3 , N_ ("&Cancel" ) },
115
114
};
116
115
117
116
static gboolean mode_change ;
@@ -165,13 +164,6 @@ chmod_init (void)
165
164
len = str_term_width1 (file_info_labels [i ]) + 2 ; // spaces around
166
165
file_info_labels_len = MAX (file_info_labels_len , len );
167
166
}
168
-
169
- for (i = 0 ; i < BUTTONS ; i ++ )
170
- {
171
- chmod_but [i ].len = str_term_width1 (chmod_but [i ].text ) + 3 ; // [], spaces and w/o &
172
- if (chmod_but [i ].flags == DEFPUSH_BUTTON )
173
- chmod_but [i ].len += 2 ; // <>
174
- }
175
167
}
176
168
177
169
/* --------------------------------------------------------------------------------------------- */
@@ -360,38 +352,23 @@ chmod_dlg_create (WPanel *panel, const char *fname, const struct stat *sf_stat)
360
352
c_fgrp = str_trunc (get_group (sf_stat -> st_gid ), file_gb_len - 3 );
361
353
group_add_widget (g , label_new (y + 6 , cols , c_fgrp ));
362
354
363
- if (! single_set )
355
+ for ( i = single_set ? BUTTONS - 2 : 0 ; i < BUTTONS ; i ++ )
364
356
{
365
- i = 0 ;
357
+ WButton * b ;
366
358
367
- group_add_widget ( g , hline_new ( lines - chmod_but [i ].y - 1 , -1 , -1 )) ;
359
+ y = lines - chmod_but [i ].y ;
368
360
369
- for (; i < BUTTONS - 2 ; i ++ )
370
- {
371
- y = lines - chmod_but [i ].y ;
372
- group_add_widget (g ,
373
- button_new (y , WIDGET (ch_dlg )-> rect .cols / 2 - chmod_but [i ].len ,
374
- chmod_but [i ].ret_cmd , chmod_but [i ].flags ,
375
- chmod_but [i ].text , NULL ));
376
- i ++ ;
377
- group_add_widget (g ,
378
- button_new (y , WIDGET (ch_dlg )-> rect .cols / 2 + 1 ,
379
- chmod_but [i ].ret_cmd , chmod_but [i ].flags ,
380
- chmod_but [i ].text , NULL ));
381
- }
382
- }
361
+ if (i == 0 || i == BUTTONS - 2 )
362
+ group_add_widget (g , hline_new (y - 1 , -1 , -1 ));
383
363
384
- i = BUTTONS - 2 ;
385
- y = lines - chmod_but [i ].y ;
386
- group_add_widget (g , hline_new (y - 1 , -1 , -1 ));
387
- group_add_widget (g ,
388
- button_new (y , WIDGET (ch_dlg )-> rect .cols / 2 - chmod_but [i ].len ,
389
- chmod_but [i ].ret_cmd , chmod_but [i ].flags , chmod_but [i ].text ,
390
- NULL ));
391
- i ++ ;
392
- group_add_widget (g ,
393
- button_new (y , WIDGET (ch_dlg )-> rect .cols / 2 + 1 , chmod_but [i ].ret_cmd ,
394
- chmod_but [i ].flags , chmod_but [i ].text , NULL ));
364
+ b = button_new (y , 1 , chmod_but [i ].ret_cmd , chmod_but [i ].flags , chmod_but [i ].text , NULL );
365
+ WIDGET (b )-> rect .x = WIDGET (ch_dlg )-> rect .cols / 2 - button_get_width (b );
366
+ group_add_widget (g , b );
367
+ i ++ ;
368
+ b = button_new (y , 1 , chmod_but [i ].ret_cmd , chmod_but [i ].flags , chmod_but [i ].text , NULL );
369
+ WIDGET (b )-> rect .x = WIDGET (ch_dlg )-> rect .cols / 2 + 1 ;
370
+ group_add_widget (g , b );
371
+ }
395
372
396
373
// select first checkbox
397
374
widget_select (WIDGET (check_perm [0 ].check ));
0 commit comments