summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrootavish <[email protected]>2014-07-25 18:32:19 +0530
committerrootavish <[email protected]>2014-07-25 18:32:19 +0530
commitd4ea4f2056a2863c7a37ad83e73bb63301de5022 (patch)
tree11932da4f199c7e49572a106f25a1aa892806d95
parentdf1fce63dca7bd7ac85c720a357adba0f1b7108a (diff)
downloadatril-d4ea4f2056a2863c7a37ad83e73bb63301de5022.tar.bz2
atril-d4ea4f2056a2863c7a37ad83e73bb63301de5022.tar.xz
Fixing dispose functions, display in webview
Fixed the backend epub_document_finalize function which was caused caja to crash when you opened the document properties dialog. Fixed the ev_window_dispose and the webview's dispose and finalise functions, now the window closes without any glib-critical errors. Also now it is possible to read epub documents, once you have changed pages at least once, I still have to figure out where I call load_uri at document load.
-rw-r--r--backend/epub/epub-document.c5
-rw-r--r--libview/ev-web-view.c35
-rw-r--r--shell/ev-window.c8
3 files changed, 27 insertions, 21 deletions
diff --git a/backend/epub/epub-document.c b/backend/epub/epub-document.c
index 0801c3ab..a107b710 100644
--- a/backend/epub/epub-document.c
+++ b/backend/epub/epub-document.c
@@ -949,20 +949,23 @@ epub_document_finalize (GObject *object)
if (epub_remove_temporary_dir (epub_document->tmp_archive_dir) == -1)
g_warning (_("There was an error deleting ā€œ%sā€."),
epub_document->tmp_archive_dir);
- g_free (epub_document->tmp_archive_dir);
}
if ( epub_document->contentList ) {
g_list_free_full(epub_document->contentList,(GDestroyNotify)free_tree_nodes);
+ epub_document->contentList = NULL;
}
if ( epub_document->tmp_archive_dir) {
g_free (epub_document->tmp_archive_dir);
+ epub_document->tmp_archive_dir = NULL;
}
if ( epub_document->archivename) {
g_free (epub_document->archivename);
+ epub_document->archivename = NULL;
}
if ( epub_document->documentdir) {
g_free (epub_document->documentdir);
+ epub_document->documentdir = NULL;
}
G_OBJECT_CLASS (epub_document_parent_class)->finalize (object);
}
diff --git a/libview/ev-web-view.c b/libview/ev-web-view.c
index aa31751d..b28befd7 100644
--- a/libview/ev-web-view.c
+++ b/libview/ev-web-view.c
@@ -48,7 +48,6 @@ struct _EvWebViewClass
{
WebKitWebViewClass base_class;
};
-G_DEFINE_TYPE (EvWebView, ev_web_view, WEBKIT_TYPE_WEB_VIEW)
/*** Callbacks ***/
static void ev_web_view_change_page (EvWebView *webview,
@@ -59,15 +58,13 @@ static void ev_web_view_page_changed_cb (EvDocumentModel
gint new_page,
EvWebView *webview);
/*** GObject ***/
+static void ev_web_view_dispose (GObject *object);
-#if GTK_CHECK_VERSION (3, 0, 0)
-static void ev_view_dispose (GObject *object);
-#else
-static void ev_web_view_destroy (GtkObject *object);
-#endif
+static void ev_web_view_finalize (GObject *object);
static void ev_web_view_class_init (EvWebViewClass *klass);
static void ev_web_view_init (EvWebView *webview);
+G_DEFINE_TYPE (EvWebView, ev_web_view, WEBKIT_TYPE_WEB_VIEW)
static void
web_view_update_range_and_current_page (EvWebView *webview)
{
@@ -83,11 +80,7 @@ web_view_update_range_and_current_page (EvWebView *webview)
}
static void
-#if GTK_CHECK_VERSION (3, 0, 0)
ev_web_view_dispose (GObject *object)
-#else
-ev_web_view_destroy (GtkObject *object)
-#endif
{
EvWebView *webview = EV_WEB_VIEW (object);
@@ -101,25 +94,23 @@ ev_web_view_destroy (GtkObject *object)
webview->model = NULL;
};
-#if GTK_CHECK_VERSION (3, 0, 0)
+
G_OBJECT_CLASS (ev_web_view_parent_class)->dispose (object);
-#else
- GTK_OBJECT_CLASS (ev_web_view_parent_class)->destroy (object);
-#endif
}
static void
ev_web_view_class_init (EvWebViewClass *klass)
{
+ G_OBJECT_CLASS(klass)->finalize = ev_web_view_finalize;
+ G_OBJECT_CLASS(klass)->dispose = ev_web_view_dispose;
}
static void
ev_web_view_init (EvWebView *webview)
{
gtk_widget_set_can_focus (GTK_WIDGET (webview), TRUE);
-#if GTK_CHECK_VERSION (3, 0, 0)
+
gtk_widget_set_has_window (GTK_WIDGET (webview), TRUE);
-#endif
webview->current_page = 0;
@@ -127,6 +118,12 @@ ev_web_view_init (EvWebView *webview)
}
+static void
+ev_web_view_finalize (GObject *object)
+{
+ G_OBJECT_CLASS(ev_web_view_parent_class)->finalize(object);
+}
+
/*** Callbacks ***/
static void
@@ -140,6 +137,7 @@ ev_web_view_change_page (EvWebView *webview,
webkit_web_view_load_uri(WEBKIT_WEB_VIEW(webview),(gchar*)page->backend_page);
webview->current_page = new_page;
+ ev_document_model_set_page(webview->model,new_page);
}
static void
@@ -249,6 +247,7 @@ ev_web_view_set_model (EvWebView *webview,
/* Initialize webview from model */
webview->fullscreen = ev_document_model_get_fullscreen (webview->model);
+ webview->document = ev_document_model_get_document(webview->model);
webview->inverted_colors = ev_document_model_get_inverted_colors(webview->model);
ev_web_view_document_changed_cb (webview->model, NULL, webview);
@@ -265,7 +264,7 @@ ev_web_view_set_model (EvWebView *webview,
void
ev_web_view_reload_page (EvWebView *webview,
- gint page)
+ gint page)
{
webkit_web_view_reload (WEBKIT_WEB_VIEW(webview));
}
@@ -370,10 +369,12 @@ gboolean
ev_web_view_zoom_in(EvWebView *webview)
{
webkit_web_view_zoom_in(WEBKIT_WEB_VIEW(webview));
+ return TRUE;
}
gboolean
ev_web_view_zoom_out(EvWebView *webview)
{
webkit_web_view_zoom_out(WEBKIT_WEB_VIEW(webview));
+ return TRUE;
} \ No newline at end of file
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 9b9a417d..89b64307 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -1487,6 +1487,7 @@ ev_window_set_document (EvWindow *ev_window, EvDocument *document)
gtk_container_remove (GTK_CONTAINER(ev_window->priv->scrolled_window),
ev_window->priv->view);
g_object_unref(ev_window->priv->view);
+ ev_window->priv->view = NULL;
gtk_container_add (GTK_CONTAINER (ev_window->priv->scrolled_window),
ev_window->priv->webview);
gtk_widget_show(ev_window->priv->webview);
@@ -5422,12 +5423,12 @@ ev_window_dispose (GObject *object)
priv->view = NULL;
}
-#ifdef ENABLE_EPUB
+/*#ifdef ENABLE_EPUB
if ( priv->webview ) {
- g_object_unref (priv->webview);
+ g_object_unref (EV_WEB_VIEW(priv->webview));
priv->webview = NULL ;
}
-#endif
+#endif*/
if (priv->password_view) {
g_object_unref (priv->password_view);
priv->password_view = NULL;
@@ -7181,6 +7182,7 @@ ev_window_init (EvWindow *ev_window)
#ifdef ENABLE_EPUB
ev_window->priv->webview = ev_web_view_new();
+ ev_web_view_set_model(EV_WEB_VIEW(ev_window->priv->webview),ev_window->priv->model);
#endif
ev_view_set_page_cache_size (EV_VIEW (ev_window->priv->view), PAGE_CACHE_SIZE);
ev_view_set_model (EV_VIEW (ev_window->priv->view), ev_window->priv->model);