PageRenderTime 25ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/src/wrappers/gtk/library/gtk_print_unix_dialog.e

http://github.com/tybor/Liberty
Specman e | 190 lines | 82 code | 25 blank | 83 comment | 4 complexity | a62e6da8bbdbec3cebcff30e4c75af40 MD5 | raw file
  1indexing
  2	description: "GtkPrintUnixDialog -- A print dialog."
  3	copyright: "[
  4					Copyright (C) 2007 Paolo Redaelli, GTK+ team
  5					
  6					This library is free software; you can redistribute it and/or
  7					modify it under the terms of the GNU Lesser General Public License
  8					as published by the Free Software Foundation; either version 2.1 of
  9					the License, or (at your option) any later version.
 10					
 11					This library is distributed in the hopeOA that it will be useful, but
 12					WITHOUT ANY WARRANTY; without even the implied warranty of
 13					MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14					Lesser General Public License for more details.
 15
 16					You should have received a copy of the GNU Lesser General Public
 17					License along with this library; if not, write to the Free Software
 18					Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 19					02110-1301 USA
 20			]"
 21
 22	wrapped_version: "2.10.6"
 23
 24class GTK_PRINT_UNIX_DIALOG
 25	-- GtkPrintUnixDialog implements a print dialog for platforms which don't
 26	-- provide a native print dialog, like Unix. It can be used very much like
 27	-- any other GTK+ dialog, at the cost of the portability offered by the
 28	-- high-level printing API
 29
 30	-- In order to print something with GtkPrintUnixDialog, you need to use
 31	-- gtk_print_unix_dialog_get_selected_printer() to obtain a GtkPrinter object
 32	-- and use it to construct a GtkPrintJob using gtk_print_job_new().
 33
 34	-- GtkPrintUnixDialog uses the following response values:
 35
 36	--   GTK_RESPONSE_OK     for the "Print" button
 37	--   GTK_RESPONSE_APPLY  for the "Preview" button
 38	--   GTK_RESPONSE_CANCEL for the "Cancel" button
 39
 40	-- Printing support was added in GTK+ 2.10.
 41
 42inherit
 43	GTK_DIALOG
 44		rename
 45			make as dialog_make
 46		undefine
 47			struct_size
 48		end
 49	-- TODO: GtkPrintUnixDialog implements AtkImplementorIface.
 50	
 51insert
 52	GTK_PRINT_UNIX_DIALOG_EXTERNALS
 53	GTK_PRINT_CAPABILITIES
 54	
 55creation make, from_external_pointer
 56
 57feature {} -- Creation
 58	make (a_title: STRING; a_parent: GTK_WINDOW) is
 59			-- Creates a new GtkPrintUnixDialog with `a_title' and `a_parent' as
 60			-- the transient parent of the dialog. Both `a_title' and `a_parent'
 61			-- can be Void.
 62		local tp, pp: POINTER
 63		do
 64			if a_title/=Void then tp:=a_title.to_external end
 65			if a_parent/=Void then pp:=a_parent.handle end
 66			from_external_pointer(gtk_print_unix_dialog_new(tp,pp))
 67		end
 68
 69feature
 70	set_page_setup (a_setup: GTK_PAGE_SETUP) is
 71			--   Sets the page setup of the GtkPrintUnixDialog.
 72		require setup_not_void: a_setup/=Void
 73		do
 74			gtk_print_unix_dialog_set_page_setup(handle,a_setup.handle)
 75		end
 76
 77	page_setup: GTK_PAGE_SETUP is
 78			-- the page setup of dialog.
 79		do
 80			create Result.from_external_pointer(gtk_print_unix_dialog_get_page_setup(handle))
 81		end
 82
 83	set_current_page (a_page: INTEGER) is
 84			-- Sets the current page number. If `a_page' is not -1, this enables
 85			-- the current page choice for the range of pages to print.
 86		do
 87			gtk_print_unix_dialog_set_current_page(handle,a_page)
 88		end
 89
 90	current_page: INTEGER is
 91			-- the current page of dialog
 92		do
 93			Result:=gtk_print_unix_dialog_get_current_page(handle)
 94		end
 95
 96	set_settings (some_settings: GTK_PRINT_SETTINGS) is
 97			-- Sets the GtkPrintSettings for the GtkPrintUnixDialog to
 98			-- `some_settings' that can be Void. Typically, this is used to restore
 99			-- saved print settings from a previous print operation before the
100			-- print dialog is shown.
101		do
102			gtk_print_unix_dialog_set_settings(handle,null_or(some_settings))
103		end
104
105	settings: GTK_PRINT_SETTINGS is
106			-- a new GtkPrintSettings object that represents the current values in
107			-- the print dialog.
108		do
109			create Result.from_external_pointer(gtk_print_unix_dialog_get_settings(handle))
110			-- Note: the original C documantation says "Note that this creates a
111			-- new object, and you need to unref it if don't want to keep
112			-- it". Since GTK_PRINT_SETTINGS is a G_OBJECT that ref the underlying
113			-- C structure during `from_external_pointer' we can safely unref it
114			-- here and let the Garbage Collector handle it nicely.
115			Result.unref
116		ensure not_void: Result/=Void
117		end
118
119	selected_printer: GTK_PRINTER is
120			-- the currently selected printer
121		do
122			create Result.from_external_pointer(handle)
123		ensure not_void: Result/=Void
124		end
125
126	add_custom_tab (a_tab, a_label: GTK_WIDGET) is
127			--   Adds `a_tab' to the print dialog as a custom tab using `a_label'.
128		do
129			gtk_print_unix_dialog_add_custom_tab(handle,a_tab.handle,a_label.handle)
130		end
131
132	set_manual_capabilities (some_capabilities: INTEGER) is
133			-- Specify the printing capabilities your application
134			-- supports.  For instance, if you can handle scaling the
135			-- output then you pass `gtk_print_capability_scale'. If you
136			-- don't pass that, then the dialog will only let you select
137			-- the scale if the printing system automatically handles
138			-- scaling.
139		require valid_capabilities: are_valid_print_capabilities(some_capabilities)
140		do
141			gtk_print_unix_dialog_set_manual_capabilities(handle,some_capabilities)
142		end
143	
144feature -- TODO: Properties
145	--   "current-page"         gint                  : Read / Write
146	--   "page-setup"           GtkPageSetup          : Read / Write
147	--   "print-settings"       GtkPrintSettings      : Read / Write
148	--   "selected-printer"     GtkPrinter            : Read
149		--Property Details
150	--
151	--  The "current-page" property
152	--
153	--   "current-page"         gint                  : Read / Write
154	--
155	--   The current page in the document.
156	--
157	--   Allowed values: >= -1
158	--
159	--   Default value: -1
160	--
161	--   --------------------------------------------------------------------------
162	--
163	--  The "page-setup" property
164	--
165	--   "page-setup"           GtkPageSetup          : Read / Write
166	--
167	--   The GtkPageSetup to use.
168	--
169	--   --------------------------------------------------------------------------
170	--
171	--  The "print-settings" property
172	--
173	--   "print-settings"       GtkPrintSettings      : Read / Write
174	--
175	--   The GtkPrintSettings used for initializing the dialog.
176	--
177	--   --------------------------------------------------------------------------
178	--
179	--  The "selected-printer" property
180	--
181	--   "selected-printer"     GtkPrinter            : Read
182	--
183	--   The GtkPrinter which is selected.
184	--
185	--See Also
186	--
187	--   GtkPageSetupUnixDialog, GtkPrinter, GtkPrintJob
188
189end -- class GTK_PRINT_UNIX_DIALOG
190