aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-cell-combo.c42
-rw-r--r--widgets/table/e-cell-popup.c37
-rw-r--r--widgets/table/e-cell-popup.h2
-rw-r--r--widgets/table/e-cell.h2
-rw-r--r--widgets/table/e-table-item.c33
5 files changed, 72 insertions, 44 deletions
diff --git a/widgets/table/e-cell-combo.c b/widgets/table/e-cell-combo.c
index ac6abe992e..d4e6b605d2 100644
--- a/widgets/table/e-cell-combo.c
+++ b/widgets/table/e-cell-combo.c
@@ -61,6 +61,8 @@
#include "e-cell-combo.h"
#include "e-cell-text.h"
+#define d(x)
+
/* The height to make the popup list if there aren't any items in it. */
#define E_CELL_COMBO_LIST_EMPTY_HEIGHT 15
@@ -74,10 +76,16 @@ static void e_cell_combo_init (ECellCombo *ecc);
static void e_cell_combo_destroy (GtkObject *object);
static gint e_cell_combo_do_popup (ECellPopup *ecp,
- GdkEvent *event);
+ GdkEvent *event,
+ int row,
+ int view_col);
static void e_cell_combo_select_matching_item (ECellCombo *ecc);
-static void e_cell_combo_show_popup (ECellCombo *ecc);
+static void e_cell_combo_show_popup (ECellCombo *ecc,
+ int row,
+ int view_col);
static void e_cell_combo_get_popup_pos (ECellCombo *ecc,
+ int row,
+ int view_col,
gint *x,
gint *y,
gint *height,
@@ -239,13 +247,15 @@ e_cell_combo_set_popdown_strings (ECellCombo *ecc,
static gint
e_cell_combo_do_popup (ECellPopup *ecp,
- GdkEvent *event)
+ GdkEvent *event,
+ int row,
+ int view_col)
{
ECellCombo *ecc = E_CELL_COMBO (ecp);
guint32 time;
gint error_code;
- e_cell_combo_show_popup (ecc);
+ e_cell_combo_show_popup (ecc, row, view_col);
e_cell_combo_select_matching_item (ecc);
if (event->type == GDK_BUTTON_PRESS) {
@@ -318,7 +328,7 @@ e_cell_combo_select_matching_item (ECellCombo *ecc)
static void
-e_cell_combo_show_popup (ECellCombo *ecc)
+e_cell_combo_show_popup (ECellCombo *ecc, int row, int view_col)
{
gint x, y, width, height, old_width, old_height;
@@ -326,7 +336,7 @@ e_cell_combo_show_popup (ECellCombo *ecc)
old_width = ecc->popup_window->allocation.width;
old_height = ecc->popup_window->allocation.height;
- e_cell_combo_get_popup_pos (ecc, &x, &y, &height, &width);
+ e_cell_combo_get_popup_pos (ecc, row, view_col, &x, &y, &height, &width);
/* workaround for gtk_scrolled_window_size_allocate bug */
if (old_width != width || old_height != height) {
@@ -341,12 +351,15 @@ e_cell_combo_show_popup (ECellCombo *ecc)
gtk_widget_show (ecc->popup_window);
E_CELL_POPUP (ecc)->popup_shown = TRUE;
+ d(g_print("%s: popup_shown = TRUE\n", __FUNCTION__));
}
/* Calculates the size and position of the popup window (like GtkCombo). */
static void
e_cell_combo_get_popup_pos (ECellCombo *ecc,
+ int row,
+ int view_col,
gint *x,
gint *y,
gint *height,
@@ -370,12 +383,12 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc,
gdk_window_get_origin (canvas->window, x, y);
- x1 = e_table_header_col_diff (eti->header, 0, eti->editing_col + 1);
- y1 = e_table_item_row_diff (eti, 0, eti->editing_row + 1);
- column_width = e_table_header_col_diff (eti->header, eti->editing_col,
- eti->editing_col + 1);
- row_height = e_table_item_row_diff (eti, eti->editing_row,
- eti->editing_row + 1);
+ x1 = e_table_header_col_diff (eti->header, 0, view_col + 1);
+ y1 = e_table_item_row_diff (eti, 0, row + 1);
+ column_width = e_table_header_col_diff (eti->header, view_col,
+ view_col + 1);
+ row_height = e_table_item_row_diff (eti, row,
+ row + 1);
gnome_canvas_item_i2w (GNOME_CANVAS_ITEM (eti), &x1, &y1);
gnome_canvas_world_to_window (GNOME_CANVAS (canvas),
@@ -477,8 +490,6 @@ e_cell_combo_get_popup_pos (ECellCombo *ecc,
-
-
/* This handles button press events in the popup window.
Note that since we have a pointer grab on this window, we also get button
press events for windows outside the application here, so we hide the popup
@@ -510,6 +521,7 @@ e_cell_combo_button_press (GtkWidget *popup_window,
gtk_widget_hide (ecc->popup_window);
E_CELL_POPUP (ecc)->popup_shown = FALSE;
+ d(g_print("%s: popup_shown = FALSE\n", __FUNCTION__));
/* We don't want to update the cell here. Since the list is in browse
mode there will always be one item selected, so when we popup the
@@ -550,6 +562,7 @@ e_cell_combo_button_release (GtkWidget *popup_window,
gtk_widget_hide (ecc->popup_window);
E_CELL_POPUP (ecc)->popup_shown = FALSE;
+ d(g_print("%s: popup_shown = FALSE\n", __FUNCTION__));
e_cell_combo_update_cell (ecc);
e_cell_combo_restart_edit (ecc);
@@ -578,6 +591,7 @@ e_cell_combo_key_press (GtkWidget *popup_window,
gtk_widget_hide (ecc->popup_window);
E_CELL_POPUP (ecc)->popup_shown = FALSE;
+ d(g_print("%s: popup_shown = FALSE\n", __FUNCTION__));
if (event->keyval != GDK_Escape)
e_cell_combo_update_cell (ecc);
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index e398dc0abc..48b445a661 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -106,7 +106,9 @@ static void ecp_show_tooltip (ECellView *ecv,
static char *ecp_get_bg_color (ECellView *ecell_view, int row);
static gint e_cell_popup_do_popup (ECellPopupView *ecp_view,
- GdkEvent *event);
+ GdkEvent *event,
+ int row,
+ int model_col);
static ECellClass *parent_class;
@@ -257,27 +259,22 @@ ecp_draw (ECellView *ecv, GdkDrawable *drawable,
int x1, int y1, int x2, int y2)
{
ECellPopup *ecp = E_CELL_POPUP (ecv->ecell);
- ETableItem *eti = E_TABLE_ITEM (ecv->e_table_item_view);
ECellPopupView *ecp_view = (ECellPopupView *) ecv;
GtkWidget *canvas = GTK_WIDGET (GNOME_CANVAS_ITEM (ecv->e_table_item_view)->canvas);
GtkShadowType shadow;
GdkRectangle rect;
gboolean show_popup_arrow = FALSE;
- /* Display the popup arrow if we are editing this cell, or the popup
+ /* Display the popup arrow if we are the cursor cell, or the popup
is shown for this cell. */
- if (eti->editing_col == view_col && eti->editing_row == row) {
+ if (flags & E_CELL_CURSOR) {
show_popup_arrow = TRUE;
ecp->popup_arrow_shown = TRUE;
-
} else if (ecp->popup_shown && ecp->popup_view_col == view_col
&& ecp->popup_row == row) {
show_popup_arrow = TRUE;
}
- if (eti->editing_col == -1)
- ecp->popup_arrow_shown = FALSE;
-
#if 0
g_print ("In ecp_draw row:%i col: %i %i,%i %i,%i Show Arrow:%i\n",
row, view_col, x1, y1, x2, y2, show_popup_arrow);
@@ -331,7 +328,7 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
switch (event->type) {
case GDK_BUTTON_PRESS:
- if (eti->editing_col == view_col && eti->editing_row == row
+ if (flags & E_CELL_CURSOR
&& ecp->popup_arrow_shown) {
width = e_table_header_col_diff (eti->header, view_col,
view_col + 1);
@@ -342,7 +339,7 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
/* FIXME: The event coords seem to be relative to the
text within the cell, so we have to add 4. */
if (event->button.x + 4 >= width - E_CELL_POPUP_ARROW_WIDTH) {
- return e_cell_popup_do_popup (ecp_view, event);
+ return e_cell_popup_do_popup (ecp_view, event, row, view_col);
}
}
break;
@@ -352,7 +349,7 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
if (event->key.state & GDK_MOD1_MASK
&& event->key.keyval == GDK_Down) {
g_print ("## Alt-Down pressed\n");
- return e_cell_popup_do_popup (ecp_view, event);
+ return e_cell_popup_do_popup (ecp_view, event, row, view_col);
}
g_print ("Key Press Event ECellPopup\n");
break;
@@ -384,17 +381,10 @@ static void *
ecp_enter_edit (ECellView *ecv, int model_col, int view_col, int row)
{
ECellPopupView *ecp_view = (ECellPopupView *) ecv;
- ECellPopup *ecp = E_CELL_POPUP (ecp_view->cell_view.ecell);
g_print ("In ecp_enter_edit model_col: %i view_col: %i row: %i\n",
model_col, view_col, row);
- if (ecp->popup_view_col != view_col || ecp->popup_row != row)
- ecp->popup_arrow_shown = FALSE;
-
- ecp->popup_view_col = view_col;
- ecp->popup_row = row;
-
return e_cell_enter_edit (ecp_view->child_view, model_col, view_col, row);
}
@@ -499,14 +489,19 @@ e_cell_popup_set_child (ECellPopup *ecp,
static gint
e_cell_popup_do_popup (ECellPopupView *ecp_view,
- GdkEvent *event)
+ GdkEvent *event,
+ int row,
+ int view_col)
{
ECellPopup *ecp = E_CELL_POPUP (ecp_view->cell_view.ecell);
- gint (*popup_func) (ECellPopup *ecp, GdkEvent *event);
+ gint (*popup_func) (ECellPopup *ecp, GdkEvent *event, int row, int view_col);
ecp->popup_cell_view = ecp_view;
popup_func = E_CELL_POPUP_CLASS (GTK_OBJECT (ecp)->klass)->popup;
- return popup_func ? popup_func (ecp, event) : FALSE;
+ ecp->popup_view_col = view_col;
+ ecp->popup_row = row;
+
+ return popup_func ? popup_func (ecp, event, row, view_col) : FALSE;
}
diff --git a/widgets/table/e-cell-popup.h b/widgets/table/e-cell-popup.h
index c2f19bad00..9deaac4a01 100644
--- a/widgets/table/e-cell-popup.h
+++ b/widgets/table/e-cell-popup.h
@@ -70,7 +70,7 @@ typedef struct {
ECellClass parent_class;
/* Virtual function for subclasses to override. */
- gint (*popup) (ECellPopup *ecp, GdkEvent *event);
+ gint (*popup) (ECellPopup *ecp, GdkEvent *event, int row, int view_col);
} ECellPopupClass;
diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h
index f992c372e4..b5277d657b 100644
--- a/widgets/table/e-cell.h
+++ b/widgets/table/e-cell.h
@@ -53,6 +53,8 @@ typedef enum {
E_CELL_FOCUSED = 1 << 3,
E_CELL_EDITING = 1 << 4,
+
+ E_CELL_CURSOR = 1 << 5,
} ECellFlags;
typedef enum {
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 1198de4d2e..988fb7e8fb 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -1711,6 +1711,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ETableCol *ecol = e_table_header_get_column (eti->header, col);
ECellView *ecell_view = eti->cell_views [col];
gboolean col_selected = selected;
+ gboolean cursor = FALSE;
ECellFlags flags;
gboolean free_background;
GdkColor *background;
@@ -1718,8 +1719,10 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
switch (eti->cursor_mode) {
case E_CURSOR_SIMPLE:
case E_CURSOR_SPREADSHEET:
- if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row(eti, row))
+ if (cursor_col == ecol->col_idx && cursor_row == view_to_model_row(eti, row)) {
col_selected = !col_selected;
+ cursor = TRUE;
+ }
break;
case E_CURSOR_LINE:
/* Nothing */
@@ -1737,6 +1740,8 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
flags = col_selected ? E_CELL_SELECTED : 0;
flags |= GTK_WIDGET_HAS_FOCUS(canvas) ? E_CELL_FOCUSED : 0;
+ flags |= cursor ? E_CELL_CURSOR : 0;
+
switch (ecol->justification) {
case GTK_JUSTIFY_LEFT:
flags |= E_CELL_JUSTIFY_LEFT;
@@ -2035,6 +2040,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
int col, row;
gint cursor_row, cursor_col;
gint new_cursor_row, new_cursor_col;
+ ECellFlags flags = 0;
d(g_print("%s: GDK_BUTTON_PRESS received, button %d\n", __FUNCTION__, e->button.button));
@@ -2063,7 +2069,18 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
button.x = x1;
button.y = y1;
- return_val = eti_e_cell_event (eti, ecell_view, (GdkEvent *) &button, button.time, view_to_model_col(eti, col), col, row, 0);
+ gtk_object_get(GTK_OBJECT(eti->selection),
+ "cursor_row", &cursor_row,
+ "cursor_col", &cursor_col,
+ NULL);
+
+ if (cursor_col == view_to_model_col (eti, col) && cursor_row == view_to_model_row(eti, row)) {
+ flags = E_CELL_CURSOR;
+ } else {
+ flags = 0;
+ }
+
+ return_val = eti_e_cell_event (eti, ecell_view, (GdkEvent *) &button, button.time, view_to_model_col(eti, col), col, row, flags);
if (return_val)
return TRUE;
@@ -2104,7 +2121,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
if (eti_editing (eti)) {
return_val = eti_e_cell_event (eti, ecell_view, (GdkEvent *) &button, button.time,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING | E_CELL_CURSOR);
if (return_val)
return TRUE;
}
@@ -2216,7 +2233,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
e->button.y = y1;
return_val = eti_e_cell_event (eti, ecell_view, e, e->button.time,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING | E_CELL_CURSOR);
}
break;
case 3:
@@ -2332,7 +2349,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
e->motion.y = y1;
return_val = eti_e_cell_event (eti, ecell_view, e, e->motion.time,
- view_to_model_col(eti, col), col, row, E_CELL_EDITING);
+ view_to_model_col(eti, col), col, row, E_CELL_EDITING | E_CELL_CURSOR);
}
break;
}
@@ -2456,7 +2473,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
ecell_view = eti->cell_views [eti->editing_col];
return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ eti->editing_col, eti->editing_row, E_CELL_EDITING | E_CELL_CURSOR);
#endif
}
gtk_signal_emit (GTK_OBJECT (eti), eti_signals [KEY_PRESS],
@@ -2509,7 +2526,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
ecell_view = eti->cell_views [eti->editing_col];
return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ eti->editing_col, eti->editing_row, E_CELL_EDITING | E_CELL_CURSOR);
if (!return_val)
e_selection_model_key_press(E_SELECTION_MODEL (eti->selection), (GdkEventKey *) e);
}
@@ -2537,7 +2554,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
ecell_view = eti->cell_views [eti->editing_col];
return_val = eti_e_cell_event (eti, ecell_view, e, e->key.time,
view_to_model_col(eti, eti->editing_col),
- eti->editing_col, eti->editing_row, E_CELL_EDITING);
+ eti->editing_col, eti->editing_row, E_CELL_EDITING | E_CELL_CURSOR);
}
break;
}