~ubuntu-branches/ubuntu/gutsy/wireshark/gutsy-security

« back to all changes in this revision

Viewing changes to gtk/expert_comp_table.c

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2007-04-01 08:58:40 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070401085840-or3qhrpv8alt1bwg
Tags: 0.99.5-1
* New upstream release.
* debian/patches/09_idl2wrs.dpatch: updated to patch idl2wrs.sh.in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * Helper routines common to all composite expert statistics
5
5
 * tap.
6
6
 *
7
 
 * $Id: expert_comp_table.c 19568 2006-10-17 01:29:55Z ulfl $
 
7
 * $Id: expert_comp_table.c 20107 2006-12-11 03:32:01Z guy $
8
8
 *
9
9
 * Wireshark - Network traffic analyzer
10
10
 * By Gerald Combs <gerald@wireshark.org>
534
534
void
535
535
init_error_table(error_equiv_table *err, guint16 num_procs, GtkWidget *vbox)
536
536
{
537
 
        guint16 i, j;
 
537
    guint16 i, j;
538
538
#if (GTK_MAJOR_VERSION < 2)
539
 
        column_arrows *col_arrows;
540
 
        GdkBitmap *ascend_bm, *descend_bm;
541
 
        GdkPixmap *ascend_pm, *descend_pm;
542
 
        GtkStyle *win_style;
543
 
        GtkWidget *column_lb;
544
 
 
545
 
    GtkTooltips *tooltips = gtk_tooltips_new();
546
 
        const char *default_titles[] = { "Group", "Protocol", "Summary", "Count"};
547
 
 
548
 
        err->scrolled_window=scrolled_window_new(NULL, NULL);
549
 
        gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
550
 
 
551
 
        err->table=(GtkCList *)gtk_clist_new(4);
552
 
 
553
 
        gtk_widget_show(GTK_WIDGET(err->table));
554
 
        gtk_widget_show(err->scrolled_window);
555
 
 
556
 
        col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * 4);
557
 
        win_style = gtk_widget_get_style(err->scrolled_window);
558
 
        ascend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
559
 
                        &ascend_bm,
560
 
                        &win_style->bg[GTK_STATE_NORMAL],
561
 
                        (gchar **)clist_ascend_xpm);
562
 
        descend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
563
 
                        &descend_bm,
564
 
                        &win_style->bg[GTK_STATE_NORMAL],
565
 
                        (gchar **)clist_descend_xpm);
566
 
        for (i = 0; i < 4; i++) {
567
 
                col_arrows[i].table = gtk_table_new(2, 2, FALSE);
568
 
                gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
569
 
                column_lb = gtk_label_new(default_titles[i]);
570
 
                gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
571
 
                gtk_widget_show(column_lb);
572
 
 
573
 
                col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
574
 
                gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
575
 
                col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
576
 
                gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
577
 
                if (i == 3) {
578
 
                        gtk_widget_show(col_arrows[i].descend_pm);
579
 
                }
580
 
                gtk_clist_set_column_widget(GTK_CLIST(err->table), i, col_arrows[i].table);
581
 
                gtk_widget_show(col_arrows[i].table);
582
 
        }
583
 
        gtk_clist_column_titles_show(GTK_CLIST(err->table));
584
 
 
585
 
        gtk_clist_set_compare_func(err->table, error_sort_column);
586
 
        gtk_clist_set_sort_column(err->table, 3);
587
 
        gtk_clist_set_sort_type(err->table, GTK_SORT_DESCENDING);
588
 
 
589
 
 
590
 
        /*XXX instead of this we should probably have some code to
591
 
                dynamically adjust the width of the columns */
592
 
        gtk_clist_set_column_width(err->table, 0, 75);
593
 
        gtk_clist_set_column_width(err->table, 1, 75);
594
 
        gtk_clist_set_column_width(err->table, 2, 400);
595
 
        gtk_clist_set_column_width(err->table, 3, 50);
596
 
 
597
 
 
598
 
        gtk_clist_set_shadow_type(err->table, GTK_SHADOW_IN);
599
 
        gtk_clist_column_titles_show(err->table);
600
 
        gtk_container_add(GTK_CONTAINER(err->scrolled_window), (GtkWidget *)err->table);
601
 
 
602
 
        SIGNAL_CONNECT(err->table, "click-column", error_click_column_cb, col_arrows);
603
 
 
604
 
        gtk_widget_show(GTK_WIDGET(err->table));
 
539
    column_arrows *col_arrows;
 
540
    GdkBitmap *ascend_bm, *descend_bm;
 
541
    GdkPixmap *ascend_pm, *descend_pm;
 
542
    GtkStyle *win_style;
 
543
    GtkWidget *column_lb;
 
544
 
 
545
    const char *default_titles[] = { "Group", "Protocol", "Summary", "Count"};
 
546
 
 
547
    err->scrolled_window=scrolled_window_new(NULL, NULL);
 
548
    gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
 
549
 
 
550
    err->table=(GtkCList *)gtk_clist_new(4);
 
551
 
 
552
    gtk_widget_show(GTK_WIDGET(err->table));
 
553
    gtk_widget_show(err->scrolled_window);
 
554
 
 
555
    col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * 4);
 
556
    win_style = gtk_widget_get_style(err->scrolled_window);
 
557
    ascend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
 
558
            &ascend_bm,
 
559
            &win_style->bg[GTK_STATE_NORMAL],
 
560
            (gchar **)clist_ascend_xpm);
 
561
    descend_pm = gdk_pixmap_create_from_xpm_d(err->scrolled_window->window,
 
562
            &descend_bm,
 
563
            &win_style->bg[GTK_STATE_NORMAL],
 
564
            (gchar **)clist_descend_xpm);
 
565
    for (i = 0; i < 4; i++) {
 
566
        col_arrows[i].table = gtk_table_new(2, 2, FALSE);
 
567
        gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
 
568
        column_lb = gtk_label_new(default_titles[i]);
 
569
        gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
570
        gtk_widget_show(column_lb);
 
571
 
 
572
        col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
 
573
        gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
574
        col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
 
575
        gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
 
576
        if (i == 3) {
 
577
            gtk_widget_show(col_arrows[i].descend_pm);
 
578
        }
 
579
        gtk_clist_set_column_widget(GTK_CLIST(err->table), i, col_arrows[i].table);
 
580
        gtk_widget_show(col_arrows[i].table);
 
581
    }
 
582
    gtk_clist_column_titles_show(GTK_CLIST(err->table));
 
583
 
 
584
    gtk_clist_set_compare_func(err->table, error_sort_column);
 
585
    gtk_clist_set_sort_column(err->table, 3);
 
586
    gtk_clist_set_sort_type(err->table, GTK_SORT_DESCENDING);
 
587
 
 
588
 
 
589
    /*XXX instead of this we should probably have some code to
 
590
        dynamically adjust the width of the columns */
 
591
    gtk_clist_set_column_width(err->table, 0, 75);
 
592
    gtk_clist_set_column_width(err->table, 1, 75);
 
593
    gtk_clist_set_column_width(err->table, 2, 400);
 
594
    gtk_clist_set_column_width(err->table, 3, 50);
 
595
 
 
596
 
 
597
    gtk_clist_set_shadow_type(err->table, GTK_SHADOW_IN);
 
598
    gtk_clist_column_titles_show(err->table);
 
599
    gtk_container_add(GTK_CONTAINER(err->scrolled_window), (GtkWidget *)err->table);
 
600
 
 
601
    SIGNAL_CONNECT(err->table, "click-column", error_click_column_cb, col_arrows);
 
602
 
 
603
    gtk_widget_show(GTK_WIDGET(err->table));
605
604
#else
606
605
    GtkTreeStore *store;
607
606
    GtkWidget *tree;
660
659
    gtk_tree_view_column_set_resizable(column, TRUE);
661
660
    gtk_tree_view_append_column (GTK_TREE_VIEW (err->tree_view), column);
662
661
 
663
 
        err->scrolled_window=scrolled_window_new(NULL, NULL);
 
662
    err->scrolled_window=scrolled_window_new(NULL, NULL);
664
663
 
665
664
    gtk_container_add(GTK_CONTAINER(err->scrolled_window), GTK_WIDGET (err->tree_view));
666
665
 
667
 
        gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
 
666
    gtk_box_pack_start(GTK_BOX(vbox), err->scrolled_window, TRUE, TRUE, 0);
668
667
 
669
668
    gtk_tree_view_set_search_column (err->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
670
669
    gtk_tree_view_set_reorderable (err->tree_view, TRUE);   /* Allow user to reorder data with drag n drop */
672
671
    /* Now enable the sorting of each column */
673
672
    gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(err->tree_view), TRUE);
674
673
    gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(err->tree_view), TRUE);
675
 
 
676
 
        gtk_container_add(GTK_CONTAINER(err->scrolled_window), GTK_WIDGET (err->tree_view));
677
674
#endif
678
675
 
679
 
        gtk_widget_show(err->scrolled_window);
 
676
    gtk_widget_show(err->scrolled_window);
680
677
 
681
678
    err->num_procs=num_procs;
682
 
        err->procedures=g_malloc(sizeof(error_procedure_t)*(num_procs+1));
683
 
        for(i=0;i<num_procs;i++){
684
 
                for(j=0;j<3;j++){
685
 
                        err->procedures[i].entries[j]=NULL; /* reset all values */
686
 
                }
687
 
        }
 
679
    err->procedures=g_malloc(sizeof(error_procedure_t)*(num_procs+1));
 
680
    for(i=0;i<num_procs;i++){
 
681
        for(j=0;j<3;j++){
 
682
            err->procedures[i].entries[j]=NULL; /* reset all values */
 
683
        }
 
684
    }
688
685
 
689
 
        /* create popup menu for this table */
690
 
        error_create_popup_menu(err);
 
686
    /* create popup menu for this table */
 
687
    error_create_popup_menu(err);
691
688
}
692
689
 
693
690
void
716
713
            err->procedures[err->num_procs].entries[j]=NULL;
717
714
        }
718
715
        err->procedures[err->num_procs].packet_num = (guint32)expert_data->packet_num;                        /* First packet num */
719
 
        err->procedures[err->num_procs].entries[0]=(char *)g_strdup_printf("%s", val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)"), NULL);   /* Group */
720
 
        err->procedures[err->num_procs].entries[1]=(char *)g_strdup_printf("%s", expert_data->protocol, NULL);    /* Protocol */
721
 
        err->procedures[err->num_procs].entries[2]=(char *)g_strdup_printf("%s", expert_data->summary, NULL);     /* Summary */
 
716
        err->procedures[err->num_procs].entries[0]=(char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)"));   /* Group */
 
717
        err->procedures[err->num_procs].entries[1]=(char *)g_strdup(expert_data->protocol);    /* Protocol */
 
718
        err->procedures[err->num_procs].entries[2]=(char *)g_strdup(expert_data->summary);     /* Summary */
722
719
        err->procedures[err->num_procs].entries[3]=(char *)g_strdup_printf("%d", err->procedures[row].count);     /* Count */
723
720
        err->procedures[err->num_procs].fvalue_value = NULL;
724
721
    }
734
731
        }
735
732
        
736
733
        /* Create the item in our memory table */
737
 
        err->procedures[row].entries[0]=(char *)g_strdup_printf("%s", val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)"));  /* Group */
738
 
        err->procedures[row].entries[1]=(char *)g_strdup_printf("%s", expert_data->protocol);    /* Protocol */
739
 
        err->procedures[row].entries[2]=(char *)g_strdup_printf("%s", expert_data->summary);     /* Summary */
 
734
        err->procedures[row].entries[0]=(char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)"));  /* Group */
 
735
        err->procedures[row].entries[1]=(char *)g_strdup(expert_data->protocol);    /* Protocol */
 
736
        err->procedures[row].entries[2]=(char *)g_strdup(expert_data->summary);     /* Summary */
740
737
 
741
738
        /* Create a new item in our tree view */
742
739
        store = GTK_TREE_STORE(gtk_tree_view_get_model(err->tree_view)); /* Get store */
743
740
        gtk_tree_store_append (store, &err->procedures[row].iter, NULL);  /* Acquire an iterator */
744
741
        
745
742
        gtk_tree_store_set (store, &err->procedures[row].iter,
746
 
                    GROUP_COLUMN, (char *)g_strdup_printf("%s", val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)")),
747
 
                    PROTOCOL_COLUMN, (char *)g_strdup_printf("%s", expert_data->protocol),
748
 
                    SUMMARY_COLUMN, (char *)g_strdup_printf("%s", expert_data->summary), -1);
 
743
                    GROUP_COLUMN, (char *)g_strdup(val_to_str(expert_data->group, expert_group_vals,"Unknown group (%u)")),
 
744
                    PROTOCOL_COLUMN, (char *)g_strdup(expert_data->protocol),
 
745
                    SUMMARY_COLUMN, (char *)g_strdup(expert_data->summary), -1);
749
746
 
750
747
        /* If an expert item was passed then build the filter string */
751
 
        if (expert_data->pitem && strcmp(expert_data->pitem->finfo->value.ftype->name,"FT_NONE")!=0) {
752
 
            err->procedures[row].fvalue_value = g_strdup_printf("%s", proto_construct_dfilter_string(expert_data->pitem->finfo, NULL));
 
748
        if (expert_data->pitem) {
 
749
            char *filter;
 
750
 
 
751
            filter = proto_construct_match_selected_string(expert_data->pitem->finfo, NULL);
 
752
            if (filter != NULL)
 
753
                err->procedures[row].fvalue_value = g_strdup(filter);
753
754
        }
754
755
        /* Store the updated count of events */
755
756
        err->num_procs = ++old_num_procs;