]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktextdisplay.c
filechooserbutton: Update the button/combo whenever the selection is changed programm...
[~andy/gtk] / gtk / gtktextdisplay.c
index 6911dae0ee089bedaa3400b006134559aa9f9494..24cc0ec6b4850970c08c3b46f341184232b7b328 100644 (file)
@@ -21,8 +21,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
  *
  * Original Tk license:
  *
@@ -122,6 +121,8 @@ struct _GtkTextRendererClass
   PangoRendererClass parent_class;
 };
 
+GType _gtk_text_renderer_get_type (void);
+
 G_DEFINE_TYPE (GtkTextRenderer, _gtk_text_renderer, PANGO_TYPE_RENDERER)
 
 static void
@@ -584,10 +585,9 @@ render_para (GtkTextRenderer    *text_renderer,
   screen_width = line_display->total_width;
 
   context = gtk_widget_get_style_context (text_renderer->widget);
+  state = gtk_widget_get_state_flags (text_renderer->widget);
 
-  state = GTK_STATE_FLAG_SELECTED;
-  if (gtk_widget_has_focus (text_renderer->widget))
-    state |= GTK_STATE_FLAG_FOCUSED;
+  state |= GTK_STATE_FLAG_SELECTED;
 
   gtk_style_context_get_background_color (context, state, &selection);
 
@@ -821,6 +821,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
                       cairo_t *cr,
                       GList **widgets)
 {
+  GtkStyleContext *context;
   gint offset_y;
   GtkTextRenderer *text_renderer;
   GtkTextIter selection_start, selection_end;
@@ -838,6 +839,8 @@ gtk_text_layout_draw (GtkTextLayout *layout,
   if (!gdk_cairo_get_clip_rectangle (cr, &clip))
     return;
 
+  context = gtk_widget_get_style_context (widget);
+
   line_list = gtk_text_layout_get_lines (layout, clip.y, clip.y + clip.height, &offset_y);
 
   if (line_list == NULL)
@@ -911,46 +914,17 @@ gtk_text_layout_draw (GtkTextLayout *layout,
               for (i = 0; i < line_display->cursors->len; i++)
                 {
                   int index;
-                  PangoRectangle strong_pos, weak_pos;
-                  GdkRectangle cursor_location;
+                  PangoDirection dir;
 
                   index = g_array_index(line_display->cursors, int, i);
-                  pango_layout_get_cursor_pos (line_display->layout, index, &strong_pos, &weak_pos);
-
-                  cursor_location.x = line_display->x_offset + PANGO_PIXELS (strong_pos.x);
-                  cursor_location.y = line_display->top_margin + PANGO_PIXELS (strong_pos.y);
-                  cursor_location.width = 0;
-                  cursor_location.height = PANGO_PIXELS (strong_pos.height);
-
-                  if (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
-                      line_display->direction == layout->cursor_direction)
-                    {
-                      gtk_draw_insertion_cursor (widget, cr,
-                                                 &cursor_location, TRUE, line_display->direction,
-                                                 layout->cursor_direction != GTK_TEXT_DIR_NONE);
-                    }
-
-                  if ((strong_pos.x != weak_pos.x || strong_pos.y != weak_pos.y) &&
-                      (layout->cursor_direction == GTK_TEXT_DIR_NONE ||
-                       line_display->direction != layout->cursor_direction))
-                    {
-                      GtkTextDirection dir;
-
-                      dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
-
-                      cursor_location.x = line_display->x_offset + PANGO_PIXELS (weak_pos.x);
-                      cursor_location.y = line_display->top_margin + PANGO_PIXELS (weak_pos.y);
-                      cursor_location.width = 0;
-                      cursor_location.height = PANGO_PIXELS (weak_pos.height);
-
-                      gtk_draw_insertion_cursor (widget, cr,
-                                                 &cursor_location, FALSE, dir,
-                                                 TRUE);
-                    }
+                  dir = (line_display->direction == GTK_TEXT_DIR_RTL) ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR;
+                  gtk_render_insertion_cursor (context, cr,
+                                               line_display->x_offset, line_display->top_margin,
+                                               line_display->layout, index, dir);
                 }
             }
         } /* line_display->height > 0 */
-          
+
       cairo_translate (cr, 0, line_display->height);
       gtk_text_layout_free_line_display (layout, line_display);
       
@@ -963,10 +937,7 @@ gtk_text_layout_draw (GtkTextLayout *layout,
   if (widgets)
     *widgets = tmp_widgets;
   else
-    {
-      g_list_foreach (tmp_widgets, (GFunc)g_object_unref, NULL);
-      g_list_free (tmp_widgets);
-    }
+    g_list_free_full (tmp_widgets, g_object_unref);
 
   g_slist_free (line_list);
 }