aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2001-10-13 05:52:49 +0800
committerChris Lahey <clahey@src.gnome.org>2001-10-13 05:52:49 +0800
commita5931319b6e19fdcbe18e077a2305cf41ccaea9e (patch)
tree7aa5a91b02815bf30928e52c2144cda58b26c06b /widgets/table
parent0ad57aa1b9f67bf68920cf6a8bbaad773f105108 (diff)
downloadgsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar.gz
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar.bz2
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar.lz
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar.xz
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.tar.zst
gsoc2013-evolution-a5931319b6e19fdcbe18e077a2305cf41ccaea9e.zip
Use new e_table_header_prioritized_column field.
2001-10-12 Christopher James Lahey <clahey@ximian.com> * e-table-click-to-add.c (set_initial_selection): Use new e_table_header_prioritized_column field. * e-table-header.c, e-table-header.h (e_table_header_prioritized_column): New function. Refactors the code from ETableClickToAdd to find the column with the highest priority. * e-table-selection-model.c, e-table-selection-model.h (model_changed_idle): Changed this function to use the e_table_header_prioritized_column function. Added an argument to set the "header" on this selection model. * e-table-utils.h: Indentation cleanup. * e-table.c (et_real_construct): Set the "header" argument on the selection model here. * e-table.h: #include <gal/e-table/e-table-sorter.h> svn path=/trunk/; revision=13633
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-table-click-to-add.c22
-rw-r--r--widgets/table/e-table-header.c23
-rw-r--r--widgets/table/e-table-header.h1
-rw-r--r--widgets/table/e-table-selection-model.c19
-rw-r--r--widgets/table/e-table-selection-model.h4
-rw-r--r--widgets/table/e-table-utils.h10
-rw-r--r--widgets/table/e-table.c1
-rw-r--r--widgets/table/e-table.h1
8 files changed, 54 insertions, 27 deletions
diff --git a/widgets/table/e-table-click-to-add.c b/widgets/table/e-table-click-to-add.c
index aef0d06564..81d3b49d50 100644
--- a/widgets/table/e-table-click-to-add.c
+++ b/widgets/table/e-table-click-to-add.c
@@ -284,25 +284,9 @@ item_key_press (ETableItem *item, int row, int col, GdkEvent *event, ETableClick
static void
set_initial_selection (ETableClickToAdd *etcta)
{
- int best_model_col = 0;
- int best_priority;
- int i;
- int count;
-
- count = e_table_header_count (etcta->eth);
- if (count == 0)
- return;
- best_priority = e_table_header_get_column (etcta->eth, 0)->priority;
- best_model_col = e_table_header_get_column (etcta->eth, 0)->col_idx;
- for (i = 1; i < count; i++) {
- int priority = e_table_header_get_column (etcta->eth, i)->priority;
- if (priority > best_priority) {
- best_priority = priority;
- best_model_col = e_table_header_get_column (etcta->eth, i)->col_idx;
- }
-
- }
- e_selection_model_do_something (E_SELECTION_MODEL(etcta->selection), 0, best_model_col, 0);
+ e_selection_model_do_something (E_SELECTION_MODEL(etcta->selection),
+ 0, e_table_header_prioritized_column (etcta->eth),
+ 0);
}
static void
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index e29730ac32..2eb7e9e9af 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -834,3 +834,26 @@ e_table_header_get_type (void)
return type;
}
+
+int
+e_table_header_prioritized_column (ETableHeader *eth)
+{
+ int best_model_col = 0;
+ int best_priority;
+ int i;
+ int count;
+
+ count = e_table_header_count (eth);
+ if (count == 0)
+ return -1;
+ best_priority = e_table_header_get_column (eth, 0)->priority;
+ best_model_col = e_table_header_get_column (eth, 0)->col_idx;
+ for (i = 1; i < count; i++) {
+ int priority = e_table_header_get_column (eth, i)->priority;
+ if (priority > best_priority) {
+ best_priority = priority;
+ best_model_col = e_table_header_get_column (eth, i)->col_idx;
+ }
+ }
+ return best_model_col;
+}
diff --git a/widgets/table/e-table-header.h b/widgets/table/e-table-header.h
index c186a8c48c..7d0315390e 100644
--- a/widgets/table/e-table-header.h
+++ b/widgets/table/e-table-header.h
@@ -84,6 +84,7 @@ void e_table_header_calc_widths (ETableHeader *eth);
GList *e_table_header_get_selected_indexes (ETableHeader *eth);
void e_table_header_update_horizontal (ETableHeader *eth);
+int e_table_header_prioritized_column (ETableHeader *eth);
#ifdef __cplusplus
diff --git a/widgets/table/e-table-selection-model.c b/widgets/table/e-table-selection-model.c
index 72ee3bacce..552b1557c6 100644
--- a/widgets/table/e-table-selection-model.c
+++ b/widgets/table/e-table-selection-model.c
@@ -8,10 +8,12 @@
* (C) 2000, 2001 Ximian, Inc.
*/
#include <config.h>
+#include "e-table-selection-model.h"
+
#include <string.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtksignal.h>
-#include "e-table-selection-model.h"
+
#include "gal/util/e-util.h"
#define ETSM_CLASS(e) ((ETableSelectionModelClass *)((GtkObject *)e)->klass)
@@ -25,6 +27,7 @@ static gint etsm_get_row_count (ESelectionModelArray *esm);
enum {
ARG_0,
ARG_MODEL,
+ ARG_HEADER,
};
static void
@@ -97,6 +100,12 @@ model_changed_idle(ETableSelectionModel *etsm)
if (etsm->cursor_id && !strcmp(etsm->cursor_id, save_id)) {
cursor_row = i;
cursor_col = e_selection_model_cursor_col(E_SELECTION_MODEL(etsm));
+ if (cursor_col == -1) {
+ if (etsm->eth) {
+ cursor_col = e_table_header_prioritized_column (etsm->eth);
+ } else
+ cursor_col = 0;
+ }
e_selection_model_change_cursor(E_SELECTION_MODEL(etsm), cursor_row, cursor_col);
g_free(etsm->cursor_id);
etsm->cursor_id = NULL;
@@ -232,6 +241,9 @@ etsm_get_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_MODEL:
GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(etsm->model);
break;
+ case ARG_HEADER:
+ GTK_VALUE_OBJECT (*arg) = (GtkObject *)etsm->eth;
+ break;
}
}
@@ -245,6 +257,9 @@ etsm_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
drop_model(etsm);
add_model(etsm, GTK_VALUE_OBJECT (*arg) ? E_TABLE_MODEL(GTK_VALUE_OBJECT (*arg)) : NULL);
break;
+ case ARG_HEADER:
+ etsm->eth = (ETableHeader *)GTK_VALUE_OBJECT (*arg);
+ break;
}
}
@@ -277,6 +292,8 @@ e_table_selection_model_class_init (ETableSelectionModelClass *klass)
gtk_object_add_arg_type ("ETableSelectionModel::model", GTK_TYPE_OBJECT,
GTK_ARG_READWRITE, ARG_MODEL);
+ gtk_object_add_arg_type ("ETableSelectionModel::header", E_TABLE_HEADER_TYPE,
+ GTK_ARG_READWRITE, ARG_HEADER);
}
E_MAKE_TYPE(e_table_selection_model, "ETableSelectionModel", ETableSelectionModel,
diff --git a/widgets/table/e-table-selection-model.h b/widgets/table/e-table-selection-model.h
index 74857efd61..9af0274faa 100644
--- a/widgets/table/e-table-selection-model.h
+++ b/widgets/table/e-table-selection-model.h
@@ -5,8 +5,7 @@
#include <gtk/gtkobject.h>
#include <gal/widgets/e-selection-model-array.h>
#include <gal/e-table/e-table-model.h>
-#include <gal/e-table/e-table-defines.h>
-#include <gal/e-table/e-table-sorter.h>
+#include <gal/e-table/e-table-header.h>
#ifdef __cplusplus
extern "C" {
@@ -22,6 +21,7 @@ typedef struct {
ESelectionModelArray base;
ETableModel *model;
+ ETableHeader *eth;
guint model_pre_change_id;
guint model_changed_id;
diff --git a/widgets/table/e-table-utils.h b/widgets/table/e-table-utils.h
index d78f1a5da2..d6d0fe201d 100644
--- a/widgets/table/e-table-utils.h
+++ b/widgets/table/e-table-utils.h
@@ -9,12 +9,12 @@
BEGIN_GNOME_DECLS
-ETableHeader *
-e_table_state_to_header (GtkWidget *widget, ETableHeader *full_header, ETableState *state);
+ETableHeader *e_table_state_to_header (GtkWidget *widget,
+ ETableHeader *full_header,
+ ETableState *state);
-ETableHeader *
-e_table_spec_to_full_header (ETableSpecification *spec,
- ETableExtras *ete);
+ETableHeader *e_table_spec_to_full_header (ETableSpecification *spec,
+ ETableExtras *ete);
END_GNOME_DECLS
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 7271348926..7cc6a215ef 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -1042,6 +1042,7 @@ et_real_construct (ETable *e_table, ETableModel *etm, ETableExtras *ete,
gtk_object_set (GTK_OBJECT (e_table->selection),
"model", etm,
"sorter", e_table->sorter,
+ "header", e_table->header,
NULL);
gtk_signal_connect(GTK_OBJECT(e_table->selection), "selection_changed",
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index ba41fbe5b8..d331dda053 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -15,6 +15,7 @@
#include <gal/e-table/e-table-specification.h>
#include <gal/widgets/e-printable.h>
#include <gal/e-table/e-table-state.h>
+#include <gal/e-table/e-table-sorter.h>
BEGIN_GNOME_DECLS