From 61353c59dcb175818ce98d9b4c7706026edbf395 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Sun, 15 Apr 2001 13:03:26 +0000 Subject: Set "bold" argument on created tooltip. Adjusted position of displayed 2001-04-15 Christopher James Lahey * e-cell-text.c (ect_show_tooltip): Set "bold" argument on created tooltip. Adjusted position of displayed tooltip. * e-cell-tree.c (offset_of_node): Changed it so that this function handles knowing whether on not to indent non expandable first level nodes. This makes things more consistent. * e-table-item.c (eti_realize): Cleaned up the ETableItem code to properly hide tooltips when going off the screen. * e-table-tooltip.h: Added a visibility_count field to ETableTooltip. svn path=/trunk/; revision=9320 --- widgets/table/e-cell-text.c | 8 +++----- widgets/table/e-cell-tree.c | 24 ++++++++++++------------ widgets/table/e-table-item.c | 30 ++++++++++++++++-------------- widgets/table/e-table-tooltip.h | 1 + 4 files changed, 32 insertions(+), 31 deletions(-) (limited to 'widgets/table') diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 4be7439d4c..6a3fc87122 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -96,11 +96,7 @@ typedef struct _CellEdit CellEdit; typedef struct { ECellView cell_view; GdkGC *gc; -#if 0 - GdkFont *font; -#else EFont *font; -#endif GdkCursor *i_cursor; GdkBitmap *stipple; /* Stipple for text */ @@ -1167,6 +1163,7 @@ ect_show_tooltip (ECellView *ecell_view, double tooltip_y; GnomeCanvasItem *rect; double text_height; + ECellText *ect = E_CELL_TEXT(ecell_view->ecell); tooltip->timer = 0; @@ -1235,6 +1232,7 @@ ect_show_tooltip (ECellView *ecell_view, e_text_get_type (), "anchor", GTK_ANCHOR_NW, /* "font_gdk", text_view->font, */ + "bold", (gboolean) ect->bold_column >= 0 && e_table_model_value_at(ecell_view->e_table_model, ect->bold_column, row), "text", cell.text, "editable", FALSE, "clip_width", max_width, @@ -1278,7 +1276,7 @@ ect_show_tooltip (ECellView *ecell_view, GTK_SIGNAL_FUNC (tooltip_event), tooltip); gtk_widget_popup (tooltip->window, pixel_origin.x + tooltip->x, - pixel_origin.y + tooltip->y + 1); + pixel_origin.y + tooltip->y - 1); unref_lines (&cell); unbuild_current_cell (&cell); diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c index fb9bbb511f..af5997eed1 100644 --- a/widgets/table/e-cell-tree.c +++ b/widgets/table/e-cell-tree.c @@ -82,7 +82,15 @@ visible_depth_of_node (ETableModel *model, int row) static gint offset_of_node (ETableModel *table_model, int row) { - return (visible_depth_of_node(table_model, row) + 1) * INDENT_AMOUNT; + ETreeModel *tree_model = e_cell_tree_get_tree_model(table_model, row); + ETreePath path = e_cell_tree_get_node(table_model, row); + + if (visible_depth_of_node (table_model, row) > 0 || + e_tree_model_node_is_expandable(tree_model, path)) { + return (visible_depth_of_node(table_model, row) + 1) * INDENT_AMOUNT; + } else { + return 0; + } } /* @@ -179,7 +187,6 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, gboolean selected; int offset, subcell_offset; - gboolean expanded, expandable; selected = flags & E_CELL_SELECTED; @@ -191,14 +198,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, node = e_cell_tree_get_node (ecell_view->e_table_model, row); - expandable = e_tree_model_node_is_expandable (tree_model, node); - expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node); - - if (visible_depth_of_node (ecell_view->e_table_model, row) > 0 || expandable) { - offset = offset_of_node (ecell_view->e_table_model, row); - } else { - offset = 0; - } + offset = offset_of_node (ecell_view->e_table_model, row); subcell_offset = offset; node_image = e_tree_model_icon_at (tree_model, node); @@ -272,11 +272,11 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable, } /* now draw our icon if we're expandable */ - if (expandable) { + if (e_tree_model_node_is_expandable (tree_model, node)) { GdkPixbuf *image; int image_width, image_height; - image = (expanded + image = (e_tree_table_adapter_node_is_expanded (tree_table_adapter, node) ? E_CELL_TREE(tree_view->cell_view.ecell)->open_pixbuf : E_CELL_TREE(tree_view->cell_view.ecell)->closed_pixbuf); diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index 8997ccd610..144500fd47 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -1122,17 +1122,21 @@ eti_init (GnomeCanvasItem *item) static const char gray50_bits[] = { 0x02, 0x01, }; -#if 0 +#ifdef DO_TOOLTIPS static gint eti_visibility_notify(GtkWidget *widget, GdkEventVisibility *event, ETableItem *eti) { - if (eti->tooltip->window) { - gtk_widget_destroy (eti->tooltip->window); - eti->tooltip->window = NULL; + if (eti->tooltip->visibility_count > 0) { + if (eti->tooltip->window) { + gtk_widget_destroy (eti->tooltip->window); + eti->tooltip->window = NULL; + } } + eti->tooltip->visibility_count ++; + return FALSE; } #endif @@ -1143,9 +1147,6 @@ eti_realize (GnomeCanvasItem *item) ETableItem *eti = E_TABLE_ITEM (item); GtkWidget *canvas_widget = GTK_WIDGET (item->canvas); GdkWindow *window; -#if 0 - GdkEventMask mask; -#endif if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize) (*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->realize)(item); @@ -1175,12 +1176,10 @@ eti_realize (GnomeCanvasItem *item) gdk_gc_set_stipple (eti->focus_gc, eti->stipple); gdk_gc_set_fill (eti->focus_gc, GDK_OPAQUE_STIPPLED); -#if 0 - mask = gtk_widget_get_events(GTK_WIDGET(item->canvas)); - mask |= GDK_VISIBILITY_NOTIFY_MASK; - gtk_widget_set_events(GTK_WIDGET(item->canvas), mask); +#ifdef DO_TOOLTIPS + gtk_widget_add_events(gtk_widget_get_toplevel(GTK_WIDGET(item->canvas)), GDK_VISIBILITY_NOTIFY_MASK); - gtk_signal_connect(GTK_OBJECT(item->canvas), "visibility_notify_event", + gtk_signal_connect(GTK_OBJECT(gtk_widget_get_toplevel(GTK_WIDGET(item->canvas))), "visibility_notify_event", GTK_SIGNAL_FUNC(eti_visibility_notify), eti); #endif @@ -1603,13 +1602,14 @@ eti_cursor_move_down (ETableItem *eti) } #endif -#if 0 +#ifdef DO_TOOLTIPS static int _do_tooltip (ETableItem *eti) { ECellView *ecell_view; int x = 0, y = 0; int i; + int height_extra = eti->horizontal_draw_grid ? 1 : 0; if (eti->tooltip->window) { gtk_widget_destroy (eti->tooltip->window); @@ -1629,6 +1629,8 @@ _do_tooltip (ETableItem *eti) y += (ETI_ROW_HEIGHT (eti, i) + height_extra); eti->tooltip->y = y; eti->tooltip->row_height = ETI_ROW_HEIGHT (eti, i); + + eti->tooltip->visibility_count = 0; e_cell_show_tooltip (ecell_view, view_to_model_col (eti, eti->tooltip->col), @@ -1854,9 +1856,9 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) eti->tooltip->window = NULL; } +#ifdef DO_TOOLTIPS if (eti->tooltip->timer > 0) gtk_timeout_remove (eti->tooltip->timer); -#if 0 eti->tooltip->col = col; eti->tooltip->row = row; eti->tooltip->cx = e->motion.x; diff --git a/widgets/table/e-table-tooltip.h b/widgets/table/e-table-tooltip.h index 3a100af5ab..e9c8921933 100644 --- a/widgets/table/e-table-tooltip.h +++ b/widgets/table/e-table-tooltip.h @@ -13,6 +13,7 @@ typedef struct { int row_height; int x, y; int cx, cy; + int visibility_count; GnomeCanvasItem *eti; } ETableTooltip; -- cgit