static void changed_cb(GtkTreeSelection *selection, gpointer param) { Selection_t *data = (Selection_t*) param; if (data->select_lock) { data->select_lock = FALSE; } else { Command_t *command, *sub_command; GtkTreeModel *model; GList *list, *selected_rows; selected_rows = gtk_tree_selection_get_selected_rows (selection, &model); command = subcommand_start (NULL); sub_command = unselect_all_command_new (data->object_list, NULL); command_add_subcommand (command, sub_command); for (list = selected_rows; list; list = list->next) { Object_t *obj; GtkTreeIter iter; GtkTreePath *path = (GtkTreePath*) list->data; gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, 0, &obj, -1); sub_command = select_command_new (obj); command_add_subcommand (command, sub_command); } command_set_name (command, sub_command->name); subcommand_end (); command_execute (command); g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL); g_list_free (selected_rows); set_buttons (data); } }
Command_t* select_region_command_new(GtkWidget *widget, ObjectList_t *list, gint x, gint y) { SelectRegionCommand_t *command = g_new(SelectRegionCommand_t, 1); Command_t *sub_command; command->widget = widget; command->list = list; command->x = x; command->y = y; (void) command_init(&command->parent, _("Select Region"), &select_region_command_class); sub_command = unselect_all_command_new(list, NULL); command_add_subcommand(&command->parent, sub_command); command->unselect_command = sub_command; return &command->parent; }