示例#1
0
static void
gnc_html_dispose( GObject* obj )
{
    GncHtml* self = GNC_HTML(obj);
    GncHtmlPrivate* priv = GNC_HTML_GET_PRIVATE(self);

    if ( priv->container != NULL )
    {
        gtk_widget_destroy( GTK_WIDGET(priv->container) );
        g_object_unref( G_OBJECT(priv->container) );
        priv->container = NULL;
    }
    if ( priv->request_info != NULL )
    {
        g_hash_table_destroy( priv->request_info );
        priv->request_info = NULL;
    }
    if ( priv->history != NULL )
    {
        gnc_html_history_destroy( priv->history );
        priv->history = NULL;
    }

    G_OBJECT_CLASS(gnc_html_parent_class)->dispose( obj );
}
示例#2
0
static PyObject *
_wrap_gnc_html_webkit_show_data(PyObject *self, PyObject *args, PyObject *kwargs)
{
    static char *kwlist[] = { "html", "data", "datalen", NULL };
    PyGObject *html;
    char *data;
    int datalen;
    GncHtmlPrivate *priv_html;
    GncHtmlWebkitPrivate *priv;

    //fprintf(stderr,"webkit show data called 1\n");

    if (!PyArg_ParseTupleAndKeywords(args, kwargs,"Osi:Gnc.HtmlWebkit.show_data", kwlist, &html, &data, &datalen))
        return NULL;

    //fprintf(stderr,"webkit show data called 2\n");

    // we now call the gnc-html class pointer
    //gnc_html_webkit_show_data(GNC_HTML_WEBKIT(html->obj), data, datalen);

    GncHtml* gself_html = GNC_HTML(html->obj);
    GncHtmlWebkit* gself = GNC_HTML_WEBKIT(html->obj);

    fprintf(stderr,"html self is %p\n",(void *)gself_html);
    fprintf(stderr,"html self is %d\n",GNC_IS_HTML(gself_html));
    fprintf(stderr,"html self class is %p\n",(void *)GNC_HTML_GET_CLASS(gself_html));
    fprintf(stderr,"html self show_data is %p\n",(void *)(GNC_HTML_GET_CLASS(gself_html)->show_data));

    fprintf(stderr,"webkit self is %p\n",(void *)gself);
    fprintf(stderr,"webkit self is %d\n",GNC_IS_HTML(gself));
    fprintf(stderr,"webkit self class is %p\n",(void *)GNC_HTML_WEBKIT_GET_CLASS(gself));
    // so this does not exist - only the parent class GncHtml defines the show_data!!
    //fprintf(stderr,"webkit self show_data is %p\n",(void *)(GNC_HTML_WEBKIT_GET_CLASS(gself)->show_data));

    // this appears to be the way we call should call it rather than
    // direct pointer call
    // great - inspection of code show this only displays stuff if priv->html_string is set
    // note that the dispose function frees this

    priv_html = GNC_HTML_GET_PRIVATE(gself_html);
    fprintf(stderr,"html self priv %p\n",(char *)&(gself_html->priv));
    fprintf(stderr,"html self priv is %p\n",(void *)priv_html);

    priv = GNC_HTML_WEBKIT_GET_PRIVATE(gself);
    priv->html_string = g_strdup(data);

    fprintf(stderr,"html self html struct len %lx\n", sizeof(GncHtml));
    fprintf(stderr,"html self htmlwebkitstruct len %lx\n", sizeof(GncHtmlWebkit));
    fprintf(stderr,"webkit self priv %p\n",(char *)&(gself->priv));
    fprintf(stderr,"webkit self priv offset %llx\n",((char *)((char *)&(gself->priv)-(char *)gself)));
    fprintf(stderr,"webkit self priv is %p\n",(void *)priv);
    fprintf(stderr,"webkit self priv html_string is %p\n",(void *)&(priv->html_string));
    fprintf(stderr,"webkit self priv html_string offset %llx\n",((char *)&(priv->html_string)-(char *)priv));

    gnc_html_show_data( GNC_HTML(gself), data, datalen );

    Py_INCREF(Py_None);
    return Py_None;
}
示例#3
0
GtkWidget *
gnc_html_get_widget( GncHtml* self )
{
    g_return_val_if_fail( self != NULL, NULL );
    g_return_val_if_fail( GNC_IS_HTML(self), NULL );

    return GNC_HTML_GET_PRIVATE(self)->container;
}
示例#4
0
gnc_html_history *
gnc_html_get_history( GncHtml* self )
{
    g_return_val_if_fail( self != NULL, NULL );
    g_return_val_if_fail( GNC_IS_HTML(self), NULL );

    return GNC_HTML_GET_PRIVATE(self)->history;
}
示例#5
0
void
gnc_html_set_urltype_cb( GncHtml* self, GncHTMLUrltypeCB urltype_cb )
{
    GncHtmlPrivate* priv;

    g_return_if_fail( self != NULL );
    g_return_if_fail( GNC_IS_HTML(self) );

    priv = GNC_HTML_GET_PRIVATE(self);
    priv->urltype_cb = urltype_cb;
}
示例#6
0
void
gnc_html_set_button_cb( GncHtml* self, GncHTMLButtonCB button_cb, gpointer data )
{
    GncHtmlPrivate* priv;

    g_return_if_fail( self != NULL );
    g_return_if_fail( GNC_IS_HTML(self) );

    priv = GNC_HTML_GET_PRIVATE(self);
    priv->button_cb = button_cb;
    priv->button_cb_data = data;
}
示例#7
0
void
gnc_html_set_flyover_cb( GncHtml* self, GncHTMLFlyoverCB flyover_cb, gpointer data )
{
    GncHtmlPrivate* priv;

    g_return_if_fail( self != NULL );
    g_return_if_fail( GNC_IS_HTML(self) );

    priv = GNC_HTML_GET_PRIVATE(self);
    priv->flyover_cb = flyover_cb;
    priv->flyover_cb_data = data;
}
示例#8
0
void
gnc_html_set_load_cb( GncHtml* self, GncHTMLLoadCB load_cb, gpointer data )
{
    GncHtmlPrivate* priv;

    g_return_if_fail( self != NULL );
    g_return_if_fail( GNC_IS_HTML(self) );

    priv = GNC_HTML_GET_PRIVATE(self);
    priv->load_cb = load_cb;
    priv->load_cb_data = data;
}
示例#9
0
URLType
gnc_html_parse_url( GncHtml* self, const gchar* url,
                    gchar** url_location, gchar** url_label )
{
    gchar uri_rexp[] = "^(([^:][^:]+):)?([^#]+)?(#(.*))?$";
    regex_t compiled;
    regmatch_t match[6];
    gchar* protocol = NULL;
    gchar* path = NULL;
    gchar* label = NULL;
    gboolean found_protocol = FALSE;
    gboolean found_path = FALSE;
    gboolean found_label = FALSE;
    URLType retval;
    GncHtmlPrivate* priv = GNC_HTML_GET_PRIVATE(self);

    g_return_val_if_fail( self != NULL, NULL );
    g_return_val_if_fail( GNC_IS_HTML(self), NULL );

    DEBUG( "parsing %s, base_location %s",
           url ? url : "(null)",
           self ? (priv->base_location ? priv->base_location
                   : "(null base_location)")
               : "(null html)");

    regcomp( &compiled, uri_rexp, REG_EXTENDED );

    if ( !regexec( &compiled, url, 6, match, 0 ) )
    {
        if ( match[2].rm_so != -1 )
        {
            protocol = g_new0( gchar, match[2].rm_eo - match[2].rm_so + 1 );
            strncpy( protocol, url + match[2].rm_so, match[2].rm_eo - match[2].rm_so );
            protocol[match[2].rm_eo - match[2].rm_so] = 0;
            found_protocol = TRUE;
        }
        if ( match[3].rm_so != -1 )
        {
            path = g_new0( gchar, match[3].rm_eo - match[3].rm_so + 1 );
            strncpy( path, url + match[3].rm_so, match[3].rm_eo - match[3].rm_so );
            path[match[3].rm_eo - match[3].rm_so] = 0;
            found_path = TRUE;
        }
        if ( match[5].rm_so != -1 )
        {
            label = g_new0( gchar, match[5].rm_eo - match[5].rm_so + 1 );
            strncpy( label, url + match[5].rm_so, match[5].rm_eo - match[5].rm_so );
            label[match[5].rm_eo - match[5].rm_so] = 0;
            found_label = TRUE;
        }
    }

    regfree( &compiled );

    if ( found_protocol )
    {
        retval = g_hash_table_lookup( gnc_html_proto_to_type_hash, protocol );
        if ( retval == NULL )
        {
            PWARN( "unhandled URL type for '%s'", url ? url : "(null)" );
            retval = URL_TYPE_OTHER;
        }
    }
    else if ( found_label && !found_path )
    {
        retval = URL_TYPE_JUMP;
    }
    else
    {
        if ( self )
        {
            retval = priv->base_type;
        }
        else
        {
            retval = URL_TYPE_FILE;
        }
    }

    g_free( protocol );

    if ( !safe_strcmp( retval, URL_TYPE_FILE ) )
    {
        if ( !found_protocol && path && self && priv->base_location )
        {
            if ( g_path_is_absolute( path ) )
            {
                *url_location = g_strdup( path );
            }
            else
            {
                *url_location = g_build_filename( priv->base_location, path, (gchar*)NULL );
            }
            g_free( path );
        }
        else
        {
            *url_location = g_strdup( path );
            g_free( path );
        }

    }
    else if ( !safe_strcmp( retval, URL_TYPE_JUMP ) )
    {
        *url_location = NULL;
        g_free( path );

    }
    else
    {
        /* case URL_TYPE_OTHER: */

        if ( !found_protocol && path && self && priv->base_location )
        {
            if ( g_path_is_absolute( path ) )
            {
                *url_location = g_build_filename( extract_machine_name( priv->base_location ),
                                                  path, (gchar*)NULL );
            }
            else
            {
                *url_location = g_build_filename( priv->base_location, path, (gchar*)NULL );
            }
            g_free( path );
        }
        else
        {
            *url_location = g_strdup( path );
            g_free( path );
        }
    }

    *url_label = label;
    return retval;
}