void print_tree_view_list_calculate_columns_width ( GtkTreeView *tree_view, gdouble page_width ) { gint total_text_width = 0; gint column; print_tree_view_list_init_tree_view_data ( tree_view ); columns_position[0] = 0.0; for ( column = 1 ; column < nbre_cols ; column++ ) columns_position[column] = (gdouble) ( tree_view_cols_width[column - 1]* page_width / 100 ) + columns_position[column - 1]; /* set the page_width of the columns */ for (column = 0 ; column < ( nbre_cols - 1 ); column++ ) { columns_width[column] = ( columns_position[column + 1] - columns_position[column] - 3 * gsb_data_print_config_get_draw_column () ) * PANGO_SCALE; total_text_width = total_text_width + columns_width[column]; } /* last column is the rest of the line */ columns_width[nbre_cols - 1] = ( page_width -3 * gsb_data_print_config_get_draw_column () * (nbre_cols) ) * PANGO_SCALE - total_text_width; }
/** * draw a column line * * \param column_position column position * \param line_position line position * * \return the new column position * */ static gint print_transactions_list_draw_column ( gint column_position, gint line_position ) { if (!gsb_data_print_config_get_draw_column ()) return column_position; cairo_move_to (cr, column_position, line_position); cairo_set_line_width (cr, 0.5); cairo_line_to (cr, column_position, line_position + size_row + 2*gsb_data_print_config_get_draw_lines ()); cairo_stroke (cr); /* add a space with the next column */ column_position++; return column_position; }
/** * fill the columns positions and columns width * * \param page_width the page width given by the print_context * * \return * */ static void print_transactions_list_calculate_columns ( gdouble page_width ) { gint total_text_width = 0; gint column; /* set the positions of the columns */ columns_position[0] = 0.0; for ( column=1 ; column<CUSTOM_MODEL_VISIBLE_COLUMNS ; column++) columns_position[column] = (gdouble) (transaction_col_width[column - 1]*page_width/100) + columns_position[column - 1]; /* set the page_width of the columns */ for (column = 0 ; column < (CUSTOM_MODEL_VISIBLE_COLUMNS - 1); column++ ) { columns_width[column] = (columns_position[column + 1] - columns_position[column] - 3*gsb_data_print_config_get_draw_column ()) * PANGO_SCALE; total_text_width = total_text_width + columns_width[column]; } /* last column is the rest of the line */ columns_width[CUSTOM_MODEL_VISIBLE_COLUMNS - 1] = (page_width -3*gsb_data_print_config_get_draw_column ()*(CUSTOM_MODEL_VISIBLE_COLUMNS)) * PANGO_SCALE - total_text_width; }
/** * Show a dialog to set wether we want the rows/columns lines, * the background color, the titles... * * \param operation GtkPrintOperation responsible of this job. * \param null Not used. * * \return A newly allocated widget. */ GtkWidget * print_transactions_list_layout_config ( GtkPrintOperation * operation, gpointer null ) { GtkWidget *check_button; GtkWidget *label; GtkWidget *hbox; GtkWidget *entry; GtkWidget *font_button_transactions; GtkWidget *font_button_title; gchar *fontname_transactions; gchar *fontname_title; GtkWidget *init_date_entry; GtkWidget *final_date_entry; GtkWidget *vbox; GtkWidget *paddingbox; GtkSizeGroup * size_group; size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); vbox = gtk_vbox_new ( FALSE, 6 ); gtk_container_set_border_width ( GTK_CONTAINER(vbox), 12 ); paddingbox = new_paddingbox_with_title ( vbox, FALSE, _("Layout") ); /* set up the title and dates, this is never saved, so ask each time */ /* title line */ hbox = gtk_hbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0); entry = gsb_automem_entry_new (&title_string, NULL, NULL); check_button = gsb_autofunc_checkbutton_new (_("Print a title: "), gsb_data_print_config_get_draw_title (), G_CALLBACK (sens_desensitive_pointeur), entry, G_CALLBACK (gsb_data_print_config_set_draw_title), 0); gtk_box_pack_start (GTK_BOX (hbox), check_button, FALSE, FALSE, 0); gtk_widget_set_sensitive (entry, gsb_data_print_config_get_draw_title ()); gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); /* add the dates interval */ hbox = gtk_hbox_new (FALSE, 10); check_button = gsb_autofunc_checkbutton_new (_("Select dates interval: "), gsb_data_print_config_get_draw_interval_dates (), G_CALLBACK (sens_desensitive_pointeur), hbox, G_CALLBACK (gsb_data_print_config_set_draw_interval_dates), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0); label = gtk_label_new (_("Initial date : ")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); init_date_entry = gsb_calendar_entry_new (FALSE); if (draw_initial_date) gsb_calendar_entry_set_date (init_date_entry, draw_initial_date); gtk_box_pack_start (GTK_BOX (hbox), init_date_entry, FALSE, FALSE, 0); label = gtk_label_new (_("Final date : ")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); final_date_entry = gsb_calendar_entry_new (FALSE); if (draw_final_date) gsb_calendar_entry_set_date (final_date_entry, draw_final_date); gtk_box_pack_start (GTK_BOX (hbox), final_date_entry, FALSE, FALSE, 0); g_object_set_data ( G_OBJECT ( operation ), "init_date_entry", init_date_entry ); g_object_set_data ( G_OBJECT ( operation ), "final_date_entry", final_date_entry ); check_button = gsb_autofunc_checkbutton_new (_("Use value date"), gsb_data_print_config_get_draw_dates_are_value_dates (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_dates_are_value_dates), 0); gtk_box_pack_start (GTK_BOX (hbox), check_button, FALSE, FALSE, 0); if (!gsb_data_print_config_get_draw_interval_dates ()) gtk_widget_set_sensitive (hbox, FALSE); /* set up all the checkbuttons */ check_button = gsb_autofunc_checkbutton_new (_("Draw the lines between transactions"), gsb_data_print_config_get_draw_lines (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_lines), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); check_button = gsb_autofunc_checkbutton_new (_("Draw the lines between the columns"), gsb_data_print_config_get_draw_column (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_column), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); check_button = gsb_autofunc_checkbutton_new (_("Fill the background as the transactions list"), gsb_data_print_config_get_draw_background (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_background), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); check_button = gsb_autofunc_checkbutton_new (_("Print the archives lines"), gsb_data_print_config_get_draw_archives (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_archives), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); check_button = gsb_autofunc_checkbutton_new (_("Print the names of the columns"), gsb_data_print_config_get_draw_columns_name (), NULL, NULL, G_CALLBACK (gsb_data_print_config_set_draw_columns_name), 0); gtk_box_pack_start (GTK_BOX (paddingbox), check_button, FALSE, FALSE, 0); paddingbox = new_paddingbox_with_title ( vbox, FALSE, _("Fonts") ); /* set up the font of the transactions, * by default use the font of the lists */ hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0); label = gtk_label_new (_("Transactions font")); gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT ); gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5); gtk_size_group_add_widget ( size_group, label ); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); fontname_transactions = pango_font_description_to_string (gsb_data_print_config_get_font_transactions ()); font_button_transactions = gtk_font_button_new_with_font ( fontname_transactions ); gtk_font_button_set_use_font ( GTK_FONT_BUTTON(font_button_transactions), TRUE ); gtk_font_button_set_use_size ( GTK_FONT_BUTTON(font_button_transactions), TRUE ); gtk_font_button_set_title ( GTK_FONT_BUTTON(font_button_transactions), _("Choosing font") ); gtk_box_pack_start (GTK_BOX (hbox), font_button_transactions, TRUE, TRUE, 0); /* set up the font for the title */ hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (paddingbox), hbox, FALSE, FALSE, 0); label = gtk_label_new (_("Title font")); gtk_label_set_justify ( GTK_LABEL (label), GTK_JUSTIFY_LEFT ); gtk_misc_set_alignment ( GTK_MISC ( label ), 0, 0.5); gtk_size_group_add_widget ( size_group, label ); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); fontname_title = pango_font_description_to_string (gsb_data_print_config_get_font_title ()); font_button_title = gtk_font_button_new_with_font ( fontname_title ); gtk_font_button_set_use_font ( GTK_FONT_BUTTON(font_button_title), TRUE ); gtk_font_button_set_use_size ( GTK_FONT_BUTTON(font_button_title), TRUE ); gtk_font_button_set_title ( GTK_FONT_BUTTON(font_button_title), _("Choosing font") ); gtk_box_pack_start (GTK_BOX (hbox), font_button_title, TRUE, TRUE, 0); /* save what we have done in all cases, so if we cancel and come back, our values * come back */ gsb_data_print_config_set_font_transaction (pango_font_description_from_string (fontname_transactions)); gsb_data_print_config_set_font_title (pango_font_description_from_string (fontname_title)); draw_initial_date = gsb_calendar_entry_get_date (init_date_entry); draw_final_date = gsb_calendar_entry_get_date (final_date_entry); g_object_set_data ( G_OBJECT(operation), "font_transaction_button", font_button_transactions ); g_object_set_data ( G_OBJECT(operation), "font_title_button", font_button_title ); gtk_widget_show_all ( vbox ); return vbox; }