@@ -102,173 +102,6 @@ static void change_window_title(GtkWidget *window, const gchar *window_title)
102
102
gtk_window_set_title (GTK_WINDOW (window ), window_title );
103
103
}
104
104
105
- #if 0
106
- static gint
107
- _calc_header_height (GtkHTML * html , GtkPrintOperation * operation ,
108
- GtkPrintContext * context )
109
- {
110
- PangoContext * pango_context ;
111
- PangoFontDescription * desc ;
112
- PangoFontMetrics * metrics ;
113
- gint header_height ;
114
-
115
- pango_context = gtk_print_context_create_pango_context (context );
116
- desc = pango_font_description_from_string ("Sans Regular 10" );
117
-
118
- metrics =
119
- pango_context_get_metrics (pango_context , desc ,
120
- pango_language_get_default ());
121
- header_height =
122
- pango_font_metrics_get_ascent (metrics ) +
123
- pango_font_metrics_get_descent (metrics );
124
- pango_font_metrics_unref (metrics );
125
-
126
- pango_font_description_free (desc );
127
- g_object_unref (pango_context );
128
-
129
- return header_height ;
130
- }
131
-
132
- static gint
133
- _calc_footer_height (GtkHTML * html , GtkPrintOperation * operation ,
134
- GtkPrintContext * context )
135
- {
136
- PangoContext * pango_context ;
137
- PangoFontDescription * desc ;
138
- PangoFontMetrics * metrics ;
139
- gint footer_height ;
140
-
141
- pango_context = gtk_print_context_create_pango_context (context );
142
- desc = pango_font_description_from_string ("Sans Regular 10" );
143
-
144
- metrics =
145
- pango_context_get_metrics (pango_context , desc ,
146
- pango_language_get_default ());
147
- footer_height =
148
- pango_font_metrics_get_ascent (metrics ) +
149
- pango_font_metrics_get_descent (metrics );
150
- pango_font_metrics_unref (metrics );
151
-
152
- pango_font_description_free (desc );
153
- g_object_unref (pango_context );
154
-
155
- return footer_height ;
156
- }
157
-
158
- static void
159
- _draw_header (GtkHTML * html , GtkPrintOperation * operation ,
160
- GtkPrintContext * context ,
161
- gint page_nr , PangoRectangle * rec , EDITOR * e )
162
- {
163
- PangoFontDescription * desc ;
164
- PangoLayout * layout ;
165
- gdouble x , y ;
166
- gchar * text ;
167
- cairo_t * cr ;
168
-
169
- text = g_strdup (e -> filename );
170
-
171
- desc = pango_font_description_from_string ("Sans Regular 10" );
172
- layout = gtk_print_context_create_pango_layout (context );
173
- pango_layout_set_alignment (layout , PANGO_ALIGN_CENTER );
174
- pango_layout_set_font_description (layout , desc );
175
- pango_layout_set_text (layout , text , -1 );
176
- pango_layout_set_width (layout , rec -> width );
177
-
178
- x = pango_units_to_double (rec -> x );
179
- y = pango_units_to_double (rec -> y );
180
-
181
- cr = gtk_print_context_get_cairo_context (context );
182
-
183
- cairo_save (cr );
184
- cairo_set_source_rgb (cr , .0 , .0 , .0 );
185
- cairo_move_to (cr , x , y );
186
- pango_cairo_show_layout (cr , layout );
187
- cairo_restore (cr );
188
-
189
- g_object_unref (layout );
190
- pango_font_description_free (desc );
191
-
192
- g_free (text );
193
- }
194
-
195
-
196
- static void
197
- _draw_footer (GtkHTML * html , GtkPrintOperation * operation ,
198
- GtkPrintContext * context ,
199
- gint page_nr , PangoRectangle * rec , EDITOR * e )
200
- {
201
- PangoFontDescription * desc ;
202
- PangoLayout * layout ;
203
- gdouble x , y ;
204
- gint n_pages ;
205
- gchar * text ;
206
- cairo_t * cr ;
207
-
208
- g_object_get (operation , "n-pages" , & n_pages , NULL );
209
- text = g_strdup_printf (_ ("Page %d of %d" ), page_nr + 1 , n_pages );
210
-
211
- desc = pango_font_description_from_string ("Sans Regular 10" );
212
- layout = gtk_print_context_create_pango_layout (context );
213
- pango_layout_set_alignment (layout , PANGO_ALIGN_CENTER );
214
- pango_layout_set_font_description (layout , desc );
215
- pango_layout_set_text (layout , text , -1 );
216
- pango_layout_set_width (layout , rec -> width );
217
-
218
- x = pango_units_to_double (rec -> x );
219
- y = pango_units_to_double (rec -> y );
220
-
221
- cr = gtk_print_context_get_cairo_context (context );
222
-
223
- cairo_save (cr );
224
- cairo_set_source_rgb (cr , .0 , .0 , .0 );
225
- cairo_move_to (cr , x , y );
226
- pango_cairo_show_layout (cr , layout );
227
- cairo_restore (cr );
228
-
229
- g_object_unref (layout );
230
- pango_font_description_free (desc );
231
-
232
- g_free (text );
233
- }
234
-
235
- static GtkPrintOperationResult
236
- _do_print (EDITOR * e , GtkPrintOperationAction action )
237
- {
238
- GtkPrintOperation * operation ;
239
- GtkPrintSettings * psettings ;
240
- GtkPageSetup * setup ;
241
- GtkPrintOperationResult result ;
242
- GError * error = NULL ;
243
-
244
- operation = gtk_print_operation_new ();
245
- psettings = gtk_print_settings_new ();
246
-
247
- psettings = gtk_print_operation_get_print_settings (operation );
248
-
249
- setup = gtk_page_setup_new ();
250
- gtk_page_setup_set_top_margin (setup , 30 , GTK_UNIT_PIXEL );
251
- gtk_page_setup_set_left_margin (setup , 50 , GTK_UNIT_PIXEL );
252
-
253
- #ifdef WIN32
254
- gtk_print_operation_set_unit (operation , GTK_UNIT_POINTS );
255
- #endif
256
- gtk_print_operation_set_default_page_setup (operation , setup );
257
-
258
- result = gtk_html_print_operation_run (GTK_HTML (e -> html_widget ), operation , action , GTK_WINDOW (e -> window ), (GtkHTMLPrintCalcHeight ) _calc_header_height , /* GtkHTMLPrintCalcHeight calc_header_height */
259
- (GtkHTMLPrintCalcHeight ) _calc_footer_height , /* GtkHTMLPrintCalcHeight calc_footer_height */
260
- (GtkHTMLPrintDrawFunc ) _draw_header , /* GtkHTMLPrintDrawFunc draw_header */
261
- (GtkHTMLPrintDrawFunc ) _draw_footer , /* GtkHTMLPrintDrawFunc draw_footer */
262
- e , /* gpointer user_data */
263
- & error );
264
-
265
- g_object_unref (operation );
266
- handle_error (& error );
267
-
268
- return result ;
269
- }
270
- #endif /* 0 */
271
-
272
105
static const gchar * file_ui =
273
106
"<ui>\n"
274
107
" <menubar name='main-menu'>\n"
@@ -360,9 +193,6 @@ static gint open_dialog(EDITOR *e)
360
193
{
361
194
GtkWidget * dialog ;
362
195
gint response ;
363
- #if 0
364
- const gchar * filename ;
365
- #endif
366
196
367
197
dialog =
368
198
gtk_file_chooser_dialog_new (_ ("Open" ), GTK_WINDOW (e -> window ),
@@ -378,13 +208,6 @@ static gint open_dialog(EDITOR *e)
378
208
#endif
379
209
NULL );
380
210
381
- /*gtk_file_chooser_set_do_overwrite_confirmation (
382
- GTK_FILE_CHOOSER (dialog), TRUE); */
383
-
384
- #if 0
385
- filename = gtkhtml_editor_get_filename (GTKHTML_EDITOR (e -> window ));
386
- #endif
387
-
388
211
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog ),
389
212
settings .studypaddir );
390
213
0 commit comments