aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-selection-model.c536
-rw-r--r--widgets/misc/e-selection-model.h233
-rw-r--r--widgets/table/e-table-group-container.c2
-rw-r--r--widgets/table/e-table-group-leaf.c2
-rw-r--r--widgets/table/e-table-item.c2
-rw-r--r--widgets/table/e-tree-selection-model.c3
6 files changed, 460 insertions, 318 deletions
diff --git a/widgets/misc/e-selection-model.c b/widgets/misc/e-selection-model.c
index 882306df9e..d27ff9b122 100644
--- a/widgets/misc/e-selection-model.c
+++ b/widgets/misc/e-selection-model.c
@@ -39,7 +39,7 @@ enum {
LAST_SIGNAL
};
-static guint e_selection_model_signals [LAST_SIGNAL] = { 0, };
+static guint signals[LAST_SIGNAL] = { 0, };
enum {
PROP_0,
@@ -75,61 +75,61 @@ esm_dispose (GObject *object)
drop_sorter(esm);
- if (G_OBJECT_CLASS (e_selection_model_parent_class)->dispose)
- (* G_OBJECT_CLASS (e_selection_model_parent_class)->dispose) (object);
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (e_selection_model_parent_class)->dispose (object);
}
static void
esm_get_property (GObject *object,
- guint prop_id,
+ guint property_id,
GValue *value,
GParamSpec *pspec)
{
ESelectionModel *esm = E_SELECTION_MODEL (object);
- switch (prop_id) {
- case PROP_SORTER:
- g_value_set_object (value, esm->sorter);
- break;
+ switch (property_id) {
+ case PROP_SORTER:
+ g_value_set_object (value, esm->sorter);
+ break;
- case PROP_SELECTION_MODE:
- g_value_set_int (value, esm->mode);
- break;
+ case PROP_SELECTION_MODE:
+ g_value_set_int (value, esm->mode);
+ break;
- case PROP_CURSOR_MODE:
- g_value_set_int (value, esm->cursor_mode);
- break;
+ case PROP_CURSOR_MODE:
+ g_value_set_int (value, esm->cursor_mode);
+ break;
}
}
static void
esm_set_property (GObject *object,
- guint prop_id,
+ guint property_id,
const GValue *value,
GParamSpec *pspec)
{
ESelectionModel *esm = E_SELECTION_MODEL (object);
- switch (prop_id) {
- case PROP_SORTER:
- drop_sorter(esm);
- add_sorter (
- esm, g_value_get_object (value) ?
- E_SORTER (g_value_get_object (value)) : NULL);
- break;
+ switch (property_id) {
+ case PROP_SORTER:
+ drop_sorter(esm);
+ add_sorter (
+ esm, g_value_get_object (value) ?
+ E_SORTER (g_value_get_object (value)) : NULL);
+ break;
- case PROP_SELECTION_MODE:
- esm->mode = g_value_get_int (value);
- if (esm->mode == GTK_SELECTION_SINGLE) {
- gint cursor_row = e_selection_model_cursor_row(esm);
- gint cursor_col = e_selection_model_cursor_col(esm);
- e_selection_model_do_something(esm, cursor_row, cursor_col, 0);
- }
- break;
+ case PROP_SELECTION_MODE:
+ esm->mode = g_value_get_int (value);
+ if (esm->mode == GTK_SELECTION_SINGLE) {
+ gint cursor_row = e_selection_model_cursor_row(esm);
+ gint cursor_col = e_selection_model_cursor_col(esm);
+ e_selection_model_do_something(esm, cursor_row, cursor_col, 0);
+ }
+ break;
- case PROP_CURSOR_MODE:
- esm->cursor_mode = g_value_get_int (value);
- break;
+ case PROP_CURSOR_MODE:
+ esm->cursor_mode = g_value_get_int (value);
+ break;
}
}
@@ -142,97 +142,89 @@ e_selection_model_init (ESelectionModel *selection)
}
static void
-e_selection_model_class_init (ESelectionModelClass *klass)
+e_selection_model_class_init (ESelectionModelClass *class)
{
GObjectClass *object_class;
- object_class = G_OBJECT_CLASS(klass);
-
+ object_class = G_OBJECT_CLASS(class);
object_class->dispose = esm_dispose;
object_class->get_property = esm_get_property;
object_class->set_property = esm_set_property;
- e_selection_model_signals [CURSOR_CHANGED] =
- g_signal_new ("cursor_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, cursor_changed),
- NULL, NULL,
- e_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
- e_selection_model_signals [CURSOR_ACTIVATED] =
- g_signal_new ("cursor_activated",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, cursor_activated),
- NULL, NULL,
- e_marshal_NONE__INT_INT,
- G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
-
- e_selection_model_signals [SELECTION_CHANGED] =
- g_signal_new ("selection_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, selection_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
- e_selection_model_signals [SELECTION_ROW_CHANGED] =
- g_signal_new ("selection_row_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (ESelectionModelClass, selection_row_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__INT,
- G_TYPE_NONE, 1, G_TYPE_INT);
-
- klass->cursor_changed = NULL;
- klass->cursor_activated = NULL;
- klass->selection_changed = NULL;
- klass->selection_row_changed = NULL;
-
- klass->is_row_selected = NULL;
- klass->foreach = NULL;
- klass->clear = NULL;
- klass->selected_count = NULL;
- klass->select_all = NULL;
- klass->invert_selection = NULL;
- klass->row_count = NULL;
-
- klass->change_one_row = NULL;
- klass->change_cursor = NULL;
- klass->cursor_row = NULL;
- klass->cursor_col = NULL;
-
- klass->select_single_row = NULL;
- klass->toggle_single_row = NULL;
- klass->move_selection_end = NULL;
- klass->set_selection_end = NULL;
-
- g_object_class_install_property (object_class, PROP_SORTER,
- g_param_spec_object ("sorter",
- "Sorter",
- NULL,
- E_SORTER_TYPE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class, PROP_SELECTION_MODE,
- g_param_spec_int ("selection_mode",
- "Selection Mode",
- NULL,
- GTK_SELECTION_NONE, GTK_SELECTION_MULTIPLE,
- GTK_SELECTION_SINGLE,
- G_PARAM_READWRITE));
-
- g_object_class_install_property (object_class, PROP_CURSOR_MODE,
- g_param_spec_int ("cursor_mode",
- "Cursor Mode",
- NULL,
- E_CURSOR_LINE, E_CURSOR_SPREADSHEET,
- E_CURSOR_LINE,
- G_PARAM_READWRITE));
+ signals[CURSOR_CHANGED] = g_signal_new (
+ "cursor_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESelectionModelClass, cursor_changed),
+ NULL, NULL,
+ e_marshal_NONE__INT_INT,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
+ signals[CURSOR_ACTIVATED] = g_signal_new (
+ "cursor_activated",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESelectionModelClass, cursor_activated),
+ NULL, NULL,
+ e_marshal_NONE__INT_INT,
+ G_TYPE_NONE, 2,
+ G_TYPE_INT,
+ G_TYPE_INT);
+
+ signals[SELECTION_CHANGED] = g_signal_new (
+ "selection_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESelectionModelClass, selection_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ signals[SELECTION_ROW_CHANGED] = g_signal_new (
+ "selection_row_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (ESelectionModelClass, selection_row_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1,
+ G_TYPE_INT);
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SORTER,
+ g_param_spec_object (
+ "sorter",
+ "Sorter",
+ NULL,
+ E_SORTER_TYPE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_SELECTION_MODE,
+ g_param_spec_int (
+ "selection_mode",
+ "Selection Mode",
+ NULL,
+ GTK_SELECTION_NONE,
+ GTK_SELECTION_MULTIPLE,
+ GTK_SELECTION_SINGLE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_CURSOR_MODE,
+ g_param_spec_int (
+ "cursor_mode",
+ "Cursor Mode",
+ NULL,
+ E_CURSOR_LINE,
+ E_CURSOR_SPREADSHEET,
+ E_CURSOR_LINE,
+ G_PARAM_READWRITE));
}
/**
@@ -246,12 +238,16 @@ e_selection_model_class_init (ESelectionModelClass *klass)
*/
gboolean
e_selection_model_is_row_selected (ESelectionModel *selection,
- gint n)
+ gint n)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->is_row_selected)
- return E_SELECTION_MODEL_GET_CLASS(selection)->is_row_selected (selection, n);
- else
- return FALSE;
+ ESelectionModelClass *class;
+
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_val_if_fail (class->is_row_selected != NULL, FALSE);
+
+ return class->is_row_selected (selection, n);
}
/**
@@ -264,12 +260,19 @@ e_selection_model_is_row_selected (ESelectionModel *selection,
* selected row, passing closure as the closure.
*/
void
-e_selection_model_foreach (ESelectionModel *selection,
- EForeachFunc callback,
- gpointer closure)
+e_selection_model_foreach (ESelectionModel *selection,
+ EForeachFunc callback,
+ gpointer closure)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->foreach)
- E_SELECTION_MODEL_GET_CLASS(selection)->foreach (selection, callback, closure);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+ g_return_if_fail (callback != NULL);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->foreach != NULL);
+
+ class->foreach (selection, callback, closure);
}
/**
@@ -279,10 +282,16 @@ e_selection_model_foreach (ESelectionModel *selection,
* This routine clears the selection to no rows selected.
*/
void
-e_selection_model_clear(ESelectionModel *selection)
+e_selection_model_clear (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->clear)
- E_SELECTION_MODEL_GET_CLASS(selection)->clear (selection);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->clear != NULL);
+
+ class->clear (selection);
}
/**
@@ -296,10 +305,14 @@ e_selection_model_clear(ESelectionModel *selection)
gint
e_selection_model_selected_count (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->selected_count)
- return E_SELECTION_MODEL_GET_CLASS(selection)->selected_count (selection);
- else
- return 0;
+ ESelectionModelClass *class;
+
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), 0);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_val_if_fail (class->selected_count != NULL, 0);
+
+ return class->selected_count (selection);
}
/**
@@ -312,8 +325,14 @@ e_selection_model_selected_count (ESelectionModel *selection)
void
e_selection_model_select_all (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->select_all)
- E_SELECTION_MODEL_GET_CLASS(selection)->select_all (selection);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->select_all != NULL);
+
+ class->select_all (selection);
}
/**
@@ -326,77 +345,139 @@ e_selection_model_select_all (ESelectionModel *selection)
void
e_selection_model_invert_selection (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->invert_selection)
- E_SELECTION_MODEL_GET_CLASS(selection)->invert_selection (selection);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->invert_selection != NULL);
+
+ class->invert_selection (selection);
}
gint
e_selection_model_row_count (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->row_count)
- return E_SELECTION_MODEL_GET_CLASS(selection)->row_count (selection);
- else
- return 0;
+ ESelectionModelClass *class;
+
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), 0);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_val_if_fail (class->row_count != NULL, 0);
+
+ return class->row_count (selection);
}
void
-e_selection_model_change_one_row(ESelectionModel *selection, gint row, gboolean grow)
+e_selection_model_change_one_row (ESelectionModel *selection,
+ gint row,
+ gboolean grow)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->change_one_row)
- E_SELECTION_MODEL_GET_CLASS(selection)->change_one_row (selection, row, grow);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->change_one_row != NULL);
+
+ return class->change_one_row (selection, row, grow);
}
void
-e_selection_model_change_cursor (ESelectionModel *selection, gint row, gint col)
+e_selection_model_change_cursor (ESelectionModel *selection,
+ gint row,
+ gint col)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->change_cursor)
- E_SELECTION_MODEL_GET_CLASS(selection)->change_cursor (selection, row, col);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->change_cursor != NULL);
+
+ class->change_cursor (selection, row, col);
}
gint
e_selection_model_cursor_row (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->cursor_row)
- return E_SELECTION_MODEL_GET_CLASS(selection)->cursor_row (selection);
- else
- return -1;
+ ESelectionModelClass *class;
+
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), -1);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_val_if_fail (class->cursor_row != NULL, -1);
+
+ return class->cursor_row (selection);
}
gint
e_selection_model_cursor_col (ESelectionModel *selection)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->cursor_col)
- return E_SELECTION_MODEL_GET_CLASS(selection)->cursor_col (selection);
- else
- return -1;
+ ESelectionModelClass *class;
+
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), -1);
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_val_if_fail (class->cursor_col != NULL, -1);
+
+ return class->cursor_col (selection);
}
void
-e_selection_model_select_single_row (ESelectionModel *selection, gint row)
+e_selection_model_select_single_row (ESelectionModel *selection,
+ gint row)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->select_single_row)
- E_SELECTION_MODEL_GET_CLASS(selection)->select_single_row (selection, row);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->select_single_row != NULL);
+
+ class->select_single_row (selection, row);
}
void
-e_selection_model_toggle_single_row (ESelectionModel *selection, gint row)
+e_selection_model_toggle_single_row (ESelectionModel *selection,
+ gint row)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->toggle_single_row)
- E_SELECTION_MODEL_GET_CLASS(selection)->toggle_single_row (selection, row);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->toggle_single_row != NULL);
+
+ class->toggle_single_row (selection, row);
}
void
-e_selection_model_move_selection_end (ESelectionModel *selection, gint row)
+e_selection_model_move_selection_end (ESelectionModel *selection,
+ gint row)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->move_selection_end)
- E_SELECTION_MODEL_GET_CLASS(selection)->move_selection_end (selection, row);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->move_selection_end != NULL);
+
+ class->move_selection_end (selection, row);
}
void
-e_selection_model_set_selection_end (ESelectionModel *selection, gint row)
+e_selection_model_set_selection_end (ESelectionModel *selection,
+ gint row)
{
- if (E_SELECTION_MODEL_GET_CLASS(selection)->set_selection_end)
- E_SELECTION_MODEL_GET_CLASS(selection)->set_selection_end (selection, row);
+ ESelectionModelClass *class;
+
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ class = E_SELECTION_MODEL_GET_CLASS (selection);
+ g_return_if_fail (class->set_selection_end != NULL);
+
+ class->set_selection_end (selection, row);
}
/**
@@ -411,14 +492,16 @@ e_selection_model_set_selection_end (ESelectionModel *selection, gint row)
*/
void
e_selection_model_do_something (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
+ guint row,
+ guint col,
+ GdkModifierType state)
{
gint shift_p = state & GDK_SHIFT_MASK;
gint ctrl_p = state & GDK_CONTROL_MASK;
gint row_count;
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
selection->old_selection = -1;
if (row == -1 && col != -1)
@@ -450,10 +533,10 @@ e_selection_model_do_something (ESelectionModel *selection,
}
e_selection_model_change_cursor(selection, row, col);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_CHANGED], 0,
+ signals[CURSOR_CHANGED], 0,
row, col);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_ACTIVATED], 0,
+ signals[CURSOR_ACTIVATED], 0,
row, col);
}
}
@@ -472,17 +555,19 @@ e_selection_model_do_something (ESelectionModel *selection,
* they don't want it to change.
*/
gboolean
-e_selection_model_maybe_do_something (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
+e_selection_model_maybe_do_something (ESelectionModel *selection,
+ guint row,
+ guint col,
+ GdkModifierType state)
{
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
+
selection->old_selection = -1;
if (e_selection_model_is_row_selected(selection, row)) {
e_selection_model_change_cursor(selection, row, col);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_CHANGED], 0,
+ signals[CURSOR_CHANGED], 0,
row, col);
return FALSE;
} else {
@@ -493,37 +578,50 @@ e_selection_model_maybe_do_something (ESelectionModel *selection,
void
e_selection_model_right_click_down (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
+ guint row,
+ guint col,
+ GdkModifierType state)
{
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
if (selection->mode == GTK_SELECTION_SINGLE) {
- selection->old_selection = e_selection_model_cursor_row (selection);
+ selection->old_selection =
+ e_selection_model_cursor_row (selection);
e_selection_model_select_single_row (selection, row);
} else {
- e_selection_model_maybe_do_something (selection, row, col, state);
+ e_selection_model_maybe_do_something (
+ selection, row, col, state);
}
}
void
e_selection_model_right_click_up (ESelectionModel *selection)
{
- if (selection->mode == GTK_SELECTION_SINGLE && selection->old_selection != -1) {
- e_selection_model_select_single_row (selection, selection->old_selection);
- }
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ if (selection->mode != GTK_SELECTION_SINGLE)
+ return;
+
+ if (selection->old_selection == -1)
+ return;
+
+ e_selection_model_select_single_row (
+ selection, selection->old_selection);
}
void
e_selection_model_select_as_key_press (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state)
+ guint row,
+ guint col,
+ GdkModifierType state)
{
gint cursor_activated = TRUE;
gint shift_p = state & GDK_SHIFT_MASK;
gint ctrl_p = state & GDK_CONTROL_MASK;
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
selection->old_selection = -1;
switch (selection->mode) {
@@ -546,19 +644,19 @@ e_selection_model_select_as_key_press (ESelectionModel *selection,
if (row != -1) {
e_selection_model_change_cursor(selection, row, col);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_CHANGED], 0,
+ signals[CURSOR_CHANGED], 0,
row, col);
if (cursor_activated)
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_ACTIVATED], 0,
+ signals[CURSOR_ACTIVATED], 0,
row, col);
}
}
static gint
move_selection (ESelectionModel *selection,
- gboolean up,
- GdkModifierType state)
+ gboolean up,
+ GdkModifierType state)
{
gint row = e_selection_model_cursor_row(selection);
gint col = e_selection_model_cursor_col(selection);
@@ -593,10 +691,13 @@ move_selection (ESelectionModel *selection,
*
* Returns: %TRUE if the #ESelectionModel used the key.
*/
-gint
-e_selection_model_key_press (ESelectionModel *selection,
- GdkEventKey *key)
+gboolean
+e_selection_model_key_press (ESelectionModel *selection,
+ GdkEventKey *key)
{
+ g_return_val_if_fail (E_IS_SELECTION_MODEL (selection), FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
selection->old_selection = -1;
switch (key->keyval) {
@@ -616,7 +717,7 @@ e_selection_model_key_press (ESelectionModel *selection,
e_selection_model_toggle_single_row (selection, row);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_ACTIVATED], 0,
+ signals[CURSOR_ACTIVATED], 0,
row, col);
return TRUE;
}
@@ -628,7 +729,7 @@ e_selection_model_key_press (ESelectionModel *selection,
gint col = e_selection_model_cursor_col(selection);
e_selection_model_select_single_row (selection, row);
g_signal_emit(selection,
- e_selection_model_signals[CURSOR_ACTIVATED], 0,
+ signals[CURSOR_ACTIVATED], 0,
row, col);
return TRUE;
}
@@ -660,37 +761,38 @@ e_selection_model_key_press (ESelectionModel *selection,
}
void
-e_selection_model_cursor_changed (ESelectionModel *selection,
- gint row,
- gint col)
+e_selection_model_cursor_changed (ESelectionModel *selection,
+ gint row,
+ gint col)
{
- g_signal_emit(selection,
- e_selection_model_signals[CURSOR_CHANGED], 0,
- row, col);
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ g_signal_emit (selection, signals[CURSOR_CHANGED], 0, row, col);
}
void
-e_selection_model_cursor_activated (ESelectionModel *selection,
- gint row,
- gint col)
+e_selection_model_cursor_activated (ESelectionModel *selection,
+ gint row,
+ gint col)
{
- g_signal_emit(selection,
- e_selection_model_signals[CURSOR_ACTIVATED], 0,
- row, col);
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ g_signal_emit (selection, signals[CURSOR_ACTIVATED], 0, row, col);
}
void
-e_selection_model_selection_changed (ESelectionModel *selection)
+e_selection_model_selection_changed (ESelectionModel *selection)
{
- g_signal_emit(selection,
- e_selection_model_signals[SELECTION_CHANGED], 0);
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ g_signal_emit (selection, signals[SELECTION_CHANGED], 0);
}
void
e_selection_model_selection_row_changed (ESelectionModel *selection,
- gint row)
+ gint row)
{
- g_signal_emit(selection,
- e_selection_model_signals[SELECTION_ROW_CHANGED], 0,
- row);
+ g_return_if_fail (E_IS_SELECTION_MODEL (selection));
+
+ g_signal_emit (selection, signals[SELECTION_ROW_CHANGED], 0, row);
}
diff --git a/widgets/misc/e-selection-model.h b/widgets/misc/e-selection-model.h
index fb62b1fc9f..a96b6e8be6 100644
--- a/widgets/misc/e-selection-model.h
+++ b/widgets/misc/e-selection-model.h
@@ -21,20 +21,32 @@
*
*/
-#ifndef _E_SELECTION_MODEL_H_
-#define _E_SELECTION_MODEL_H_
+#ifndef E_SELECTION_MODEL_H
+#define E_SELECTION_MODEL_H
#include <gtk/gtk.h>
#include <e-util/e-sorter.h>
-G_BEGIN_DECLS
+/* Standard GObject macros */
+#define E_TYPE_SELECTION_MODEL \
+ (e_selection_model_get_type ())
+#define E_SELECTION_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), E_TYPE_SELECTION_MODEL, ESelectionModel))
+#define E_SELECTION_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_CAST \
+ ((cls), E_TYPE_SELECTION_MODEL, ESelectionModelClass))
+#define E_IS_SELECTION_MODEL(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), E_TYPE_SELECTION_MODEL))
+#define E_IS_SELECTION_MODEL_CLASS(cls) \
+ (G_TYPE_CHECK_CLASS_TYPE \
+ ((cls), E_TYPE_SELECTION_MODEL))
+#define E_SELECTION_MODEL_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), E_TYPE_SELECTION_MODEL, ESelectionModelClass))
-#define E_SELECTION_MODEL_TYPE (e_selection_model_get_type ())
-#define E_SELECTION_MODEL(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), E_SELECTION_MODEL_TYPE, ESelectionModel))
-#define E_SELECTION_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), E_SELECTION_MODEL_TYPE, ESelectionModelClass))
-#define E_IS_SELECTION_MODEL(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_SELECTION_MODEL_TYPE))
-#define E_IS_SELECTION_MODEL_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_SELECTION_MODEL_TYPE))
-#define E_SELECTION_MODEL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), E_SELECTION_MODEL_TYPE, ESelectionModelClass))
+G_BEGIN_DECLS
#ifndef _E_FOREACH_FUNC_H_
#define _E_FOREACH_FUNC_H_
@@ -42,6 +54,9 @@ typedef void (*EForeachFunc) (gint model_row,
gpointer closure);
#endif
+typedef struct _ESelectionModel ESelectionModel;
+typedef struct _ESelectionModelClass ESelectionModelClass;
+
/* list selection modes */
typedef enum {
E_CURSOR_LINE,
@@ -49,8 +64,8 @@ typedef enum {
E_CURSOR_SPREADSHEET
} ECursorMode;
-typedef struct {
- GObject base;
+struct _ESelectionModel {
+ GObject parent;
ESorter *sorter;
@@ -58,105 +73,129 @@ typedef struct {
ECursorMode cursor_mode;
gint old_selection;
-} ESelectionModel;
+};
-typedef struct {
+struct _ESelectionModelClass {
GObjectClass parent_class;
/* Virtual methods */
- gboolean (*is_row_selected) (ESelectionModel *esm, gint row);
- void (*foreach) (ESelectionModel *esm, EForeachFunc callback, gpointer closure);
- void (*clear) (ESelectionModel *esm);
- gint (*selected_count) (ESelectionModel *esm);
- void (*select_all) (ESelectionModel *esm);
- void (*invert_selection) (ESelectionModel *esm);
- gint (*row_count) (ESelectionModel *esm);
+ gboolean (*is_row_selected) (ESelectionModel *esm,
+ gint row);
+ void (*foreach) (ESelectionModel *esm,
+ EForeachFunc callback,
+ gpointer closure);
+ void (*clear) (ESelectionModel *esm);
+ gint (*selected_count) (ESelectionModel *esm);
+ void (*select_all) (ESelectionModel *esm);
+ void (*invert_selection) (ESelectionModel *esm);
+ gint (*row_count) (ESelectionModel *esm);
/* Protected virtual methods. */
- void (*change_one_row) (ESelectionModel *esm, gint row, gboolean on);
- void (*change_cursor) (ESelectionModel *esm, gint row, gint col);
- gint (*cursor_row) (ESelectionModel *esm);
- gint (*cursor_col) (ESelectionModel *esm);
-
- void (*select_single_row) (ESelectionModel *selection, gint row);
- void (*toggle_single_row) (ESelectionModel *selection, gint row);
- void (*move_selection_end) (ESelectionModel *selection, gint row);
- void (*set_selection_end) (ESelectionModel *selection, gint row);
-
- /*
- * Signals
- */
-
- void (*cursor_changed) (ESelectionModel *esm, gint row, gint col);
- void (*cursor_activated) (ESelectionModel *esm, gint row, gint col);
- void (*selection_row_changed) (ESelectionModel *esm, gint row);
- void (*selection_changed) (ESelectionModel *esm);
-
-} ESelectionModelClass;
-
-GType e_selection_model_get_type (void);
-void e_selection_model_do_something (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
-gboolean e_selection_model_maybe_do_something (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
-void e_selection_model_right_click_down (ESelectionModel *selection,
- guint row,
- guint col,
- GdkModifierType state);
-void e_selection_model_right_click_up (ESelectionModel *selection);
-gint e_selection_model_key_press (ESelectionModel *esm,
- GdkEventKey *key);
-void e_selection_model_select_as_key_press (ESelectionModel *esm,
- guint row,
- guint col,
- GdkModifierType state);
+ void (*change_one_row) (ESelectionModel *esm,
+ gint row,
+ gboolean on);
+ void (*change_cursor) (ESelectionModel *esm,
+ gint row,
+ gint col);
+ gint (*cursor_row) (ESelectionModel *esm);
+ gint (*cursor_col) (ESelectionModel *esm);
+
+ void (*select_single_row) (ESelectionModel *selection,
+ gint row);
+ void (*toggle_single_row) (ESelectionModel *selection,
+ gint row);
+ void (*move_selection_end) (ESelectionModel *selection,
+ gint row);
+ void (*set_selection_end) (ESelectionModel *selection,
+ gint row);
+
+ /* Signals */
+ void (*cursor_changed) (ESelectionModel *esm,
+ gint row,
+ gint col);
+ void (*cursor_activated) (ESelectionModel *esm,
+ gint row,
+ gint col);
+ void (*selection_row_changed)(ESelectionModel *esm,
+ gint row);
+ void (*selection_changed) (ESelectionModel *esm);
+};
+
+GType e_selection_model_get_type (void);
+void e_selection_model_do_something (ESelectionModel *esm,
+ guint row,
+ guint col,
+ GdkModifierType state);
+gboolean e_selection_model_maybe_do_something
+ (ESelectionModel *esm,
+ guint row,
+ guint col,
+ GdkModifierType state);
+void e_selection_model_right_click_down
+ (ESelectionModel *selection,
+ guint row,
+ guint col,
+ GdkModifierType state);
+void e_selection_model_right_click_up(ESelectionModel *selection);
+gboolean e_selection_model_key_press (ESelectionModel *esm,
+ GdkEventKey *key);
+void e_selection_model_select_as_key_press
+ (ESelectionModel *esm,
+ guint row,
+ guint col,
+ GdkModifierType state);
/* Virtual functions */
-gboolean e_selection_model_is_row_selected (ESelectionModel *esm,
- gint n);
-void e_selection_model_foreach (ESelectionModel *esm,
- EForeachFunc callback,
- gpointer closure);
-void e_selection_model_clear (ESelectionModel *esm);
-gint e_selection_model_selected_count (ESelectionModel *esm);
-void e_selection_model_select_all (ESelectionModel *esm);
-void e_selection_model_invert_selection (ESelectionModel *esm);
-gint e_selection_model_row_count (ESelectionModel *esm);
+gboolean e_selection_model_is_row_selected
+ (ESelectionModel *esm,
+ gint n);
+void e_selection_model_foreach (ESelectionModel *esm,
+ EForeachFunc callback,
+ gpointer closure);
+void e_selection_model_clear (ESelectionModel *esm);
+gint e_selection_model_selected_count(ESelectionModel *esm);
+void e_selection_model_select_all (ESelectionModel *esm);
+void e_selection_model_invert_selection
+ (ESelectionModel *esm);
+gint e_selection_model_row_count (ESelectionModel *esm);
/* Private virtual Functions */
-void e_selection_model_change_one_row (ESelectionModel *esm,
- gint row,
- gboolean on);
-void e_selection_model_change_cursor (ESelectionModel *esm,
- gint row,
- gint col);
-gint e_selection_model_cursor_row (ESelectionModel *esm);
-gint e_selection_model_cursor_col (ESelectionModel *esm);
-void e_selection_model_select_single_row (ESelectionModel *selection,
- gint row);
-void e_selection_model_toggle_single_row (ESelectionModel *selection,
- gint row);
-void e_selection_model_move_selection_end (ESelectionModel *selection,
- gint row);
-void e_selection_model_set_selection_end (ESelectionModel *selection,
- gint row);
+void e_selection_model_change_one_row(ESelectionModel *esm,
+ gint row,
+ gboolean on);
+void e_selection_model_change_cursor (ESelectionModel *esm,
+ gint row,
+ gint col);
+gint e_selection_model_cursor_row (ESelectionModel *esm);
+gint e_selection_model_cursor_col (ESelectionModel *esm);
+void e_selection_model_select_single_row
+ (ESelectionModel *selection,
+ gint row);
+void e_selection_model_toggle_single_row
+ (ESelectionModel *selection,
+ gint row);
+void e_selection_model_move_selection_end
+ (ESelectionModel *selection,
+ gint row);
+void e_selection_model_set_selection_end
+ (ESelectionModel *selection,
+ gint row);
/* Signals */
-void e_selection_model_cursor_changed (ESelectionModel *selection,
- gint row,
- gint col);
-void e_selection_model_cursor_activated (ESelectionModel *selection,
- gint row,
- gint col);
-void e_selection_model_selection_row_changed (ESelectionModel *selection,
- gint row);
-void e_selection_model_selection_changed (ESelectionModel *selection);
+void e_selection_model_cursor_changed(ESelectionModel *selection,
+ gint row,
+ gint col);
+void e_selection_model_cursor_activated
+ (ESelectionModel *selection,
+ gint row,
+ gint col);
+void e_selection_model_selection_row_changed
+ (ESelectionModel *selection,
+ gint row);
+void e_selection_model_selection_changed
+ (ESelectionModel *selection);
G_END_DECLS
-#endif /* _E_SELECTION_MODEL_H_ */
+#endif /* E_SELECTION_MODEL_H */
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index 2f45be08ec..57a1aa537c 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -981,7 +981,7 @@ etgc_class_init (ETableGroupContainerClass *klass)
g_param_spec_object ("selection_model",
"Selection model",
"Selection model",
- E_SELECTION_MODEL_TYPE,
+ E_TYPE_SELECTION_MODEL,
G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_LENGTH_THRESHOLD,
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index 7d0f079cb6..c1ddbb677a 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -650,7 +650,7 @@ etgl_class_init (ETableGroupLeafClass *klass)
g_param_spec_object ("selection_model",
"Selection model",
"Selection model",
- E_SELECTION_MODEL_TYPE,
+ E_TYPE_SELECTION_MODEL,
G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_HEIGHT,
diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c
index c0def7f286..9bf410a200 100644
--- a/widgets/table/e-table-item.c
+++ b/widgets/table/e-table-item.c
@@ -2850,7 +2850,7 @@ eti_class_init (ETableItemClass *klass)
g_param_spec_object ("selection_model",
"Selection model",
"Selection model",
- E_SELECTION_MODEL_TYPE,
+ E_TYPE_SELECTION_MODEL,
G_PARAM_WRITABLE));
g_object_class_install_property (object_class, PROP_TABLE_ALTERNATING_ROW_COLORS,
diff --git a/widgets/table/e-tree-selection-model.c b/widgets/table/e-tree-selection-model.c
index 0c877e2279..bcd6cfcc3e 100644
--- a/widgets/table/e-tree-selection-model.c
+++ b/widgets/table/e-tree-selection-model.c
@@ -29,7 +29,8 @@
#include "e-tree-selection-model.h"
-G_DEFINE_TYPE (ETreeSelectionModel, e_tree_selection_model, E_SELECTION_MODEL_TYPE)
+G_DEFINE_TYPE (
+ ETreeSelectionModel, e_tree_selection_model, E_TYPE_SELECTION_MODEL)
enum {
PROP_0,