[PATCH 1/2] Hook up colour printing with print dialog.
amit.k.chaudhuri at gmail.com
amit.k.chaudhuri at gmail.com
Wed Mar 13 00:18:49 PDT 2013
From: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
Add a button and callback to the print dialog to let the user select colour printing.
Add a state variable to the options struct to track the users choice.
Signed-off-by: Amit Chaudhuri <amit.k.chaudhuri at gmail.com>
---
display.h | 1 +
print.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/display.h b/display.h
index 7153cc0..cef0ad1 100644
--- a/display.h
+++ b/display.h
@@ -54,6 +54,7 @@ extern void get_plot_details(struct graphics_context *gc, int time, char *buf, s
struct options {
enum { PRETTY, TABLE, TWOPERPAGE } type;
int print_selected;
+ int colour_selected;
};
extern char zoomed_plot, dc_number;
diff --git a/print.c b/print.c
index d7b6d44..7408bb6 100644
--- a/print.c
+++ b/print.c
@@ -598,8 +598,9 @@ static int show_dive_table(struct dive *dive, cairo_t *cr, PangoLayout *layout,
static void show_dive_profile(struct dive *dive, cairo_t *cr, double w,
double h)
{
+ int colour = print_options.colour_selected == 1 ? 2 : 1; /* 1 for B/W, 2 for colour */
struct graphics_context gc = {
- .printer = 1,
+ .printer = colour,
.cr = cr,
.drawing_area = { w/20.0, h/20.0, w, h},
};
@@ -870,6 +871,7 @@ static void name(GtkWidget *w, gpointer data) \
}
OPTIONSELECTEDCALLBACK(print_selection_toggle, print_options.print_selected)
+OPTIONSELECTEDCALLBACK(colour_selection_toggle, print_options.colour_selected)
static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
@@ -919,6 +921,13 @@ static GtkWidget *print_dialog(GtkPrintOperation *operation, gpointer user_data)
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 2);
g_signal_connect(G_OBJECT(button), "toggled",
G_CALLBACK(print_selection_toggle), NULL);
+ GtkWidget *colourButton;
+ colourButton = gtk_check_button_new_with_label(_("Print in colour"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(colourButton),
+ print_options.colour_selected);
+ gtk_box_pack_start(GTK_BOX(box), colourButton, FALSE, FALSE, 2);
+ g_signal_connect(G_OBJECT(colourButton), "toggled",
+ G_CALLBACK(colour_selection_toggle), NULL);
}
gtk_widget_show_all(vbox);
--
1.7.10.4
More information about the subsurface
mailing list