Commit 655ca968 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Rework to use cmd_reorganize_sheets2.

2005-06-30  Morten Welinder  <terra@gnome.org>

	* dialog-sheet-order.c (cb_ok_clicked): Rework to use
	cmd_reorganize_sheets2.

2005-06-30  Morten Welinder  <terra@gnome.org>

	* src/workbook.c (workbook_sheet_rename_check,
	workbook_sheet_change_protection,
	workbook_sheet_change_visibility, workbook_sheet_recolor,
	workbook_sheet_reorder_by_idx): Remove.  No longer used.

	* src/commands.c (command_redo_sheet_delete,
	cmd_reorganize_sheets_delete_get_this_sheet_info,
	cmd_reorganize_sheets_delete_shift_list,
	cmd_reorganize_sheets_delete_get_all_sheets_info,
	cmd_reorganize_sheets_delete_recreate_sheet,
	cmd_reorganize_sheets_delete_free, cmd_reorganize_sheets_undo,
	cmd_reorganize_sheets_redo, cb_slist_gdk_color_free,
	cmd_reorganize_sheets_finalize, cmd_reorganize_sheets_fix_list,
	cmd_reorganize_sheets):  Remove.  No longer used.
parent 8ea3d259
2005-06-30 Morten Welinder <terra@gnome.org>
* src/workbook.c (workbook_sheet_rename_check,
workbook_sheet_change_protection,
workbook_sheet_change_visibility, workbook_sheet_recolor,
workbook_sheet_reorder_by_idx): Remove. No longer used.
* src/commands.c (command_redo_sheet_delete,
cmd_reorganize_sheets_delete_get_this_sheet_info,
cmd_reorganize_sheets_delete_shift_list,
cmd_reorganize_sheets_delete_get_all_sheets_info,
cmd_reorganize_sheets_delete_recreate_sheet,
cmd_reorganize_sheets_delete_free, cmd_reorganize_sheets_undo,
cmd_reorganize_sheets_redo, cb_slist_gdk_color_free,
cmd_reorganize_sheets_finalize, cmd_reorganize_sheets_fix_list,
cmd_reorganize_sheets): Remove. No longer used.
2005-06-28 Jody Goldberg <jody@gnome.org>
* src/style-conditions.c (gnm_style_conditions_overlay) : when
......
2005-06-30 Morten Welinder <terra@gnome.org>
* src/workbook.c (workbook_sheet_rename_check,
workbook_sheet_change_protection,
workbook_sheet_change_visibility, workbook_sheet_recolor,
workbook_sheet_reorder_by_idx): Remove. No longer used.
* src/commands.c (command_redo_sheet_delete,
cmd_reorganize_sheets_delete_get_this_sheet_info,
cmd_reorganize_sheets_delete_shift_list,
cmd_reorganize_sheets_delete_get_all_sheets_info,
cmd_reorganize_sheets_delete_recreate_sheet,
cmd_reorganize_sheets_delete_free, cmd_reorganize_sheets_undo,
cmd_reorganize_sheets_redo, cb_slist_gdk_color_free,
cmd_reorganize_sheets_finalize, cmd_reorganize_sheets_fix_list,
cmd_reorganize_sheets): Remove. No longer used.
2005-06-28 Jody Goldberg <jody@gnome.org>
* src/style-conditions.c (gnm_style_conditions_overlay) : when
......
......@@ -757,26 +757,6 @@ command_undo_sheet_delete (Sheet* sheet)
return (TRUE);
}
static gboolean
command_redo_sheet_delete (Sheet* sheet)
{
Workbook *wb = sheet->workbook;
g_return_val_if_fail (IS_SHEET (sheet), FALSE);
if (wb->undo_commands != NULL) {
command_list_release (wb->undo_commands);
wb->undo_commands = NULL;
WORKBOOK_FOREACH_CONTROL (wb, view, ctl,
wb_control_undo_redo_truncate (ctl, 0, TRUE););
undo_redo_menu_labels (wb);
}
workbook_sheet_delete (sheet);
return (TRUE);
}
/******************************************************************/
#define CMD_SET_TEXT_TYPE (cmd_set_text_get_type ())
......@@ -4665,643 +4645,6 @@ cmd_reorganize_sheets2 (WorkbookControl *wbc,
/******************************************************************/
#define CMD_REORGANIZE_SHEETS_TYPE (cmd_reorganize_sheets_get_type ())
#define CMD_REORGANIZE_SHEETS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), CMD_REORGANIZE_SHEETS_TYPE, CmdReorganizeSheets))
typedef struct {
GnmCommand cmd;
Workbook *wb;
GSList *new_order;
GSList *old_order;
GSList *changed_names;
GSList *new_names;
GSList *old_names;
GSList *deleted_sheets;
GSList *deleted_sheets_data;
GSList *color_changed;
GSList *new_colors_fore;
GSList *new_colors_back;
GSList *old_colors_fore;
GSList *old_colors_back;
GSList *protection_changed;
GSList *new_locks;
GSList *old_locks;
GSList *visibility_changed;
GSList *new_visibility;
GSList *old_visibility;
guint new_sheet_start;
guint new_sheet_count;
} CmdReorganizeSheets;
MAKE_GNM_COMMAND (CmdReorganizeSheets, cmd_reorganize_sheets, NULL);
typedef struct {
char *name;
guint pos;
GnmCellRegion *content;
ColRowStateList *col_info;
ColRowStateList *row_info;
GSList *sheet_objects;
} cmd_reorganize_sheets_delete_t;
static cmd_reorganize_sheets_delete_t *
cmd_reorganize_sheets_delete_get_this_sheet_info (Workbook *wb, guint pos)
{
cmd_reorganize_sheets_delete_t *data;
Sheet *sheet;
GnmRange r;
GSList *l;
g_return_val_if_fail (wb != NULL, NULL);
g_return_val_if_fail (pos < (guint)workbook_sheet_count (wb), NULL);
data = g_new0 (cmd_reorganize_sheets_delete_t, 1);
sheet = workbook_sheet_by_index (wb, pos);
data->name = g_strdup (sheet->name_unquoted);
data->pos = pos;
data->content = clipboard_copy_range (sheet, range_init_full_sheet (&r));
data->col_info = colrow_get_states (sheet, TRUE, 0, SHEET_MAX_COLS - 1);
data->row_info = colrow_get_states (sheet, FALSE, 0, SHEET_MAX_ROWS - 1);
if (data->sheet_objects != NULL) {
for (l = data->sheet_objects; l != NULL; l = l->next) {
GObject *so = l->data;
g_object_unref (so);
}
g_slist_free (data->sheet_objects);
data->sheet_objects = NULL;
}
data->sheet_objects = NULL;
for (l = sheet->sheet_objects; l != NULL; l = l->next)
data->sheet_objects = g_slist_prepend (data->sheet_objects, l->data);
data->sheet_objects = g_slist_reverse (data->sheet_objects);
for (l = data->sheet_objects; l != NULL; l = l->next) {
SheetObject *so = l->data;
g_object_ref (G_OBJECT (so));
sheet_object_clear_sheet (so);
}
return data;
}
static void
cmd_reorganize_sheets_delete_shift_list (GSList *list, guint pos)
{
while (list) {
guint val = GPOINTER_TO_UINT (list->data);
if (val == pos)
g_warning ("Deleted Sheet index appears "
"in data list!");
if (val > pos)
list->data = GUINT_TO_POINTER (val - 1);
list = list->next;
}
}
static gint
cmd_reorganize_sheets_delete_cmp_f (gconstpointer a,
gconstpointer b)
{
guint const a_val = GPOINTER_TO_INT (a);
guint const b_val = GPOINTER_TO_INT (b);
if (a_val > b_val)
return -1;
if (a_val < b_val)
return 1;
return 0;
}
static void
cmd_reorganize_sheets_delete_get_all_sheets_info (GnmCommand *cmd,
WorkbookControl *wbc)
{
CmdReorganizeSheets *me = CMD_REORGANIZE_SHEETS (cmd);
GSList *list;
/* First we need to sort the to be deleted sheets from biggest */
/* to smallest */
me->deleted_sheets = g_slist_sort (me->deleted_sheets,
cmd_reorganize_sheets_delete_cmp_f);
/* Then we retrieve the data */
for (list = me->deleted_sheets; list != NULL; list = list->next) {
guint pos = GPOINTER_TO_UINT (list->data);
me->deleted_sheets_data
= g_slist_prepend (me->deleted_sheets_data,
cmd_reorganize_sheets_delete_get_this_sheet_info
(me->wb, pos));
/* and shift the remaining lists */
cmd_reorganize_sheets_delete_shift_list (me->protection_changed,
pos);
cmd_reorganize_sheets_delete_shift_list (me->color_changed,
pos);
cmd_reorganize_sheets_delete_shift_list (me->new_order,
pos);
}
me->deleted_sheets_data = g_slist_reverse (me->deleted_sheets_data);
}
static void
cmd_reorganize_sheets_delete_recreate_sheet (WorkbookControl *wbc, Workbook *wb,
cmd_reorganize_sheets_delete_t *sheet)
{
Sheet *a_new_sheet;
guint pos = sheet->pos;
GSList *l;
a_new_sheet = sheet_new (wb, sheet->name);
workbook_sheet_attach_at_pos (wb, a_new_sheet, pos);
if (sheet->content) {
GnmPasteTarget pt;
GnmRange r;
clipboard_paste_region (sheet->content,
paste_target_init (&pt, a_new_sheet,
range_init_full_sheet(&r),
PASTE_ALL_TYPES),
GO_CMD_CONTEXT (wbc));
}
if (sheet->col_info)
colrow_set_states (a_new_sheet, TRUE, 0, sheet->col_info);
if (sheet->row_info)
colrow_set_states (a_new_sheet, FALSE, 0, sheet->row_info);
if (sheet->sheet_objects != NULL) {
for (l = sheet->sheet_objects; l != NULL; l = l->next) {
SheetObject *so = l->data;
sheet_object_set_sheet (so, a_new_sheet);
g_object_unref (so);
}
g_slist_free (sheet->sheet_objects);
sheet->sheet_objects = NULL;
}
g_object_unref (a_new_sheet);
}
static void
cmd_reorganize_sheets_delete_free (cmd_reorganize_sheets_delete_t *sheet)
{
GSList *l;
g_return_if_fail (sheet != NULL);
cellregion_unref (sheet->content);
g_free (sheet->name);
if (sheet->col_info)
sheet->col_info = colrow_state_list_destroy (sheet->col_info);
if (sheet->row_info)
sheet->row_info = colrow_state_list_destroy (sheet->row_info);
if (sheet->sheet_objects != NULL) {
for (l = sheet->sheet_objects; l != NULL; l = l->next) {
GObject *so = l->data;
g_object_unref (so);
}
g_slist_free (sheet->sheet_objects);
sheet->sheet_objects = NULL;
}
g_free (sheet);
}
static gboolean
cmd_reorganize_sheets_undo (GnmCommand *cmd, WorkbookControl *wbc)
{
CmdReorganizeSheets *me = CMD_REORGANIZE_SHEETS (cmd);
guint n;
GSList *list;
g_return_val_if_fail (me != NULL, TRUE);
workbook_set_dirty (me->wb, TRUE);
/* undo reordering */
if (me->new_order) {
if (me->old_order == NULL) {
GSList *l = me->new_order;
guint new_pos = 0;
me->old_order = g_slist_copy (l);
while (l) {
guint old_pos = GPOINTER_TO_UINT (l->data);
g_slist_nth (me->old_order, old_pos)->data =
GUINT_TO_POINTER (new_pos);
l = l->next;
new_pos++;
}
}
if (workbook_sheet_reorder_by_idx (me->wb, me->old_order))
return TRUE;
}
/* undo changing protection */
if (me->protection_changed) {
if (workbook_sheet_change_protection
(me->wb, me->protection_changed, me->old_locks))
return TRUE;
}
/* undo changing visibility */
if (me->visibility_changed) {
if (workbook_sheet_change_visibility
(me->wb, me->visibility_changed, me->old_visibility))
return TRUE;
}
/* undo changing colors */
if (me->color_changed) {
if (workbook_sheet_recolor (me->wb, me->color_changed,
me->old_colors_fore,
me->old_colors_back))
return TRUE;
}
/* undo adding sheets */
for (n = 0; n < me->new_sheet_count; n++) {
Sheet *sheet = workbook_sheet_by_index (me->wb, me->new_sheet_start);
if (sheet)
command_undo_sheet_delete (sheet);
}
/* undo renaming sheets */
if (workbook_sheet_rename (me->wb, me->changed_names, me->old_names,
GO_CMD_CONTEXT (wbc)))
return TRUE;
/* undo deleting sheets */
for (list = me->deleted_sheets_data; list != NULL; list = list->next)
{
cmd_reorganize_sheets_delete_recreate_sheet
(wbc, me->wb,
(cmd_reorganize_sheets_delete_t *)list->data);
}
return FALSE;
}
static gboolean
cmd_reorganize_sheets_redo (GnmCommand *cmd, WorkbookControl *wbc)
{
CmdReorganizeSheets *me = CMD_REORGANIZE_SHEETS (cmd);
GSList *list, *names;
g_return_val_if_fail (me != NULL, TRUE);
workbook_set_dirty (me->wb, TRUE);
/* deleting sheets */
if (me->deleted_sheets != NULL && me->deleted_sheets_data == NULL)
cmd_reorganize_sheets_delete_get_all_sheets_info (cmd, wbc);
for (list = me->deleted_sheets; list != NULL; list = list->next) {
guint pos = GPOINTER_TO_UINT (list->data);
Sheet *sheet = workbook_sheet_by_index (me->wb, pos);
command_redo_sheet_delete (sheet);
}
/* renaming sheets */
if (workbook_sheet_rename (me->wb, me->changed_names, me->new_names,
GO_CMD_CONTEXT (wbc)))
return TRUE;
/* adding sheets */
list = me->changed_names;
names = me->new_names;
while (list && names) {
if (GPOINTER_TO_INT (list->data) == -1) {
char *name = names->data;
Sheet *a_new_sheet ;
gboolean free_name = (name == NULL);
if (free_name)
name = workbook_sheet_get_free_name
(me->wb, _("Sheet"), TRUE, FALSE);
a_new_sheet = sheet_new (me->wb, name);
if (free_name)
g_free (name);
workbook_sheet_attach (me->wb, a_new_sheet);
}
list = list->next;
names = names->next;
}
/* changing colors */
if (me->color_changed) {
if (workbook_sheet_recolor (me->wb, me->color_changed,
me->new_colors_fore,
me->new_colors_back))
return TRUE;
}
/* changing protection */
if (me->protection_changed) {
if (workbook_sheet_change_protection
(me->wb, me->protection_changed, me->new_locks))
return TRUE;
}
/* changing visibility */
if (me->visibility_changed) {
if (workbook_sheet_change_visibility
(me->wb, me->visibility_changed, me->new_visibility))
return TRUE;
}
/* reordering */
if (me->new_order) {
if (workbook_sheet_reorder_by_idx (me->wb, me->new_order))
return TRUE;
}
return FALSE;
}
static void
cb_slist_gdk_color_free (gpointer data,
G_GNUC_UNUSED gpointer user_data)
{
if (data)
gdk_color_free (data);
}
static void
cmd_reorganize_sheets_finalize (GObject *cmd)
{
CmdReorganizeSheets *me = CMD_REORGANIZE_SHEETS (cmd);
GSList *list;
g_slist_free (me->old_order);
me->old_order = NULL;
g_slist_free (me->new_order);
me->new_order = NULL;
g_slist_free (me->changed_names);
me->changed_names = NULL;
g_slist_foreach (me->old_names, (GFunc)g_free, NULL);
g_slist_free (me->old_names);
me->old_names = NULL;
g_slist_foreach (me->new_names, (GFunc)g_free, NULL);
g_slist_free (me->new_names);
me->new_names = NULL;
g_slist_free (me->color_changed);
me->color_changed = NULL;
g_slist_free (me->protection_changed);
me->protection_changed = NULL;
g_slist_free (me->new_locks);
me->new_locks = NULL;
g_slist_free (me->old_locks);
me->old_locks = NULL;
g_slist_free (me->visibility_changed);
me->visibility_changed = NULL;
g_slist_free (me->new_visibility);
me->new_visibility = NULL;
g_slist_free (me->old_visibility);
me->old_visibility = NULL;
g_slist_free (me->deleted_sheets);
me->deleted_sheets = NULL;
for (list = me->deleted_sheets_data; list != NULL; list = list->next) {
cmd_reorganize_sheets_delete_free
((cmd_reorganize_sheets_delete_t *)list->data);
}
g_slist_free (me->deleted_sheets_data);
me->deleted_sheets_data = NULL;
g_slist_foreach (me->new_colors_fore, cb_slist_gdk_color_free, NULL);
g_slist_free (me->new_colors_fore);
me->new_colors_fore = NULL;
g_slist_foreach (me->new_colors_back, cb_slist_gdk_color_free, NULL);
g_slist_free (me->new_colors_back);
me->new_colors_back = NULL;
g_slist_foreach (me->old_colors_fore, cb_slist_gdk_color_free, NULL);
g_slist_free (me->old_colors_fore);
me->old_colors_fore = NULL;
g_slist_foreach (me->old_colors_back, cb_slist_gdk_color_free, NULL);
g_slist_free (me->old_colors_back);
me->old_colors_back = NULL;
gnm_command_finalize (cmd);
}
static GSList *
cmd_reorganize_sheets_fix_list (GSList *list, guint start, guint count,
gboolean append)
{
GSList *l = list;
GSList *ret = list;
while (l != NULL && count > 0) {
if (GPOINTER_TO_INT (l->data) == -1) {
l->data = GUINT_TO_POINTER (start);
start++;
count--;
}
l = l->next;
}
if (append) {
while (count > 0) {
ret = g_slist_append (ret, GUINT_TO_POINTER (start));
start++;
count--;
}
}
return ret;
}
gboolean
cmd_reorganize_sheets (WorkbookControl *wbc, GSList *new_order,
GSList *changed_names, GSList *new_names, GSList *deleted_sheets,
GSList *color_changed, GSList *new_colors_back,
GSList *new_colors_fore,
GSList *protection_changed, GSList *new_locks,
GSList *visibility_changed, GSList *new_visibility)
{
CmdReorganizeSheets *me;
Workbook *wb = wb_control_workbook (wbc);
GSList *the_sheets;
int selector = 0;
me = g_object_new (CMD_REORGANIZE_SHEETS_TYPE, NULL);
/* Store the specs for the object */
me->wb = wb;
me->new_order = new_order;
me->old_order = NULL;
me->changed_names = changed_names;
me->new_names = new_names;
me->old_names = NULL;
me->color_changed = color_changed;
me->new_colors_fore = new_colors_fore;
me->new_colors_back = new_colors_back;
me->old_colors_fore = NULL;
me->old_colors_back = NULL;
me->protection_changed = protection_changed;
me->new_locks = new_locks;
me->old_locks = NULL;
me->visibility_changed = visibility_changed;
me->new_visibility = new_visibility;
me->old_visibility = NULL;
me->deleted_sheets = deleted_sheets;
me->deleted_sheets_data = NULL;
me->new_sheet_start = workbook_sheet_count (wb);
me->new_sheet_count = 0;
the_sheets = changed_names;
while (the_sheets) {
if (-1 == GPOINTER_TO_INT (the_sheets->data)) {
me->old_names = g_slist_prepend (me->old_names, NULL);
me->new_sheet_count++;
} else {
Sheet *sheet = workbook_sheet_by_index
(wb, GPOINTER_TO_INT (the_sheets->data));
me->old_names = g_slist_prepend
(me->old_names, g_strdup (sheet->name_unquoted));
}
the_sheets = the_sheets->next;
}
me->old_names = g_slist_reverse (me->old_names);
the_sheets = color_changed;
while (the_sheets) {
Sheet *sheet = workbook_sheet_by_index (wb, GPOINTER_TO_INT (the_sheets->data));
if (sheet == NULL) {
me->old_colors_fore = g_slist_prepend (me->old_colors_fore, NULL);
me->old_colors_back = g_slist_prepend (me->old_colors_back, NULL);
} else {
me->old_colors_fore = g_slist_prepend (me->old_colors_fore,
sheet->tab_text_color ?
gdk_color_copy (&sheet->tab_text_color->gdk_color) : NULL);
me->old_colors_back = g_slist_prepend (me->old_colors_back,
sheet->tab_color ?
gdk_color_copy (&sheet->tab_color->gdk_color) : NULL);
}
the_sheets = the_sheets->next;
}
me->old_colors_fore = g_slist_reverse (me->old_colors_fore);
me->old_colors_back = g_slist_reverse (me->old_colors_back);
the_sheets = protection_changed;
while (the_sheets) {
Sheet *sheet = workbook_sheet_by_index (wb, GPOINTER_TO_INT (the_sheets->data));
me->old_locks = g_slist_prepend (me->old_locks, GINT_TO_POINTER (
(sheet != NULL) && sheet->is_protected));
the_sheets = the_sheets->next;
}
me->old_locks = g_slist_reverse (me->old_locks);
the_sheets = visibility_changed;
while (the_sheets) {
Sheet *sheet = workbook_sheet_by_index (wb, GPOINTER_TO_INT (the_sheets->data));
me->old_visibility = g_slist_prepend (me->old_visibility, GINT_TO_POINTER (
sheet ? sheet->visibility : GNM_SHEET_VISIBILITY_VISIBLE));
the_sheets = the_sheets->next;
}
me->old_visibility = g_slist_reverse (me->old_visibility);
me->cmd.sheet = NULL;
me->cmd.size = 1 + g_slist_length (color_changed) + g_slist_length (changed_names) + 1000 * g_slist_length (deleted_sheets);
if (new_order != NULL)
selector += (1 << 0);
if (new_names != NULL && me->new_sheet_count == 0) {
selector += (1 << 1);
}
if (new_names != NULL && me->new_sheet_count == g_slist_length (new_names)) {
selector += (1 << 2);
}
if (new_names != NULL && me->new_sheet_count < g_slist_length (new_names) &&
me->new_sheet_count > 0) {
selector += (1 << 1) +(1 << 2) ;
}
if (color_changed != NULL)
selector += (1 << 3);
if (protection_changed != NULL)
selector += (1 << 4);
if (deleted_sheets != NULL) {
selector += (1 << 5);
if (deleted_sheets->next == NULL)
selector += (1 << 6);
}
if (visibility_changed != NULL)
selector += (1 << 7);
switch (selector) {
case 0:
me->cmd.cmd_descriptor = g_strdup ("Nothing to do?");
break;
case (1 << 0):
me->cmd.cmd_descriptor = g_strdup (_("Reordering Sheets"));
break;
case (1 << 1):
me->cmd.cmd_descriptor = g_strdup (_("Renaming Sheets"));
break;
case (1 << 2):
me->cmd.cmd_descriptor = g_strdup_printf (_("Appending %i Sheets"),
me->new_sheet_count);
break;
case (1 << 3):
me->cmd.cmd_descriptor = g_strdup (_("Changing Tab Colors"));
break;
case (1 << 4):
me->cmd.cmd_descriptor = g_strdup (_("Changing Sheet Protection"));
break;
case (1 << 5):
me->cmd.cmd_descriptor = g_strdup (_("Delete sheets"));
break;
case ((1 << 5) + (1 << 6)):
me->cmd.cmd_descriptor = g_strdup (_("Delete a sheet"));
break;
case (1 << 7):
me->cmd.cmd_descriptor = g_strdup (_("Changing Sheet Visibility"));
break;
default:
me->cmd.cmd_descriptor = g_strdup (_("Reorganizing Sheets"));
break;
}
if (!workbook_sheet_rename_check (me->wb, me->changed_names,
me->new_names,
me->deleted_sheets,
GO_CMD_CONTEXT (wbc))) {
g_object_unref (me);
return TRUE;
}
/* Replace the `-1' in most lists with the corresponding index value */
me->new_order = cmd_reorganize_sheets_fix_list
(me->new_order, me->new_sheet_start, me->new_sheet_count,
FALSE);
me->color_changed = cmd_reorganize_sheets_fix_list
(me->color_changed, me->new_sheet_start, me->new_sheet_count,
FALSE);
me->protection_changed = cmd_reorganize_sheets_fix_list
(me->protection_changed, me->new_sheet_start,
me->new_sheet_count, FALSE);
/* Register the command object */
return command_push_undo (wbc, G_OBJECT (me));
}
/******************************************************************/
gboolean
cmd_rename_sheet (WorkbookControl *wbc,
Sheet *sheet,
......@@ -6936,6 +6279,20 @@ typedef struct {
MAKE_GNM_COMMAND (CmdTabulate, cmd_tabulate, NULL);
static gint
cmd_reorganize_sheets_delete_cmp_f (gconstpointer a,
gconstpointer b)
{
guint const a_val = GPOINTER_TO_INT (a);
guint const b_val = GPOINTER_TO_INT (b);
if (a_val > b_val)
return -1;
if (a_val < b_val)
return 1;
return 0;
}