Commit 81eb53df authored by Shawn Amundson's avatar Shawn Amundson

Changes from Owen Taylor which allow GIMP to compile with

new GTK changes.  ChangeLog is more specific.

-Shawn
parent 92f0e489
Wed Dec 17 23:51:30 CST 1997 Shawn T. Amundson <amundson@gimp.org>
* All these changes are from Owen Taylor to make GIMP work
with reference changes make in GTK. This mainly affects
functions gtk_pixmap_destroy, gdk_colormap_destroy,
gdk_font(set)_free; they have disappeared and where
changed to *_unref. These simple changes affected:
app/about_dialog.c, app/channels_dialog.c,
app/curves.c, app/gradient.c, app/layer_select.c,
app/text_tool.c, plug-ins/gfig/gfig.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/libgck/gck/gckcolor.c,
plug-ins/libgck/gck/gcknotebook.c
* app/color_area.c: check for initial expose before drawing
* app/disp_callbacks.c: gc for scrolling
* app/gdisplay.c: destroy gc, event now pointer
* app/scroll.c: use scroll_gc, make sure graphics expose events
are processed before scrolling again
* gimp/app/gdisplay.h: add scroll_gc to struct
Wed Dec 17 23:23:05 1997 Ray Lehtiniemi <rayl@netrover.com>
* app/brush_select.c (brush_popup_open): fix memory leak
......
......@@ -155,7 +155,7 @@ about_dialog_create (int timeout)
style = gtk_style_new ();
gdk_font_free (style->font);
gdk_font_unref (style->font);
style->font = gdk_font_load ("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*");
gtk_widget_push_style (style);
......
......@@ -404,7 +404,7 @@ curves_free ()
curves_dialog->image_map = NULL;
}
if (curves_dialog->pixmap)
gdk_pixmap_destroy (curves_dialog->pixmap);
gdk_pixmap_unref (curves_dialog->pixmap);
gtk_widget_destroy (curves_dialog->shell);
}
}
......
......@@ -1048,7 +1048,7 @@ static void
channel_widget_delete (ChannelWidget *channel_widget)
{
if (channel_widget->channel_pixmap)
gdk_pixmap_destroy (channel_widget->channel_pixmap);
gdk_pixmap_unref (channel_widget->channel_pixmap);
/* Remove the channel widget from the list */
channelsD->channel_widgets = remove_from_list (channelsD->channel_widgets, channel_widget);
......
......@@ -83,6 +83,10 @@ color_area_draw (void)
int def_width, def_height;
int swap_width, swap_height;
if (!color_area_pixmap) /* we haven't gotten initial expose yet,
* no point in drawing anything */
return;
gdk_window_get_size (color_area_pixmap, &width, &height);
win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
......
......@@ -191,6 +191,9 @@ gdisplay_delete (GDisplay *gdisp)
/* free the selection structure */
selection_free (gdisp->select);
if (gdisp->scroll_gc)
gdk_gc_destroy (gdisp->scroll_gc);
/* free the area lists */
gdisplay_free_area_list (gdisp->update_areas);
......@@ -1084,12 +1087,13 @@ gdisplay_active ()
{
GtkWidget *event_widget;
GtkWidget *toplevel_widget;
GdkEvent event;
GdkEvent *event;
GDisplay *gdisp;
/* If the popup shell is valid, then get the gdisplay associated with that shell */
gtk_get_current_event (&event);
event_widget = gtk_get_event_widget (&event);
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......
......@@ -84,6 +84,8 @@ struct _GDisplay
Selection *select; /* Selection object */
GdkGC *scroll_gc; /* GC for scrolling */
link_ptr update_areas; /* Update areas list */
link_ptr display_areas; /* Display areas list */
......
......@@ -404,7 +404,7 @@ curves_free ()
curves_dialog->image_map = NULL;
}
if (curves_dialog->pixmap)
gdk_pixmap_destroy (curves_dialog->pixmap);
gdk_pixmap_unref (curves_dialog->pixmap);
gtk_widget_destroy (curves_dialog->shell);
}
}
......
......@@ -155,7 +155,7 @@ about_dialog_create (int timeout)
style = gtk_style_new ();
gdk_font_free (style->font);
gdk_font_unref (style->font);
style->font = gdk_font_load ("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*");
gtk_widget_push_style (style);
......
......@@ -97,6 +97,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
/* create GC for scrolling */
gdisp->scroll_gc = gdk_gc_new (gdisp->canvas->window);
gdk_gc_set_exposures (gdisp->scroll_gc, TRUE);
/* set up the scrollbar observers */
gtk_signal_connect (GTK_OBJECT (gdisp->hsbdata), "value_changed",
(GtkSignalFunc) scrollbar_horz_update,
......@@ -257,24 +262,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
grab_and_scroll (gdisp, mevent);
flush = FALSE;
while (gdk_event_get (&tmp_event, expose_predicate, canvas->window))
{
flush = TRUE;
x1 = tmp_event.expose.area.x;
y1 = tmp_event.expose.area.y;
x2 = (x1 + tmp_event.expose.area.width);
y2 = (y1 + tmp_event.expose.area.height);
x1 = BOUNDS (x1, 0, gdisp->disp_width);
y1 = BOUNDS (y1, 0, gdisp->disp_height);
x2 = BOUNDS (x2, 0, gdisp->disp_width);
y2 = BOUNDS (y2, 0, gdisp->disp_height);
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
}
if (flush)
gdisplays_flush ();
}
......
......@@ -97,6 +97,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
/* create GC for scrolling */
gdisp->scroll_gc = gdk_gc_new (gdisp->canvas->window);
gdk_gc_set_exposures (gdisp->scroll_gc, TRUE);
/* set up the scrollbar observers */
gtk_signal_connect (GTK_OBJECT (gdisp->hsbdata), "value_changed",
(GtkSignalFunc) scrollbar_horz_update,
......@@ -257,24 +262,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
grab_and_scroll (gdisp, mevent);
flush = FALSE;
while (gdk_event_get (&tmp_event, expose_predicate, canvas->window))
{
flush = TRUE;
x1 = tmp_event.expose.area.x;
y1 = tmp_event.expose.area.y;
x2 = (x1 + tmp_event.expose.area.width);
y2 = (y1 + tmp_event.expose.area.height);
x1 = BOUNDS (x1, 0, gdisp->disp_width);
y1 = BOUNDS (y1, 0, gdisp->disp_height);
x2 = BOUNDS (x2, 0, gdisp->disp_width);
y2 = BOUNDS (y2, 0, gdisp->disp_height);
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
}
if (flush)
gdisplays_flush ();
}
......
......@@ -136,6 +136,7 @@ scroll_display (GDisplay *gdisp,
int old_x, old_y;
int src_x, src_y;
int dest_x, dest_y;
GdkEvent *event;
old_x = gdisp->offset_x;
old_y = gdisp->offset_y;
......@@ -170,7 +171,7 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_y += y_offset;
gdk_draw_pixmap (gdisp->canvas->window,
gdisp->select->gc_in,
gdisp->scroll_gc,
gdisp->canvas->window,
src_x, src_y,
dest_x, dest_y,
......@@ -201,6 +202,22 @@ scroll_display (GDisplay *gdisp,
if (x_offset || y_offset)
gdisplays_flush ();
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
!= NULL)
{
gtk_widget_event (gdisp->canvas, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
return 1;
}
......
......@@ -191,6 +191,9 @@ gdisplay_delete (GDisplay *gdisp)
/* free the selection structure */
selection_free (gdisp->select);
if (gdisp->scroll_gc)
gdk_gc_destroy (gdisp->scroll_gc);
/* free the area lists */
gdisplay_free_area_list (gdisp->update_areas);
......@@ -1084,12 +1087,13 @@ gdisplay_active ()
{
GtkWidget *event_widget;
GtkWidget *toplevel_widget;
GdkEvent event;
GdkEvent *event;
GDisplay *gdisp;
/* If the popup shell is valid, then get the gdisplay associated with that shell */
gtk_get_current_event (&event);
event_widget = gtk_get_event_widget (&event);
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......
......@@ -84,6 +84,8 @@ struct _GDisplay
Selection *select; /* Selection object */
GdkGC *scroll_gc; /* GC for scrolling */
link_ptr update_areas; /* Update areas list */
link_ptr display_areas; /* Display areas list */
......
......@@ -97,6 +97,11 @@ gdisplay_canvas_events (GtkWidget *canvas,
gdisp->disp_width = gdisp->canvas->allocation.width;
gdisp->disp_height = gdisp->canvas->allocation.height;
/* create GC for scrolling */
gdisp->scroll_gc = gdk_gc_new (gdisp->canvas->window);
gdk_gc_set_exposures (gdisp->scroll_gc, TRUE);
/* set up the scrollbar observers */
gtk_signal_connect (GTK_OBJECT (gdisp->hsbdata), "value_changed",
(GtkSignalFunc) scrollbar_horz_update,
......@@ -257,24 +262,6 @@ gdisplay_canvas_events (GtkWidget *canvas,
grab_and_scroll (gdisp, mevent);
flush = FALSE;
while (gdk_event_get (&tmp_event, expose_predicate, canvas->window))
{
flush = TRUE;
x1 = tmp_event.expose.area.x;
y1 = tmp_event.expose.area.y;
x2 = (x1 + tmp_event.expose.area.width);
y2 = (y1 + tmp_event.expose.area.height);
x1 = BOUNDS (x1, 0, gdisp->disp_width);
y1 = BOUNDS (y1, 0, gdisp->disp_height);
x2 = BOUNDS (x2, 0, gdisp->disp_width);
y2 = BOUNDS (y2, 0, gdisp->disp_height);
gdisplay_expose_area (gdisp, x1, y1, (x2 - x1), (y2 - y1));
}
if (flush)
gdisplays_flush ();
}
......
......@@ -284,7 +284,7 @@ layer_select_set_gimage (LayerSelect *layer_select,
if (layer_select->layer_pixmap)
{
gdk_pixmap_destroy (layer_select->layer_pixmap);
gdk_pixmap_unref (layer_select->layer_pixmap);
layer_select->layer_pixmap = NULL;
}
}
......
......@@ -136,6 +136,7 @@ scroll_display (GDisplay *gdisp,
int old_x, old_y;
int src_x, src_y;
int dest_x, dest_y;
GdkEvent *event;
old_x = gdisp->offset_x;
old_y = gdisp->offset_y;
......@@ -170,7 +171,7 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_y += y_offset;
gdk_draw_pixmap (gdisp->canvas->window,
gdisp->select->gc_in,
gdisp->scroll_gc,
gdisp->canvas->window,
src_x, src_y,
dest_x, dest_y,
......@@ -201,6 +202,22 @@ scroll_display (GDisplay *gdisp,
if (x_offset || y_offset)
gdisplays_flush ();
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
!= NULL)
{
gtk_widget_event (gdisp->canvas, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
return 1;
}
......
......@@ -191,6 +191,9 @@ gdisplay_delete (GDisplay *gdisp)
/* free the selection structure */
selection_free (gdisp->select);
if (gdisp->scroll_gc)
gdk_gc_destroy (gdisp->scroll_gc);
/* free the area lists */
gdisplay_free_area_list (gdisp->update_areas);
......@@ -1084,12 +1087,13 @@ gdisplay_active ()
{
GtkWidget *event_widget;
GtkWidget *toplevel_widget;
GdkEvent event;
GdkEvent *event;
GDisplay *gdisp;
/* If the popup shell is valid, then get the gdisplay associated with that shell */
gtk_get_current_event (&event);
event_widget = gtk_get_event_widget (&event);
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......
......@@ -84,6 +84,8 @@ struct _GDisplay
Selection *select; /* Selection object */
GdkGC *scroll_gc; /* GC for scrolling */
link_ptr update_areas; /* Update areas list */
link_ptr display_areas; /* Display areas list */
......
......@@ -2598,7 +2598,7 @@ control_update(int recalculate)
if (!g_editor->control_pixmap || (cwidth != pwidth) || (cheight != pheight)) {
if (g_editor->control_pixmap)
gdk_pixmap_destroy(g_editor->control_pixmap);
gdk_pixmap_unref(g_editor->control_pixmap);
g_editor->control_pixmap = gdk_pixmap_new(g_editor->control->window, cwidth, cheight, -1);
......
......@@ -2598,7 +2598,7 @@ control_update(int recalculate)
if (!g_editor->control_pixmap || (cwidth != pwidth) || (cheight != pheight)) {
if (g_editor->control_pixmap)
gdk_pixmap_destroy(g_editor->control_pixmap);
gdk_pixmap_unref(g_editor->control_pixmap);
g_editor->control_pixmap = gdk_pixmap_new(g_editor->control->window, cwidth, cheight, -1);
......
......@@ -155,7 +155,7 @@ about_dialog_create (int timeout)
style = gtk_style_new ();
gdk_font_free (style->font);
gdk_font_unref (style->font);
style->font = gdk_font_load ("-Adobe-Helvetica-Medium-R-Normal--*-140-*-*-*-*-*-*");
gtk_widget_push_style (style);
......
......@@ -1048,7 +1048,7 @@ static void
channel_widget_delete (ChannelWidget *channel_widget)
{
if (channel_widget->channel_pixmap)
gdk_pixmap_destroy (channel_widget->channel_pixmap);
gdk_pixmap_unref (channel_widget->channel_pixmap);
/* Remove the channel widget from the list */
channelsD->channel_widgets = remove_from_list (channelsD->channel_widgets, channel_widget);
......
......@@ -83,6 +83,10 @@ color_area_draw (void)
int def_width, def_height;
int swap_width, swap_height;
if (!color_area_pixmap) /* we haven't gotten initial expose yet,
* no point in drawing anything */
return;
gdk_window_get_size (color_area_pixmap, &width, &height);
win_bg = &(color_area->style->bg[GTK_STATE_NORMAL]);
......
......@@ -2598,7 +2598,7 @@ control_update(int recalculate)
if (!g_editor->control_pixmap || (cwidth != pwidth) || (cheight != pheight)) {
if (g_editor->control_pixmap)
gdk_pixmap_destroy(g_editor->control_pixmap);
gdk_pixmap_unref(g_editor->control_pixmap);
g_editor->control_pixmap = gdk_pixmap_new(g_editor->control->window, cwidth, cheight, -1);
......
......@@ -284,7 +284,7 @@ layer_select_set_gimage (LayerSelect *layer_select,
if (layer_select->layer_pixmap)
{
gdk_pixmap_destroy (layer_select->layer_pixmap);
gdk_pixmap_unref (layer_select->layer_pixmap);
layer_select->layer_pixmap = NULL;
}
}
......
......@@ -1986,9 +1986,9 @@ static void
layer_widget_delete (LayerWidget *layer_widget)
{
if (layer_widget->layer_pixmap)
gdk_pixmap_destroy (layer_widget->layer_pixmap);
gdk_pixmap_unref (layer_widget->layer_pixmap);
if (layer_widget->mask_pixmap)
gdk_pixmap_destroy (layer_widget->mask_pixmap);
gdk_pixmap_unref (layer_widget->mask_pixmap);
/* Remove the layer widget from the list */
layersD->layer_widgets = remove_from_list (layersD->layer_widgets, layer_widget);
......
......@@ -284,7 +284,7 @@ layer_select_set_gimage (LayerSelect *layer_select,
if (layer_select->layer_pixmap)
{
gdk_pixmap_destroy (layer_select->layer_pixmap);
gdk_pixmap_unref (layer_select->layer_pixmap);
layer_select->layer_pixmap = NULL;
}
}
......
......@@ -1986,9 +1986,9 @@ static void
layer_widget_delete (LayerWidget *layer_widget)
{
if (layer_widget->layer_pixmap)
gdk_pixmap_destroy (layer_widget->layer_pixmap);
gdk_pixmap_unref (layer_widget->layer_pixmap);
if (layer_widget->mask_pixmap)
gdk_pixmap_destroy (layer_widget->mask_pixmap);
gdk_pixmap_unref (layer_widget->mask_pixmap);
/* Remove the layer widget from the list */
layersD->layer_widgets = remove_from_list (layersD->layer_widgets, layer_widget);
......
......@@ -136,6 +136,7 @@ scroll_display (GDisplay *gdisp,
int old_x, old_y;
int src_x, src_y;
int dest_x, dest_y;
GdkEvent *event;
old_x = gdisp->offset_x;
old_y = gdisp->offset_y;
......@@ -170,7 +171,7 @@ scroll_display (GDisplay *gdisp,
gdisp->offset_y += y_offset;
gdk_draw_pixmap (gdisp->canvas->window,
gdisp->select->gc_in,
gdisp->scroll_gc,
gdisp->canvas->window,
src_x, src_y,
dest_x, dest_y,
......@@ -201,6 +202,22 @@ scroll_display (GDisplay *gdisp,
if (x_offset || y_offset)
gdisplays_flush ();
/* Make sure graphics expose events are processed before scrolling
* again */
while ((event = gdk_event_get_graphics_expose (gdisp->canvas->window))
!= NULL)
{
gtk_widget_event (gdisp->canvas, event);
if (event->expose.count == 0)
{
gdk_event_free (event);
break;
}
gdk_event_free (event);
}
return 1;
}
......
......@@ -342,7 +342,7 @@ text_resize_text_widget (TextTool *text_tool)
GtkStyle *style;
style = gtk_style_new ();
gdk_font_free (style->font);
gdk_font_unref (style->font);
style->font = text_tool->font;
gdk_font_ref (style->font);
......@@ -1381,7 +1381,7 @@ text_load_font (TextTool *text_tool)
if (font)
{
if (text_tool->font)
gdk_font_free (text_tool->font);
gdk_font_unref (text_tool->font);
text_tool->font = font;
text_resize_text_widget (text_tool);
......@@ -1681,13 +1681,13 @@ text_render (GImage *gimage,
}
/* free the pixmap */
gdk_pixmap_destroy (pixmap);
gdk_pixmap_unref (pixmap);
/* free the gc */
gdk_gc_destroy (gc);
/* free the font */
gdk_font_free (font);
gdk_font_unref (font);
return layer;
}
......
......@@ -404,7 +404,7 @@ curves_free ()
curves_dialog->image_map = NULL;
}
if (curves_dialog->pixmap)
gdk_pixmap_destroy (curves_dialog->pixmap);
gdk_pixmap_unref (curves_dialog->pixmap);
gtk_widget_destroy (curves_dialog->shell);
}
}
......
......@@ -404,7 +404,7 @@ curves_free ()
curves_dialog->image_map = NULL;
}
if (curves_dialog->pixmap)
gdk_pixmap_destroy (curves_dialog->pixmap);
gdk_pixmap_unref (curves_dialog->pixmap);
gtk_widget_destroy (curves_dialog->shell);
}
}
......
......@@ -342,7 +342,7 @@ text_resize_text_widget (TextTool *text_tool)
GtkStyle *style;
style = gtk_style_new ();
gdk_font_free (style->font);
gdk_font_unref (style->font);
style->font = text_tool->font;
gdk_font_ref (style->font);
......@@ -1381,7 +1381,7 @@ text_load_font (TextTool *text_tool)
if (font)
{