aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorDamon Chaplin <damon@ximian.com>2001-03-05 07:45:29 +0800
committerDamon Chaplin <damon@src.gnome.org>2001-03-05 07:45:29 +0800
commit49ba8c5c71000ccae7f21177e8e18081ac254a31 (patch)
treec33125edb85bd48480f1a59f511b7d4d034b423c /widgets/table
parentf3573fb2c91f02498dab4aa00e3b3ef191756025 (diff)
downloadgsoc2013-evolution-49ba8c5c71000ccae7f21177e8e18081ac254a31.tar.gz
gsoc2013-evolution-49ba8c5c71000ccae7f21177e8e18081ac254a31.tar.zst
gsoc2013-evolution-49ba8c5c71000ccae7f21177e8e18081ac254a31.zip
added "editable" Arg, to stop the user from editing the text. The user can
2001-03-04 Damon Chaplin <damon@ximian.com> * e-cell-text.c: added "editable" Arg, to stop the user from editing the text. The user can still select the text, though. The "editable" Arg is useful for ECellCombo where we want the user to select an item in the popup but not edit the field itself. * e-cell-combo.c: updated to select the matcing item before it pops up the list. svn path=/trunk/; revision=8544
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-cell-combo.c55
-rw-r--r--widgets/table/e-cell-popup.c2
-rw-r--r--widgets/table/e-cell-text.c21
-rw-r--r--widgets/table/e-cell-text.h1
4 files changed, 74 insertions, 5 deletions
diff --git a/widgets/table/e-cell-combo.c b/widgets/table/e-cell-combo.c
index 8aa689937a..87f9ce6c9e 100644
--- a/widgets/table/e-cell-combo.c
+++ b/widgets/table/e-cell-combo.c
@@ -70,6 +70,7 @@ static void e_cell_combo_destroy (GtkObject *object);
static gint e_cell_combo_do_popup (ECellPopup *ecp,
GdkEvent *event);
+static void e_cell_combo_select_matching_item (ECellCombo *ecc);
static void e_cell_combo_show_popup (ECellCombo *ecc);
static void e_cell_combo_get_popup_pos (ECellCombo *ecc,
gint *x,
@@ -225,6 +226,7 @@ e_cell_combo_do_popup (ECellPopup *ecp,
gint error_code;
e_cell_combo_show_popup (ecc);
+ e_cell_combo_select_matching_item (ecc);
if (event->type == GDK_BUTTON_PRESS) {
GTK_LIST (ecc->popup_list)->drag_selection = TRUE;
@@ -249,6 +251,48 @@ e_cell_combo_do_popup (ECellPopup *ecp,
static void
+e_cell_combo_select_matching_item (ECellCombo *ecc)
+{
+ ECellPopup *ecp = E_CELL_POPUP (ecc);
+ ECellView *ecv = (ECellView*) ecp->popup_cell_view;
+ ETableItem *eti = E_TABLE_ITEM (ecp->popup_cell_view->cell_view.e_table_item_view);
+ ETableCol *ecol;
+ GtkList *list;
+ GtkWidget *listitem, *label;
+ GList *elem;
+ gboolean found = FALSE;
+ char *cell_text, *list_item_text;
+
+ ecol = e_table_header_get_column (eti->header, ecp->popup_view_col);
+ cell_text = e_table_model_value_at (ecv->e_table_model,
+ ecol->col_idx, ecp->popup_row);
+
+ list = GTK_LIST (ecc->popup_list);
+ elem = list->children;
+ while (elem) {
+ listitem = GTK_WIDGET (elem->data);
+ label = GTK_BIN (listitem)->child;
+ gtk_label_get (GTK_LABEL (label), &list_item_text);
+
+ if (!strcmp (list_item_text, cell_text)) {
+ found = TRUE;
+ gtk_list_select_child (list, listitem);
+ gtk_widget_grab_focus (listitem);
+ break;
+ }
+
+ elem = elem->next;
+ }
+
+ if (!found) {
+ gtk_list_unselect_all (list);
+ if (list->children)
+ gtk_widget_grab_focus (GTK_WIDGET (list->children->data));
+ }
+}
+
+
+static void
e_cell_combo_show_popup (ECellCombo *ecc)
{
gint x, y, width, height, old_width, old_height;
@@ -273,8 +317,6 @@ e_cell_combo_show_popup (ECellCombo *ecc)
gdk_window_resize (ecc->popup_window->window, width, height);
gtk_widget_show (ecc->popup_window);
- gtk_widget_grab_focus (ecc->popup_list);
-
E_CELL_POPUP (ecc)->popup_shown = TRUE;
}
@@ -417,7 +459,7 @@ e_cell_combo_button_press (GtkWidget *popup_window,
{
GtkWidget *event_widget;
- g_print ("In e_cell_popup_button_press\n");
+ g_print ("In e_cell_combo_button_press\n");
event_widget = gtk_get_event_widget (event);
@@ -439,7 +481,12 @@ e_cell_combo_button_press (GtkWidget *popup_window,
E_CELL_POPUP (ecc)->popup_shown = FALSE;
- e_cell_combo_update_cell (ecc);
+ /* 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
+ list one item is selected even if it doesn't match the current text
+ in the cell. So if you click outside the popup (which is what has
+ happened here) it is better to not update the cell. */
+ /*e_cell_combo_update_cell (ecc);*/
e_cell_combo_restart_edit (ecc);
return TRUE;
diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c
index 2acc921d12..a4bba62555 100644
--- a/widgets/table/e-cell-popup.c
+++ b/widgets/table/e-cell-popup.c
@@ -351,7 +351,7 @@ ecp_event (ECellView *ecv, GdkEvent *event, int model_col, int view_col,
case GDK_KEY_PRESS:
if (event->key.state & GDK_MOD1_MASK
&& event->key.keyval == GDK_Down) {
- g_print ("## Enter key pressed\n");
+ g_print ("## Alt-Down pressed\n");
return e_cell_popup_do_popup (ecp_view, event);
}
g_print ("Key Press Event ECellPopup\n");
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 2db05f7320..969e17f84f 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -66,6 +66,7 @@ enum {
ARG_STRIKEOUT_COLUMN,
ARG_BOLD_COLUMN,
ARG_COLOR_COLUMN,
+ ARG_EDITABLE,
};
@@ -1324,6 +1325,10 @@ ect_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
text->color_column = GTK_VALUE_INT (*arg);
break;
+ case ARG_EDITABLE:
+ text->editable = GTK_VALUE_BOOL (*arg) ? TRUE : FALSE;
+ break;
+
default:
return;
}
@@ -1350,6 +1355,10 @@ ect_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_INT (*arg) = text->color_column;
break;
+ case ARG_EDITABLE:
+ GTK_VALUE_BOOL (*arg) = text->editable ? TRUE : FALSE;
+ break;
+
default:
arg->type = GTK_TYPE_INVALID;
break;
@@ -1392,6 +1401,8 @@ e_cell_text_class_init (GtkObjectClass *object_class)
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_BOLD_COLUMN);
gtk_object_add_arg_type ("ECellText::color_column",
GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_COLOR_COLUMN);
+ gtk_object_add_arg_type ("ECellText::editable",
+ GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_EDITABLE);
if (!clipboard_atom)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
@@ -1405,6 +1416,7 @@ e_cell_text_init (ECellText *ect)
ect->strikeout_column = -1;
ect->bold_column = -1;
ect->color_column = -1;
+ ect->editable = TRUE;
}
E_MAKE_TYPE(e_cell_text, "ECellText", ECellText, e_cell_text_class_init, e_cell_text_init, PARENT_TYPE);
@@ -1888,6 +1900,7 @@ e_cell_text_view_command (ETextEventProcessor *tep, ETextEventProcessorCommand *
CellEdit *edit = (CellEdit *) data;
CurrentCell *cell = CURRENT_CELL(edit);
ECellTextView *text_view = cell->text_view;
+ ECellText *ect = E_CELL_TEXT (text_view->cell_view.ecell);
gboolean change = FALSE;
gboolean redraw = FALSE;
@@ -1897,6 +1910,14 @@ e_cell_text_view_command (ETextEventProcessor *tep, ETextEventProcessorCommand *
font = text_view->font;
+ /* If the EText isn't editable, then ignore any commands that would
+ modify the text. */
+ if (!ect->editable && (command->action == E_TEP_DELETE
+ || command->action == E_TEP_INSERT
+ || command->action == E_TEP_PASTE
+ || command->action == E_TEP_GET_SELECTION))
+ return;
+
switch (command->action) {
case E_TEP_MOVE:
edit->selection_start = _get_position (text_view, command);
diff --git a/widgets/table/e-cell-text.h b/widgets/table/e-cell-text.h
index 78e9576a07..8ea9c509bd 100644
--- a/widgets/table/e-cell-text.h
+++ b/widgets/table/e-cell-text.h
@@ -49,6 +49,7 @@ typedef struct {
char *ellipsis; /* The ellipsis characters. NULL = "...". */
guint use_ellipsis : 1; /* Whether to use the ellipsis. */
+ guint editable : 1; /* Whether the text can be edited. */
int strikeout_column;
int bold_column;