[gnumeric] Add a print item to the sheet object context menu. [#660248]
- From: Andreas J. Guelzow <guelzow src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Add a print item to the sheet object context menu. [#660248]
- Date: Thu, 29 Sep 2011 06:21:59 +0000 (UTC)
commit 200a62937c43716ce0f235ec7f21483561220e8f
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date: Thu Sep 29 00:20:43 2011 -0600
Add a print item to the sheet object context menu. [#660248]
2011-09-29 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/print.c (gnm_draw_so_page_cb): new
(gnm_print_so): implement
* src/sheet-object.c (sheet_object_populate_menu_real): enable print item
ChangeLog | 6 +++++
NEWS | 3 +-
src/print.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++-
src/sheet-object.c | 4 +-
4 files changed, 64 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d38b84f..ec22096 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-09-29 Andreas J. Guelzow <aguelzow pyrshep ca>
+
+ * src/print.c (gnm_draw_so_page_cb): new
+ (gnm_print_so): implement
+ * src/sheet-object.c (sheet_object_populate_menu_real): enable print item
+
2011-09-28 Andreas J. Guelzow <aguelzow pyrshep ca>
* src/gnm-pane.c (cb_so_menu_activate): delete
diff --git a/NEWS b/NEWS
index 998a920..b64eae0 100644
--- a/NEWS
+++ b/NEWS
@@ -22,7 +22,8 @@ Andreas:
* Fix import of non-UTF8 csv files. [#658916]
* Fix copy/paste of graphs to other programs. [#660242]
* Allow for the omission of a string indicator (quote) in configurable
- text import [#658981]
+ text import. [#658981]
+ * Add a print item to the sheet object context menu. [#660248]
Jean:
* Make things build against gtk+-3.0.
diff --git a/src/print.c b/src/print.c
index cb6342c..6de85db 100644
--- a/src/print.c
+++ b/src/print.c
@@ -1817,8 +1817,61 @@ gnm_print_sheet (WorkbookControl *wbc, Sheet *sheet,
g_object_unref (print);
}
+static void
+gnm_draw_so_page_cb (GtkPrintOperation *operation,
+ GtkPrintContext *context,
+ gint page_nr,
+ gpointer user_data)
+{
+
+ SheetObject *so = (SheetObject *) user_data;
+ cairo_t *cr= gtk_print_context_get_cairo_context (context);
+ Sheet *sheet = sheet_object_get_sheet (so);
+
+ cairo_save (cr);
+ cairo_translate (cr, 0, 0);
+ sheet_object_draw_cairo (so, (gpointer)cr, sheet->text_is_rtl);
+ cairo_restore (cr);
+}
+
void
gnm_print_so (WorkbookControl *wbc, SheetObject *so)
{
- g_print ("gnm_print_so\n");
+ GtkPrintOperation *print;
+ GtkPageSetup *page_setup;
+ GtkPrintSettings* settings;
+ Sheet *sheet;
+ GtkWindow *parent = NULL;
+
+ g_return_if_fail (so != NULL);
+
+ sheet = sheet_object_get_sheet (so);
+ if (NULL != wbc && IS_WBC_GTK(wbc))
+ parent = wbcg_toplevel (WBC_GTK (wbc));
+
+ print = gtk_print_operation_new ();
+
+ settings = gnm_conf_get_print_settings ();
+ gtk_print_settings_set_use_color (settings,
+ !sheet->print_info->print_black_and_white);
+ gtk_print_operation_set_print_settings (print, settings);
+ g_object_unref (settings);
+
+ page_setup = print_info_get_page_setup (sheet->print_info);
+ if (page_setup) {
+ gtk_print_operation_set_default_page_setup (print, page_setup);
+ g_object_unref (page_setup);
+ }
+
+ gtk_print_operation_set_n_pages(print, 1);
+
+ g_signal_connect (print, "draw-page", G_CALLBACK (gnm_draw_so_page_cb), so);
+
+ gtk_print_operation_set_use_full_page (print, FALSE);
+ gtk_print_operation_set_unit (print, GTK_UNIT_POINTS);
+ gtk_print_operation_set_show_progress (print, TRUE);
+
+ gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, parent, NULL);
+
+ g_object_unref (print);
}
diff --git a/src/sheet-object.c b/src/sheet-object.c
index 6ab9118..8d1103f 100644
--- a/src/sheet-object.c
+++ b/src/sheet-object.c
@@ -226,8 +226,8 @@ sheet_object_populate_menu_real (SheetObject *so, GPtrArray *actions)
{ GTK_STOCK_CUT, NULL, NULL, 0, cb_so_cut, NULL },
{ GTK_STOCK_COPY, NULL, NULL, 0, cb_so_copy, NULL },
{ GTK_STOCK_DELETE, NULL, NULL, 0, cb_so_delete, NULL },
- /* { NULL, NULL, NULL, 0, NULL, NULL }, */
- /* { GTK_STOCK_PRINT, NULL, NULL, 0, cb_so_print, sheet_object_can_print}, */
+ { NULL, NULL, NULL, 0, NULL, NULL },
+ { GTK_STOCK_PRINT, NULL, NULL, 0, cb_so_print, sheet_object_can_print},
};
for (i = 0; i < G_N_ELEMENTS (so_actions); i++)
g_ptr_array_add (actions, (gpointer) (so_actions + i));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]