[C en GTK (Gimp ToolKit)] Gaim: show_widget

Pagina: 1
Acties:

  • Valium
  • Registratie: Oktober 1999
  • Laatst online: 23:59

Valium

- rustig maar -

Topicstarter
Ik ben een alternatief appletje aan het schrijven voor het programma Gaim (Linux Instant Messenger die ALLE protocollen aankan en ook nog eens werkt ;) ). Nu ben ik op een probleem gestuit bij het maken van dat nieuwe appletje.

Ik heb de source even online gegooid, maar het is nogal groot. Dus ik quote hier maar een klein stukje:
Source
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
    while (c) {
            number_protocols_online++;
            protocol = ((struct gaim_connection *)c->data)->prpl->protocol;
            c = g_slist_next(c);
            switch (protocol) {
                case 1:
                    pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_aim_pm, icon_aim_bm);
                    gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online], FALSE, TRUE, 0);
                break;
                case 3:
                    pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_icq_pm, icon_icq_bm);
                    gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online] , FALSE, TRUE, 0);
                break;
                case 4:
                    pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_msn_pm, icon_msn_bm);
                    gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online] , FALSE, TRUE, 0);
                break;
                case 8:
                    pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_jabber_pm, icon_jabber_bm);
                    gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online] , FALSE, TRUE, 0);
                break;
                default:
                    printf("unknown protocol. Loading general icon: %d\n", protocol);
                    pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_online_pm, icon_online_bm);
                    gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online] , FALSE, TRUE, 0);
                break;
            }
            printf("protocol: %d, number of protocols: %d\n", protocol, number_protocols_online);
    }
    
    if ( number_protocols_online == 0) {
        number_protocols_online++;
        pixmaparray[number_protocols_online] = gtk_pixmap_new(icon_offline_pm, icon_offline_bm);
        gtk_box_pack_start(GTK_BOX(newbox), pixmaparray[number_protocols_online] , FALSE, TRUE, 0);
    }
    icons = gtk_container_children(GTK_CONTAINER(newbox));
    update_pixmaps();
    while (icons) {
        gtk_widget_show(icons->data);
        icons = g_list_next(icons);
        printf("Showing icon widget: %d\n", number_protocols_online);
    }
    gtk_widget_show(newbox);
    if (orient == ORIENT_UP || orient == ORIENT_DOWN) {
        gtk_widget_set_usize(appletframe, ( sizehint * number_protocols_online ) , sizehint);
    } else {
        gtk_widget_set_usize(appletframe, sizehint, (sizehint * number_protocols_online ));
    }
    printf("Applet size: %d x %d along and %d orthogonal to the panel\n", sizehint, number_protocols_online, sizehint); 
    gtk_container_add(GTK_CONTAINER(appletframe),newbox);
    gtk_widget_show(appletframe);

Dat was regel 167-217 :P Hierin worden de icoontjes toegevoegd aan een box. Vervolgens worden ze aangezet (show). Ik heb d'r ook nogal wat debug-tekst tussen gegooid, maar niet zo veel commentaar...

Het probleem is dus dat alleen van het protocol wat het eerst online komt, het icoontje weergegeven wordt. Zodra ik dat protcol afmeld, dan wordt het icoontje van het 2e protocol zichtbaar.

Dus: Meerdere protocollen online. Alleen icoontje zichtbaar van het eerste protocol. Zodra die weg is, dan zie je alleen het icoontje van het 2e protocol. enz....