]> www.fi.muni.cz Git - evince.git/commitdiff
Fix for the bug #325067 with more intelligent selection of current link in
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Wed, 28 Dec 2005 13:37:40 +0000 (13:37 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Wed, 28 Dec 2005 13:37:40 +0000 (13:37 +0000)
* backend/ev-link.c: (ev_link_get_page), (ev_link_init):
* shell/ev-page-action.c: (build_new_tree_cb):
* shell/ev-sidebar-links.c: (links_page_num_func),
(update_page_callback_foreach), (update_page_callback):
* shell/ev-view.c: (scroll_to_current_page):

Fix for the bug #325067 with more intelligent selection
of current link in sidebar. Make sidebar handle links
of FITR-like type more correctly.

* dvi/pixbuf-device.c: (dvi_pixbuf_draw_rule),
(dvi_pixbuf_put_pixel):

Fix memory consumtion with disabled alpha channel.

ChangeLog
backend/ev-link.c
dvi/pixbuf-device.c
shell/ev-page-action.c
shell/ev-sidebar-links.c
shell/ev-view.c

index 44f695d141d64c52c85b6cbd4478b262b1ecaa79..051e3a01ab676559ecf04fae095aaae9f60f0ac1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2005-12-28  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
+
+       * backend/ev-link.c: (ev_link_get_page), (ev_link_init):
+       * shell/ev-page-action.c: (build_new_tree_cb):
+       * shell/ev-sidebar-links.c: (links_page_num_func),
+       (update_page_callback_foreach), (update_page_callback):
+       * shell/ev-view.c: (scroll_to_current_page):
+       
+       Fix for the bug #325067 with more intelligent selection
+       of current link in sidebar. Make sidebar handle links
+       of FITR-like type more correctly.
+
+       * dvi/pixbuf-device.c: (dvi_pixbuf_draw_rule),
+       (dvi_pixbuf_put_pixel):
+       
+       Fix memory consumtion with disabled alpha channel.
+
 2005-12-28  Nickolay V. Shmyrev  <nshmyrev@yandex.ru>
 
        * data/evince-ui.xml:
index b8721d9b5841c349a7d7cf56d234e2d5dae4de85..a325c3525788badbe1921341668a8996e2921f89 100644 (file)
@@ -120,7 +120,7 @@ ev_link_get_link_type (EvLink *self)
 int
 ev_link_get_page (EvLink *self)
 {
-       g_return_val_if_fail (EV_IS_LINK (self), 0);
+       g_return_val_if_fail (EV_IS_LINK (self), -1);
        
        return self->priv->page;
 }
@@ -316,7 +316,7 @@ static void
 ev_link_init (EvLink *ev_link)
 {
        ev_link->priv = EV_LINK_GET_PRIVATE (ev_link);
-
+       ev_link->priv->page = -1;
        ev_link->priv->type = EV_LINK_TYPE_TITLE;
 }
 
index 1a81c0119a253e47b1ec75854e75a610fc1975cc..1ef436587812c3728d005dff8445f98235d78642 100644 (file)
@@ -70,25 +70,22 @@ static void dvi_pixbuf_draw_rule(DviContext *dvi, int x, int y, Uint w, Uint h,
            return;
        
        rowstride = gdk_pixbuf_get_rowstride (c_device->pixbuf);
-       p = gdk_pixbuf_get_pixels (c_device->pixbuf) + rowstride * y + 4 * x;
+       p = gdk_pixbuf_get_pixels (c_device->pixbuf) + rowstride * y + 3 * x;
 
        for (i = 0; i < h; i++) {
            if (i == 0 || i == h - 1 || fill) {
                  for (j = 0; j < w; j++) {
-                       p[j * 4] = red;
-                       p[j * 4 + 1] = green;
-                       p[j * 4 + 2] = blue;
-                       p[j * 4 + 3] = 0xff;
+                       p[j * 3] = red;
+                       p[j * 3 + 1] = green;
+                       p[j * 3 + 2] = blue;
                  }
            } else {
                p[0] = red;
                p[1] = green;
                p[2] = blue;
-               p[3] = 0xff;
-               p[(w - 1) * 4] = red;
-               p[(w - 1) * 4 + 1] = green;
-               p[(w - 1) * 4 + 2] = blue;
-               p[(w - 1) * 4 + 3] = 0xff;
+               p[(w - 1) * 3] = red;
+               p[(w - 1) * 3 + 1] = green;
+               p[(w - 1) * 3 + 2] = blue;
            }
            p += rowstride;
       }
@@ -142,12 +139,11 @@ static void dvi_pixbuf_put_pixel(void *image, int x, int y, Ulong color)
 {
     guchar *p;
     
-    p = gdk_pixbuf_get_pixels (GDK_PIXBUF(image)) + y * gdk_pixbuf_get_rowstride(GDK_PIXBUF(image)) + x * 4;
+    p = gdk_pixbuf_get_pixels (GDK_PIXBUF(image)) + y * gdk_pixbuf_get_rowstride(GDK_PIXBUF(image)) + x * 3;
 
     p[0] = (color >> 16) & 0xff;
     p[1] = (color >> 8) & 0xff;
     p[2] = color & 0xff;
-    p[3] = (color >> 24) & 0xff;
 }
 
 static void dvi_pixbuf_set_color(void *device_data, Ulong fg, Ulong bg)
index 73152b4e2240576a9fd85a34e48f0432a5e5a84e..fc81cb709932f516a2f4d0fd82a4f2559da18653 100644 (file)
@@ -298,7 +298,7 @@ build_new_tree_cb (GtkTreeModel *model,
                            EV_DOCUMENT_LINKS_COLUMN_LINK, &link,
                            -1);
 
-       if (link && ev_link_get_link_type (link) == EV_LINK_TYPE_PAGE) {
+       if (link && ev_link_get_page (link) >= 0) {
                GtkTreeIter filter_iter;
 
                gtk_list_store_append (GTK_LIST_STORE (filter_model), &filter_iter);
index 4107063ad2310fd8049df3a1bb0adc0931f3ca32..60d4134796514341968c22c234e8142b3a6f0528 100644 (file)
@@ -446,7 +446,7 @@ links_page_num_func (GtkTreeViewColumn *tree_column,
                            -1);
        
        if (link != NULL &&
-           ev_link_get_link_type (link) == EV_LINK_TYPE_PAGE) {
+           ev_link_get_page (link) >= 0) {
                gchar *page_label;
                gchar *page_string;
 
@@ -495,7 +495,7 @@ update_page_callback_foreach (GtkTreeModel *model,
                            EV_DOCUMENT_LINKS_COLUMN_LINK, &link,
                            -1);
 
-       if (link && ev_link_get_link_type (link) == EV_LINK_TYPE_PAGE) {
+       if (link) {
                int current_page;
 
                current_page = ev_page_cache_get_current_page (sidebar_links->priv->page_cache);
@@ -503,17 +503,14 @@ update_page_callback_foreach (GtkTreeModel *model,
                        GtkTreeSelection *selection;
 
                        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sidebar_links->priv->tree_view));
-
                        gtk_tree_selection_select_path (selection, path);
-       
                        g_object_unref (link);
+                       
                        return TRUE;
                }
+               g_object_unref (link);
        }
 
-       if (link)
-               g_object_unref (link);
-       
        return FALSE;
 }
 
@@ -523,19 +520,37 @@ update_page_callback (EvPageCache    *page_cache,
                      EvSidebarLinks *sidebar_links)
 {
        GtkTreeSelection *selection;
+       GtkTreeModel *model;
+       GtkTreeIter iter;
+       
+       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sidebar_links->priv->tree_view));
+
+       if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
+               EvLink *link;
+
+               gtk_tree_model_get (model, &iter,
+                                   EV_DOCUMENT_LINKS_COLUMN_LINK, &link,
+                                   -1);
+               if (link) {
+                       gint current_page;              
+                       current_page = ev_page_cache_get_current_page (sidebar_links->priv->page_cache);
+                       if (ev_link_get_page (link) == current_page) {
+                               g_object_unref (link);
+                               return;
+                       }
+                       g_object_unref (link);
+               }
+       }               
+
        /* We go through the tree linearly looking for the first page that
         * matches.  This is pretty inefficient.  We can do something neat with
         * a GtkTreeModelSort here to make it faster, if it turns out to be
         * slow.
         */
-
-       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (sidebar_links->priv->tree_view));
-
        g_signal_handler_block (selection, sidebar_links->priv->selection_id);
        g_signal_handler_block (sidebar_links->priv->tree_view, sidebar_links->priv->row_activated_id);
 
-       gtk_tree_selection_unselect_all (selection);
-       gtk_tree_model_foreach (sidebar_links->priv->model,
+       gtk_tree_model_foreach (model,
                                update_page_callback_foreach,
                                sidebar_links);
 
index b1e9733648c3a6376dd0ef5628399687a451986c..f0a371cd605c027d32a0aa376c08881c2d776bca 100644 (file)
@@ -329,7 +329,7 @@ scroll_to_current_page (EvView *view, GtkOrientation orientation)
        if (orientation == GTK_ORIENTATION_VERTICAL) {
                if (view->continuous) {
                        gtk_adjustment_clamp_page (view->vadjustment,
-                                                  view_point.y - view->spacing,
+                                                  view_point.y - view->spacing / 2,
                                                   view_point.y + view->vadjustment->page_size);
                } else {
                        gtk_adjustment_set_value (view->vadjustment,