2011-10-25 [colin] 3.7.10cvs52
authorColin Leroy <colin@colino.net>
Tue, 25 Oct 2011 19:28:04 +0000 (19:28 +0000)
committerColin Leroy <colin@colino.net>
Tue, 25 Oct 2011 19:28:04 +0000 (19:28 +0000)
* src/gtk/gtkcmclist.c
* src/gtk/gtkcmctree.c
Fix focus things.

ChangeLog
PATCHSETS
configure.ac
src/gtk/gtkcmclist.c
src/gtk/gtkcmctree.c

index f40753d..cc233e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-10-25 [colin]     3.7.10cvs52
+
+       * src/gtk/gtkcmclist.c
+       * src/gtk/gtkcmctree.c
+               Fix focus things.
+
 2011-10-25 [colin]     3.7.10cvs51
 
        * src/stock_pixmap.c
index 30fb5ef..296269a 100644 (file)
--- a/PATCHSETS
+++ b/PATCHSETS
 ( cvs diff -u -r 1.2.2.35 -r 1.2.2.36 src/gtk/colorlabel.c;  cvs diff -u -r 1.1.2.20 -r 1.1.2.21 src/gtk/gtkcmclist.c;  ) > 3.7.10cvs49.patchset
 ( cvs diff -u -r 1.382.2.587 -r 1.382.2.588 src/compose.c;  cvs diff -u -r 1.94.2.220 -r 1.94.2.221 src/messageview.c;  cvs diff -u -r 1.150.2.118 -r 1.150.2.119 src/procmsg.c;  cvs diff -u -r 1.60.2.56 -r 1.60.2.57 src/procmsg.h;  ) > 3.7.10cvs50.patchset
 ( cvs diff -u -r 1.25.2.71 -r 1.25.2.72 src/stock_pixmap.c;  ) > 3.7.10cvs51.patchset
+( cvs diff -u -r 1.1.2.21 -r 1.1.2.22 src/gtk/gtkcmclist.c;  cvs diff -u -r 1.1.2.22 -r 1.1.2.23 src/gtk/gtkcmctree.c;  ) > 3.7.10cvs52.patchset
index 6331ea4..3b7d266 100644 (file)
@@ -12,7 +12,7 @@ MINOR_VERSION=7
 MICRO_VERSION=10
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=51
+EXTRA_VERSION=52
 EXTRA_RELEASE=
 EXTRA_GTK2_VERSION=
 
index 060e66b..69df1dc 100644 (file)
@@ -5861,16 +5861,16 @@ draw_row (GtkCMCList     *clist,
       gtk_widget_get_can_focus (widget) && gtk_widget_has_focus(widget))
     {
       if (!area) {
-       cairo_rectangle(cr, row_rectangle.x + 1, row_rectangle.y,
-                           row_rectangle.width - 1, row_rectangle.height);
+       cairo_rectangle(cr, row_rectangle.x, row_rectangle.y,
+                           row_rectangle.width + 1, row_rectangle.height);
        gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
        cairo_stroke(cr);
       }
       else if (gdk_rectangle_intersect (area, &row_rectangle,
                                        &intersect_rectangle))
        {
-         cairo_rectangle(cr, row_rectangle.x + 1, row_rectangle.y,
-                           row_rectangle.width - 1, row_rectangle.height);
+         cairo_rectangle(cr, row_rectangle.x, row_rectangle.y,
+                           row_rectangle.width + 1, row_rectangle.height);
          gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
          cairo_stroke(cr);
        }
@@ -5929,11 +5929,19 @@ draw_rows (GtkCMCList     *clist,
 
   if (!area) {
     int w, h, y;
-    gdk_drawable_get_size (GDK_DRAWABLE (clist->clist_window), &w, &h);
+    cairo_t *cr;
+#if GTK_CHECK_VERSION(2,24,0)
+    w = gdk_window_get_width(clist->clist_window);
+    h = gdk_window_get_height(clist->clist_window);
+#else
+    gdk_drawable_get_size(clist->clist_window, &w, &h);
+#endif
+    cr = gdk_cairo_create(clist->clist_window);
     y = ROW_TOP_YPIXEL (clist, i);
-    gdk_window_clear_area (clist->clist_window,
-                           0, y,
-                           w, h - y);
+    gdk_cairo_set_source_color(cr, &gtk_widget_get_style(GTK_WIDGET(clist))->base[GTK_STATE_NORMAL]);
+    cairo_rectangle(cr, 0, y, w, h - y);
+    cairo_fill(cr);
+    cairo_destroy(cr);
   }
 }
 
@@ -6239,18 +6247,19 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
   if (gtk_widget_is_drawable (GTK_WIDGET(clist)))
     {
       GtkWidget *focus_child = gtk_container_get_focus_child (container);
+      gdk_window_scroll (clist->clist_window, dx, 0);
+      gdk_window_process_updates (clist->clist_window, FALSE);
+
       if (gtk_widget_get_can_focus(GTK_WIDGET(clist)) && 
           gtk_widget_has_focus(GTK_WIDGET(clist)) &&
           !focus_child && GTK_CMCLIST_ADD_MODE(clist))
         {
           y = ROW_TOP_YPIXEL (clist, clist->focus_row);
-         cairo_rectangle(cr, 0, y, clist->clist_window_width - 1,
-                              clist->row_height - 1);
+         cairo_rectangle(cr, 0, y, clist->clist_window_width + 1,
+                              clist->row_height);
          cairo_stroke(cr);
         }
-      gdk_window_scroll (clist->clist_window, dx, 0);
-      gdk_window_process_updates (clist->clist_window, FALSE);
 
       if (gtk_widget_get_can_focus(GTK_WIDGET(clist)) && 
           gtk_widget_has_focus(GTK_WIDGET(clist)) &&
@@ -6265,35 +6274,11 @@ hadjustment_value_changed (GtkAdjustment *adjustment,
               draw_rows (clist, &area);
               clist->focus_row = focus_row;
          
-             cairo_rectangle(cr, 0, y, clist->clist_window_width - 1,
-                              clist->row_height - 1);
+             cairo_rectangle(cr, 0, y, clist->clist_window_width + 1,
+                              clist->row_height);
              cairo_stroke(cr);
               return;
             }
-          else if (ABS(dx) < clist->clist_window_width - 1)
-            {
-              gint x0;
-              gint x1;
-         
-              if (dx > 0)
-                {
-                  x0 = clist->clist_window_width - 1;
-                  x1 = dx;
-                }
-              else
-                {
-                  x0 = 0;
-                  x1 = clist->clist_window_width - 1 + dx;
-                }
-
-              y = ROW_TOP_YPIXEL (clist, clist->focus_row);
-             cairo_move_to(cr, x0, y + 1);
-             cairo_line_to(cr, x0, y + clist->row_height - 2);
-             cairo_stroke(cr);
-             cairo_move_to(cr, x1, y + 1);
-             cairo_line_to(cr, x1, y + clist->row_height - 2);
-             cairo_stroke(cr);
-            }
         }
     }
     cairo_destroy(cr);
@@ -6556,8 +6541,8 @@ gtk_cmclist_draw_focus (GtkWidget *widget)
     cairo_dash_from_add_mode(clist, cr);
     cairo_set_line_width(cr, 1.0);
     cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
-    cairo_rectangle(cr, 1, ROW_TOP_YPIXEL(clist, clist->focus_row),
-                       clist->clist_window_width - 1,
+    cairo_rectangle(cr, 0, ROW_TOP_YPIXEL(clist, clist->focus_row),
+                       clist->clist_window_width + 1,
                        clist->row_height);
     cairo_stroke(cr);
     cairo_destroy(cr);
@@ -6568,17 +6553,32 @@ static void
 gtk_cmclist_undraw_focus (GtkWidget *widget)
 {
   GtkCMCList *clist;
-
+  int row;
   cm_return_if_fail (GTK_IS_CMCLIST (widget));
 
+  clist = GTK_CMCLIST(widget);
+
+  if (clist->focus_row < 0)
+    return;
+
   if (!gtk_widget_is_drawable (widget) || !gtk_widget_get_can_focus (widget))
     return;
 
   clist = GTK_CMCLIST (widget);
   if (clist->focus_row >= 0) {
-    GTK_CMCLIST_GET_CLASS(clist)->draw_row(clist, NULL, clist->focus_row, 
-       ROW_ELEMENT (clist, clist->focus_row)->data);
+    cairo_t *cr = gdk_cairo_create(clist->clist_window);
+    cairo_set_line_width(cr, 1.0);
+    gdk_cairo_set_source_color(cr, &gtk_widget_get_style(widget)->base[GTK_STATE_NORMAL]);
+    cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+    cairo_rectangle(cr, 0, ROW_TOP_YPIXEL(clist, clist->focus_row),
+                       clist->clist_window_width + 1,
+                       clist->row_height);
+    cairo_stroke(cr);
+    cairo_destroy(cr);
   }
+
+  row = clist->focus_row;
+  GTK_CMCLIST_GET_CLASS(GTK_CMCLIST(widget))->draw_row(clist, NULL, row, ROW_ELEMENT (clist, row)->data);
 }
 
 static gint
index 8c7a475..21aebc4 100644 (file)
@@ -638,7 +638,7 @@ draw_row (GtkCMCList     *clist,
   static GdkColor greybg={0, 0, 0, 0};
   static gboolean color_change = TRUE;
   cairo_t *cr;
-  GdkColor *fgcolor, *bgcolor, *focuscolor;
+  GdkColor *fgcolor, *bgcolor;
 
   cm_return_if_fail (clist != NULL);
   widget = GTK_WIDGET (clist);
@@ -700,10 +700,8 @@ draw_row (GtkCMCList     *clist,
   if (prefs_common.use_stripes_everywhere && GTK_SCTREE(ctree)->show_stripes
       && color_change && row % 2) {
     bgcolor = &greybg;
-    focuscolor = &greybg;
   } else {
     bgcolor = &style->base[GTK_STATE_NORMAL];
-    focuscolor = &style->base[GTK_STATE_NORMAL];
   }
   state = clist_row->state;
 
@@ -716,7 +714,7 @@ draw_row (GtkCMCList     *clist,
       crect = &intersect_rectangle;
 
       if (gdk_rectangle_intersect (area, &cell_rectangle, crect)) {
-        gdk_cairo_rectangle(cr, crect);
+        gdk_cairo_rectangle(cr, &cell_rectangle);
        gdk_cairo_set_source_color(cr, &style->base[GTK_STATE_NORMAL]);
        cairo_fill(cr);
       }
@@ -726,7 +724,7 @@ draw_row (GtkCMCList     *clist,
       rect = &clip_rectangle;
       crect = &cell_rectangle;
 
-      gdk_cairo_rectangle(cr, crect);
+      gdk_cairo_rectangle(cr, &cell_rectangle);
       gdk_cairo_set_source_color(cr, &style->base[GTK_STATE_NORMAL]);
       cairo_fill(cr);
     }
@@ -780,12 +778,6 @@ draw_row (GtkCMCList     *clist,
       pixbuf_width = 0;
       height = 0;
 
-          gdk_cairo_rectangle(cr, &cell_rectangle);
-         if (state == GTK_STATE_NORMAL)
-               gdk_cairo_set_source_color(cr, bgcolor);
-         else
-               gdk_cairo_set_source_color(cr, &style->base[state]);
-         cairo_fill(cr);
       if (area && !gdk_rectangle_intersect (area, &cell_rectangle,
                                            &intersect_rectangle))
        {
@@ -794,6 +786,13 @@ draw_row (GtkCMCList     *clist,
        }
       else
        {
+         gdk_cairo_rectangle(cr, &cell_rectangle);
+         if (state == GTK_STATE_NORMAL)
+               gdk_cairo_set_source_color(cr, bgcolor);
+         else
+               gdk_cairo_set_source_color(cr, &style->base[state]);
+         cairo_fill(cr);
+
          layout = create_cell_layout (clist, clist_row, i);
          if (layout)
            {
@@ -954,6 +953,22 @@ draw_row (GtkCMCList     *clist,
           g_object_unref (G_OBJECT (layout));
        }
     }
+   /* draw focus rectangle */
+  if (clist->focus_row == row &&
+      gtk_widget_get_can_focus (widget) && gtk_widget_has_focus (widget))
+    {
+      if (!area || gdk_rectangle_intersect (area, &row_rectangle,
+                                       &intersect_rectangle))
+       {
+           cairo_set_line_width(cr, 1.0);
+           cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+           gdk_cairo_set_source_color(cr, &style->fg[GTK_STATE_NORMAL]);
+           cairo_rectangle(cr, row_rectangle.x, row_rectangle.y,
+                             row_rectangle.width + 1,
+                             row_rectangle.height);
+           cairo_stroke(cr);
+       }
+     }
     cairo_destroy(cr);
 }