comparison finch/libgnt/gnttree.c @ 15971:05d347516fcd

Fine tune column hiding.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 30 Mar 2007 06:47:54 +0000
parents 790d1d003825
children 5eb0621e0760
comparison
equal deleted inserted replaced
15970:790d1d003825 15971:05d347516fcd
221 { 221 {
222 GString *string = g_string_new(NULL); 222 GString *string = g_string_new(NULL);
223 GList *iter; 223 GList *iter;
224 int i; 224 int i;
225 gboolean notfirst = FALSE; 225 gboolean notfirst = FALSE;
226 int lastvisible = tree->ncol;
227
228 while (lastvisible && tree->columns[lastvisible].invisible)
229 lastvisible--;
226 230
227 for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next) 231 for (i = 0, iter = row->columns; i < tree->ncol && iter; i++, iter = iter->next)
228 { 232 {
229 GntTreeCol *col = iter->data; 233 GntTreeCol *col = iter->data;
230 const char *text; 234 const char *text;
231 int len = gnt_util_onscreen_width(col->text, NULL); 235 int len = gnt_util_onscreen_width(col->text, NULL);
232 int fl = 0; 236 int fl = 0;
233 gboolean cut = FALSE; 237 gboolean cut = FALSE;
238 int width;
234 239
235 if (tree->columns[i].invisible) 240 if (tree->columns[i].invisible)
236 continue; 241 continue;
242
243 if (i == lastvisible)
244 width = GNT_WIDGET(tree)->priv.width - gnt_util_onscreen_width(string->str, NULL);
245 else
246 width = tree->columns[i].width;
237 247
238 if (i == 0) 248 if (i == 0)
239 { 249 {
240 if (row->choice) 250 if (row->choice)
241 { 251 {
267 else 277 else
268 g_string_append_c(string, ' '); 278 g_string_append_c(string, ' ');
269 279
270 notfirst = TRUE; 280 notfirst = TRUE;
271 281
272 if (len > tree->columns[i].width) { 282 if (len > width) {
273 len = tree->columns[i].width - 1; 283 len = width - 1;
274 cut = TRUE; 284 cut = TRUE;
275 } 285 }
276 text = gnt_util_onscreen_width_to_pointer(col->text, len - fl, NULL); 286 text = gnt_util_onscreen_width_to_pointer(col->text, len - fl, NULL);
277 string = g_string_append_len(string, col->text, text - col->text); 287 string = g_string_append_len(string, col->text, text - col->text);
278 if (cut) { /* ellipsis */ 288 if (cut) { /* ellipsis */
282 string = g_string_append(string, "\342\200\246"); 292 string = g_string_append(string, "\342\200\246");
283 len++; 293 len++;
284 } 294 }
285 295
286 if (len < tree->columns[i].width && iter->next) 296 if (len < tree->columns[i].width && iter->next)
287 g_string_append_printf(string, "%*s", tree->columns[i].width - len, ""); 297 g_string_append_printf(string, "%*s", width - len, "");
288 } 298 }
289 return g_string_free(string, FALSE); 299 return g_string_free(string, FALSE);
290 } 300 }
291 301
292 #define NEXT_X x += tree->columns[i].width + (i > 0 ? 1 : 0) 302 #define NEXT_X x += tree->columns[i].width + (i > 0 ? 1 : 0)