[dots/remove-assistant: 11/38] Implement printing. It sends the raw text file to the printer
- From: Fernando Herrera de las Heras <fherrera src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dots/remove-assistant: 11/38] Implement printing. It sends the raw text file to the printer
- Date: Thu, 15 Jul 2010 21:07:54 +0000 (UTC)
commit d5212acb294870571d35c23e7d24a4687797cd88
Author: Fernando Herrera <fherrera onirica com>
Date: Thu Jul 8 19:43:26 2010 +0200
Implement printing. It sends the raw text file to the printer
data/app_window.xml | 28 ++++++++++++++++++++++++++++
dots/app_window.py | 28 ++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/data/app_window.xml b/data/app_window.xml
index 3b25a58..1399753 100644
--- a/data/app_window.xml
+++ b/data/app_window.xml
@@ -49,6 +49,15 @@
</object>
</child>
<child>
+ <object class="GtkImageMenuItem" id="imagemenuitem11">
+ <property name="visible">True</property>
+ <property name="related_action">action_print</property>
+ <property name="use_action_appearance">True</property>
+ <property name="use_underline">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ </child>
+ <child>
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
<property name="visible">True</property>
</object>
@@ -223,6 +232,19 @@
<property name="homogeneous">True</property>
</packing>
</child>
+ <child>
+ <object class="GtkToolButton" id="toolbutton3">
+ <property name="visible">True</property>
+ <property name="related_action">action_print</property>
+ <property name="use_action_appearance">True</property>
+ <property name="label" translatable="yes">toolbutton3</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -273,4 +295,10 @@
<property name="stock_id">gtk-quit</property>
<signal name="activate" handler="_onQuit"/>
</object>
+ <object class="GtkAction" id="action_print">
+ <property name="stock_id">gtk-print</property>
+ <property name="sensitive">False</property>
+ <signal name="activate" handler="_onPrint"/>
+ </object>
+
</interface>
diff --git a/dots/app_window.py b/dots/app_window.py
index b0580ad..f226bab 100644
--- a/dots/app_window.py
+++ b/dots/app_window.py
@@ -22,6 +22,7 @@ import host_settings
from dots_project import DotsProject
from document_builder import document_new
import gconf
+import gtkunixprint
class AppWindow(object):
def __init__(self):
@@ -190,6 +191,8 @@ class AppWindow(object):
action.set_sensitive(True)
action = self.main_xml.get_object('action_save')
action.set_sensitive(True)
+ action = self.main_xml.get_object('action_print')
+ action.set_sensitive(True)
def _OnBrailleViewToggle(self, ascii_item):
@@ -230,6 +233,31 @@ class AppWindow(object):
dialog.destroy()
+ def _printJobSent(self, job, data, errormsg):
+ if errormsg is not None:
+ print "Error printing: " + errormsg
+
+ os.unlink(data)
+
+
+ def _onPrint(self, action):
+ dialog = gtkunixprint.PrintUnixDialog()
+ response = dialog.run()
+ if response == gtk.RESPONSE_OK:
+ printer = dialog.get_selected_printer()
+ settings = dialog.get_settings()
+ setup = dialog.get_page_setup()
+ job = gtkunixprint.PrintJob("dots", printer, settings, setup)
+ tmpfile = tempfile.NamedTemporaryFile (delete=False)
+ tmpfile.write (self.project.buffer.get_text(
+ self.project.buffer.get_start_iter(),
+ self.project.buffer.get_end_iter()))
+ tmpfile.close()
+ job.set_source_file(tmpfile.name)
+ job.send(self._printJobSent, tmpfile.name)
+ dialog.destroy()
+
+
def addDocument(self, document):
container = self.main_xml.get_object('main_alignment')
if self.project is not None:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]