X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fgtksheet%2Fgsheetmodel.c;h=3fa8f0afdcfd8dc7a844fbaba833375ebdc4d645;hb=ad10aed69efec78ddbfcdbe4774bf9a0435fcfd6;hp=3a447188b9b7c6912dcf2e7b6956d105fed7fa11;hpb=a6df7a4863f51dd4121a067f947335fba197617b;p=pspp-builds.git diff --git a/lib/gtksheet/gsheetmodel.c b/lib/gtksheet/gsheetmodel.c index 3a447188..3fa8f0af 100644 --- a/lib/gtksheet/gsheetmodel.c +++ b/lib/gtksheet/gsheetmodel.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include "gsheetmodel.h" #include "gtkextra-marshal.h" @@ -24,6 +26,8 @@ enum { RANGE_CHANGED, ROWS_INSERTED, ROWS_DELETED, + COLUMNS_INSERTED, + COLUMNS_DELETED, LAST_SIGNAL }; @@ -108,7 +112,30 @@ g_sheet_model_base_init (gpointer g_class) G_TYPE_INT, G_TYPE_INT); - + sheet_model_signals[COLUMNS_INSERTED] = + g_signal_new ("columns_inserted", + G_TYPE_SHEET_MODEL, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GSheetModelIface, columns_inserted), + NULL, NULL, + gtkextra_VOID__INT_INT, + G_TYPE_NONE, 2, + G_TYPE_INT, + G_TYPE_INT); + + + sheet_model_signals[COLUMNS_DELETED] = + g_signal_new ("columns_deleted", + G_TYPE_SHEET_MODEL, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (GSheetModelIface, columns_deleted), + NULL, NULL, + gtkextra_VOID__INT_INT, + G_TYPE_NONE, 2, + G_TYPE_INT, + G_TYPE_INT); + + initialized = TRUE; } } @@ -117,11 +144,11 @@ g_sheet_model_base_init (gpointer g_class) /** * g_sheet_model_free_strings * @sheet_model: A #GSheetModel - * - * Returns: True if strings obtained with get_string should be freed by the + * + * Returns: True if strings obtained with get_string should be freed by the * sheet when no longer required. **/ -inline gboolean +inline gboolean g_sheet_model_free_strings (const GSheetModel *sheet_model) { g_return_val_if_fail (G_IS_SHEET_MODEL (sheet_model), FALSE); @@ -135,18 +162,18 @@ g_sheet_model_free_strings (const GSheetModel *sheet_model) * @sheet_model: A #GSheetModel * @row: The row of the cell to be retrieved. * @column: The column of the cell to be retrieved. - * + * * Retrieves the datum at location ROW, COLUMN in the form of a string. * Returns: The string representation of the datum, or NULL on error. **/ inline gchar * -g_sheet_model_get_string (const GSheetModel *sheet_model, - gint row, gint column) +g_sheet_model_get_string (const GSheetModel *sheet_model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (sheet_model), 0); g_assert (G_SHEET_MODEL_GET_IFACE (sheet_model)->get_string); - + return (G_SHEET_MODEL_GET_IFACE (sheet_model)->get_string) (sheet_model, row, column); } @@ -156,20 +183,20 @@ g_sheet_model_get_string (const GSheetModel *sheet_model, * @text: The text describing the datum to be set. * @row: The row of the cell to be cleared. * @column: The column of the cell to be cleared. - * + * * Sets the datum at a location from a string. * Returns: TRUE if the datum was changed, FALSE otherwise. **/ gboolean -g_sheet_model_set_string (GSheetModel *sheet_model, - const gchar *text, - gint row, gint column) +g_sheet_model_set_string (GSheetModel *sheet_model, + const gchar *text, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (sheet_model), FALSE); g_assert (G_SHEET_MODEL_GET_IFACE (sheet_model)->set_string); - return G_SHEET_MODEL_GET_IFACE (sheet_model)->set_string (sheet_model, + return G_SHEET_MODEL_GET_IFACE (sheet_model)->set_string (sheet_model, text, row, column); } @@ -180,19 +207,19 @@ g_sheet_model_set_string (GSheetModel *sheet_model, * @sheet_model: A #GSheetModel * @row: The row of the cell to be cleared. * @column: The column of the cell to be cleared. - * + * * Called when the datum at a location is to be cleared. * Returns: TRUE if the datum was cleared, FALSE otherwise. **/ gboolean -g_sheet_model_datum_clear (GSheetModel *sheet_model, - gint row, gint column) +g_sheet_model_datum_clear (GSheetModel *sheet_model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (sheet_model), FALSE); g_assert (G_SHEET_MODEL_GET_IFACE (sheet_model)->clear_datum); - return G_SHEET_MODEL_GET_IFACE (sheet_model)->clear_datum (sheet_model, + return G_SHEET_MODEL_GET_IFACE (sheet_model)->clear_datum (sheet_model, row, column); } @@ -201,17 +228,17 @@ g_sheet_model_datum_clear (GSheetModel *sheet_model, * g_sheet_model_range_changed: * @sheet_model: A #GSheetModel * @range: The #GSheetRange range of cells which have changed. - * + * * Emits the "range_changed" signal on @sheet_model. **/ void g_sheet_model_range_changed (GSheetModel *sheet_model, - gint row0, gint col0, - gint rowi, gint coli) + glong row0, glong col0, + glong rowi, glong coli) { g_return_if_fail (G_IS_SHEET_MODEL (sheet_model)); - g_signal_emit (sheet_model, sheet_model_signals[RANGE_CHANGED], 0, + g_signal_emit (sheet_model, sheet_model_signals[RANGE_CHANGED], 0, row0, col0, rowi, coli); } @@ -223,20 +250,39 @@ g_sheet_model_range_changed (GSheetModel *sheet_model, * @sheet_model: A #GSheetModel * @row: The row before which the new rows should be inserted. * @n_rows: The number of rows to insert. - * + * * Emits the "rows_inserted" signal on @sheet_model. **/ void g_sheet_model_rows_inserted (GSheetModel *sheet_model, - gint row, gint n_rows) + glong row, glong n_rows) { g_return_if_fail (G_IS_SHEET_MODEL (sheet_model)); - g_signal_emit (sheet_model, sheet_model_signals[ROWS_INSERTED], 0, + g_signal_emit (sheet_model, sheet_model_signals[ROWS_INSERTED], 0, row, n_rows); } +/** + * g_sheet_model_columns_inserted: + * @sheet_model: A #GSheetModel + * @column: The column before which the new columns should be inserted. + * @n_columns: The number of columns to insert. + * + * Emits the "columns_inserted" signal on @sheet_model. + **/ +void +g_sheet_model_columns_inserted (GSheetModel *sheet_model, + glong column, glong n_columns) +{ + g_return_if_fail (G_IS_SHEET_MODEL (sheet_model)); + + g_signal_emit (sheet_model, sheet_model_signals[COLUMNS_INSERTED], 0, + column, n_columns); +} + + /** @@ -244,61 +290,82 @@ g_sheet_model_rows_inserted (GSheetModel *sheet_model, * @sheet_model: A #GSheetModel * @row: The first row to be deleted. * @n_rows: The number of rows to delete. - * + * * Emits the "rows_deleted" signal on @sheet_model. **/ void g_sheet_model_rows_deleted (GSheetModel *sheet_model, - gint row, gint n_rows) + glong row, glong n_rows) { g_return_if_fail (G_IS_SHEET_MODEL (sheet_model)); - g_signal_emit (sheet_model, sheet_model_signals[ROWS_DELETED], 0, + g_signal_emit (sheet_model, sheet_model_signals[ROWS_DELETED], 0, row, n_rows); } +/** + * g_sheet_model_columns_deleted: + * @sheet_model: A #GSheetModel + * @column: The first column to be deleted. + * @n_columns: The number of columns to delete. + * + * Emits the "columns_deleted" signal on @sheet_model. + **/ +void +g_sheet_model_columns_deleted (GSheetModel *sheet_model, + glong column, glong n_columns) +{ + g_return_if_fail (G_IS_SHEET_MODEL (sheet_model)); + + g_signal_emit (sheet_model, sheet_model_signals[COLUMNS_DELETED], 0, + column, n_columns); +} + + + + /** * g_sheet_model_is_editable: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column - * + * * Returns: TRUE if the cell is editable, FALSE otherwise **/ -inline gboolean -g_sheet_model_is_editable (const GSheetModel *model, - gint row, gint column) +inline gboolean +g_sheet_model_is_editable (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), TRUE); if ( ! G_SHEET_MODEL_GET_IFACE (model)->is_editable ) return TRUE; - return G_SHEET_MODEL_GET_IFACE (model)->is_editable (model, + return G_SHEET_MODEL_GET_IFACE (model)->is_editable (model, row, column); } /** * g_sheet_model_is_visible: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column - * + * * Returns: TRUE if the cell is visible, FALSE otherwise **/ -inline gboolean -g_sheet_model_is_visible (const GSheetModel *model, - gint row, gint column) +inline gboolean +g_sheet_model_is_visible (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), TRUE); if ( ! G_SHEET_MODEL_GET_IFACE (model)->is_visible ) return TRUE; - return G_SHEET_MODEL_GET_IFACE (model)->is_visible (model, + return G_SHEET_MODEL_GET_IFACE (model)->is_visible (model, row, column); } @@ -306,73 +373,73 @@ g_sheet_model_is_visible (const GSheetModel *model, /** * g_sheet_model_get_foreground: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column * * Returns the foreground colour of the cell at @row, @column * Returns: the foreground colour, or NULL on error. **/ inline const GdkColor * -g_sheet_model_get_foreground (const GSheetModel *model, - gint row, gint column) +g_sheet_model_get_foreground (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL); if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_foreground ) return NULL; - return G_SHEET_MODEL_GET_IFACE (model)->get_foreground (model, + return G_SHEET_MODEL_GET_IFACE (model)->get_foreground (model, row, column); } /** * g_sheet_model_get_background: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column * * Returns the background colour of the cell at @row, @column * Returns: the background colour, or NULL on error. **/ inline const GdkColor * -g_sheet_model_get_background (const GSheetModel *model, - gint row, gint column) +g_sheet_model_get_background (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL); if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_background ) return NULL; - return G_SHEET_MODEL_GET_IFACE (model)->get_background (model, + return G_SHEET_MODEL_GET_IFACE (model)->get_background (model, row, column); } /** * g_sheet_model_get_justification: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column * * Returns the justification of the cell at @row, @column * Returns: the justification, or NULL on error. **/ inline const GtkJustification * -g_sheet_model_get_justification (const GSheetModel *model, - gint row, gint column) +g_sheet_model_get_justification (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL); if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_justification) return NULL; - return G_SHEET_MODEL_GET_IFACE (model)->get_justification (model, + return G_SHEET_MODEL_GET_IFACE (model)->get_justification (model, row, column); } /** * g_sheet_model_get_font_desc: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column * * Returns the font description of the cell at @row, @column @@ -380,36 +447,64 @@ g_sheet_model_get_justification (const GSheetModel *model, **/ inline const PangoFontDescription * g_sheet_model_get_font_desc(const GSheetModel *model, - gint row, gint column) + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL); if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_font_desc) return NULL; - return G_SHEET_MODEL_GET_IFACE (model)->get_font_desc (model, + return G_SHEET_MODEL_GET_IFACE (model)->get_font_desc (model, row, column); } /** * g_sheet_model_get_cell_border: * @sheet_model: A #GSheetModel - * @row: The row + * @row: The row * @column: The column * * Returns the cell border of the cell at @row, @column * Returns: the cell border, or NULL on error. **/ -inline const GtkSheetCellBorder * -g_sheet_model_get_cell_border (const GSheetModel *model, - gint row, gint column) +inline const GtkSheetCellBorder * +g_sheet_model_get_cell_border (const GSheetModel *model, + glong row, glong column) { g_return_val_if_fail (G_IS_SHEET_MODEL (model), NULL); if ( ! G_SHEET_MODEL_GET_IFACE (model)->get_cell_border) return NULL; - return G_SHEET_MODEL_GET_IFACE (model)->get_cell_border (model, + return G_SHEET_MODEL_GET_IFACE (model)->get_cell_border (model, row, column); } +/** + * g_sheet_model_get_column_count: + * @model: A #GSheetModel + * + * Returns the total number of columns represented by the model + **/ +inline glong +g_sheet_model_get_column_count (const GSheetModel *model) +{ + g_return_val_if_fail (G_IS_SHEET_MODEL (model), -1); + + return G_SHEET_MODEL_GET_IFACE (model)->get_column_count (model); +} + +/** + * g_sheet_model_get_row_count: + * @model: A #GSheetModel + * + * Returns the total number of rows represented by the model + **/ +inline gint +g_sheet_model_get_row_count(const GSheetModel *model) +{ + g_return_val_if_fail (G_IS_SHEET_MODEL (model), -1); + + + return G_SHEET_MODEL_GET_IFACE (model)->get_row_count (model); +}