Remove unused tooltip support from ECanvas/ETable/EText.

This commit is contained in:
Matthew Barnes
2010-01-13 22:52:37 -05:00
parent 999074a9c6
commit 95072d1bc3
10 changed files with 1 additions and 471 deletions

View File

@ -36,10 +36,6 @@ static gint e_canvas_key (GtkWidget *widget,
static gint e_canvas_button (GtkWidget *widget,
GdkEventButton *event);
static gint e_canvas_visibility (GtkWidget *widget,
GdkEventVisibility *event,
ECanvas *canvas);
static gint e_canvas_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint e_canvas_focus_out (GtkWidget *widget,
@ -131,8 +127,6 @@ e_canvas_dispose (GObject *object)
canvas->im_context = NULL;
}
e_canvas_hide_tooltip(canvas);
if ((G_OBJECT_CLASS (e_canvas_parent_class))->dispose)
(*(G_OBJECT_CLASS (e_canvas_parent_class))->dispose) (object);
}
@ -534,18 +528,6 @@ e_canvas_button (GtkWidget *widget, GdkEventButton *event)
return retval;
}
/* Key event handler for the canvas */
static gint
e_canvas_visibility (GtkWidget *widget, GdkEventVisibility *event, ECanvas *canvas)
{
if (! canvas->visibility_first) {
e_canvas_hide_tooltip(canvas);
}
canvas->visibility_first = FALSE;
return FALSE;
}
/**
* e_canvas_item_grab_focus:
* @item: A canvas item.
@ -801,37 +783,6 @@ e_canvas_item_set_reflow_callback (GnomeCanvasItem *item, ECanvasItemReflowFunc
g_object_set_data(G_OBJECT(item), "ECanvasItem::reflow_callback", (gpointer) func);
}
void
e_canvas_popup_tooltip (ECanvas *canvas, GtkWidget *widget, gint x, gint y)
{
if (canvas->tooltip_window && canvas->tooltip_window != widget) {
e_canvas_hide_tooltip(canvas);
}
canvas->tooltip_window = widget;
canvas->visibility_first = TRUE;
if (canvas->toplevel == NULL) {
canvas->toplevel = gtk_widget_get_toplevel (GTK_WIDGET(canvas));
if (canvas->toplevel) {
gtk_widget_add_events(canvas->toplevel, GDK_VISIBILITY_NOTIFY_MASK);
g_object_ref (canvas->toplevel);
canvas->visibility_notify_id =
g_signal_connect (canvas->toplevel, "visibility_notify_event",
G_CALLBACK (e_canvas_visibility), canvas);
}
}
gtk_window_move (GTK_WINDOW (widget), x, y);
gtk_widget_show (widget);
}
void
e_canvas_hide_tooltip (ECanvas *canvas)
{
if (canvas->tooltip_window) {
gtk_widget_destroy (canvas->tooltip_window);
canvas->tooltip_window = NULL;
}
}
static gboolean
grab_cancelled_check (gpointer data)
{

View File

@ -83,8 +83,6 @@ struct _ECanvas
gint visibility_notify_id;
GtkWidget *toplevel;
guint visibility_first : 1;
/* Input context for dead key support */
GtkIMContext *im_context;
@ -124,13 +122,6 @@ void e_canvas_item_ungrab (ECanvas
GnomeCanvasItem *item,
guint32 etime);
/* Not implemented yet. */
void e_canvas_popup_tooltip (ECanvas *canvas,
GtkWidget *widget,
gint x,
gint y);
void e_canvas_hide_tooltip (ECanvas *canvas);
G_END_DECLS
#endif /* __E_CANVAS_H__ */

View File

@ -138,7 +138,6 @@ libetableinclude_HEADERS = \
e-table-state.h \
e-table-subset.h \
e-table-subset-variable.h \
e-table-tooltip.h \
e-table-utils.h \
e-table-without.h \
e-table.h \

View File

@ -58,7 +58,6 @@
#include "e-table.h"
#include "e-cell-text.h"
#include "e-table-item.h"
#include "e-table-tooltip.h"
#define d(x)
#define DO_SELECTION 1
#define VIEW_TO_CELL(view) E_CELL_TEXT (((ECellView *)view)->ecell)

View File

@ -26,7 +26,6 @@
#include <gtk/gtk.h>
#include <table/e-table-model.h>
#include <table/e-table-tooltip.h>
G_BEGIN_DECLS

View File

@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <table/e-table-header.h>
#include <libgnomecanvas/gnome-canvas.h>
G_BEGIN_DECLS

View File

@ -1413,26 +1413,6 @@ eti_dispose (GObject *object)
g_free (eti->height_cache);
eti->height_cache = NULL;
if (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas))
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
if (eti->tooltip) {
if (eti->tooltip->background)
gdk_color_free (eti->tooltip->background);
eti->tooltip->background = NULL;
if (eti->tooltip->foreground)
gdk_color_free (eti->tooltip->foreground);
eti->tooltip->foreground = NULL;
if (eti->tooltip->timer) {
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
g_free (eti->tooltip);
eti->tooltip = NULL;
}
if (G_OBJECT_CLASS (eti_parent_class)->dispose)
(*G_OBJECT_CLASS (eti_parent_class)->dispose) (object);
}
@ -1597,12 +1577,6 @@ eti_init (ETableItem *eti)
eti->in_key_press = 0;
eti->tooltip = g_new0 (ETableTooltip, 1);
eti->tooltip->timer = 0;
eti->tooltip->eti = GNOME_CANVAS_ITEM (eti);
eti->tooltip->background = NULL;
eti->tooltip->foreground = NULL;
eti->maybe_did_something = TRUE;
eti->grabbed_count = 0;
@ -1725,22 +1699,6 @@ eti_unrealize (GnomeCanvasItem *item)
eti->height_cache = NULL;
eti->height_cache_idle_count = 0;
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
if (eti->tooltip) {
if (eti->tooltip->background) {
gdk_color_free (eti->tooltip->background);
eti->tooltip->background = NULL;
}
if (eti->tooltip->foreground) {
gdk_color_free (eti->tooltip->foreground);
eti->tooltip->foreground = NULL;
}
if (eti->tooltip->timer) {
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
}
g_object_unref (eti->fill_gc);
eti->fill_gc = NULL;
g_object_unref (eti->grid_gc);
@ -2216,11 +2174,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
d(g_print("%s: GDK_BUTTON_PRESS received, button %d\n", __FUNCTION__, e->button.button));
if (eti->tooltip->timer) {
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
switch (e->button.button) {
case 1: /* Fall through. */
case 2:
@ -2357,11 +2310,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
}
}
if (eti->tooltip->timer) {
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
switch (e->button.button) {
case 1: /* Fall through. */
case 2:
@ -2515,8 +2463,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
"cursor_col", &cursor_col,
NULL);
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
flags = 0;
if (cursor_row == view_to_model_row(eti, row) && cursor_col == view_to_model_col(eti, col)) {
flags = E_CELL_EDITING | E_CELL_CURSOR;
@ -2546,12 +2492,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
"cursor_col", &cursor_col,
NULL);
if (eti->tooltip->timer) {
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
}
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(eti)->canvas));
if (cursor_row == -1 && cursor_col == -1)
return FALSE;
@ -2769,9 +2709,6 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
d(leave = TRUE);
case GDK_ENTER_NOTIFY:
d(g_print("%s: %s received\n", __FUNCTION__, leave ? "GDK_LEAVE_NOTIFY" : "GDK_ENTER_NOTIFY"));
if (eti->tooltip->timer)
g_source_remove (eti->tooltip->timer);
eti->tooltip->timer = 0;
if (eti->motion_row != -1 && eti->motion_col != -1)
return_val = eti_e_cell_event (eti, eti->cell_views [eti->motion_col],
e, e->crossing.time,

View File

@ -29,7 +29,6 @@
#include <table/e-table-model.h>
#include <table/e-table-header.h>
#include <table/e-table-defines.h>
#include <table/e-table-tooltip.h>
#include <misc/e-selection-model.h>
#include <misc/e-printable.h>
@ -159,11 +158,6 @@ typedef struct {
gint grabbed_col, grabbed_row;
gint grabbed_count;
/*
* Tooltip
*/
ETableTooltip *tooltip;
} ETableItem;
typedef struct {

View File

@ -1,43 +0,0 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with the program; if not, see <http://www.gnu.org/licenses/>
*
*
* Authors:
* Chris Lahey <clahey@ximian.com>
*
* Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
*
*/
#ifndef _E_TABLE_TOOLTIP_H_
#define _E_TABLE_TOOLTIP_H_
#include <libgnomecanvas/gnome-canvas.h>
G_BEGIN_DECLS
typedef struct {
gint timer;
gint col, row;
gint row_height;
gint x, y;
gint cx, cy;
GdkColor *foreground;
GdkColor *background;
GnomeCanvasItem *eti;
} ETableTooltip;
G_END_DECLS
#endif

View File

@ -195,10 +195,6 @@ e_text_dispose (GObject *object)
text = E_TEXT (object);
if (text->tooltip_owner)
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
text->tooltip_owner = 0;
if (text->model_changed_signal_id)
g_signal_handler_disconnect (text->model,
text->model_changed_signal_id);
@ -240,11 +236,6 @@ e_text_dispose (GObject *object)
text->timer = NULL;
}
if ( text->tooltip_timeout ) {
g_source_remove (text->tooltip_timeout);
text->tooltip_timeout = 0;
}
if ( text->dbl_timeout ) {
g_source_remove (text->dbl_timeout);
text->dbl_timeout = 0;
@ -1913,261 +1904,6 @@ _blink_scroll_timeout (gpointer data)
return TRUE;
}
static gboolean
tooltip_event(GtkWidget *tooltip, GdkEvent *event, EText *text)
{
gint ret_val = FALSE;
if (!text->model)
return FALSE;
switch (event->type) {
case GDK_LEAVE_NOTIFY:
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
break;
case GDK_BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
if (event->type == GDK_BUTTON_RELEASE) {
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
}
/* Forward events to the text item */
g_signal_emit_by_name (text, "event", event,
&ret_val);
if (!ret_val)
gtk_propagate_event (GTK_WIDGET(GNOME_CANVAS_ITEM(text)->canvas), event);
ret_val = TRUE;
default:
break;
}
return ret_val;
}
static gboolean
tooltip_ungrab (GtkWidget *tooltip, GdkEvent *event, EText *text)
{
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
gtk_propagate_event (GTK_WIDGET(GNOME_CANVAS_ITEM(text)->canvas), event);
return TRUE;
}
static void
tooltip_destroy(gpointer data, GObject *where_object_was)
{
EText *text = data;
text->tooltip_owner = FALSE;
g_object_unref (text);
}
static gboolean
_do_tooltip (gpointer data)
{
/* FIXME: need to sort out tooltip stuff. */
EText *text = E_TEXT (data);
GtkWidget *canvas;
gint i;
gint max_width;
gboolean cut_off;
double i2c[6];
ArtPoint origin = {0, 0};
ArtPoint pixel_origin;
gint canvas_x, canvas_y;
GnomeCanvas *text_canvas;
GnomeCanvasItem *tooltip_text;
double tooltip_width;
double tooltip_height;
double tooltip_x;
double tooltip_y;
#if 0
double x1, x2, y1, y2;
#endif
GnomeCanvasItem *rect;
GtkAdjustment *adjustment;
GtkWidget *tooltip_window; /* GtkWindow for displaying the tooltip */
GdkWindow *window;
text->tooltip_count = 0;
text_canvas = GNOME_CANVAS_ITEM (text)->canvas;
if (E_CANVAS(text_canvas)->tooltip_window || text->editing || !text->num_lines) {
text->tooltip_timeout = 0;
return FALSE;
}
cut_off = FALSE;
for ( i = 0; i < text->num_lines; i++ ) {
PangoLayoutLine *line = pango_layout_get_line (text->layout, i);
PangoRectangle pango_rect;
pango_layout_line_get_pixel_extents (line, &pango_rect, NULL);
if (pango_rect.width > text->clip_width) {
cut_off = TRUE;
break;
}
}
if ( ! cut_off ) {
text->tooltip_timeout = 0;
return FALSE;
}
gnome_canvas_item_i2c_affine(GNOME_CANVAS_ITEM(text), i2c);
art_affine_point (&pixel_origin, &origin, i2c);
window = gtk_widget_get_window (GTK_WIDGET (text_canvas));
gdk_window_get_origin (window, &canvas_x, &canvas_y);
pixel_origin.x += canvas_x;
pixel_origin.y += canvas_y;
adjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (text_canvas));
pixel_origin.x -= (gint) gtk_adjustment_get_value (adjustment);
adjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (text_canvas));
pixel_origin.y -= (gint) gtk_adjustment_get_value (adjustment);
tooltip_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_container_set_border_width (GTK_CONTAINER (tooltip_window), 1);
gtk_window_set_type_hint (GTK_WINDOW (tooltip_window), GDK_WINDOW_TYPE_HINT_TOOLTIP);
canvas = e_canvas_new ();
gtk_container_add (GTK_CONTAINER (tooltip_window), canvas);
/* Get the longest line length */
pango_layout_get_size (text->layout, &max_width, NULL);
rect = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
gnome_canvas_rect_get_type (),
"x1", (double) 0,
"y1", (double) 0,
"x2", (double) max_width + 4,
"y2", (double) text->height + 4,
NULL);
tooltip_text = gnome_canvas_item_new (gnome_canvas_root (GNOME_CANVAS (canvas)),
e_text_get_type (),
"anchor", GTK_ANCHOR_NW,
"bold", text->bold,
"strikeout", text->strikeout,
"text", text->text,
"editable", FALSE,
"clip_width", text->max_lines != 1 ? text->clip_width : max_width,
"clip_height", text->max_lines != 1 ? -1 : (double)text->height,
"clip", TRUE,
"line_wrap", text->line_wrap,
"justification", text->justification,
NULL);
if (text->draw_borders)
e_canvas_item_move_absolute(tooltip_text, 1 + BORDER_INDENT, 1 + BORDER_INDENT);
else
e_canvas_item_move_absolute(tooltip_text, 1, 1);
create_layout (E_TEXT (tooltip_text));
split_into_lines (E_TEXT(tooltip_text));
calc_height (E_TEXT(tooltip_text));
gnome_canvas_item_set (tooltip_text,
"clip_height", (double) E_TEXT(tooltip_text)->height,
"clip_width", (double) E_TEXT(tooltip_text)->width,
NULL);
tooltip_width = E_TEXT(tooltip_text)->width;
tooltip_height = E_TEXT(tooltip_text)->height;
tooltip_x = 0;
tooltip_y = 0;
switch (E_TEXT(tooltip_text)->justification) {
case GTK_JUSTIFY_CENTER:
tooltip_x = - tooltip_width / 2;
break;
case GTK_JUSTIFY_RIGHT:
tooltip_x = tooltip_width / 2;
break;
case GTK_JUSTIFY_FILL:
case GTK_JUSTIFY_LEFT:
tooltip_x = 0;
break;
}
switch (text->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_N:
case GTK_ANCHOR_NE:
break;
case GTK_ANCHOR_W:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_E:
tooltip_y -= tooltip_height / 2.0;
break;
case GTK_ANCHOR_SW:
case GTK_ANCHOR_S:
case GTK_ANCHOR_SE:
tooltip_y -= tooltip_height;
break;
}
switch (E_TEXT(tooltip_text)->anchor) {
case GTK_ANCHOR_NW:
case GTK_ANCHOR_W:
case GTK_ANCHOR_SW:
break;
case GTK_ANCHOR_N:
case GTK_ANCHOR_CENTER:
case GTK_ANCHOR_S:
tooltip_x -= tooltip_width / 2.0;
break;
case GTK_ANCHOR_NE:
case GTK_ANCHOR_E:
case GTK_ANCHOR_SE:
tooltip_x -= tooltip_width;
break;
}
gnome_canvas_item_set(rect,
"x2", (double) tooltip_width + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0),
"y2", (double) tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0),
NULL);
gtk_widget_show (canvas);
gtk_widget_realize (tooltip_window);
gtk_widget_set_size_request (tooltip_window,
tooltip_width + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0),
tooltip_height + 4 + (text->draw_borders ? BORDER_INDENT * 2 : 0));
gnome_canvas_set_scroll_region (GNOME_CANVAS(canvas), 0.0, 0.0,
tooltip_width + (text->draw_borders ? BORDER_INDENT * 2 : 0),
(double)tooltip_height + (text->draw_borders ? BORDER_INDENT * 2 : 0));
g_signal_connect (tooltip_window, "event",
G_CALLBACK(tooltip_event), text);
g_object_weak_ref (G_OBJECT (tooltip_window),
tooltip_destroy, text);
g_object_ref (text);
e_canvas_popup_tooltip (
E_CANVAS (text_canvas), tooltip_window,
pixel_origin.x - 2 + tooltip_x,
pixel_origin.y - 2 + tooltip_y);
window = gtk_widget_get_window (tooltip_window);
gdk_keyboard_grab (window, FALSE, GDK_CURRENT_TIME);
g_signal_connect (
tooltip_window, "key-press-event",
G_CALLBACK (tooltip_ungrab), text);
text->tooltip_owner = TRUE;
text->tooltip_timeout = 0;
return FALSE;
}
static void
start_editing (EText *text)
{
@ -2350,15 +2086,6 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
case GDK_KEY_RELEASE:
if (text->tooltip_count > 0)
text->tooltip_count --;
if ( text->tooltip_count == 0 && text->clip) {
if ( text->tooltip_timeout ) {
g_source_remove (text->tooltip_timeout);
text->tooltip_timeout = 0;
}
}
if (text->editing) {
GdkEventKey key;
gint ret;
@ -2400,11 +2127,6 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
break;
case GDK_BUTTON_PRESS: /* Fall Through */
case GDK_BUTTON_RELEASE:
if (text->tooltip_timeout) {
g_source_remove (text->tooltip_timeout);
text->tooltip_timeout = 0;
}
e_canvas_hide_tooltip (E_CANVAS(GNOME_CANVAS_ITEM(text)->canvas));
#if 0
if ((!text->editing)
&& text->editable
@ -2499,14 +2221,6 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
}
break;
case GDK_ENTER_NOTIFY:
{
if ( text->tooltip_count == 0 && text->clip) {
if (!text->tooltip_timeout)
text->tooltip_timeout = g_timeout_add_seconds (2, _do_tooltip, text);
}
text->tooltip_count ++;
}
text->pointer_in = TRUE;
if (text->editing || text->draw_borders) {
if ( text->default_cursor_shown ) {
@ -2516,15 +2230,6 @@ e_text_event (GnomeCanvasItem *item, GdkEvent *event)
}
break;
case GDK_LEAVE_NOTIFY:
if (text->tooltip_count > 0)
text->tooltip_count --;
if ( text->tooltip_count == 0 && text->clip) {
if ( text->tooltip_timeout ) {
g_source_remove (text->tooltip_timeout);
text->tooltip_timeout = 0;
}
}
text->pointer_in = FALSE;
if (text->editing || text->draw_borders) {
if ( ! text->default_cursor_shown ) {
@ -3896,9 +3601,6 @@ e_text_init (EText *text)
text->line_wrap = FALSE;
text->break_characters = NULL;
text->max_lines = -1;
text->tooltip_timeout = 0;
text->tooltip_count = 0;
text->tooltip_owner = FALSE;
text->dbl_timeout = 0;
text->tpl_timeout = 0;