[gtk+extra] Patch for sigsegv in gtksheet

Roy Rankin rrankin at fedoraproject.org
Mon Feb 21 09:30:32 UTC 2011


commit fdef0074a9e5b76f6ad2ba702ce83e1f67c08f8d
Author: Roy Rankin <rrankin at ihug.com.au>
Date:   Mon Feb 21 20:29:49 2011 +1100

    Patch for sigsegv in gtksheet

 gtk+extra-2.1.2-gtkitementry.patch | 1002 ++++++++++++++++++++++++++++++++++++
 gtk+extra.spec                     |    7 +-
 2 files changed, 1008 insertions(+), 1 deletions(-)
---
diff --git a/gtk+extra-2.1.2-gtkitementry.patch b/gtk+extra-2.1.2-gtkitementry.patch
new file mode 100644
index 0000000..ed2a4d6
--- /dev/null
+++ b/gtk+extra-2.1.2-gtkitementry.patch
@@ -0,0 +1,1002 @@
+Index: gtkextra/gtkitementry.c
+===================================================================
+RCS file: /cvsroot/gtkextra/gtkextra-2/gtkextra/gtkitementry.c,v
+retrieving revision 1.8
+diff -U3 -r1.8 gtkitementry.c
+--- gtkextra/gtkitementry.c	12 Jun 2010 00:37:15 -0000	1.8
++++ gtkextra/gtkitementry.c	19 Feb 2011 06:51:36 -0000
+@@ -24,14 +24,37 @@
+  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
+  */
+ 
++/**
++ * SECTION: gtkitementry
++ * @short_description: An item entry widget.
++ *
++ * Originally GtkSheetEntry. This widget allows to change colors and justification and can be dinamically resized.
++ */
++
++/**
++ * GtkItemEntry:
++ *
++ * The GtkItemEntry struct contains only private data.
++ * It should only be accessed through the functions described below.
++ */
++
+ #include <string.h>
+ 
+ #include <pango/pango.h>
+ 
+ #include <gdk/gdkkeysyms.h>
+ #include <gtk/gtk.h>
++//#include "gtkextra-compat.h"
+ #include "gtkitementry.h"
+ 
++#if !GTK_CHECK_VERSION(2,20,0)
++#define gtk_widget_set_realized_true(widget)  \
++        GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED)
++#else
++#define gtk_widget_set_realized_true(widget)  gtk_widget_set_realized(widget, TRUE)
++#endif
++
++
+ #define MIN_ENTRY_WIDTH  150
+ #define DRAW_TIMEOUT     20
+ #define INNER_BORDER     0
+@@ -188,29 +211,17 @@
+ 
+ };
+ 
+-#define GTK_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_ENTRY, GtkEntryPrivate))
++#define GTK_ENTRY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), gtk_entry_get_type(), GtkEntryPrivate))
+ 
+ #endif
+ 
+-GtkType
++GType
+ gtk_item_entry_get_type (void)
+ {
+-  static GtkType item_entry_type = 0;
++  static GType item_entry_type = 0;
+ 
+   if (!item_entry_type)
+     {
+-      static const GtkTypeInfo item_entry_info =
+-      {
+-	"GtkItemEntry",
+-	sizeof (GtkItemEntry),
+-	sizeof (GtkItemEntryClass),
+-	(GtkClassInitFunc) gtk_item_entry_class_init,
+-	(GtkObjectInitFunc) gtk_item_entry_init,
+-	/* reserved_1 */ NULL,
+-	/* reserved_2 */ NULL,
+-        (GtkClassInitFunc) NULL,
+-      };
+-
+       static const GInterfaceInfo item_editable_info =
+       {
+         (GInterfaceInitFunc) gtk_item_entry_editable_init,    /* interface_init */
+@@ -219,10 +230,18 @@
+       };
+ 
+ 
+-      item_entry_type = gtk_type_unique (GTK_TYPE_ENTRY, &item_entry_info);
++      item_entry_type = g_type_register_static_simple (
++		gtk_entry_get_type(),
++		"GtkItemEntry",
++		sizeof (GtkItemEntryClass),
++		(GClassInitFunc) gtk_item_entry_class_init,
++		sizeof (GtkItemEntry),
++		(GInstanceInitFunc) gtk_item_entry_init,
++		0);
++		
+ 
+       g_type_add_interface_static (item_entry_type,
+-                                   GTK_TYPE_EDITABLE,
++                                   gtk_editable_get_type (),
+                                    &item_editable_info);
+ 
+     }
+@@ -239,7 +258,7 @@
+ 
+   object_class = (GtkObjectClass*) class;
+   widget_class = (GtkWidgetClass*) class;
+-  parent_class = gtk_type_class (GTK_TYPE_ENTRY);
++  parent_class = g_type_class_ref (gtk_entry_get_type());
+   entry_class = (GtkEntryClass *) class;
+ 
+   widget_class->realize = gtk_entry_realize;
+@@ -300,7 +319,8 @@
+   GdkWindowAttr attributes;
+   gint attributes_mask;
+ 
+-  GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
++  gtk_widget_set_realized_true(widget);
++
+   entry = GTK_ENTRY (widget);
+   editable = GTK_EDITABLE (widget);
+ 
+@@ -323,23 +343,30 @@
+                             GDK_LEAVE_NOTIFY_MASK);
+   attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ 
+-  widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+-  gdk_window_set_user_data (widget->window, entry);
++  gtk_widget_set_window(widget ,
++		gdk_window_new (gtk_widget_get_parent_window (widget), 
++				&attributes, attributes_mask));
++  gdk_window_set_user_data (gtk_widget_get_window(widget), entry);
+ 
+   get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
+ 
+   attributes.cursor = gdk_cursor_new (GDK_XTERM);
+   attributes_mask |= GDK_WA_CURSOR;
+ 
+-  entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask);
++  entry->text_area = gdk_window_new (gtk_widget_get_window(widget), 
++					&attributes, attributes_mask);
+   gdk_window_set_user_data (entry->text_area, entry);
+ 
+   gdk_cursor_unref (attributes.cursor);
+ 
+-  widget->style = gtk_style_attach (widget->style, widget->window);
+-
+-  gdk_window_set_background (widget->window, &widget->style->bg[GTK_WIDGET_STATE(widget)]);
+-  gdk_window_set_background (entry->text_area, &widget->style->bg[GTK_WIDGET_STATE (widget)]);
++  gtk_widget_set_style(widget, gtk_style_attach (
++				     gtk_widget_get_style(widget), 
++				     gtk_widget_get_window(widget)));
++
++  gdk_window_set_background (gtk_widget_get_window(widget), 
++	    &(gtk_widget_get_style(widget)->bg[gtk_widget_get_state(widget)]));
++  gdk_window_set_background (entry->text_area, 
++	    &(gtk_widget_get_style(widget)->bg[gtk_widget_get_state(widget)]));
+ 
+   gdk_window_show (entry->text_area);
+ 
+@@ -364,8 +391,8 @@
+ 
+   if (entry->has_frame)
+     {
+-      *xborder = widget->style->xthickness;
+-      *yborder = widget->style->ythickness;
++      *xborder = gtk_widget_get_style(widget)->xthickness;
++      *yborder = gtk_widget_get_style(widget)->ythickness;
+     }
+   else
+     {
+@@ -382,38 +409,37 @@
+ }
+ 
+ static void
+-gtk_entry_size_request (GtkWidget      *widget,
+-			GtkRequisition *requisition)
++    gtk_entry_size_request (GtkWidget *widget, GtkRequisition *requisition)
+ {
+-  GtkEntry *entry = GTK_ENTRY (widget);
+-  PangoFontMetrics *metrics;
+-  gint xborder, yborder;
+-  PangoContext *context;
+-  
+-  context = gtk_widget_get_pango_context (widget);
+-  metrics = pango_context_get_metrics (context,
+-				       widget->style->font_desc,
+-				       pango_context_get_language (context));
++    GtkEntry *entry = GTK_ENTRY (widget);
++    PangoFontMetrics *metrics;
++    gint xborder, yborder;
++    PangoContext *context;
+ 
+-  entry->ascent = pango_font_metrics_get_ascent (metrics);
+-  entry->descent = pango_font_metrics_get_descent (metrics);
++    context = gtk_widget_get_pango_context (widget);
++    metrics = pango_context_get_metrics (context,
++                                         gtk_widget_get_style(widget)->font_desc,
++                                         pango_context_get_language (context));
+ 
+-  get_borders (entry, &xborder, &yborder);
+-  
+-  xborder += INNER_BORDER;
+-  yborder += INNER_BORDER;
+-  
+-  if (entry->width_chars < 0)
+-    requisition->width = MIN_ENTRY_WIDTH + xborder * 2;
+-  else
++    entry->ascent = pango_font_metrics_get_ascent (metrics);
++    entry->descent = pango_font_metrics_get_descent (metrics);
++
++    get_borders (entry, &xborder, &yborder);
++
++    xborder += INNER_BORDER;
++    yborder += INNER_BORDER;
++
++    if (entry->width_chars < 0)
++        requisition->width = MIN_ENTRY_WIDTH + xborder * 2;
++    else
+     {
+-      gint char_width = pango_font_metrics_get_approximate_char_width (metrics);
+-      requisition->width = PANGO_PIXELS (char_width) * entry->width_chars + xborder * 2;
++        gint char_width = pango_font_metrics_get_approximate_char_width (metrics);
++        requisition->width = PANGO_PIXELS (char_width) * entry->width_chars + xborder * 2;
+     }
+-    
+-  requisition->height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2;
+ 
+-  pango_font_metrics_unref (metrics);
++    requisition->height = PANGO_PIXELS (entry->ascent + entry->descent) + yborder * 2;
++
++    pango_font_metrics_unref (metrics);
+ }
+ 
+ static void
+@@ -425,6 +451,8 @@
+ {
+   gint xborder, yborder;
+   GtkRequisition requisition;
++  GtkAllocation allocation;
++
+   GtkWidget *widget = GTK_WIDGET (entry);
+ 
+   gtk_widget_get_child_requisition (widget, &requisition);
+@@ -438,7 +466,10 @@
+     *y = yborder;
+   
+   if (width)
+-    *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;
++  {
++      gtk_widget_get_allocation(widget, &allocation);
++      *width = allocation.width - xborder * 2;
++  }
+ 
+   if (height)
+     *height = requisition.height - yborder * 2;
+@@ -452,28 +483,30 @@
+                         gint     *height)
+ {
+   GtkRequisition requisition;
++  GtkAllocation allocation;
+   GtkWidget *widget = GTK_WIDGET (entry);
+       
+   gtk_widget_get_child_requisition (widget, &requisition);
++  gtk_widget_get_allocation(widget, &allocation);
+ 
+   if (x)
+-    *x = widget->allocation.x;
++    *x = allocation.x;
+ 
+   if (y)
+     {
+       if (entry->is_cell_renderer)
+-	*y = widget->allocation.y;
++	*y = allocation.y;
+       else
+-	*y = widget->allocation.y + (widget->allocation.height - requisition.height) / 2;
++	*y = allocation.y + (allocation.height - requisition.height) / 2;
+     }
+ 
+   if (width)
+-    *width = widget->allocation.width;
++    *width = allocation.width;
+ 
+   if (height)
+     {
+       if (entry->is_cell_renderer)
+-	*height = widget->allocation.height;
++	*height = allocation.height;
+       else
+ 	*height = requisition.height;
+     }
+@@ -489,9 +522,9 @@
+   if(ientry->text_max_size > 0)
+     allocation->width = MIN(ientry->text_max_size, allocation->width);
+  
+-  widget->allocation = *allocation;
++  gtk_widget_set_allocation(widget, allocation);
+  
+-  if (GTK_WIDGET_REALIZED (widget))
++  if (gtk_widget_get_realized (widget))
+     {
+       /* We call gtk_widget_get_child_requisition, since we want (for
+        * backwards compatibility reasons) the realization here to
+@@ -501,8 +534,9 @@
+ 
+       get_widget_window_size (entry, &x, &y, &width, &height);
+      
+-      gdk_window_move_resize (widget->window,
+-                              allocation->x, allocation->y, allocation->width, allocation->height);   
++      gdk_window_move_resize (gtk_widget_get_window(widget),
++                              allocation->x, allocation->y, 
++				allocation->width, allocation->height);   
+ 
+       get_text_area_size (entry, &x, &y, &width, &height);
+       
+@@ -524,7 +558,7 @@
+ {
+   GtkEntry *entry = GTK_ENTRY (widget);
+ 
+-  if (widget->window == event->window)
++  if (gtk_widget_get_window(widget) == event->window)
+     gtk_entry_draw_frame (widget);
+   else if (entry->text_area == event->window)
+     {
+@@ -533,12 +567,12 @@
+       get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
+ 
+       gdk_draw_rectangle (entry->text_area,
+-                          widget->style->bg_gc[GTK_WIDGET_STATE(widget)],
+-                          TRUE,
+-                          0, 0, area_width, area_height);
++              gtk_widget_get_style(widget)->bg_gc[gtk_widget_get_state(widget)],
++              TRUE,
++              0, 0, area_width, area_height);
+ 
+       if ((entry->visible || entry->invisible_char != 0) &&
+-	  GTK_WIDGET_HAS_FOCUS (widget) &&
++	  gtk_widget_has_focus (GTK_WIDGET(widget)) &&
+ 	  entry->selection_bound == entry->current_pos && entry->cursor_visible)
+ 	gtk_entry_draw_cursor (GTK_ENTRY (widget), CURSOR_STANDARD);
+ 
+@@ -585,19 +619,21 @@
+ {
+   GtkEntry *entry = GTK_ENTRY (widget);
+   
+-  if (GTK_WIDGET_REALIZED (widget))
++  if (gtk_widget_get_realized (widget))
+     {
+-      gdk_window_set_background (widget->window, &widget->style->bg[GTK_WIDGET_STATE (widget)]);
+-      gdk_window_set_background (entry->text_area, &widget->style->bg[GTK_WIDGET_STATE (widget)]);
++      gdk_window_set_background (gtk_widget_get_window(widget), 
++	      &gtk_widget_get_style(widget)->bg[gtk_widget_get_state (widget)]);
++      gdk_window_set_background (entry->text_area, 
++	      &gtk_widget_get_style(widget)->bg[gtk_widget_get_state (widget)]);
+     }
+ 
+-  if (!GTK_WIDGET_IS_SENSITIVE (widget))
++  if (!gtk_widget_is_sensitive (widget))
+     {
+       /* Clear any selection */
+       gtk_editable_select_region (GTK_EDITABLE (entry), entry->current_pos, entry->current_pos);      
+     }
+   
+-  gtk_widget_queue_clear (widget);
++  gtk_widget_queue_draw (widget);
+ }
+ 
+ /* GtkEditable method implementations
+@@ -660,12 +696,14 @@
+ {
+   GtkEntry *entry = GTK_ENTRY (widget);
+ 
+-  if (previous_style && GTK_WIDGET_REALIZED (widget))
++  if (previous_style && gtk_widget_get_realized (widget))
+     {
+       gtk_entry_recompute (entry);
+ 
+-      gdk_window_set_background (widget->window, &widget->style->bg[GTK_WIDGET_STATE(widget)]);
+-      gdk_window_set_background (entry->text_area, &widget->style->bg[GTK_WIDGET_STATE (widget)]);
++      gdk_window_set_background (gtk_widget_get_window(widget), 
++	&gtk_widget_get_style(widget)->bg[gtk_widget_get_state(widget)]);
++      gdk_window_set_background (entry->text_area, 
++	&gtk_widget_get_style(widget)->bg[gtk_widget_get_state (widget)]);
+     }
+ }
+ 
+@@ -718,84 +756,96 @@
+  */
+ static void
+ gtk_entry_real_insert_text (GtkEditable *editable,
+-			    const gchar *new_text,
+-			    gint         new_text_length,
+-			    gint        *position)
++                            const gchar *new_text,
++                            gint         new_text_length,
++                            gint        *position)
+ {
+-  gint n_chars;
++    gint n_chars;
++    GtkEntry *entry = GTK_ENTRY (editable);
+ 
+-  GtkItemEntry *ientry = GTK_ITEM_ENTRY (editable);
+-  GtkEntry *entry = GTK_ENTRY (editable);
+ 
+-  if (new_text_length < 0)
+-    new_text_length = strlen (new_text);
++    if (new_text_length < 0)
++        new_text_length = strlen (new_text);
+ 
+-  n_chars = g_utf8_strlen (new_text, new_text_length);
+-  if (entry->text_max_length > 0 && n_chars + entry->text_length > entry->text_max_length)
++    n_chars = g_utf8_strlen (new_text, new_text_length);
++    if (entry->text_max_length > 0 && n_chars + entry->text_length > entry->text_max_length)
+     {
+-      gdk_beep ();
+-      n_chars = entry->text_max_length - entry->text_length;
+-      new_text_length = g_utf8_offset_to_pointer (new_text, n_chars) - new_text;
++        gdk_beep ();
++        n_chars = entry->text_max_length - entry->text_length;
++        new_text_length = g_utf8_offset_to_pointer (new_text, n_chars) - new_text;
+     }
+ 
+ #ifdef GTK_TYPE_ENTRY_BUFFER
+-   GtkEntryBuffer *buffer = get_buffer(entry);
+-   n_chars  = gtk_entry_buffer_insert_text(buffer, *position, new_text, new_text_length);
++
++    {
++        guint n_inserted;
++        GtkEntryBuffer *buffer = get_buffer(entry);
++
++        n_inserted  = gtk_entry_buffer_insert_text(buffer, *position, new_text, new_text_length);
++
++        if (n_inserted != n_chars)
++        {
++            gtk_widget_error_bell (GTK_WIDGET (editable));
++            n_chars = n_inserted;
++        }
++    }
++
+ #else
+ 
+-  if (new_text_length + ientry->item_n_bytes + 1 > ientry->item_text_size)
++    GtkItemEntry *ientry = GTK_ITEM_ENTRY (editable);
++    if (new_text_length + ientry->item_n_bytes + 1 > ientry->item_text_size)
+     {
+-      while (new_text_length + ientry->item_n_bytes + 1 > ientry->item_text_size)
+-	{
+-	  if (ientry->item_text_size == 0)
+-	    ientry->item_text_size = MIN_SIZE;
+-	  else
+-	    {
+-	      if (2 * (guint)ientry->item_text_size < MAX_SIZE &&
+-		  2 * (guint)ientry->item_text_size > ientry->item_text_size)
+-		ientry->item_text_size *= 2;
+-	      else
+-		{
+-		  ientry->item_text_size = MAX_SIZE;
+-		  if (new_text_length > (gint)ientry->item_text_size - (gint)ientry->item_n_bytes - 1)
+-		    {
+-		      new_text_length = (gint)ientry->item_text_size - (gint)ientry->item_n_bytes - 1;
+-		      new_text_length = g_utf8_find_prev_char (new_text, new_text + new_text_length + 1) - new_text;
+-		      n_chars = g_utf8_strlen (new_text, new_text_length);
+-		    }
+-		  break;
+-		}
+-	    }
+-	}
++        while (new_text_length + ientry->item_n_bytes + 1 > ientry->item_text_size)
++        {
++            if (ientry->item_text_size == 0)
++                ientry->item_text_size = MIN_SIZE;
++            else
++            {
++                if (2 * (guint)ientry->item_text_size < MAX_SIZE &&
++                    2 * (guint)ientry->item_text_size > ientry->item_text_size)
++                    ientry->item_text_size *= 2;
++                else
++                {
++                    ientry->item_text_size = MAX_SIZE;
++                    if (new_text_length > (gint)ientry->item_text_size - (gint)ientry->item_n_bytes - 1)
++                    {
++                        new_text_length = (gint)ientry->item_text_size - (gint)ientry->item_n_bytes - 1;
++                        new_text_length = g_utf8_find_prev_char (new_text, new_text + new_text_length + 1) - new_text;
++                        n_chars = g_utf8_strlen (new_text, new_text_length);
++                    }
++                    break;
++                }
++            }
++        }
+ 
+-      entry->text = g_realloc (entry->text, ientry->item_text_size);
++        entry->text = g_realloc (entry->text, ientry->item_text_size);
+     }
+ 
+-  gint index;
+-  index = g_utf8_offset_to_pointer (entry->text, *position) - entry->text;
++    gint index;
++    index = g_utf8_offset_to_pointer (entry->text, *position) - entry->text;
+ 
+-  g_memmove (entry->text + index + new_text_length, entry->text + index, ientry->item_n_bytes - index);
+-  memcpy (entry->text + index, new_text, new_text_length);
+-#endif //GTK_TYPE_ENTRY_BUFFER
++    g_memmove (entry->text + index + new_text_length, entry->text + index, ientry->item_n_bytes - index);
++    memcpy (entry->text + index, new_text, new_text_length);
+ 
+-  ientry->item_n_bytes += new_text_length;
+-  entry->text_length += n_chars;
++    ientry->item_n_bytes += new_text_length;
+ 
+-  /* NUL terminate for safety and convenience */
+-  entry->text[ientry->item_n_bytes] = '\0';
+-  
+-  if (entry->current_pos > *position)
+-    entry->current_pos += n_chars;
+-  
+-  if (entry->selection_bound > *position)
+-    entry->selection_bound += n_chars;
++    /* NUL terminate for safety and convenience */
++    entry->text[ientry->item_n_bytes] = '\0';
++    entry->text_length += n_chars;
+ 
+-  *position += n_chars;
++    if (entry->current_pos > *position)
++        entry->current_pos += n_chars;
+ 
+-  gtk_entry_recompute (entry);
++    if (entry->selection_bound > *position)
++        entry->selection_bound += n_chars;
++#endif //GTK_TYPE_ENTRY_BUFFER
++
++    *position += n_chars;
++
++    gtk_entry_recompute (entry);
+ 
+-  g_signal_emit_by_name (editable, "changed");
+-  g_object_notify (G_OBJECT (editable), "text");
++    g_signal_emit_by_name (editable, "changed");
++    g_object_notify (G_OBJECT (editable), "text");
+ }
+ 
+ static void
+@@ -821,8 +871,8 @@
+       gint end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text;
+ 
+       g_memmove (entry->text + start_index, entry->text + end_index, ientry->item_n_bytes + 1 - end_index);
+-      entry->text_length -= (end_pos - start_pos);
+       ientry->item_n_bytes -= (end_index - start_index);
++      entry->text_length -= (end_pos - start_pos);
+       
+       if (entry->current_pos > start_pos)
+ 	entry->current_pos -= MIN (entry->current_pos, end_pos) - start_pos;
+@@ -830,6 +880,8 @@
+       if (entry->selection_bound > start_pos)
+ 	entry->selection_bound -= MIN (entry->selection_bound, end_pos) - start_pos;
+ #endif // GTK_TYPE_ENTRY_BUFFER
++
++
+       /* We might have deleted the selection
+        */
+       gtk_entry_update_primary_selection (entry);
+@@ -1086,10 +1138,11 @@
+ gtk_entry_retrieve_surrounding_cb (GtkIMContext *context,
+                                GtkEntry     *entry)
+ {
+-  GtkItemEntry *ientry = GTK_ITEM_ENTRY (entry);
++  GtkEntryBuffer *buffer = get_buffer(entry);
++
+   gtk_im_context_set_surrounding (context,
+                                   entry->text,
+-                                  ientry->item_n_bytes,
++                                  gtk_entry_buffer_get_bytes(buffer),
+                                   g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text);
+ 
+   return TRUE;
+@@ -1266,7 +1319,6 @@
+ gtk_entry_create_layout (GtkEntry *entry,
+ 			 gboolean  include_preedit)
+ {
+-  GtkItemEntry *ientry = GTK_ITEM_ENTRY (entry);
+   PangoLayout *layout = gtk_widget_create_pango_layout (GTK_WIDGET (entry), NULL);
+   PangoAttrList *tmp_attrs = pango_attr_list_new ();
+   
+@@ -1286,12 +1338,14 @@
+   if (preedit_length)
+     {
+       GString *tmp_string = g_string_new (NULL);
++      GtkEntryBuffer *buffer = get_buffer(entry);
+       
+       gint cursor_index = g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text;
+       
+       if (entry->visible)
+         {
+-          g_string_prepend_len (tmp_string, entry->text, ientry->item_n_bytes);
++
++          g_string_prepend_len (tmp_string, entry->text, gtk_entry_buffer_get_bytes(buffer));
+           g_string_insert (tmp_string, cursor_index, preedit_string);
+         }
+       else
+@@ -1300,7 +1354,7 @@
+           gint preedit_len_chars;
+           gunichar invisible_char;
+           
+-          ch_len = g_utf8_strlen (entry->text, ientry->item_n_bytes);
++          ch_len = g_utf8_strlen (entry->text, gtk_entry_buffer_get_bytes(buffer));
+           preedit_len_chars = g_utf8_strlen (preedit_string, -1);
+           ch_len += preedit_len_chars;
+ 
+@@ -1334,7 +1388,8 @@
+     {
+       if (entry->visible)
+         {
+-          pango_layout_set_text (layout, entry->text, ientry->item_n_bytes);
++          GtkEntryBuffer *buffer = get_buffer(entry);
++          pango_layout_set_text (layout, entry->text, gtk_entry_buffer_get_bytes(buffer));
+         }
+       else
+         {
+@@ -1434,7 +1489,7 @@
+   if (!entry->visible && entry->invisible_char == 0)
+     return;
+   
+-  if (GTK_WIDGET_DRAWABLE (entry))
++  if (gtk_widget_is_drawable (GTK_WIDGET(entry)))
+     {
+       PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE);
+       gint area_width, area_height;
+@@ -1449,9 +1504,10 @@
+       get_text_area_size (entry, NULL, NULL, &area_width, &area_height);
+ 
+ 
+-      gdk_draw_layout (entry->text_area, widget->style->text_gc [widget->state],       
+-                       x, y,
+-		       layout);
++      gdk_draw_layout (entry->text_area, 
++	       gtk_widget_get_style(widget)->text_gc [gtk_widget_get_state(widget)],
++               x, y,
++	       layout);
+      
+  
+       if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos))
+@@ -1472,15 +1528,19 @@
+ 
+           pango_layout_get_extents (layout, NULL, &logical_rect);
+           
+-	  if (GTK_WIDGET_HAS_FOCUS (entry))
++	  if (gtk_widget_has_focus (GTK_WIDGET(entry)))
+ 	    {
+-	      selection_gc = widget->style->base_gc [GTK_STATE_SELECTED];
+-	      text_gc = widget->style->text_gc [GTK_STATE_SELECTED];
++	      selection_gc = 
++		   gtk_widget_get_style(widget)->base_gc [GTK_STATE_SELECTED];
++	      text_gc = 
++		   gtk_widget_get_style(widget)->text_gc [GTK_STATE_SELECTED];
+ 	    }
+ 	  else
+ 	    {
+-	      selection_gc = widget->style->base_gc [GTK_STATE_ACTIVE];
+-	      text_gc = widget->style->text_gc [GTK_STATE_ACTIVE];
++	      selection_gc = 
++		   gtk_widget_get_style(widget)->base_gc [GTK_STATE_ACTIVE];
++	      text_gc = 
++		   gtk_widget_get_style(widget)->text_gc [GTK_STATE_ACTIVE];
+ 	    }
+ 	  
+ 	  for (i=0; i < n_ranges; i++)
+@@ -1543,9 +1603,11 @@
+   else
+     gc_values.foreground = *fallback;
+   
+-  gdk_rgb_find_color (widget->style->colormap, &gc_values.foreground);
+-  return gtk_gc_get (widget->style->depth, widget->style->colormap,
+-    &gc_values, gc_values_mask);
++  gdk_rgb_find_color (gtk_widget_get_style(widget)->colormap, 
++		      &gc_values.foreground);
++  return gtk_gc_get (gtk_widget_get_style(widget)->depth, 
++		     gtk_widget_get_style(widget)->colormap,
++    		     &gc_values, gc_values_mask);
+ }
+ 
+ static GdkGC *
+@@ -1554,11 +1616,13 @@
+ {
+   CursorInfo *cursor_info;
+ 
+-  cursor_info = g_object_get_data (G_OBJECT (widget->style), "gtk-style-cursor-info");
++  cursor_info = g_object_get_data (G_OBJECT (gtk_widget_get_style(widget)), 
++				   "gtk-style-cursor-info");
+   if (!cursor_info)
+     {
+       cursor_info = g_new (CursorInfo, 1);
+-      g_object_set_data (G_OBJECT (widget->style), "gtk-style-cursor-info", cursor_info);
++      g_object_set_data (G_OBJECT (gtk_widget_get_style(widget)), 
++			 "gtk-style-cursor-info", cursor_info);
+       cursor_info->primary_gc = NULL;
+       cursor_info->secondary_gc = NULL;
+       cursor_info->for_type = G_TYPE_INVALID;
+@@ -1589,8 +1653,8 @@
+     {
+       if (!cursor_info->primary_gc)
+ 	cursor_info->primary_gc = make_cursor_gc (widget,
+-						  "cursor-color",
+-						  &widget->style->black);
++					  "cursor-color",
++					  &gtk_widget_get_style(widget)->black);
+ 	
+       return g_object_ref (cursor_info->primary_gc);
+     }
+@@ -1683,7 +1747,7 @@
+     GTK_TEXT_DIR_LTR : GTK_TEXT_DIR_RTL;
+   GtkTextDirection widget_direction = gtk_widget_get_direction (GTK_WIDGET (entry));
+  
+-  if (GTK_WIDGET_DRAWABLE (entry) && GTK_ENTRY(entry)->cursor_visible)
++  if (gtk_widget_is_drawable (GTK_WIDGET(entry)) && GTK_ENTRY(entry)->cursor_visible)
+     {
+       GtkWidget *widget = GTK_WIDGET (entry);
+       GdkRectangle cursor_location;
+@@ -1752,7 +1816,7 @@
+ static void
+ gtk_entry_queue_draw (GtkEntry *entry)
+ {
+-  if (GTK_WIDGET_REALIZED (entry))
++  if (gtk_widget_get_realized (GTK_WIDGET(entry)))
+     gdk_window_invalidate_rect (entry->text_area, NULL, FALSE);
+ }
+ 
+@@ -1812,7 +1876,7 @@
+   GtkItemEntry *item_entry;
+   gint text_width;
+ 
+-  if (!GTK_WIDGET_REALIZED (entry))
++  if (!gtk_widget_get_realized (GTK_WIDGET(entry)))
+     return;
+ 
+   item_entry = GTK_ITEM_ENTRY(entry);
+@@ -1847,7 +1911,7 @@
+             if(item_entry->text_max_size != 0 &&
+                text_area_width + 2 <= item_entry->text_max_size){
+                GtkAllocation allocation;
+-               allocation = GTK_WIDGET(entry)->allocation;
++	       gtk_widget_get_allocation(GTK_WIDGET(entry), &allocation);
+                allocation.width += text_width - text_area_width;
+                entry->scroll_offset = 0;
+                gtk_entry_size_allocate(GTK_WIDGET(entry), &allocation);
+@@ -1868,7 +1932,7 @@
+               if(item_entry->text_max_size != 0 &&
+                 text_area_width + 2 <= item_entry->text_max_size){
+                 GtkAllocation allocation;
+-                allocation = GTK_WIDGET(entry)->allocation;
++	       gtk_widget_get_allocation(GTK_WIDGET(entry), &allocation);
+                 allocation.x -= text_width - text_area_width;
+                 allocation.width += text_width - text_area_width;
+                 entry->scroll_offset = 0;
+@@ -1894,7 +1958,7 @@
+               if(item_entry->text_max_size != 0 &&
+                           text_area_width+1<=item_entry->text_max_size){
+                 GtkAllocation allocation;
+-                allocation = GTK_WIDGET(entry)->allocation;
++	        gtk_widget_get_allocation(GTK_WIDGET(entry), &allocation);
+                 allocation.x += (text_area_width/2 - text_width/2);
+                 allocation.width += text_width - text_area_width;
+                 entry->scroll_offset = 0;
+@@ -2200,23 +2264,38 @@
+ GtkWidget*
+ gtk_item_entry_new (void)
+ {
+-  GtkWidget *widget;
+-
+-  widget = GTK_WIDGET (gtk_type_new (GTK_TYPE_ITEM_ENTRY));
+-  return widget;
++  return gtk_widget_new(G_TYPE_ITEM_ENTRY, NULL);
+ }
+ 
++/**
++ * gtk_item_entry_new_with_max_length:
++ * @max: the maximum length of the entry, or 0 for no maximum. (other than the maximum length of entries.) 
++ * The value passed in will be clamped to the range 0-65536.
++ * 
++ * Creates a new #GtkItemEntry with the maximum allowed length of the contents of the widget. 
++ * If the current contents are longer than the given length, then they will be truncated to fit. 
++ *  
++ * Returns: the newly-created #GtkItemEntry widget.
++ */
+ GtkWidget*
+ gtk_item_entry_new_with_max_length (gint max)
+ {
+   GtkItemEntry *entry;
+ 
+-  entry = gtk_type_new (GTK_TYPE_ITEM_ENTRY);
++  entry = g_object_new (G_TYPE_ITEM_ENTRY, NULL);
+   gtk_entry_set_max_length(GTK_ENTRY(entry), max);
+ 
+   return GTK_WIDGET (entry);
+ }
+ 
++/**
++ * gtk_item_entry_set_text:
++ * @entry: a #GtkItemEntry
++ * @text: the new text
++ * @justification: a #GtkJustification : GTK_JUSTIFY_LEFT,GTK_JUSTIFY_RIGHT,GTK_JUSTIFY_CENTER,GTK_JUSTIFY_FILL
++ * 
++ * Sets the text in the widget to the given value, replacing the current contents.
++ */
+ void
+ gtk_item_entry_set_text (GtkItemEntry    *entry,
+ 	      	         const gchar *text,
+@@ -2277,7 +2356,7 @@
+  * gtk_entry_text_index_to_layout_index() are needed to convert byte
+  * indices in the layout to byte indices in the entry contents.
+  * 
+- **/
++ */
+ void
+ gtk_item_entry_get_layout_offsets (GtkItemEntry *entry,
+                                    gint     *x,
+@@ -2300,6 +2379,13 @@
+     *y += text_area_y;
+ }
+ 
++/**
++ * gtk_item_entry_set_justification:
++ * @entry: a #GtkItemEntry
++ * @just: a #GtkJustification : GTK_JUSTIFY_LEFT,GTK_JUSTIFY_RIGHT,GTK_JUSTIFY_CENTER,GTK_JUSTIFY_FILL
++ * 
++ * Sets justification of the widget to the given value, replacing the current one.
++ */
+ void
+ gtk_item_entry_set_justification(GtkItemEntry *entry, GtkJustification just)
+ {
+@@ -2325,7 +2411,7 @@
+   GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (entry));
+   gboolean blink;
+ 
+-  if (GTK_WIDGET_HAS_FOCUS (entry) &&
++  if (gtk_widget_has_focus (GTK_WIDGET(entry)) &&
+       entry->selection_bound == entry->current_pos)
+     {
+       g_object_get (G_OBJECT (settings), "gtk-cursor-blink", &blink, NULL);
+@@ -2353,7 +2439,7 @@
+     {
+       entry->cursor_visible = TRUE;
+ 
+-      if (GTK_WIDGET_HAS_FOCUS (entry) && entry->selection_bound == entry->current_pos)
++      if (gtk_widget_has_focus (GTK_WIDGET(entry)) && entry->selection_bound == entry->current_pos)
+ 	gtk_widget_queue_draw (GTK_WIDGET (entry));
+     }
+ }
+@@ -2365,7 +2451,7 @@
+     {
+       entry->cursor_visible = FALSE;
+ 
+-      if (GTK_WIDGET_HAS_FOCUS (entry) && entry->selection_bound == entry->current_pos)
++      if (gtk_widget_has_focus (GTK_WIDGET(entry)) && entry->selection_bound == entry->current_pos)
+ 	gtk_widget_queue_draw (GTK_WIDGET (entry));
+     }
+ }
+@@ -2382,22 +2468,28 @@
+ 
+   entry = GTK_ENTRY (data);
+   
+-  g_assert (GTK_WIDGET_HAS_FOCUS (entry));
++  g_assert (gtk_widget_has_focus (GTK_WIDGET(entry)));
+   g_assert (entry->selection_bound == entry->current_pos);
+ 
+   if (entry->cursor_visible)
+     {
+       hide_cursor (entry);
+-      entry->blink_timeout = gtk_timeout_add (get_cursor_time (entry) * CURSOR_OFF_MULTIPLIER,
+-					      blink_cb,
+-					      entry);
++      entry->blink_timeout = g_timeout_add_full (
++		0, 
++		get_cursor_time (entry) * CURSOR_OFF_MULTIPLIER,
++	 	blink_cb,
++		entry,
++		NULL);
+     }
+   else
+     {
+       show_cursor (entry);
+-      entry->blink_timeout = gtk_timeout_add (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER,
+-					      blink_cb,
+-					      entry);
++      entry->blink_timeout = g_timeout_add_full (
++		0,
++		get_cursor_time (entry) * CURSOR_ON_MULTIPLIER,
++		blink_cb,
++		entry,
++		NULL);
+     }
+ 
+   GDK_THREADS_LEAVE ();
+@@ -2413,9 +2505,12 @@
+     {
+       if (!entry->blink_timeout)
+ 	{
+-	  entry->blink_timeout = gtk_timeout_add (get_cursor_time (entry) * CURSOR_ON_MULTIPLIER,
+-						  blink_cb,
+-						  entry);
++	  entry->blink_timeout = g_timeout_add_full (
++		0,
++		get_cursor_time (entry) * CURSOR_ON_MULTIPLIER,
++		blink_cb,
++		entry,
++		NULL);
+ 	  show_cursor (entry);
+ 	}
+     }
+@@ -2423,7 +2518,7 @@
+     {
+       if (entry->blink_timeout)  
+ 	{ 
+-	  gtk_timeout_remove (entry->blink_timeout);
++	  g_source_remove (entry->blink_timeout);
+ 	  entry->blink_timeout = 0;
+ 	}
+       
+@@ -2438,15 +2533,25 @@
+   if (cursor_blinks (entry))
+     {
+       if (entry->blink_timeout != 0)
+-	gtk_timeout_remove (entry->blink_timeout);
++	g_source_remove (entry->blink_timeout);
+       
+-      entry->blink_timeout = gtk_timeout_add (get_cursor_time (entry) * CURSOR_PEND_MULTIPLIER,
+-					      blink_cb,
+-					      entry);
++      entry->blink_timeout = g_timeout_add_full (
++		0,
++		get_cursor_time (entry) * CURSOR_PEND_MULTIPLIER,
++		blink_cb,
++		entry,
++		NULL);
+       show_cursor (entry);
+     }
+ }
+ 
++/**
++ * gtk_item_set_cursor_visible:
++ * @entry: a #GtkItemEntry
++ * @visible: TRUE(visible) or FALSE (invisible)
++ * 
++ * Sets the cursor visibility in the widget.
++ */
+ void
+ gtk_item_entry_set_cursor_visible(GtkItemEntry *entry, gboolean visible)
+ {
+@@ -2455,6 +2560,14 @@
+   GTK_ENTRY(entry)->cursor_visible = visible;
+ }
+ 
++/**
++ * gtk_item_get_cursor_visible:
++ * @entry: a #GtkItemEntry
++ * 
++ * Gets the cursor visibility in the widget.
++ *  
++ * Returns: TRUE(visible) or FALSE (invisible)
++ */
+ gboolean
+ gtk_item_entry_get_cursor_visible(GtkItemEntry *entry)
+ {
+Index: gtkextra/gtkitementry.h
+===================================================================
+RCS file: /cvsroot/gtkextra/gtkextra-2/gtkextra/gtkitementry.h,v
+retrieving revision 1.4
+diff -U3 -r1.4 gtkitementry.h
+--- gtkextra/gtkitementry.h	11 Mar 2010 20:33:21 -0000	1.4
++++ gtkextra/gtkitementry.h	19 Feb 2011 06:51:36 -0000
+@@ -28,11 +28,11 @@
+ #endif /* __cplusplus */
+ 
+ 
+-#define GTK_TYPE_ITEM_ENTRY            (gtk_item_entry_get_type ())
+-#define GTK_ITEM_ENTRY(obj)            (GTK_CHECK_CAST (obj, gtk_item_entry_get_type (), GtkItemEntry))
+-#define GTK_ITEM_ENTRY_CLASS(klass)    (GTK_CHECK_CLASS_CAST (klass, gtk_item_entry_get_type (), GtkItemEntryClass))
+-#define GTK_IS_ITEM_ENTRY(obj)         (GTK_CHECK_TYPE (obj, gtk_item_entry_get_type ()))
+-#define GTK_IS_ITEM_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_ENTRY))
++#define G_TYPE_ITEM_ENTRY            (gtk_item_entry_get_type ())
++#define GTK_ITEM_ENTRY(obj)            (G_TYPE_CHECK_INSTANCE_CAST (obj, gtk_item_entry_get_type (), GtkItemEntry))
++#define GTK_ITEM_ENTRY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST (klass, gtk_item_entry_get_type (), GtkItemEntryClass))
++#define GTK_IS_ITEM_ENTRY(obj)         (G_TYPE_CHECK_INSTANCE_TYPE (obj, gtk_item_entry_get_type ()))
++#define GTK_IS_ITEM_ENTRY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), gtk_entry_get_type()))
+ 
+ 
+ typedef struct _GtkItemEntry       GtkItemEntry;
+@@ -54,15 +54,15 @@
+   GtkEntryClass parent_class;
+ };
+ 
+-GtkType    gtk_item_entry_get_type       (void);
++GType      gtk_item_entry_get_type       (void);
+ GtkWidget* gtk_item_entry_new            (void);
+ GtkWidget* gtk_item_entry_new_with_max_length (gint   max);
+-void       gtk_item_entry_set_text            (GtkItemEntry *item_entry, 
++void       gtk_item_entry_set_text            (GtkItemEntry *entry, 
+                                                const gchar *text,
+                                                GtkJustification justification);
+ 
+-void       gtk_item_entry_set_justification (GtkItemEntry        *item_entry,
+-					     GtkJustification   justification);
++void       gtk_item_entry_set_justification (GtkItemEntry        *entry,
++					     GtkJustification   just);
+ 
+ void       gtk_item_entry_set_cursor_visible 	(GtkItemEntry *entry,
+ 					 	 gboolean visible);
diff --git a/gtk+extra.spec b/gtk+extra.spec
index 473bce2..f50fc28 100644
--- a/gtk+extra.spec
+++ b/gtk+extra.spec
@@ -1,6 +1,6 @@
 Name:		gtk+extra
 Version:	2.1.2
-Release:	5%{?dist}
+Release:	6%{?dist}
 Summary:	A library of gtk+ widgets
 Summary(fr):	Une bibliothèque de widgets gtk+
 
@@ -11,6 +11,7 @@ Source:		http://downloads.sourceforge.net/gtkextra/gtk+extra-%{version}.tar.gz
 Patch:		%{name}-%{version}-gtk2.21.patch
 Patch1:		%{name}-%{version}-make.patch
 Patch2:		%{name}-%{version}-marshal.patch
+Patch3:		%{name}-%{version}-gtkitementry.patch
 BuildRoot:	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:	gtk2-devel libtool gtk-doc
@@ -49,6 +50,7 @@ qui utilisent les widgets gtk+extra.
 %patch -p0
 %patch1 -p0
 %patch2 -p0
+%patch3 -p0
 libtoolize --force
 aclocal
 autoheader
@@ -92,6 +94,9 @@ rm -rf $RPM_BUILD_ROOT
 
 
 %changelog
+* Mon Feb 21 2011 Roy Rankin <rrankin[AT]ihug[DOT]com[DOT]au> - 2.1.2-6
+- patch for sigsegv when using gtksheet
+
 * Wed Feb 09 2011 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 2.1.2-5
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
 


More information about the scm-commits mailing list