aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-28 12:25:22 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-28 12:25:22 +0800
commitf91435fc0c0186d48079dc44d8626135eba92462 (patch)
treee8e3cac32823d3ff377dbebfa72351a0d2e8eb50 /widgets/table
parent0473e106f01671731351f69bdf29f3d438b75b05 (diff)
downloadgsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar.gz
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar.bz2
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar.lz
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar.xz
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.tar.zst
gsoc2013-evolution-f91435fc0c0186d48079dc44d8626135eba92462.zip
Added double click handling.
2000-05-28 Christopher James Lahey <clahey@helixcode.com> * e-table-group-container.c, e-table-group-leaf.c, e-table-group.c, e-table-group.h, e-table-item.c, e-table-item.h, e-table.c, e-table.h: Added double click handling. svn path=/trunk/; revision=3238
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table-group-container.c9
-rw-r--r--widgets/table/e-table-group-leaf.c9
-rw-r--r--widgets/table/e-table-group.c21
-rw-r--r--widgets/table/e-table-group.h8
-rw-r--r--widgets/table/e-table-item.c34
-rw-r--r--widgets/table/e-table-item.h3
-rw-r--r--widgets/table/e-table.c22
-rw-r--r--widgets/table/e-table.h1
8 files changed, 101 insertions, 6 deletions
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index 6c69d1765d..8b6859af8b 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -292,6 +292,13 @@ child_row_selection (ETableGroup *etg, int row, gboolean selected,
}
static void
+child_double_click (ETableGroup *etg, int row,
+ ETableGroupContainer *etgc)
+{
+ e_table_group_double_click (E_TABLE_GROUP (etgc), row);
+}
+
+static void
etgc_add (ETableGroup *etg, gint row)
{
ETableGroupContainer *etgc = E_TABLE_GROUP_CONTAINER (etg);
@@ -342,6 +349,8 @@ etgc_add (ETableGroup *etg, gint row)
NULL);
gtk_signal_connect (GTK_OBJECT (child), "row_selection",
GTK_SIGNAL_FUNC (child_row_selection), etgc);
+ gtk_signal_connect (GTK_OBJECT (child), "double_click",
+ GTK_SIGNAL_FUNC (child_double_click), etgc);
child_node->child = child;
child_node->key = e_table_model_duplicate_value (etg->model, etgc->ecol->col_idx, val);
child_node->count = 1;
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index 4f7f462ee8..674a70608a 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -91,6 +91,13 @@ etgl_row_selection (GtkObject *object, gint row, gboolean selected, ETableGroupL
}
static void
+etgl_double_click (GtkObject *object, gint row, ETableGroupLeaf *etgl)
+{
+ if (row < E_TABLE_SUBSET(etgl->subset)->n_map)
+ e_table_group_double_click (E_TABLE_GROUP(etgl), E_TABLE_SUBSET(etgl->subset)->map_table[row]);
+}
+
+static void
etgl_reflow (GnomeCanvasItem *item, gint flags)
{
ETableGroupLeaf *leaf = E_TABLE_GROUP_LEAF(item);
@@ -124,6 +131,8 @@ etgl_realize (GnomeCanvasItem *item)
gtk_signal_connect (GTK_OBJECT(etgl->item), "row_selection",
GTK_SIGNAL_FUNC(etgl_row_selection), etgl);
+ gtk_signal_connect (GTK_OBJECT(etgl->item), "double_click",
+ GTK_SIGNAL_FUNC(etgl_double_click), etgl);
e_canvas_item_request_reflow(item);
}
diff --git a/widgets/table/e-table-group.c b/widgets/table/e-table-group.c
index 5adc4f85b1..90893cfee2 100644
--- a/widgets/table/e-table-group.c
+++ b/widgets/table/e-table-group.c
@@ -29,6 +29,7 @@ static GnomeCanvasGroupClass *etg_parent_class;
enum {
ROW_SELECTION,
+ DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -202,6 +203,17 @@ e_table_group_row_selection (ETableGroup *e_table_group, gint row, gboolean sele
row, selected);
}
+void
+e_table_group_double_click (ETableGroup *e_table_group, gint row)
+{
+ g_return_if_fail (e_table_group != NULL);
+ g_return_if_fail (E_IS_TABLE_GROUP (e_table_group));
+
+ gtk_signal_emit (GTK_OBJECT (e_table_group),
+ etg_signals [DOUBLE_CLICK],
+ row);
+}
+
ETableHeader *
e_table_group_get_header (ETableGroup *etg)
{
@@ -251,6 +263,7 @@ etg_class_init (GtkObjectClass *object_class)
item_class->event = etg_event;
klass->row_selection = NULL;
+ klass->double_click = NULL;
klass->add = NULL;
klass->add_all = NULL;
@@ -271,6 +284,14 @@ etg_class_init (GtkObjectClass *object_class)
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+ etg_signals [DOUBLE_CLICK] =
+ gtk_signal_new ("double_click",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableGroupClass, double_click),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
gtk_object_class_add_signals (object_class, etg_signals, LAST_SIGNAL);
}
diff --git a/widgets/table/e-table-group.h b/widgets/table/e-table-group.h
index dd0771745b..8226ad055c 100644
--- a/widgets/table/e-table-group.h
+++ b/widgets/table/e-table-group.h
@@ -41,8 +41,12 @@ typedef struct {
typedef struct {
GnomeCanvasGroupClass parent_class;
- void (*row_selection) (ETableGroup *etg, int row, gboolean selected);
+ /* Signals */
+ void (*row_selection) (ETableGroup *etg, int row, gboolean selected);
+ void (*double_click) (ETableGroup *etg, int row);
+
+ /* Virtual functions. */
void (*add) (ETableGroup *etg, gint row);
void (*add_all) (ETableGroup *etg);
gboolean (*remove) (ETableGroup *etg, gint row);
@@ -88,6 +92,8 @@ void e_table_group_construct (GnomeCanvasGroup *parent,
void e_table_group_row_selection (ETableGroup *etg,
gint row,
gboolean selected);
+void e_table_group_double_click (ETableGroup *etg,
+ gint row);
GtkType e_table_group_get_type (void);
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index 05b722f27c..ad645a8c39 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -28,6 +28,7 @@ static GnomeCanvasItemClass *eti_parent_class;
enum {
ROW_SELECTION,
+ DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -1127,8 +1128,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
switch (e->type){
case GDK_BUTTON_PRESS:
- case GDK_BUTTON_RELEASE:
- case GDK_2BUTTON_PRESS: {
+ case GDK_BUTTON_RELEASE: {
double x1, y1;
int col, row;
@@ -1164,6 +1164,23 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e)
break;
}
+ case GDK_2BUTTON_PRESS: {
+ double x1, y1;
+ int col, row;
+
+ if (e->button.button == 5 ||
+ e->button.button == 4)
+ return FALSE;
+
+ gnome_canvas_item_w2i (item, &e->button.x, &e->button.y);
+
+ if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1))
+ return TRUE;
+
+ gtk_signal_emit (GTK_OBJECT (eti), eti_signals [DOUBLE_CLICK],
+ GPOINTER_TO_INT (eti->selection->data));
+ break;
+ }
case GDK_MOTION_NOTIFY: {
int col, row;
double x1, y1;
@@ -1317,7 +1334,8 @@ eti_class_init (GtkObjectClass *object_class)
item_class->point = eti_point;
item_class->event = eti_event;
- eti_class->row_selection = eti_row_selection;
+ eti_class->row_selection = eti_row_selection;
+ eti_class->double_click = NULL;
gtk_object_add_arg_type ("ETableItem::ETableHeader", GTK_TYPE_OBJECT,
GTK_ARG_WRITABLE, ARG_TABLE_HEADER);
@@ -1348,7 +1366,15 @@ eti_class_init (GtkObjectClass *object_class)
GTK_SIGNAL_OFFSET (ETableItemClass, row_selection),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
-
+
+ eti_signals [DOUBLE_CLICK] =
+ gtk_signal_new ("double_click",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableItemClass, double_click),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
+
gtk_object_class_add_signals (object_class, eti_signals, LAST_SIGNAL);
}
diff --git a/widgets/table/e-table-item.h b/widgets/table/e-table-item.h
index 9cdb04c2ff..1e9b6a46d6 100644
--- a/widgets/table/e-table-item.h
+++ b/widgets/table/e-table-item.h
@@ -79,7 +79,8 @@ typedef struct {
typedef struct {
GnomeCanvasItemClass parent_class;
- void (*row_selection) (ETableItem *eti, int row, gboolean selected);
+ void (*row_selection) (ETableItem *eti, int row, gboolean selected);
+ void (*double_click) (ETableItem *eti, int row);
} ETableItemClass;
GtkType e_table_item_get_type (void);
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 61f7f97918..f5abd29d5a 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -40,6 +40,7 @@ static GtkObjectClass *e_table_parent_class;
enum {
ROW_SELECTION,
+ DOUBLE_CLICK,
LAST_SIGNAL
};
@@ -188,6 +189,14 @@ group_row_selection (ETableGroup *etg, int row, gboolean selected, ETable *et)
row, selected);
}
+static void
+group_double_click (ETableGroup *etg, int row, ETable *et)
+{
+ gtk_signal_emit (GTK_OBJECT (et),
+ et_signals [DOUBLE_CLICK],
+ row);
+}
+
static gboolean
changed_idle (gpointer data)
{
@@ -209,6 +218,8 @@ changed_idle (gpointer data)
NULL);
gtk_signal_connect (GTK_OBJECT (et->group), "row_selection",
GTK_SIGNAL_FUNC (group_row_selection), et);
+ gtk_signal_connect (GTK_OBJECT (et->group), "double_click",
+ GTK_SIGNAL_FUNC (group_double_click), et);
e_table_fill_table (et, et->model);
gtk_object_set (GTK_OBJECT (et->group),
@@ -289,6 +300,8 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
gtk_signal_connect (GTK_OBJECT (e_table->group), "row_selection",
GTK_SIGNAL_FUNC(group_row_selection), e_table);
+ gtk_signal_connect (GTK_OBJECT (e_table->group), "double_click",
+ GTK_SIGNAL_FUNC(group_double_click), e_table);
e_table->table_model_change_id = gtk_signal_connect (
GTK_OBJECT (model), "model_changed",
@@ -695,6 +708,7 @@ e_table_class_init (GtkObjectClass *object_class)
object_class->get_arg = et_get_arg;
klass->row_selection = NULL;
+ klass->double_click = NULL;
et_signals [ROW_SELECTION] =
gtk_signal_new ("row_selection",
@@ -703,6 +717,14 @@ e_table_class_init (GtkObjectClass *object_class)
GTK_SIGNAL_OFFSET (ETableClass, row_selection),
gtk_marshal_NONE__INT_INT,
GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT);
+
+ et_signals [DOUBLE_CLICK] =
+ gtk_signal_new ("double_click",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (ETableClass, double_click),
+ gtk_marshal_NONE__INT,
+ GTK_TYPE_NONE, 1, GTK_TYPE_INT);
gtk_object_class_add_signals (object_class, et_signals, LAST_SIGNAL);
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index 053de782e5..25467843f3 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -58,6 +58,7 @@ typedef struct {
GtkTableClass parent_class;
void (*row_selection) (ETable *et, int row, gboolean selected);
+ void (*double_click) (ETable *et, int row);
} ETableClass;
GtkType e_table_get_type (void);