From 0479b8d9a06faa76dd5622fd8549f380f8cac242 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Thu, 11 Apr 2002 20:02:31 +0000 Subject: Fixed a memory leak here by using the "selection-done" signal. 2002-04-11 Christopher James Lahey * e-table-header-item.c (ethi_header_context_menu): Fixed a memory leak here by using the "selection-done" signal. * e-table.c, e-table.h (white_item_event): Added the "white_space_event" signal. svn path=/trunk/; revision=16439 --- widgets/table/e-table-header-item.c | 26 +++++++++++++++++++------- widgets/table/e-table.c | 35 +++++++++++++++++++++++++++++------ widgets/table/e-table.h | 1 + 3 files changed, 49 insertions(+), 13 deletions(-) (limited to 'widgets/table') diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c index ba149237ba..1542853d16 100644 --- a/widgets/table/e-table-header-item.c +++ b/widgets/table/e-table-header-item.c @@ -40,6 +40,7 @@ #include "gal/util/e-xml-utils.h" #include "gal/widgets/e-canvas.h" #include "gal/widgets/e-popup-menu.h" +#include "gal/widgets/e-gui-utils.h" #include "e-table-header.h" #include "e-table-header-utils.h" #include "e-table-col-dnd.h" @@ -1439,6 +1440,12 @@ ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info) } } +static void +free_popup_info (GtkWidget *w, EthiHeaderInfo *info) +{ + g_free (info); +} + /* Bit 1 is always disabled. */ /* Bit 2 is disabled if not "sortable". */ /* Bit 4 is disabled if we don't have a pointer to our table object. */ @@ -1466,16 +1473,21 @@ ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event) { EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1); ETableCol *col; + GtkMenu *popup; info->ethi = ethi; info->col = ethi_find_col_by_x (ethi, event->x); col = e_table_header_get_column (ethi->eth, info->col); - e_popup_menu_run (ethi_context_menu, (GdkEvent *) event, - 1 + - (col->sortable ? 0 : 2) + - ((ethi->table || ethi->tree) ? 0 : 4) + - ((e_table_header_count (ethi->eth) > 1) ? 0 : 8), - ((e_table_sort_info_get_can_group (ethi->sort_info)) ? 0 : 16) + - 128, info); + + popup = e_popup_menu_create (ethi_context_menu, + 1 + + (col->sortable ? 0 : 2) + + ((ethi->table || ethi->tree) ? 0 : 4) + + ((e_table_header_count (ethi->eth) > 1) ? 0 : 8), + ((e_table_sort_info_get_can_group (ethi->sort_info)) ? 0 : 16) + + 128, info); + gtk_signal_connect (GTK_OBJECT (popup), "selection-done", + GTK_SIGNAL_FUNC (free_popup_info), info); + e_popup_menu (popup, (GdkEvent *) event); } static void diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 9116f03356..3a321eee00 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -75,6 +75,7 @@ enum { KEY_PRESS, START_DRAG, STATE_CHANGE, + WHITE_SPACE_EVENT, TABLE_DRAG_BEGIN, TABLE_DRAG_END, @@ -956,6 +957,16 @@ et_canvas_realize (GtkWidget *canvas, ETable *e_table) set_header_width (e_table); } +static gint +white_item_event (GnomeCanvasItem *white_item, GdkEvent *event, ETable *e_table) +{ + int return_val = 0; + gtk_signal_emit (GTK_OBJECT (e_table), + et_signals [WHITE_SPACE_EVENT], + event, &return_val); + return return_val; +} + static void et_eti_leave_edit (ETable *et) { @@ -1090,12 +1101,15 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h "fill_color_gdk", >K_WIDGET(e_table->table_canvas)->style->base[GTK_STATE_NORMAL], NULL); - gtk_signal_connect ( - GTK_OBJECT(e_table->table_canvas), "realize", - GTK_SIGNAL_FUNC(et_canvas_realize), e_table); - gtk_signal_connect ( - GTK_OBJECT(gnome_canvas_root (e_table->table_canvas)), "event", - GTK_SIGNAL_FUNC(et_canvas_root_event), e_table); + gtk_signal_connect (GTK_OBJECT (e_table->white_item), "event", + GTK_SIGNAL_FUNC (white_item_event), e_table); + + gtk_signal_connect (GTK_OBJECT(e_table->table_canvas), "realize", + GTK_SIGNAL_FUNC(et_canvas_realize), e_table); + + gtk_signal_connect (GTK_OBJECT(gnome_canvas_root (e_table->table_canvas)), "event", + GTK_SIGNAL_FUNC(et_canvas_root_event), e_table); + e_table->canvas_vbox = gnome_canvas_item_new( gnome_canvas_root(e_table->table_canvas), e_canvas_vbox_get_type(), @@ -2921,6 +2935,7 @@ e_table_class_init (ETableClass *class) class->key_press = NULL; class->start_drag = et_real_start_drag; class->state_change = NULL; + class->white_space_event = NULL; class->table_drag_begin = NULL; class->table_drag_end = NULL; @@ -3004,6 +3019,14 @@ e_table_class_init (ETableClass *class) gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); + et_signals [WHITE_SPACE_EVENT] = + gtk_signal_new ("white_space_event", + GTK_RUN_LAST, + E_OBJECT_CLASS_TYPE (object_class), + GTK_SIGNAL_OFFSET (ETableClass, white_space_event), + gtk_marshal_INT__POINTER, + GTK_TYPE_INT, 1, GTK_TYPE_GDK_EVENT); + et_signals[TABLE_DRAG_BEGIN] = gtk_signal_new ("table_drag_begin", GTK_RUN_LAST, diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h index 067b3ab872..d288db73e0 100644 --- a/widgets/table/e-table.h +++ b/widgets/table/e-table.h @@ -168,6 +168,7 @@ typedef struct { gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); gint (*start_drag) (ETable *et, int row, int col, GdkEvent *event); void (*state_change) (ETable *et); + gint (*white_space_event) (ETable *et, GdkEvent *event); void (*set_scroll_adjustments) (ETable *table, GtkAdjustment *hadjustment, -- cgit