gyrus r321 - in branches/gyrus-python: . src
- From: avaldes svn gnome org
- To: svn-commits-list gnome org
- Subject: gyrus r321 - in branches/gyrus-python: . src
- Date: Tue, 29 Jan 2008 16:49:05 +0000 (GMT)
Author: avaldes
Date: Tue Jan 29 16:49:04 2008
New Revision: 321
URL: http://svn.gnome.org/viewvc/gyrus?rev=321&view=rev
Log:
add create report of mailbox quota.
M src/gyrus_print.py
M ChangeLog
Modified:
branches/gyrus-python/ChangeLog
branches/gyrus-python/src/gyrus_print.py
Modified: branches/gyrus-python/src/gyrus_print.py
==============================================================================
--- branches/gyrus-python/src/gyrus_print.py (original)
+++ branches/gyrus-python/src/gyrus_print.py Tue Jan 29 16:49:04 2008
@@ -17,16 +17,14 @@
gtk.glade.textdomain(APPNAME)
def show_dialog_print(admin):
- window = gtk.Window()
- window.connect("destroy",gtk.main_quit)
+ settings = gtk.PrintSettings()
op = gtk.PrintOperation()
- settings = gtk.PrintSettings()
op.set_print_settings(settings)
- op.set_n_pages(1)
op.set_unit(gtk.UNIT_MM)
+
+ op.connect("begin_print",begin_print,admin)
op.connect("draw_page",draw_page,admin)
- #op.connect("done",gtk.main_quit)
response = op.run(gtk.PRINT_OPERATION_ACTION_PRINT_DIALOG)
@@ -34,55 +32,74 @@
settings = op.get_print_settings()
-def draw_page(PrintOperation,PrintContext,Page,admin):
- context = PrintContext.get_cairo_context()
- width = PrintContext.get_width()
+def begin_print(operation,context,admin):
+ operation.set_n_pages(5)
+
- page_setup = PrintContext.get_page_setup()
+def draw_page(operation,context,page,admin):
+ print page
+
+ cairo_context = context.get_cairo_context()
+ width = context.get_width()
+
+ page_setup = context.get_page_setup()
left_margin = page_setup.get_left_margin(gtk.UNIT_MM)
right_margin = page_setup.get_right_margin(gtk.UNIT_MM)
top_margin = page_setup.get_top_margin(gtk.UNIT_MM)
+ bottom_margin = page_setup.get_bottom_margin(gtk.UNIT_MM)
page_width = page_setup.get_page_width(gtk.UNIT_MM)
+ page_height = page_setup.get_page_height(gtk.UNIT_MM)
x = left_margin
- layout = PrintContext.create_pango_layout()
+ layout = context.create_pango_layout()
desc = pango.FontDescription("Sans 10")
layout.set_font_description(desc)
# print header
- print_header(context,layout,x,page_width,right_margin,top_margin)
+ print_header(cairo_context,layout,x,page_width,right_margin,top_margin)
model = admin.treeview_users.get_model()
- y = top_margin + 8
+ yini = top_margin + 8
+ y = yini
iter = model.get_iter_first()
while iter:
mb = model.get(iter,COLUMN_MAILBOX)
res,msg,free,quota = gyrus_admin_mailbox.get_quota_of_mailbox (admin,mb[0])
- print_string(context,layout,x,y,mb[0])
- iter = model.iter_next(iter)
- y = y + 4
+ print_string(cairo_context,layout,x,y,mb[0])
+ print_string(cairo_context,layout,x + 40,y,str(quota))
+ print_string(cairo_context,layout,x + 80,y,str(0))
+ print_string(cairo_context,layout,x + 120,y,str(free))
+ print_string(cairo_context,layout,x + 150,y,"%")
+ iter = model.iter_next(iter)
+ if iter:
+ y = y + 4
-def print_line(context,width_line,x,width,y):
- context.move_to(x,y)
- context.line_to(width,y)
- context.set_line_join(cairo.LINE_JOIN_ROUND)
- context.set_line_width(width_line)
- context.stroke()
+ if y > page_height:
+ print_header(cairo_context,layout,x,page_width,right_margin,top_margin)
+ y = yini
+
+
+def print_line(cairo_context,width_line,x,width,y):
+ cairo_context.move_to(x,y)
+ cairo_context.line_to(width,y)
+ cairo_context.set_line_join(cairo.LINE_JOIN_ROUND)
+ cairo_context.set_line_width(width_line)
+ cairo_context.stroke()
-def print_string(context,layout,x,y,string):
- context.move_to(x,y)
+def print_string(cairo_context,layout,x,y,string):
+ cairo_context.move_to(x,y)
layout.set_text(string)
- context.show_layout(layout)
+ cairo_context.show_layout(layout)
-def print_header(context,layout,x,page_width,right_margin,top_margin):
- print_line(context,WIDTH_LINE,x,page_width - right_margin,top_margin)
- print_string(context,layout,x,top_margin + 1,_("Mailbox"))
- print_string(context,layout,x + 40,top_margin + 1,_("Quota assigned"))
- print_string(context,layout,x + 80,top_margin + 1,_("Quota used"))
- print_string(context,layout,x + 120,top_margin + 1,_("Quota free"))
- print_string(context,layout,x + 150,top_margin + 1,_("Status"))
- print_line(context,WIDTH_LINE,x,page_width - right_margin,top_margin + 6)
+def print_header(cairo_context,layout,x,page_width,right_margin,top_margin):
+ print_line(cairo_context,WIDTH_LINE,x,page_width - right_margin,top_margin)
+ print_string(cairo_context,layout,x,top_margin + 1,_("Mailbox"))
+ print_string(cairo_context,layout,x + 40,top_margin + 1,_("Quota assigned"))
+ print_string(cairo_context,layout,x + 80,top_margin + 1,_("Quota used"))
+ print_string(cairo_context,layout,x + 120,top_margin + 1,_("Quota free"))
+ print_string(cairo_context,layout,x + 150,top_margin + 1,_("Percentage"))
+ print_line(cairo_context,WIDTH_LINE,x,page_width - right_margin,top_margin + 6)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]