aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-05-24 02:38:21 +0800
committerChris Lahey <clahey@src.gnome.org>2000-05-24 02:38:21 +0800
commit46700211974920a7a79c82d2ad4420934d3e7266 (patch)
tree2e6296566cae9b9bd05707835e679de933aea3a9 /widgets
parent713e609ecb0df1373edbca1f1a05dd838416599a (diff)
downloadgsoc2013-evolution-46700211974920a7a79c82d2ad4420934d3e7266.tar.gz
gsoc2013-evolution-46700211974920a7a79c82d2ad4420934d3e7266.tar.zst
gsoc2013-evolution-46700211974920a7a79c82d2ad4420934d3e7266.zip
Added right click menus to the table header items.
2000-05-23 Christopher James Lahey <clahey@helixcode.com> * e-table-header-item.c: Added right click menus to the table header items. * e-table-sort-info.c: Fixed a small bug. svn path=/trunk/; revision=3184
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table/ChangeLog7
-rw-r--r--widgets/e-table/e-table-header-item.c196
-rw-r--r--widgets/e-table/e-table-sorted-variable.c5
-rw-r--r--widgets/table/e-table-header-item.c196
-rw-r--r--widgets/table/e-table-sorted-variable.c5
5 files changed, 371 insertions, 38 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index cdfcf78621..f712cf65d6 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,5 +1,12 @@
2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+ * e-table-header-item.c: Added right click menus to the table
+ header items.
+
+ * e-table-sort-info.c: Fixed a small bug.
+
+2000-05-23 Christopher James Lahey <clahey@helixcode.com>
+
* e-table.c: Make scrollbar arrow buttons work.
2000-05-19 Christopher James Lahey <clahey@helixcode.com>
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index ef0976502a..436b2c8283 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -923,21 +923,183 @@ ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event)
g_hash_table_destroy (arrows);
}
+typedef struct {
+ ETableHeaderItem *ethi;
+ int col;
+} EthiHeaderInfo;
+
static void
-ethi_button_pressed (ETableHeaderItem *ethi, GdkEventButton *event)
+ethi_popup_sort_ascending(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ int length;
+ int i;
+ int found = FALSE;
+ ETableHeaderItem *ethi = info->ethi;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ length = e_table_sort_info_grouping_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_grouping_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 1;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 1;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ ETableSortColumn column = { model_col, 1 };
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ if (length == 0)
+ length++;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column);
+ }
+}
+
+static void
+ethi_popup_sort_descending(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ int length;
+ int i;
+ int found = FALSE;
+ ETableHeaderItem *ethi = info->ethi;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ length = e_table_sort_info_grouping_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_grouping_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 0;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 0;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ ETableSortColumn column = { model_col, 0 };
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ if (length == 0)
+ length++;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column);
+ }
+}
+
+static void
+ethi_popup_group_field(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ ETableHeaderItem *ethi = info->ethi;
+ ETableSortColumn column;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ column.column = model_col;
+ column.ascending = 1;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, 0, column);
+ e_table_sort_info_grouping_truncate(ethi->sort_info, 1);
+}
+
+static void
+ethi_popup_group_box(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_remove_column(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_field_chooser(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_alignment(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_best_fit(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_format_columns(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info)
{
- gtk_signal_emit (GTK_OBJECT (ethi),
- ethi_signals [BUTTON_PRESSED], event);
}
static EPopupMenu ethi_context_menu [] = {
+ { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 0},
+ { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 0},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 0},
+ { "Group By This Field", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), 0},
+ { "Group By Box", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_box), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Remove This Column", NULL, GTK_SIGNAL_FUNC(ethi_popup_remove_column), 1},
+ { "Field Chooser", NULL, GTK_SIGNAL_FUNC(ethi_popup_field_chooser), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Alignment", NULL, GTK_SIGNAL_FUNC(ethi_popup_alignment), 1},
+ { "Best Fit", NULL, GTK_SIGNAL_FUNC(ethi_popup_best_fit), 1},
+ { "Format Columns...", NULL, GTK_SIGNAL_FUNC(ethi_popup_format_columns), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Customize Current View...", NULL, GTK_SIGNAL_FUNC(ethi_popup_customize_view), 1},
{ NULL, NULL, NULL, 0 }
};
static void
ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event)
{
- e_popup_menu_run (ethi_context_menu, event, 0, ethi);
+ EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1);
+ info->ethi = ethi;
+ info->col = ethi_find_col_by_x (ethi, event->x);
+ e_popup_menu_run (ethi_context_menu, event, 1, info);
+}
+
+static void
+ethi_button_pressed (ETableHeaderItem *ethi, GdkEventButton *event)
+{
+ gtk_signal_emit (GTK_OBJECT (ethi),
+ ethi_signals [BUTTON_PRESSED], event);
}
/*
@@ -993,18 +1155,18 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
case GDK_BUTTON_PRESS:
convert (canvas, e->button.x, e->button.y, &x, &y);
- if (is_pointer_on_division (ethi, x, &start, &col)){
+ if (is_pointer_on_division (ethi, x, &start, &col) && e->button.button == 1){
ETableCol *ecol;
-
- /*
- * Record the important bits.
- *
- * By setting resize_pos to a non -1 value,
- * we know that we are being resized (used in the
- * other event handlers).
- */
+
+ /*
+ * Record the important bits.
+ *
+ * By setting resize_pos to a non -1 value,
+ * we know that we are being resized (used in the
+ * other event handlers).
+ */
ecol = e_table_header_get_column (ethi->eth, col);
-
+
if (!ecol->resizeable)
break;
ethi->resize_col = col;
@@ -1021,11 +1183,11 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
ethi_button_pressed (ethi, &e->button);
}
break;
-
+
case GDK_2BUTTON_PRESS:
if (!resizing)
break;
-
+
if (e->button.button != 1)
break;
break;
@@ -1034,7 +1196,7 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
gboolean needs_ungrab = FALSE;
was_maybe_drag = ethi->maybe_drag;
-
+
ethi->maybe_drag = FALSE;
if (ethi->resize_col != -1){
diff --git a/widgets/e-table/e-table-sorted-variable.c b/widgets/e-table/e-table-sorted-variable.c
index acfb33deb7..0d2ecce800 100644
--- a/widgets/e-table/e-table-sorted-variable.c
+++ b/widgets/e-table/e-table-sorted-variable.c
@@ -250,6 +250,7 @@ etsv_sort(ETableSortedVariable *etsv)
ETableSubset *etss = E_TABLE_SUBSET(etsv);
static int reentering = 0;
int rows = E_TABLE_SUBSET(etsv)->n_map;
+ int total_rows = e_table_model_row_count(E_TABLE_SUBSET(etsv)->source);
int i;
int j;
int cols;
@@ -260,7 +261,7 @@ etsv_sort(ETableSortedVariable *etsv)
cols_closure = cols;
etsv_closure = etsv;
printf ("starting\n");
- vals_closure = g_new(void *, rows * cols);
+ vals_closure = g_new(void *, total_rows * cols);
ascending_closure = g_new(int, cols);
compare_closure = g_new(GCompareFunc, cols);
for (j = 0; j < cols; j++) {
@@ -277,7 +278,7 @@ etsv_sort(ETableSortedVariable *etsv)
gtk_main_iteration();
}
#endif
- vals_closure[i * cols + j] = e_table_model_value_at (etss->source, col->col_idx, i);
+ vals_closure[E_TABLE_SUBSET(etsv)->map_table[i] * cols + j] = e_table_model_value_at (etss->source, col->col_idx, E_TABLE_SUBSET(etsv)->map_table[i]);
}
compare_closure[j] = col->compare;
ascending_closure[j] = column.ascending;
diff --git a/widgets/table/e-table-header-item.c b/widgets/table/e-table-header-item.c
index ef0976502a..436b2c8283 100644
--- a/widgets/table/e-table-header-item.c
+++ b/widgets/table/e-table-header-item.c
@@ -923,21 +923,183 @@ ethi_start_drag (ETableHeaderItem *ethi, GdkEvent *event)
g_hash_table_destroy (arrows);
}
+typedef struct {
+ ETableHeaderItem *ethi;
+ int col;
+} EthiHeaderInfo;
+
static void
-ethi_button_pressed (ETableHeaderItem *ethi, GdkEventButton *event)
+ethi_popup_sort_ascending(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ int length;
+ int i;
+ int found = FALSE;
+ ETableHeaderItem *ethi = info->ethi;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ length = e_table_sort_info_grouping_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_grouping_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 1;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 1;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ ETableSortColumn column = { model_col, 1 };
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ if (length == 0)
+ length++;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column);
+ }
+}
+
+static void
+ethi_popup_sort_descending(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ int length;
+ int i;
+ int found = FALSE;
+ ETableHeaderItem *ethi = info->ethi;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ length = e_table_sort_info_grouping_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_grouping_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 0;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ if (!found) {
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ for (i = 0; i < length; i++) {
+ ETableSortColumn column = e_table_sort_info_sorting_get_nth(ethi->sort_info, i);
+ if (model_col == column.column){
+ column.ascending = 0;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, i, column);
+ found = 1;
+ break;
+ }
+ }
+ }
+ if (!found) {
+ ETableSortColumn column = { model_col, 0 };
+ length = e_table_sort_info_sorting_get_count(ethi->sort_info);
+ if (length == 0)
+ length++;
+ e_table_sort_info_sorting_set_nth(ethi->sort_info, length - 1, column);
+ }
+}
+
+static void
+ethi_popup_group_field(GtkWidget *widget, EthiHeaderInfo *info)
+{
+ ETableCol *col;
+ int model_col;
+ ETableHeaderItem *ethi = info->ethi;
+ ETableSortColumn column;
+
+ col = e_table_header_get_column (ethi->eth, info->col);
+ model_col = col->col_idx;
+
+ column.column = model_col;
+ column.ascending = 1;
+ e_table_sort_info_grouping_set_nth(ethi->sort_info, 0, column);
+ e_table_sort_info_grouping_truncate(ethi->sort_info, 1);
+}
+
+static void
+ethi_popup_group_box(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_remove_column(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_field_chooser(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_alignment(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_best_fit(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_format_columns(GtkWidget *widget, EthiHeaderInfo *info)
+{
+}
+
+static void
+ethi_popup_customize_view(GtkWidget *widget, EthiHeaderInfo *info)
{
- gtk_signal_emit (GTK_OBJECT (ethi),
- ethi_signals [BUTTON_PRESSED], event);
}
static EPopupMenu ethi_context_menu [] = {
+ { "Sort Ascending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_ascending), 0},
+ { "Sort Descending", NULL, GTK_SIGNAL_FUNC(ethi_popup_sort_descending), 0},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 0},
+ { "Group By This Field", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_field), 0},
+ { "Group By Box", NULL, GTK_SIGNAL_FUNC(ethi_popup_group_box), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Remove This Column", NULL, GTK_SIGNAL_FUNC(ethi_popup_remove_column), 1},
+ { "Field Chooser", NULL, GTK_SIGNAL_FUNC(ethi_popup_field_chooser), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Alignment", NULL, GTK_SIGNAL_FUNC(ethi_popup_alignment), 1},
+ { "Best Fit", NULL, GTK_SIGNAL_FUNC(ethi_popup_best_fit), 1},
+ { "Format Columns...", NULL, GTK_SIGNAL_FUNC(ethi_popup_format_columns), 1},
+ { "", NULL, GTK_SIGNAL_FUNC(NULL), 1},
+ { "Customize Current View...", NULL, GTK_SIGNAL_FUNC(ethi_popup_customize_view), 1},
{ NULL, NULL, NULL, 0 }
};
static void
ethi_header_context_menu (ETableHeaderItem *ethi, GdkEventButton *event)
{
- e_popup_menu_run (ethi_context_menu, event, 0, ethi);
+ EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1);
+ info->ethi = ethi;
+ info->col = ethi_find_col_by_x (ethi, event->x);
+ e_popup_menu_run (ethi_context_menu, event, 1, info);
+}
+
+static void
+ethi_button_pressed (ETableHeaderItem *ethi, GdkEventButton *event)
+{
+ gtk_signal_emit (GTK_OBJECT (ethi),
+ ethi_signals [BUTTON_PRESSED], event);
}
/*
@@ -993,18 +1155,18 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
case GDK_BUTTON_PRESS:
convert (canvas, e->button.x, e->button.y, &x, &y);
- if (is_pointer_on_division (ethi, x, &start, &col)){
+ if (is_pointer_on_division (ethi, x, &start, &col) && e->button.button == 1){
ETableCol *ecol;
-
- /*
- * Record the important bits.
- *
- * By setting resize_pos to a non -1 value,
- * we know that we are being resized (used in the
- * other event handlers).
- */
+
+ /*
+ * Record the important bits.
+ *
+ * By setting resize_pos to a non -1 value,
+ * we know that we are being resized (used in the
+ * other event handlers).
+ */
ecol = e_table_header_get_column (ethi->eth, col);
-
+
if (!ecol->resizeable)
break;
ethi->resize_col = col;
@@ -1021,11 +1183,11 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
ethi_button_pressed (ethi, &e->button);
}
break;
-
+
case GDK_2BUTTON_PRESS:
if (!resizing)
break;
-
+
if (e->button.button != 1)
break;
break;
@@ -1034,7 +1196,7 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
gboolean needs_ungrab = FALSE;
was_maybe_drag = ethi->maybe_drag;
-
+
ethi->maybe_drag = FALSE;
if (ethi->resize_col != -1){
diff --git a/widgets/table/e-table-sorted-variable.c b/widgets/table/e-table-sorted-variable.c
index acfb33deb7..0d2ecce800 100644
--- a/widgets/table/e-table-sorted-variable.c
+++ b/widgets/table/e-table-sorted-variable.c
@@ -250,6 +250,7 @@ etsv_sort(ETableSortedVariable *etsv)
ETableSubset *etss = E_TABLE_SUBSET(etsv);
static int reentering = 0;
int rows = E_TABLE_SUBSET(etsv)->n_map;
+ int total_rows = e_table_model_row_count(E_TABLE_SUBSET(etsv)->source);
int i;
int j;
int cols;
@@ -260,7 +261,7 @@ etsv_sort(ETableSortedVariable *etsv)
cols_closure = cols;
etsv_closure = etsv;
printf ("starting\n");
- vals_closure = g_new(void *, rows * cols);
+ vals_closure = g_new(void *, total_rows * cols);
ascending_closure = g_new(int, cols);
compare_closure = g_new(GCompareFunc, cols);
for (j = 0; j < cols; j++) {
@@ -277,7 +278,7 @@ etsv_sort(ETableSortedVariable *etsv)
gtk_main_iteration();
}
#endif
- vals_closure[i * cols + j] = e_table_model_value_at (etss->source, col->col_idx, i);
+ vals_closure[E_TABLE_SUBSET(etsv)->map_table[i] * cols + j] = e_table_model_value_at (etss->source, col->col_idx, E_TABLE_SUBSET(etsv)->map_table[i]);
}
compare_closure[j] = col->compare;
ascending_closure[j] = column.ascending;