Exemple #1
0
/**
 * positionne les couleurs pour les tree_view
 *
 *\param tree_view
 *
 * */
void utils_set_tree_view_selection_and_text_color ( GtkWidget *tree_view )
{
    gtk_widget_modify_base ( tree_view, GTK_STATE_SELECTED, gsb_color_get_couleur ( "couleur_selection" ) );
    gtk_widget_modify_base ( tree_view, GTK_STATE_ACTIVE, gsb_color_get_couleur ( "couleur_selection" ) );

    gtk_widget_modify_text ( tree_view, GTK_STATE_SELECTED, gsb_color_get_couleur_with_indice ( "text_color", 0 ) );
    gtk_widget_modify_text ( tree_view, GTK_STATE_ACTIVE, gsb_color_get_couleur_with_indice ( "text_color", 0 ) );
}
/**
 * draw the background of all the rows of the transaction
 *
 * \param cr		cairo context
 * \param record	record to draw
 * \param color_bg	TRUE to colorize, FALSE to let blank
 * \param line_position	position where drawing the line
 *
 * \return
 * */
static void print_transactions_list_draw_background ( CustomRecord *record,
						      gboolean color_bg,
						      gint line_position )
{
    if (!gsb_data_print_config_get_draw_background ())
        return;

    if (record -> what_is_line == IS_ARCHIVE)
    {
        GdkColor *color;

        color = gsb_color_get_couleur ( "archive_background_color" );
        cairo_rectangle ( cr, 0, line_position, page_width, size_row + 2*gsb_data_print_config_get_draw_lines ( ) );
        cairo_set_source_rgb ( cr,
                        (gdouble) color -> red/65535,
                        (gdouble) color -> green/65535,
                        (gdouble) color -> blue/65535 );
    }
    else
    {
        CustomList *custom_list = transaction_model_get_model ( );
        GdkColor *color;

        if ( color_bg )
            color = gsb_color_get_couleur_with_indice ( "couleur_fond", 0 );
        else
            color = gsb_color_get_couleur_with_indice ( "couleur_fond", 1 );

        cairo_rectangle (cr, 0, line_position, page_width,
                        custom_list -> nb_rows_by_transaction * size_row + 2*gsb_data_print_config_get_draw_lines ( ) );
        cairo_set_source_rgb (cr,
                        (gdouble) color -> red/65535,
                        (gdouble) color -> green/65535,
                        (gdouble) color -> blue/65535 );
    }
    cairo_fill ( cr );
    cairo_set_source_rgb ( cr, 0.0, 0.0, 0.0 );
}
Exemple #3
0
/**
 * set the background colors of the list
 *
 * \param tree_view
 * \param n° de colonne
 *
 * \return FALSE
 * */
gboolean utils_set_tree_view_background_color ( GtkWidget *tree_view, gint color_column )
{
    GtkTreeModel *model;
    GtkTreeIter iter;

    if ( !tree_view )
        return FALSE;

    model = gtk_tree_view_get_model ( GTK_TREE_VIEW ( tree_view ) );

    if ( gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter ) )
    {
        gint current_color = 0;
        GtkTreeIter fils_iter;
        GtkTreePath *path;

        do
        {
            gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                        &iter,
                        color_column, gsb_color_get_couleur_with_indice ( "couleur_fond", current_color ),
                        -1 );

            current_color = !current_color;
            path = gtk_tree_model_get_path ( model, &iter );

            if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &fils_iter, &iter )
             &&
             gtk_tree_view_row_expanded ( GTK_TREE_VIEW ( tree_view ), path ) )
            {
                GtkTreeIter third_iter;

                do
                {
                    gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                                &fils_iter,
                                color_column, gsb_color_get_couleur_with_indice ( "couleur_fond", current_color ),
                                -1 );

                    current_color = !current_color;
                    gtk_tree_path_free ( path );
                    path = gtk_tree_model_get_path ( model, &fils_iter );

                    if ( gtk_tree_model_iter_children ( GTK_TREE_MODEL ( model ), &third_iter, &fils_iter )
                     &&
                     gtk_tree_view_row_expanded ( GTK_TREE_VIEW ( tree_view ), path ) )
                    {
                        do
                        {
                            gtk_tree_store_set ( GTK_TREE_STORE ( model ),
                                        &third_iter,
                                        color_column, gsb_color_get_couleur_with_indice ( "couleur_fond", current_color ),
                                        -1 );

                            current_color = !current_color;
                        }
                        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &third_iter ) );
                    }
                }
                while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &fils_iter ) );
            }

            gtk_tree_path_free ( path );
        }
        while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );
    }

    return FALSE;
}