source: trunk/third/gtkhtml/src/htmliframe.c @ 18136

Revision 18136, 20.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18135, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* This file is part of the GtkHTML library.
3   
4   Copyright (C) 2000 Helix Code, Inc.
5
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Library General Public
8   License as published by the Free Software Foundation; either
9   version 2 of the License, or (at your option) any later version.
10   
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   Library General Public License for more details.
15   
16   You should have received a copy of the GNU Library General Public License
17   along with this library; see the file COPYING.LIB.  If not, write to
18   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19   Boston, MA 02111-1307, USA.
20*/
21
22#include <config.h>
23#include <gtk/gtk.h>
24#include <string.h>
25#include "gtkhtml.h"
26#include "gtkhtml-private.h"
27#include "gtkhtml-stream.h"
28#include "htmlcolorset.h"
29#include "htmlgdkpainter.h"
30#include "htmlprinter.h"
31#include "htmliframe.h"
32#include "htmlengine-search.h"
33#include "htmlengine-save.h"
34#include "htmlsearch.h"
35#include "htmlselection.h"
36#include "htmlsettings.h"
37#include "htmltokenizer.h"
38#include "htmlembedded.h"
39#include <libgnome/gnome-i18n.h>
40
41#ifndef USE_SCROLLED_WINDOW
42#include <gal/widgets/e-scroll-frame.h>
43#endif
44
45HTMLIFrameClass html_iframe_class;
46static HTMLEmbeddedClass *parent_class = NULL;
47static gboolean calc_size (HTMLObject *o, HTMLPainter *painter, GList **changed_objs);
48       
49static void
50iframe_set_base (GtkHTML *html, const char *url, gpointer data)
51{
52        char *new_url = gtk_html_get_url_base_relative (html, url);
53
54        gtk_html_set_base (html, new_url);
55        g_free (new_url);
56}
57
58static void
59iframe_url_requested (GtkHTML *html, const char *url, GtkHTMLStream *handle, gpointer data)
60{
61        HTMLIFrame *iframe = HTML_IFRAME (data);
62        GtkHTML *parent = GTK_HTML (HTML_EMBEDDED(iframe)->parent);
63
64        gtk_signal_emit_by_name (GTK_OBJECT (parent->engine), "url_requested",
65                                 url, handle);
66}
67
68static void
69iframe_size_changed (GtkHTML *html, gpointer data)
70{
71        HTMLIFrame *iframe = HTML_IFRAME (data);
72        GtkHTML *parent = GTK_HTML (HTML_EMBEDDED(iframe)->parent);
73       
74        html_engine_schedule_update (parent->engine);
75}
76
77static gboolean
78iframe_object_requested (GtkHTML *html, GtkHTMLEmbedded *eb, gpointer data)
79{
80        HTMLIFrame *iframe = HTML_IFRAME (data);
81        GtkHTML *parent = GTK_HTML (HTML_EMBEDDED(iframe)->parent);
82        gboolean ret_val;
83
84        ret_val = FALSE;
85        gtk_signal_emit_by_name (GTK_OBJECT (parent), "object_requested", eb, &ret_val);
86        return ret_val;
87}
88
89static void
90iframe_set_gdk_painter (HTMLIFrame *iframe, HTMLPainter *painter)
91{
92        if (painter)
93                gtk_object_ref (GTK_OBJECT (painter));
94       
95        if (iframe->gdk_painter)
96                gtk_object_unref (GTK_OBJECT (iframe->gdk_painter));
97
98        iframe->gdk_painter = painter;
99}
100
101HTMLObject *
102html_iframe_new (GtkWidget *parent,
103                 char *src,
104                 gint width,
105                 gint height,
106                 gboolean border)
107{
108        HTMLIFrame *iframe;
109       
110        iframe = g_new (HTMLIFrame, 1);
111       
112        html_iframe_init (iframe,
113                          &html_iframe_class,
114                          parent,
115                          src,
116                          width,
117                          height,
118                          border);
119       
120        return HTML_OBJECT (iframe);
121}
122
123static gboolean
124html_iframe_grab_cursor(GtkWidget *iframe, GdkEvent *event)
125{
126        /* Keep the focus! Fight the power */
127        return TRUE;
128}
129
130static gint
131calc_min_width (HTMLObject *o,
132                HTMLPainter *painter)
133{
134        HTMLIFrame *iframe;
135
136        iframe = HTML_IFRAME (o);
137        if (iframe->width < 0)
138                return html_engine_calc_min_width (GTK_HTML (HTML_IFRAME (o)->html)->engine);
139        else
140                return iframe->width;
141}
142
143static void
144set_max_width (HTMLObject *o, HTMLPainter *painter, gint max_width)
145{
146        HTMLEngine *e = GTK_HTML (HTML_IFRAME (o)->html)->engine;
147
148        o->max_width = max_width;
149        html_object_set_max_width (e->clue, e->painter, max_width - e->leftBorder - e->rightBorder);
150}
151
152static void
153reset (HTMLObject *o)
154{
155        HTMLIFrame *iframe;
156
157        (* HTML_OBJECT_CLASS (parent_class)->reset) (o);
158        iframe = HTML_IFRAME (o);
159        html_object_reset (GTK_HTML (iframe->html)->engine->clue);
160}
161
162static void
163draw_background (HTMLObject *self,
164                 HTMLPainter *p,
165                 gint x, gint y,
166                 gint width, gint height,
167                 gint tx, gint ty)
168{
169}
170
171/* FIXME rodo - draw + set_painter is not much clean now, needs refactoring */
172
173static void
174draw (HTMLObject *o,
175      HTMLPainter *p,
176      gint x, gint y,
177      gint width, gint height,
178      gint tx, gint ty)
179{
180        HTMLIFrame   *iframe  = HTML_IFRAME (o);
181        HTMLEngine   *e       = GTK_HTML (iframe->html)->engine;
182        ArtIRect paint;
183
184        if (GTK_OBJECT_TYPE (e->painter) == HTML_TYPE_PRINTER) {
185                gint pixel_size = html_painter_get_pixel_size (e->painter);
186                html_object_calc_intersection (o, &paint, x, y, width, height);
187                if (art_irect_empty (&paint))
188                        return;
189
190                html_object_draw (e->clue, e->painter,
191                                  x, y,
192                                  width - pixel_size * (e->leftBorder + e->rightBorder),
193                                  height - pixel_size * (e->topBorder + e->bottomBorder),
194                                  tx + pixel_size * e->leftBorder, ty + pixel_size * e->topBorder);
195        } else
196                (*HTML_OBJECT_CLASS (parent_class)->draw) (o, p, x, y, width, height, tx, ty);
197}
198
199static void
200set_painter (HTMLObject *o, HTMLPainter *painter)
201{
202        HTMLIFrame *iframe;
203
204        iframe = HTML_IFRAME (o);
205        if (GTK_OBJECT_TYPE (GTK_HTML (iframe->html)->engine->painter) != HTML_TYPE_PRINTER) {
206                iframe_set_gdk_painter (iframe, GTK_HTML (iframe->html)->engine->painter);
207        }
208       
209        html_engine_set_painter (GTK_HTML (iframe->html)->engine,
210                                 GTK_OBJECT_TYPE (painter) != HTML_TYPE_PRINTER ? iframe->gdk_painter : painter);
211}
212
213static void
214forall (HTMLObject *self,
215        HTMLEngine *e,
216        HTMLObjectForallFunc func,
217        gpointer data)
218{
219        HTMLIFrame *iframe;
220
221        iframe = HTML_IFRAME (self);
222        (* func) (self, html_object_get_engine (self, e), data);
223        html_object_forall (GTK_HTML (iframe->html)->engine->clue, html_object_get_engine (self, e), func, data);
224}
225
226static gint
227check_page_split (HTMLObject *self, gint y)
228{
229        gint y1, y2;
230        HTMLEngine *e = GTK_HTML (HTML_IFRAME (self)->html)->engine;
231
232        y1 = self->y - self->ascent + e->topBorder;
233        y2 = self->y + self->descent + e->topBorder;
234       
235        if (y1 > y)
236                return 0;
237
238        if (y >= y1 && y < y2)
239                return html_object_check_page_split (e->clue, y - y1) + y1;
240       
241        return y;
242}
243
244static void
245copy (HTMLObject *self,
246      HTMLObject *dest)
247{
248        HTMLIFrame *s = HTML_IFRAME (self);
249        HTMLIFrame *d = HTML_IFRAME (dest);
250
251        (* HTML_OBJECT_CLASS (parent_class)->copy) (self, dest);
252        /*
253        html_iframe_init (d, &html_iframe_class,
254                          HTML_EMBEDDED (dest)->parent,
255                          s->url,
256                          s->width,
257                          s->height,
258                          s->frameborder);
259        */
260        d->scroll = s->scroll;
261        d->html = gtk_html_new ();
262
263        d->gdk_painter = NULL;
264        d->old_painter = NULL;
265        d->parent_painter = NULL;
266
267        d->url = g_strdup (s->url);
268        d->width = s->width;
269        d->height = s->height;
270        d->frameborder = s->frameborder;
271}
272
273static HTMLObject *
274op_copy (HTMLObject *self, HTMLObject *parent, HTMLEngine *e, GList *from, GList *to, guint *len)
275{
276        HTMLObject *dup, *clue;
277        GtkHTML *html;
278
279        dup = html_object_dup (self);
280        html = GTK_HTML (HTML_IFRAME (dup)->html);
281        clue = GTK_HTML (HTML_IFRAME (self)->html)->engine->clue;
282        GTK_HTML (HTML_IFRAME (dup)->html)->engine->clue =
283                html_object_op_copy (clue, dup, GTK_HTML (HTML_IFRAME (self)->html)->engine,
284                                     html_object_get_bound_list (clue, from),
285                                     html_object_get_bound_list (clue, to), len);
286        GTK_HTML (HTML_IFRAME (dup)->html)->engine->clue->parent = parent;
287       
288        return dup;
289}
290
291void
292html_iframe_set_margin_width (HTMLIFrame *iframe, gint margin_width)
293{
294        HTMLEngine *e;
295
296        e = GTK_HTML (iframe->html)->engine;
297
298        e->leftBorder = e->rightBorder = margin_width;
299        html_engine_schedule_redraw (e);
300}
301
302void
303html_iframe_set_margin_height (HTMLIFrame *iframe, gint margin_height)
304{
305        HTMLEngine *e;
306
307        e = GTK_HTML (iframe->html)->engine;
308
309        e->bottomBorder = e->topBorder = margin_height;
310        html_engine_schedule_redraw (e);
311}
312
313void
314html_iframe_set_scrolling (HTMLIFrame *iframe, GtkPolicyType scroll)
315{
316#if E_USE_SCROLLED_WINDOW
317        gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (iframe->scroll),
318                                        scroll, scroll);
319#else
320        e_scroll_frame_set_policy (E_SCROLL_FRAME (iframe->scroll),
321                                   scroll, scroll);
322#endif                                 
323}
324
325static gboolean
326calc_size (HTMLObject *o, HTMLPainter *painter, GList **changed_objs)
327{
328        HTMLIFrame *iframe;
329        HTMLEngine *e;
330        gint width, height;
331        gint old_width, old_ascent, old_descent;
332       
333        old_width = o->width;
334        old_ascent = o->ascent;
335        old_descent = o->descent;
336
337        iframe = HTML_IFRAME (o);
338        e      = GTK_HTML (iframe->html)->engine;
339       
340        if (HTML_EMBEDDED (o)->widget == NULL)
341                return TRUE;
342
343        if ((iframe->width < 0) && (iframe->height < 0)) {
344                e->width = o->max_width;
345                html_engine_calc_size (e, changed_objs);
346
347                height = html_engine_get_doc_height (e);
348                width = html_engine_get_doc_width (e);
349
350                /* FIXME: fix frames for height > 32767 */
351                gtk_widget_set_usize (iframe->scroll, width, MIN (height, 32767));
352                gtk_widget_queue_resize (iframe->scroll);
353               
354                html_iframe_set_scrolling (iframe, GTK_POLICY_NEVER);
355
356                o->width = width;
357                o->ascent = height;
358                o->descent = 0;
359        } else
360                return (* HTML_OBJECT_CLASS (parent_class)->calc_size) (o, painter, changed_objs);
361
362        if (o->descent != old_descent
363            || o->ascent != old_ascent
364            || o->width != old_width)
365                return TRUE;
366
367        return FALSE;
368}
369
370static gboolean
371search (HTMLObject *self, HTMLSearch *info)
372{
373        HTMLEngine *e = GTK_HTML (HTML_IFRAME (self)->html)->engine;
374
375        /* printf ("search\n"); */
376
377        /* search_next? */
378        if (info->stack && HTML_OBJECT (info->stack->data) == e->clue) {
379                /* printf ("next\n"); */
380                info->engine = GTK_HTML (GTK_HTML (HTML_IFRAME (self)->html)->iframe_parent)->engine;
381                html_search_pop (info);
382                html_engine_unselect_all (e);
383                return html_search_next_parent (info);
384        }
385
386        info->engine = e;
387        html_search_push (info, e->clue);
388        if (html_object_search (e->clue, info))
389                return TRUE;
390        html_search_pop (info);
391
392        info->engine = GTK_HTML (GTK_HTML (HTML_IFRAME (self)->html)->iframe_parent)->engine;
393        /* printf ("FALSE\n"); */
394
395        return FALSE;
396}
397
398static HTMLObject *
399head (HTMLObject *self)
400{
401        return GTK_HTML (HTML_IFRAME (self)->html)->engine->clue;
402}
403
404static HTMLObject *
405tail (HTMLObject *self)
406{
407        return GTK_HTML (HTML_IFRAME (self)->html)->engine->clue;
408}
409
410static HTMLEngine *
411get_engine (HTMLObject *self, HTMLEngine *e)
412{
413        return GTK_HTML (HTML_IFRAME (self)->html)->engine;
414}
415
416static HTMLObject*
417check_point (HTMLObject *self,
418             HTMLPainter *painter,
419             gint x, gint y,
420             guint *offset_return,
421             gboolean for_cursor)
422{
423        HTMLEngine *e = GTK_HTML (HTML_IFRAME (self)->html)->engine;
424
425        if (x < self->x || x >= self->x + self->width
426            || y >= self->y + self->descent || y < self->y - self->ascent)
427                return NULL;
428
429        x -= self->x + e->leftBorder - e->x_offset;
430        y -= self->y - self->ascent + e->topBorder - e->y_offset;
431
432        if (for_cursor && (x < 0 || y < e->clue->y - e->clue->ascent))
433                return html_object_check_point (e->clue, e->painter, 0, e->clue->y - e->clue->ascent,
434                                                offset_return, for_cursor);
435
436        if (for_cursor && (x > e->clue->width - 1 || y > e->clue->y + e->clue->descent - 1))
437                return html_object_check_point (e->clue, e->painter, e->clue->width - 1, e->clue->y + e->clue->descent - 1,
438                                                offset_return, for_cursor);
439
440        return html_object_check_point (e->clue, e->painter, x, y, offset_return, for_cursor);
441}
442
443static gboolean
444is_container (HTMLObject *self)
445{
446        return TRUE;
447}
448
449static void
450append_selection_string (HTMLObject *self,
451                         GString *buffer)
452{
453        html_object_append_selection_string (GTK_HTML (HTML_IFRAME (self)->html)->engine->clue, buffer);
454}
455
456static void
457reparent (HTMLEmbedded *emb, GtkWidget *html)
458{
459        HTMLIFrame *iframe = HTML_IFRAME (emb);
460
461        gtk_html_set_iframe_parent (GTK_HTML (iframe->html),
462                                    html,
463                                    GTK_HTML (iframe->html)->frame);
464        (* HTML_EMBEDDED_CLASS (parent_class)->reparent) (emb, html);
465}
466
467/* static gboolean
468select_range (HTMLObject *self,
469              HTMLEngine *engine,
470              guint start,
471              gint length,
472              gboolean queue_draw)
473{
474        return html_object_select_range (GTK_HTML (HTML_IFRAME (self)->html)->engine->clue,
475                                         GTK_HTML (HTML_IFRAME (self)->html)->engine,
476                                         start, length, queue_draw);
477} */
478
479static gboolean
480save (HTMLObject *s,
481      HTMLEngineSaveState *state)
482{
483        HTMLIFrame *iframe = HTML_IFRAME (s);
484        HTMLEngineSaveState *buffer;
485        HTMLEngine *e;
486
487        e = GTK_HTML (iframe->html)->engine;
488       
489        /*
490         * FIXME: we should actually save the iframe definition if inline_frames is not
491         * set, but that is a feature and not critical for release.  We should also probably
492         * wrap the body in a <table> tag with a bg etc.
493         */
494        if (state->inline_frames && e->clue) {
495                buffer = html_engine_save_buffer_new (e, state->inline_frames);
496                html_object_save (e->clue, buffer);
497                if (state->error ||
498                    !html_engine_save_output_string (state, html_engine_save_buffer_peek_text (buffer))) {
499                        html_engine_save_buffer_free (buffer);
500                        return FALSE;
501                }
502                html_engine_save_buffer_free (buffer);
503        } else {
504                HTMLEngine *e = GTK_HTML (iframe->html)->engine;
505
506                if (!html_engine_save_output_string (state, "<IFRAME SRC=\"%s\"", iframe->url))
507                         return FALSE;
508       
509                 if (iframe->width >= 0)
510                         if (!html_engine_save_output_string (state, " WIDTH=\"%d\"", iframe->width))
511                                 return FALSE;
512
513                 if (iframe->width >= 0)
514                         if (!html_engine_save_output_string (state, " WIDTH=\"%d\"", iframe->width))
515                                 return FALSE;
516
517                 if (e->topBorder != TOP_BORDER || e->bottomBorder != BOTTOM_BORDER)
518                         if (!html_engine_save_output_string (state, " MARGINHEIGHT=\"%d\"", e->topBorder))
519                                 return FALSE;
520
521                 if (e->leftBorder != LEFT_BORDER || e->rightBorder != RIGHT_BORDER)
522                         if (!html_engine_save_output_string (state, " MARGINWIDTH=\"%d\"", e->leftBorder))
523                                 return FALSE;
524
525                 if (!html_engine_save_output_string (state, " FRAMEBORDER=\"%d\"", iframe->frameborder))
526                         return FALSE;
527                 
528                 if (!html_engine_save_output_string (state, "></IFRAME>"))
529                     return FALSE;
530        }
531        return TRUE;
532}
533
534static gboolean
535save_plain (HTMLObject *s,
536            HTMLEngineSaveState *state,
537            gint requested_width)
538{
539        HTMLIFrame *iframe = HTML_IFRAME (s);
540        HTMLEngineSaveState *buffer;
541        HTMLEngine *e;
542
543        e = GTK_HTML (iframe->html)->engine;
544
545        if (state->inline_frames && e->clue) {
546                buffer = html_engine_save_buffer_new (e, state->inline_frames);
547                html_object_save_plain (e->clue, buffer, requested_width);
548                if (state->error ||
549                    !html_engine_save_output_string (state, html_engine_save_buffer_peek_text (buffer))) {
550                        html_engine_save_buffer_free (buffer);
551                        return FALSE;
552                }
553                html_engine_save_buffer_free (buffer);
554        }
555
556        return TRUE;
557}
558
559static void
560destroy (HTMLObject *o)
561{
562        HTMLIFrame *iframe = HTML_IFRAME (o);
563
564        iframe_set_gdk_painter (iframe, NULL);
565
566        g_free (iframe->url);
567
568        if (iframe->html) {
569                if (iframe->old_painter)
570                        gtk_object_unref (GTK_OBJECT (iframe->old_painter));
571                if (iframe->parent_painter)
572                        gtk_object_unref (GTK_OBJECT (iframe->parent_painter));
573                iframe->old_painter = iframe->parent_painter = NULL;
574
575                gtk_signal_disconnect_by_data (GTK_OBJECT (iframe->html), o);
576                iframe->html = NULL;
577        }
578
579        HTML_OBJECT_CLASS (parent_class)->destroy (o);
580}
581
582void
583html_iframe_init (HTMLIFrame *iframe,
584                  HTMLIFrameClass *klass,
585                  GtkWidget *parent,
586                  char *src,
587                  gint width,
588                  gint height,
589                  gboolean border)
590{
591        HTMLEmbedded *em = HTML_EMBEDDED (iframe);
592        HTMLTokenizer *new_tokenizer;
593        GtkWidget *new_widget;
594        GtkHTML   *new_html;
595        GtkHTML   *parent_html;
596        GtkHTMLStream *handle;
597        GtkWidget *scrolled_window;
598        gint depth;
599
600        g_assert (GTK_IS_HTML (parent));
601        parent_html = GTK_HTML (parent);
602
603        html_embedded_init (em, HTML_EMBEDDED_CLASS (klass),
604                            parent, NULL, NULL);
605       
606#if USE_SCROLLED_WINDOW
607        scrolled_window = gtk_scrolled_window_new (NULL, NULL);
608#else
609        scrolled_window = e_scroll_frame_new (NULL, NULL);
610        e_scroll_frame_set_shadow_type (E_SCROLL_FRAME (scrolled_window),
611                                        border ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
612
613#endif
614
615        iframe->scroll = scrolled_window;
616        html_iframe_set_scrolling (iframe, GTK_POLICY_AUTOMATIC);
617
618        new_widget = gtk_html_new ();
619        new_html = GTK_HTML (new_widget);
620
621        /* use parent_html font_manager */
622        gtk_object_ref (GTK_OBJECT (new_html->engine->painter));
623        gtk_object_ref (GTK_OBJECT (parent_html->engine->painter));
624        iframe->old_painter = new_html->engine->painter;
625        iframe->parent_painter = parent_html->engine->painter;
626
627        new_tokenizer = html_tokenizer_clone (parent_html->engine->ht);
628
629        html_engine_set_tokenizer (new_html->engine, new_tokenizer);
630        gtk_object_unref (GTK_OBJECT (new_tokenizer));
631        new_tokenizer = NULL;
632
633        gtk_html_set_default_content_type (new_html,
634                                           parent_html->priv->content_type);
635        iframe->html = new_widget;
636        depth = gtk_html_set_iframe_parent (new_html, parent, HTML_OBJECT (iframe));
637        gtk_container_add (GTK_CONTAINER (scrolled_window), new_widget);
638        gtk_widget_show (new_widget);
639
640        iframe->url = g_strdup (src);
641        iframe->width = width;
642        iframe->height = height;
643        iframe->gdk_painter = NULL;
644        iframe->frameborder = border;
645        gtk_html_set_base (new_html, src);
646
647        handle = gtk_html_begin (new_html);
648
649        new_html->engine->clue->parent = HTML_OBJECT (iframe);
650
651        gtk_signal_connect (GTK_OBJECT (new_html), "url_requested",
652                            GTK_SIGNAL_FUNC (iframe_url_requested),
653                            (gpointer)iframe);
654#if 0
655        /* NOTE: because of peculiarities of the frame/gtkhtml relationship
656         * on_url and link_clicked are emitted from the toplevel widget not
657         * proxied like url_requested is.
658         */
659        gtk_signal_connect (GTK_OBJECT (new_html), "on_url",
660                            GTK_SIGNAL_FUNC (iframe_on_url),
661                            (gpointer)iframe);
662        gtk_signal_connect (GTK_OBJECT (new_html), "link_clicked",
663                            GTK_SIGNAL_FUNC (iframe_link_clicked),
664                            (gpointer)iframe); 
665#endif
666        gtk_signal_connect (GTK_OBJECT (new_html), "size_changed",
667                            GTK_SIGNAL_FUNC (iframe_size_changed),
668                            (gpointer)iframe); 
669        gtk_signal_connect (GTK_OBJECT (new_html), "set_base",
670                            GTK_SIGNAL_FUNC (iframe_set_base),
671                            (gpointer)iframe); 
672        gtk_signal_connect (GTK_OBJECT (new_html), "object_requested",
673                            GTK_SIGNAL_FUNC (iframe_object_requested),
674                            (gpointer)iframe); 
675
676        /*
677          gtk_signal_connect (GTK_OBJECT (html), "button_press_event",
678          GTK_SIGNAL_FUNC (iframe_button_press_event), iframe);
679        */
680
681        if (depth < 10) {
682                gtk_signal_emit_by_name (GTK_OBJECT (parent_html->engine),
683                                         "url_requested", src, handle);
684        } else {
685                gtk_html_stream_printf (handle, "%s", _("Error: maximium frame depth exceded"));
686                gtk_html_stream_close (handle, GTK_HTML_STREAM_OK);
687        }
688
689        /* FIXME: fix frames for height > 32767 */
690        gtk_widget_set_usize (scrolled_window, width, MIN (height, 32767));
691        gtk_widget_show (scrolled_window);     
692
693        html_embedded_set_widget (em, scrolled_window);
694
695        gtk_signal_connect(GTK_OBJECT (scrolled_window), "button_press_event",
696                           GTK_SIGNAL_FUNC (html_iframe_grab_cursor), NULL);
697
698        /* inherit the current colors from our parent */
699        html_colorset_set_unchanged (new_html->engine->defaultSettings->color_set,
700                                     parent_html->engine->settings->color_set);
701        html_colorset_set_unchanged (new_html->engine->settings->color_set,
702                                     parent_html->engine->settings->color_set);
703        html_painter_set_focus (new_html->engine->painter, parent_html->engine->have_focus);
704        /*
705        gtk_signal_connect (GTK_OBJECT (html), "title_changed",
706                            GTK_SIGNAL_FUNC (title_changed_cb), (gpointer)app);
707        gtk_signal_connect (GTK_OBJECT (html), "button_press_event",
708                            GTK_SIGNAL_FUNC (on_button_press_event), popup_menu);
709        gtk_signal_connect (GTK_OBJECT (html), "redirect",
710                            GTK_SIGNAL_FUNC (on_redirect), NULL);
711        gtk_signal_connect (GTK_OBJECT (html), "object_requested",
712                            GTK_SIGNAL_FUNC (object_requested_cmd), NULL);
713        */
714}
715
716void
717html_iframe_type_init (void)
718{
719        html_iframe_class_init (&html_iframe_class, HTML_TYPE_IFRAME, sizeof (HTMLIFrame));
720}
721
722void
723html_iframe_class_init (HTMLIFrameClass *klass,
724                        HTMLType type,
725                        guint size)
726{
727        HTMLEmbeddedClass *embedded_class;
728        HTMLObjectClass  *object_class;
729
730        g_return_if_fail (klass != NULL);
731       
732        embedded_class = HTML_EMBEDDED_CLASS (klass);
733        object_class = HTML_OBJECT_CLASS (klass);
734
735        html_embedded_class_init (embedded_class, type, size);
736        parent_class = &html_embedded_class;
737
738        object_class->destroy                 = destroy;
739        object_class->save                    = save;
740        object_class->save_plain              = save_plain;
741        object_class->calc_size               = calc_size;
742        object_class->calc_min_width          = calc_min_width;
743        object_class->set_painter             = set_painter;
744        object_class->reset                   = reset;
745        object_class->draw                    = draw;
746        object_class->copy                    = copy;
747        object_class->op_copy                 = op_copy;
748        object_class->set_max_width           = set_max_width;
749        object_class->forall                  = forall;
750        object_class->check_page_split        = check_page_split;
751        object_class->search                  = search;
752        object_class->head                    = head;
753        object_class->tail                    = tail;
754        object_class->get_engine              = get_engine;
755        object_class->check_point             = check_point;
756        object_class->is_container            = is_container;
757        object_class->draw_background         = draw_background;
758        object_class->append_selection_string = append_selection_string;
759       
760        embedded_class->reparent = reparent;
761}
Note: See TracBrowser for help on using the repository browser.