~ubuntu-branches/ubuntu/maverick/krb5/maverick

« back to all changes in this revision

Viewing changes to src/windows/identity/ui/configwnd.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hartman, Russ Allbery, Sam Hartman
  • Date: 2008-08-21 10:41:41 UTC
  • mfrom: (11.1.15 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080821104141-a0f9c4o4cpo8xd0o
Tags: 1.6.dfsg.4~beta1-4
[ Russ Allbery ]
* Translation updates:
  - Swedish, thanks Martin Bagge.  (Closes: #487669, #491774)
  - Italian, thanks Luca Monducci.  (Closes: #493962)

[ Sam Hartman ]
* Translation Updates:
    - Dutch, Thanks Vincent Zweije, Closes: #495733

Show diffs side-by-side

added added

removed removed

Lines of Context:
142
142
    HICON hicon;
143
143
 
144
144
    d = cfgui_get_wnd_data(hwnd);
 
145
    if (d == NULL)
 
146
        return;
145
147
 
146
148
    /* create and fill the image list for the treeview */
147
149
 
241
243
    HWND hwtv;
242
244
 
243
245
    d = cfgui_get_wnd_data(hwnd);
 
246
    if (d == NULL)
 
247
        return;
244
248
 
245
249
    hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
246
250
 
298
302
    HWND hwtv;
299
303
 
300
304
    d = cfgui_get_wnd_data(hwnd);
 
305
    if (d == NULL)
 
306
        return;
 
307
 
301
308
    hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
302
309
    hItem = (HTREEITEM) khui_cfg_get_param(node);
303
310
 
423
430
}
424
431
 
425
432
static void
 
433
cfgui_remove_item(HWND hwtv,
 
434
                  HTREEITEM hItem) {
 
435
    khui_config_node node;
 
436
    HTREEITEM hChild;
 
437
    TVITEMEX itemex;
 
438
 
 
439
    for (hChild = TreeView_GetChild(hwtv, hItem);
 
440
         hChild;
 
441
         hChild = TreeView_GetChild(hwtv, hItem)) {
 
442
 
 
443
        cfgui_remove_item(hwtv, hChild);
 
444
 
 
445
    }
 
446
 
 
447
    ZeroMemory(&itemex, sizeof(itemex));
 
448
 
 
449
    itemex.mask = TVIF_PARAM;
 
450
    itemex.hItem = hItem;
 
451
 
 
452
    TreeView_GetChild(hwtv, &itemex);
 
453
 
 
454
    node = (khui_config_node) itemex.lParam;
 
455
 
 
456
    if (node) {
 
457
        HWND hw;
 
458
        hw = khui_cfg_get_hwnd(node);
 
459
 
 
460
        if (hw)
 
461
            DestroyWindow(hw);
 
462
 
 
463
        khui_cfg_release(node);
 
464
    }
 
465
 
 
466
    TreeView_DeleteItem(hwtv, hItem);
 
467
}
 
468
 
 
469
struct cfgui_child_info {
 
470
    HTREEITEM hItem;
 
471
    khui_config_node node;
 
472
    BOOL checked;
 
473
};
 
474
 
 
475
#define CI_ALLOC_INCR 8
 
476
 
 
477
static void
 
478
cfgui_sync_node(cfgui_wnd_data * d,
 
479
                HWND hwtv,
 
480
                khui_config_node c,
 
481
                HTREEITEM hItem) {
 
482
    khui_config_node child;
 
483
    HTREEITEM hChild;
 
484
    struct cfgui_child_info * childinfo = NULL;
 
485
    khm_size n_childinfo = 0;
 
486
    khm_size nc_childinfo = 0;
 
487
    khm_size i;
 
488
 
 
489
    /* first, get the list of children from the treeview control */
 
490
    for (hChild = TreeView_GetChild(hwtv, hItem);
 
491
         hChild;
 
492
         hChild = TreeView_GetNextSibling(hwtv, hChild)) {
 
493
 
 
494
        if (n_childinfo >= nc_childinfo) {
 
495
            nc_childinfo = UBOUNDSS(n_childinfo + 1,
 
496
                                    CI_ALLOC_INCR, CI_ALLOC_INCR);
 
497
#ifdef DEBUG
 
498
            assert(nc_childinfo > n_childinfo);
 
499
#endif
 
500
            childinfo = PREALLOC(childinfo,
 
501
                                 sizeof(*childinfo) * nc_childinfo);
 
502
#ifdef DEBUG
 
503
            assert(childinfo);
 
504
#endif
 
505
        }
 
506
 
 
507
        ZeroMemory(&childinfo[n_childinfo],
 
508
                   sizeof(childinfo[n_childinfo]));
 
509
 
 
510
        childinfo[n_childinfo].hItem = hChild;
 
511
        childinfo[n_childinfo].checked = FALSE;
 
512
        n_childinfo++;
 
513
    }
 
514
 
 
515
    /* now, go through the list of actual nodes and make sure they
 
516
       match up */
 
517
    child = NULL;
 
518
    for (khui_cfg_get_first_child(c, &child);
 
519
         child;
 
520
         khui_cfg_get_next_release(&child)) {
 
521
 
 
522
        hChild = (HTREEITEM) khui_cfg_get_param(child);
 
523
 
 
524
        for (i=0; i < n_childinfo; i++) {
 
525
            if (childinfo[i].hItem == hChild)
 
526
                break;
 
527
        }
 
528
 
 
529
        if (i < n_childinfo) {
 
530
            childinfo[i].checked = TRUE;
 
531
        } else {
 
532
            /* add it to the list, so we can create the node in the
 
533
               tree view control later. */
 
534
            if (n_childinfo >= nc_childinfo) {
 
535
                nc_childinfo = UBOUNDSS(n_childinfo + 1,
 
536
                                        CI_ALLOC_INCR, CI_ALLOC_INCR);
 
537
#ifdef DEBUG
 
538
                assert(nc_childinfo > n_childinfo);
 
539
#endif
 
540
                childinfo = PREALLOC(childinfo,
 
541
                                     sizeof(*childinfo) * nc_childinfo);
 
542
#ifdef DEBUG
 
543
                assert(childinfo);
 
544
#endif
 
545
            }
 
546
 
 
547
            ZeroMemory(&childinfo[n_childinfo],
 
548
                       sizeof(childinfo[n_childinfo]));
 
549
 
 
550
            childinfo[n_childinfo].node = child;
 
551
            khui_cfg_hold(child);
 
552
            n_childinfo++;
 
553
        }
 
554
    }
 
555
 
 
556
    /* by this point, the childinfo list contains items of the
 
557
       following forms:
 
558
 
 
559
       1. childinfo[i].hItem != NULL && childinfo[i].checked == TRUE
 
560
 
 
561
          Corresponds to a tree view item that has a matching
 
562
          configuration node.  Nothing to do here.
 
563
 
 
564
       2. childinfo[i].hItem != NULL && childinfo[i].checked == FALSE
 
565
 
 
566
          Corresponds to a tree view item that has no matching
 
567
          configuration node.  These should be removed.
 
568
 
 
569
       3. childinfo[i].hItem == NULL && childinfo[i].node != NULL
 
570
 
 
571
          Corresponds to a configuration node that has no matching
 
572
          tree view item.  These nodes should be added.
 
573
    */
 
574
 
 
575
    /* first do the removals */
 
576
    for (i=0; i < n_childinfo; i++) {
 
577
        if (childinfo[i].hItem == NULL)
 
578
            break;              /* nothing more to see from this point
 
579
                                   on */
 
580
        if (!childinfo[i].checked) {
 
581
            /* remove! */
 
582
            cfgui_remove_item(hwtv, childinfo[i].hItem);
 
583
        }
 
584
    }
 
585
 
 
586
    /* continue from where the previous loop left off */
 
587
    for (; i < n_childinfo; i++) {
 
588
#ifdef DEBUG
 
589
        assert(childinfo[i].hItem == NULL);
 
590
        assert(childinfo[i].node != NULL);
 
591
#endif
 
592
 
 
593
        cfgui_add_node(d, hwtv, childinfo[i].node, c, FALSE);
 
594
 
 
595
        khui_cfg_release(childinfo[i].node);
 
596
        childinfo[i].node = NULL;
 
597
    }
 
598
 
 
599
    if (childinfo)
 
600
        PFREE(childinfo);
 
601
 
 
602
    /* finally recurse through to the next level */
 
603
    for (hChild = TreeView_GetChild(hwtv, hItem);
 
604
         hChild;
 
605
         hChild = TreeView_GetNextSibling(hwtv, hChild)) {
 
606
 
 
607
        TVITEMEX itemex;
 
608
 
 
609
        ZeroMemory(&itemex, sizeof(itemex));
 
610
 
 
611
        itemex.mask = TVIF_PARAM;
 
612
        itemex.hItem = hChild;
 
613
 
 
614
        TreeView_GetItem(hwtv, &itemex);
 
615
 
 
616
        if (itemex.lParam) {
 
617
            child = (khui_config_node) itemex.lParam;
 
618
 
 
619
            cfgui_sync_node(d, hwtv, child, hChild);
 
620
        }
 
621
    }
 
622
}
 
623
 
 
624
static void
 
625
cfgui_sync_node_list(cfgui_wnd_data * d, HWND hwnd) {
 
626
    HWND hwtv;
 
627
    HTREEITEM hItem;
 
628
 
 
629
    hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
 
630
    hItem = TreeView_GetRoot(hwtv);
 
631
 
 
632
    cfgui_sync_node(d, hwtv, NULL, hItem);
 
633
}
 
634
 
 
635
static void
426
636
cfgui_update_state(HWND hwnd, 
427
637
                   khm_int32 flags,
428
638
                   khui_config_node node) {
433
643
    int idx;
434
644
 
435
645
    d = cfgui_get_wnd_data(hwnd);
 
646
    if (d == NULL)
 
647
        return;
 
648
 
436
649
    hwtv = GetDlgItem(hwnd, IDC_CFG_NODELIST);
437
650
    hItem = (HTREEITEM) khui_cfg_get_param(node);
438
651
 
476
689
 
477
690
    case WM_CTLCOLORSTATIC:
478
691
        d = cfgui_get_wnd_data(hwnd);
 
692
        if (d == NULL)
 
693
            break;
 
694
 
479
695
        return (BOOL)(DWORD_PTR) d->hbr_white;
480
696
 
481
697
    case WM_ERASEBKGND:
486
702
            RECT r_fill;
487
703
 
488
704
            d = cfgui_get_wnd_data(hwnd);
 
705
            if (d == NULL)
 
706
                break;
489
707
 
490
708
            GetClientRect(hwnd, &r_client);
491
709
            SetRectEmpty(&r_logo);
578
796
        cfgui_uninitialize_dialog(hwnd);
579
797
 
580
798
        d = cfgui_get_wnd_data(hwnd);
 
799
        if (d == NULL)
 
800
            break;
 
801
 
581
802
        khui_delete_bitmap(&d->kbmp_logo);
582
803
        DeleteObject(d->hbr_white);
583
804
 
 
805
        cfgui_set_wnd_data(hwnd, NULL);
 
806
 
584
807
        khm_del_dialog(hwnd);
585
808
 
586
809
        SetForegroundWindow(khm_hwnd_main);
587
810
 
 
811
        PFREE(d);
 
812
 
588
813
        return FALSE;
589
814
 
590
815
    case WM_NOTIFY:
635
860
    case WM_CTLCOLORSTATIC:
636
861
        {
637
862
            d = cfgui_get_wnd_data(hwnd);
 
863
            if (d == NULL)
 
864
                break;
 
865
 
638
866
            return (BOOL)(DWORD_PTR) d->hbr_white;
639
867
        }
640
868
        /* implicit break */
670
898
            break;
671
899
 
672
900
        case WMCFG_SYNC_NODE_LIST:
673
 
            /*TODO: synchronize the node lists here */
 
901
            d = cfgui_get_wnd_data(hwnd);
 
902
            if (d == NULL)
 
903
                break;
 
904
 
 
905
            cfgui_sync_node_list(d, hwnd);
674
906
            break;
675
907
        }
676
908
 
825
1057
 
826
1058
            khui_cfg_remove(cfg_iter);
827
1059
        }
 
1060
 
 
1061
        if (tident)
 
1062
            kcdb_identity_release(tident);
828
1063
    }
829
1064
 
830
1065
    /* Now iterate through the root level configuration nodes and make
836
1071
    if (omenu == NULL)
837
1072
        goto _cleanup;
838
1073
 
 
1074
    khui_action_lock();
 
1075
 
839
1076
    do {
840
1077
        khm_int32 action;
841
1078
        khm_int32 flags;
882
1119
                goto _next_cfg;
883
1120
            }
884
1121
 
885
 
            khui_menu_insert_action(omenu, -1, action, 0);
 
1122
            khui_menu_insert_action(omenu, (khm_size) -1, action, 0);
886
1123
 
887
1124
            refresh_menu = TRUE;
888
1125
        }
892
1129
            break;
893
1130
    } while(cfg_r);
894
1131
 
895
 
    if (refresh_menu)
896
 
        khm_menu_refresh_items();
 
1132
    khui_action_unlock();
 
1133
 
 
1134
    if (refresh_menu) {
 
1135
        khui_refresh_actions();
 
1136
    }
897
1137
 
898
1138
 _cleanup:
899
1139
    if (cfg_ids)