|
From: <pa...@us...> - 2008-09-21 13:14:08
|
Revision: 566
http://osmo-pim.svn.sourceforge.net/osmo-pim/?rev=566&view=rev
Author: pasp
Date: 2008-09-21 13:14:04 +0000 (Sun, 21 Sep 2008)
Log Message:
-----------
* Added calendar print skeleton
Modified Paths:
--------------
trunk/ChangeLog
trunk/README
trunk/src/Makefile.am
trunk/src/calendar.c
Added Paths:
-----------
trunk/src/calendar_print.c
trunk/src/calendar_print.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-09-19 21:36:01 UTC (rev 565)
+++ trunk/ChangeLog 2008-09-21 13:14:04 UTC (rev 566)
@@ -1,6 +1,6 @@
-2008-09-xx: version 0.2.4
- * Exporting calendar events to iCal files
+2008-09-27: version 0.2.4
+ * Exporting calendar events to iCal file
* Visible tasks list can be printed
* Improved birthdays browser
* Option to save data after every modification
Modified: trunk/README
===================================================================
--- trunk/README 2008-09-19 21:36:01 UTC (rev 565)
+++ trunk/README 2008-09-21 13:14:04 UTC (rev 566)
@@ -31,6 +31,7 @@
o integration with Tasks and Contacts modules
* Tasks:
o advanced reminder
+ o tasks list printing
o category filter
o priority per task
o due date modification on the fly
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2008-09-19 21:36:01 UTC (rev 565)
+++ trunk/src/Makefile.am 2008-09-21 13:14:04 UTC (rev 566)
@@ -10,6 +10,7 @@
calendar_jumpto.c calendar_jumpto.h \
calendar_moon.h \
calendar_notes.c calendar_notes.h \
+ calendar_print.c calendar_print.h \
calendar_timeline.c calendar_timeline.h \
calendar_utils.c calendar_utils.h \
calendar_widget.c calendar_widget.h \
Modified: trunk/src/calendar.c
===================================================================
--- trunk/src/calendar.c 2008-09-19 21:36:01 UTC (rev 565)
+++ trunk/src/calendar.c 2008-09-21 13:14:04 UTC (rev 566)
@@ -21,6 +21,7 @@
#include "calendar.h"
#include "i18n.h"
+#include "calendar_print.h"
#include "calendar_widget.h"
#include "calendar_jumpto.h"
#include "calendar_fullyear.h"
@@ -1416,6 +1417,15 @@
/*------------------------------------------------------------------------------*/
+void
+calendar_print_cb (GtkWidget *widget, gpointer data) {
+
+ GUI *appGUI = (GUI *)data;
+ calendar_print (appGUI);
+}
+
+/*------------------------------------------------------------------------------*/
+
#ifdef HAVE_LIBICAL
void
popup_ical_export_cb (gpointer user_data)
@@ -1476,6 +1486,7 @@
" <toolitem name=\"jump_to_date\" action=\"jump_to_date\" />\n"
" <toolitem name=\"full_year\" action=\"full_year\" />\n"
" <toolitem name=\"date_calc\" action=\"date_calc\" />\n"
+" <toolitem name=\"print\" action=\"print\" />\n"
" <separator name=\"sep2\" />\n"
" <toolitem name=\"edit_note\" action=\"edit_note\" />\n"
" </toolbar>\n";
@@ -1490,6 +1501,7 @@
{ "next_year", OSMO_STOCK_NEXT_YEAR, _("Next year"), NULL, _("Next year"), NULL},
{ "jump_to_date", OSMO_STOCK_JUMPTO, _("Jump to date"), NULL, _("Jump to date"), NULL},
{ "full_year", OSMO_STOCK_FULLYEAR, _("Full-year calendar"), NULL, _("Full-year calendar"), NULL},
+ { "print", OSMO_STOCK_PRINT, _("Print calendar"), NULL, _("Print calendar"), NULL },
{ "date_calc", OSMO_STOCK_CALCULATOR, _("Date calculator"), NULL, _("Date calculator"), NULL},
};
@@ -1566,6 +1578,8 @@
G_CALLBACK(calendar_create_fullyear_window_cb), appGUI);
g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (uim_widget, "/toolbar/date_calc")), "clicked",
G_CALLBACK(calendar_create_datecalc_window_cb), appGUI);
+ g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (uim_widget, "/toolbar/print")), "clicked",
+ G_CALLBACK(calendar_print_cb), appGUI);
g_signal_connect (G_OBJECT(gtk_ui_manager_get_widget (uim_widget, "/toolbar/edit_note")), "toggled",
G_CALLBACK(calendar_edit_note_cb), appGUI);
Added: trunk/src/calendar_print.c
===================================================================
--- trunk/src/calendar_print.c (rev 0)
+++ trunk/src/calendar_print.c 2008-09-21 13:14:04 UTC (rev 566)
@@ -0,0 +1,113 @@
+
+/*
+ * Osmo - a handy personal organizer
+ *
+ * Copyright (C) 2007 Tomasz Maka <pa...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "i18n.h"
+#include "utils.h"
+
+
+/*------------------------------------------------------------------------------*/
+
+void
+calendar_begin_print (GtkPrintOperation *operation, GtkPrintContext *context,
+ gpointer user_data) {
+
+gdouble height;
+
+ GUI *appGUI = (GUI *)user_data;
+
+ height = gtk_print_context_get_height (context);
+ appGUI->print_lines_per_page = floor (height / appGUI->print_font_size);
+
+ appGUI->print_nlines = 1; /* FIXME */
+
+ appGUI->print_npages = (appGUI->print_nlines - 1) / appGUI->print_lines_per_page + 1;
+ gtk_print_operation_set_n_pages (operation, appGUI->print_npages);
+}
+
+/*------------------------------------------------------------------------------*/
+
+void
+calendar_draw_page (GtkPrintOperation *operation, GtkPrintContext *context,
+ gint npage, gpointer user_data) {
+
+cairo_t *cr;
+gint text_width, text_height;
+gdouble width;
+PangoLayout *layout;
+PangoFontDescription *desc;
+
+ GUI *appGUI = (GUI *)user_data;
+
+ cr = gtk_print_context_get_cairo_context (context);
+ width = gtk_print_context_get_width (context);
+
+ layout = gtk_print_context_create_pango_layout (context);
+
+ desc = pango_font_description_from_string ("mono");
+ pango_font_description_set_size (desc, appGUI->print_font_size * 2 * PANGO_SCALE);
+ pango_layout_set_font_description (layout, desc);
+ pango_font_description_free (desc);
+
+ cairo_move_to (cr, 0, 0);
+
+ pango_layout_set_text (layout, "Calendar", -1);
+ pango_layout_get_pixel_size (layout, &text_width, &text_height);
+ pango_cairo_show_layout (cr, layout);
+ cairo_rel_move_to (cr, 0, text_height*2);
+
+
+ g_object_unref (layout);
+}
+
+/*------------------------------------------------------------------------------*/
+
+void
+calendar_print (GUI *appGUI) {
+
+GtkPrintOperation *print;
+GtkPrintOperationResult result;
+GError *error = NULL;
+gchar buffer[BUFFER_SIZE];
+
+ print = gtk_print_operation_new ();
+
+ appGUI->print_lines_per_page = 0;
+ appGUI->print_nlines = 0;
+ appGUI->print_npages = 0;
+
+ g_signal_connect (print, "begin_print", G_CALLBACK (calendar_begin_print), appGUI);
+ g_signal_connect (print, "draw_page", G_CALLBACK (calendar_draw_page), appGUI);
+
+ result = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+ GTK_WINDOW (appGUI->main_window), &error);
+
+ if (result == GTK_PRINT_OPERATION_RESULT_ERROR) {
+ g_snprintf (buffer, BUFFER_SIZE, "%s: %s", _("Error printing"), error->message);
+ gui_create_dialog(GTK_MESSAGE_ERROR, buffer, GTK_WINDOW (appGUI->main_window));
+ g_error_free (error);
+ }
+
+ g_object_unref (print);
+}
+
+/*------------------------------------------------------------------------------*/
+
+
Property changes on: trunk/src/calendar_print.c
___________________________________________________________________
Added: svn:keywords
+ Id
Added: trunk/src/calendar_print.h
===================================================================
--- trunk/src/calendar_print.h (rev 0)
+++ trunk/src/calendar_print.h 2008-09-21 13:14:04 UTC (rev 566)
@@ -0,0 +1,29 @@
+
+/*
+ * Osmo - a handy personal organizer
+ *
+ * Copyright (C) 2007 Tomasz Maka <pa...@us...>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CALENDAR_PRINT_H
+#define _CALENDAR_PRINT_H
+
+void calendar_print (GUI *appGUI);
+
+
+#endif /* _CALENDAR_PRINT_H */
+
Property changes on: trunk/src/calendar_print.h
___________________________________________________________________
Added: svn:keywords
+ Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|