diff options
Diffstat (limited to 'widgets/table/e-table-scrolled.c')
-rw-r--r-- | widgets/table/e-table-scrolled.c | 277 |
1 files changed, 11 insertions, 266 deletions
diff --git a/widgets/table/e-table-scrolled.c b/widgets/table/e-table-scrolled.c index ab490ad7b3..aad041beb4 100644 --- a/widgets/table/e-table-scrolled.c +++ b/widgets/table/e-table-scrolled.c @@ -28,71 +28,10 @@ static GtkObjectClass *parent_class; enum { - CURSOR_CHANGE, - DOUBLE_CLICK, - RIGHT_CLICK, - CLICK, - KEY_PRESS, - LAST_SIGNAL -}; - -enum { ARG_0, - ARG_TABLE_DRAW_GRID, - ARG_TABLE_DRAW_FOCUS, - ARG_CURSOR_MODE, - ARG_LENGTH_THRESHOLD, - ARG_CLICK_TO_ADD_MESSAGE, + ARG_TABLE, }; -static gint ets_signals [LAST_SIGNAL] = { 0, }; - -static void -cursor_change_proxy (ETable *et, int row, ETableScrolled *ets) -{ - gtk_signal_emit (GTK_OBJECT (ets), - ets_signals [CURSOR_CHANGE], - row); -} - -static void -double_click_proxy (ETable *et, int row, ETableScrolled *ets) -{ - gtk_signal_emit (GTK_OBJECT (ets), - ets_signals [DOUBLE_CLICK], - row); -} - -static gint -right_click_proxy (ETable *et, int row, int col, GdkEvent *event, ETableScrolled *ets) -{ - int return_val = 0; - gtk_signal_emit (GTK_OBJECT (ets), - ets_signals [RIGHT_CLICK], - row, col, event, &return_val); - return return_val; -} - -static gint -click_proxy (ETable *et, int row, int col, GdkEvent *event, ETableScrolled *ets) -{ - int return_val = 0; - gtk_signal_emit (GTK_OBJECT (ets), - ets_signals [CLICK], - row, col, event, &return_val); - return return_val; -} - -static gint -key_press_proxy (ETable *et, int row, int col, GdkEvent *event, ETableScrolled *ets) -{ - int return_val; - gtk_signal_emit (GTK_OBJECT (ets), - ets_signals [KEY_PRESS], - row, col, event, &return_val); - return return_val; -} - static void e_table_scrolled_init (GtkObject *object) { @@ -119,17 +58,6 @@ e_table_scrolled_real_construct (ETableScrolled *ets) gtk_container_add(GTK_CONTAINER(ets), GTK_WIDGET(ets->table)); - gtk_signal_connect(GTK_OBJECT(ets->table), "cursor_change", - GTK_SIGNAL_FUNC(cursor_change_proxy), ets); - gtk_signal_connect(GTK_OBJECT(ets->table), "double_click", - GTK_SIGNAL_FUNC(double_click_proxy), ets); - gtk_signal_connect(GTK_OBJECT(ets->table), "right_click", - GTK_SIGNAL_FUNC(right_click_proxy), ets); - gtk_signal_connect(GTK_OBJECT(ets->table), "click", - GTK_SIGNAL_FUNC(click_proxy), ets); - gtk_signal_connect(GTK_OBJECT(ets->table), "key_press", - GTK_SIGNAL_FUNC(key_press_proxy), ets); - gtk_widget_show(GTK_WIDGET(ets->table)); } @@ -214,148 +142,23 @@ GtkWidget *e_table_scrolled_new_from_spec_file (ETableModel *e return GTK_WIDGET (ets); } -gchar *e_table_scrolled_get_state (ETableScrolled *ets) -{ - g_return_val_if_fail(ets != NULL, NULL); - g_return_val_if_fail(E_IS_TABLE_SCROLLED(ets), NULL); - - return e_table_get_state(ets->table); -} - -void e_table_scrolled_save_state (ETableScrolled *ets, - const gchar *filename) -{ - g_return_if_fail(ets != NULL); - g_return_if_fail(E_IS_TABLE_SCROLLED(ets)); - g_return_if_fail(filename != NULL); - - e_table_save_state(ets->table, filename); -} - -void -e_table_scrolled_set_state(ETableScrolled *ets, const char *state) -{ - g_return_if_fail(ets != NULL); - g_return_if_fail(E_IS_TABLE_SCROLLED(ets)); - g_return_if_fail(state != NULL); - - e_table_set_state(ets->table, state); -} - -void -e_table_scrolled_load_state(ETableScrolled *ets, const gchar *filename) -{ - g_return_if_fail(ets != NULL); - g_return_if_fail(E_IS_TABLE_SCROLLED(ets)); - g_return_if_fail(filename != NULL); - - e_table_load_state(ets->table, filename); -} - -void -e_table_scrolled_set_cursor_row (ETableScrolled *ets, int row) -{ - g_return_if_fail(ets != NULL); - g_return_if_fail(E_IS_TABLE_SCROLLED(ets)); - - e_table_set_cursor_row(ets->table, row); -} - -int -e_table_scrolled_get_cursor_row (ETableScrolled *ets) +ETable * +e_table_scrolled_get_table (ETableScrolled *ets) { - g_return_val_if_fail(ets != NULL, -1); - g_return_val_if_fail(E_IS_TABLE_SCROLLED(ets), -1); - - return e_table_get_cursor_row(ets->table); -} - -void -e_table_scrolled_selected_row_foreach (ETableScrolled *ets, - ETableForeachFunc callback, - gpointer closure) -{ - g_return_if_fail(ets != NULL); - g_return_if_fail(E_IS_TABLE_SCROLLED(ets)); - - e_table_selected_row_foreach(ets->table, - callback, - closure); -} - -EPrintable * -e_table_scrolled_get_printable (ETableScrolled *ets) -{ - g_return_val_if_fail(ets != NULL, NULL); - g_return_val_if_fail(E_IS_TABLE_SCROLLED(ets), NULL); - - return e_table_get_printable(ets->table); + return ets->table; } static void ets_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) { ETableScrolled *ets = E_TABLE_SCROLLED (o); - gboolean bool_val; - gchar *string_val; switch (arg_id){ - case ARG_TABLE_DRAW_GRID: - gtk_object_get(GTK_OBJECT(ets->table), - "drawgrid", &bool_val, - NULL); - GTK_VALUE_BOOL (*arg) = bool_val; - break; - - case ARG_TABLE_DRAW_FOCUS: - gtk_object_get(GTK_OBJECT(ets->table), - "drawfocus", &bool_val, - NULL); - GTK_VALUE_BOOL (*arg) = bool_val; - break; - - case ARG_CLICK_TO_ADD_MESSAGE: - gtk_object_get(GTK_OBJECT(ets->table), - "click_to_add_message", &string_val, - NULL); - GTK_VALUE_STRING (*arg) = string_val; - break; - } -} - -static void -ets_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) -{ - ETableScrolled *ets = E_TABLE_SCROLLED (o); - - switch (arg_id){ - case ARG_LENGTH_THRESHOLD: - gtk_object_set(GTK_OBJECT(ets->table), - "length_threshold", GTK_VALUE_INT (*arg), - NULL); - break; - - case ARG_TABLE_DRAW_GRID: - gtk_object_set(GTK_OBJECT(ets->table), - "drawgrid", GTK_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_TABLE_DRAW_FOCUS: - gtk_object_set(GTK_OBJECT(ets->table), - "drawfocus", GTK_VALUE_BOOL (*arg), - NULL); - break; - - case ARG_CURSOR_MODE: - gtk_object_set(GTK_OBJECT(ets->table), - "cursor_mode", GTK_VALUE_INT (*arg), - NULL); - break; - case ARG_CLICK_TO_ADD_MESSAGE: - gtk_object_set(GTK_OBJECT(ets->table), - "click_to_add_message", GTK_VALUE_STRING (*arg), - NULL); + case ARG_TABLE: + if (ets->table) + GTK_VALUE_OBJECT (*arg) = GTK_OBJECT(ets->table); + else + GTK_VALUE_OBJECT (*arg) = NULL; break; } } @@ -363,70 +166,12 @@ ets_set_arg (GtkObject *o, GtkArg *arg, guint arg_id) static void e_table_scrolled_class_init (GtkObjectClass *object_class) { - ETableScrolledClass *klass = E_TABLE_SCROLLED_CLASS(object_class); parent_class = gtk_type_class (PARENT_TYPE); - object_class->set_arg = ets_set_arg; object_class->get_arg = ets_get_arg; - klass->cursor_change = NULL; - klass->double_click = NULL; - klass->right_click = NULL; - klass->click = NULL; - klass->key_press = NULL; - - ets_signals [CURSOR_CHANGE] = - gtk_signal_new ("cursor_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableScrolledClass, cursor_change), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - ets_signals [DOUBLE_CLICK] = - gtk_signal_new ("double_click", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableScrolledClass, double_click), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - ets_signals [RIGHT_CLICK] = - gtk_signal_new ("right_click", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableScrolledClass, right_click), - e_marshal_INT__INT_INT_POINTER, - GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); - - ets_signals [CLICK] = - gtk_signal_new ("click", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableScrolledClass, click), - e_marshal_INT__INT_INT_POINTER, - GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); - - ets_signals [KEY_PRESS] = - gtk_signal_new ("key_press", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (ETableScrolledClass, key_press), - e_marshal_INT__INT_INT_POINTER, - GTK_TYPE_INT, 3, GTK_TYPE_INT, GTK_TYPE_INT, GTK_TYPE_POINTER); - - gtk_object_class_add_signals (object_class, ets_signals, LAST_SIGNAL); - - gtk_object_add_arg_type ("ETableScrolled::drawgrid", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID); - gtk_object_add_arg_type ("ETableScrolled::drawfocus", GTK_TYPE_BOOL, - GTK_ARG_READWRITE, ARG_TABLE_DRAW_FOCUS); - gtk_object_add_arg_type ("ETableScrolled::cursor_mode", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_CURSOR_MODE); - gtk_object_add_arg_type ("ETableScrolled::length_threshold", GTK_TYPE_INT, - GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD); - gtk_object_add_arg_type ("ETableScrolled::click_to_add_message", GTK_TYPE_STRING, - GTK_ARG_READWRITE, ARG_CLICK_TO_ADD_MESSAGE); + gtk_object_add_arg_type ("ETableScrolled::table", GTK_TYPE_OBJECT, + GTK_ARG_READABLE, ARG_TABLE); } E_MAKE_TYPE(e_table_scrolled, "ETableScrolled", ETableScrolled, e_table_scrolled_class_init, e_table_scrolled_init, PARENT_TYPE); |